@netlify/spark-ui 1.27.5 → 1.27.6
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/components/preact/DropZone/drop-core/errors.d.ts +10 -0
- package/dist/components/preact/DropZone/drop-core/errors.js +8 -0
- package/dist/components/preact/DropZone/drop-core/index.js +7 -6
- package/dist/components/preact/DropZone/drop-core/readFiles.js +136 -131
- package/package.json +1 -1
- package/packages/components/preact/DropZone/drop-core/errors.ts +18 -0
- package/packages/components/preact/DropZone/drop-core/readFiles.ts +19 -3
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thrown when the user drops or picks a single loose file that Drop can't turn
|
|
3
|
+
* into a site on its own — anything that isn't a `.zip` (a site archive) or an
|
|
4
|
+
* HTML page (served as index.html). A folder, multiple files, a zip, or a lone
|
|
5
|
+
* HTML file are all fine; any other single file is rejected rather than
|
|
6
|
+
* deployed as a one-asset site (matches react-ui).
|
|
7
|
+
*/
|
|
8
|
+
export declare class UnsupportedDropError extends Error {
|
|
9
|
+
constructor();
|
|
10
|
+
}
|
|
1
11
|
/**
|
|
2
12
|
* Turn a raw deploy failure into copy a non-technical user can act on.
|
|
3
13
|
* The original message is still tracked via analytics — this is only for display.
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
+
class n extends Error {
|
|
2
|
+
constructor() {
|
|
3
|
+
super("unsupported single file"), this.name = "UnsupportedDropError";
|
|
4
|
+
}
|
|
5
|
+
}
|
|
1
6
|
function a(e) {
|
|
2
7
|
if (!(e instanceof Error)) return "Something went wrong. Please try again.";
|
|
8
|
+
if (e instanceof n)
|
|
9
|
+
return "To deploy, drop a folder or a .zip file — or a single HTML page.";
|
|
3
10
|
if (e.message === "Deploy did not become ready in time")
|
|
4
11
|
return "Your site is taking longer than expected to go live. Please try again in a moment.";
|
|
5
12
|
if (e instanceof TypeError)
|
|
@@ -25,5 +32,6 @@ function a(e) {
|
|
|
25
32
|
}
|
|
26
33
|
}
|
|
27
34
|
export {
|
|
35
|
+
n as UnsupportedDropError,
|
|
28
36
|
a as humanizeDropError
|
|
29
37
|
};
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { getDigest as
|
|
2
|
-
import { getSingleNonIndexHtmlFileName as n, hasMultipleHtmlFilesWithoutIndex as l, readDataTransfer as i, readFileList as m, renameSingleNonIndexHtmlToIndex as
|
|
1
|
+
import { getDigest as o } from "./digest.js";
|
|
2
|
+
import { getSingleNonIndexHtmlFileName as n, hasMultipleHtmlFilesWithoutIndex as l, readDataTransfer as i, readFileList as m, renameSingleNonIndexHtmlToIndex as p } from "./readFiles.js";
|
|
3
3
|
import { AnonymousDropClient as x } from "./client.js";
|
|
4
4
|
import { deployFiles as s } from "./deploy.js";
|
|
5
|
-
import {
|
|
5
|
+
import { UnsupportedDropError as g, humanizeDropError as u } from "./errors.js";
|
|
6
6
|
export {
|
|
7
7
|
x as AnonymousDropClient,
|
|
8
|
+
g as UnsupportedDropError,
|
|
8
9
|
s as deployFiles,
|
|
9
|
-
|
|
10
|
+
o as getDigest,
|
|
10
11
|
n as getSingleNonIndexHtmlFileName,
|
|
11
12
|
l as hasMultipleHtmlFilesWithoutIndex,
|
|
12
|
-
|
|
13
|
+
u as humanizeDropError,
|
|
13
14
|
i as readDataTransfer,
|
|
14
15
|
m as readFileList,
|
|
15
|
-
|
|
16
|
+
p as renameSingleNonIndexHtmlToIndex
|
|
16
17
|
};
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import { g as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { g as P } from "../../../../chunks/_commonjsHelpers.C6fGbg64.js";
|
|
2
|
+
import { UnsupportedDropError as U } from "./errors.js";
|
|
3
|
+
var L = { exports: {} }, G = L.exports, D;
|
|
4
|
+
function J() {
|
|
5
|
+
return D || (D = 1, function(y, m) {
|
|
6
|
+
(function(_, h) {
|
|
7
|
+
y.exports = h();
|
|
8
|
+
})(typeof self < "u" ? self : G, function() {
|
|
8
9
|
return (
|
|
9
10
|
/******/
|
|
10
|
-
function(
|
|
11
|
-
var
|
|
11
|
+
function(w) {
|
|
12
|
+
var _ = {};
|
|
12
13
|
function h(v) {
|
|
13
|
-
if (
|
|
14
|
-
return
|
|
15
|
-
var s =
|
|
14
|
+
if (_[v])
|
|
15
|
+
return _[v].exports;
|
|
16
|
+
var s = _[v] = {
|
|
16
17
|
/******/
|
|
17
18
|
i: v,
|
|
18
19
|
/******/
|
|
@@ -21,16 +22,16 @@ function z() {
|
|
|
21
22
|
exports: {}
|
|
22
23
|
/******/
|
|
23
24
|
};
|
|
24
|
-
return
|
|
25
|
+
return w[v].call(s.exports, s, s.exports, h), s.l = !0, s.exports;
|
|
25
26
|
}
|
|
26
|
-
return h.m =
|
|
27
|
+
return h.m = w, h.c = _, h.d = function(v, s, g) {
|
|
27
28
|
h.o(v, s) || Object.defineProperty(v, s, {
|
|
28
29
|
/******/
|
|
29
30
|
configurable: !1,
|
|
30
31
|
/******/
|
|
31
32
|
enumerable: !0,
|
|
32
33
|
/******/
|
|
33
|
-
get:
|
|
34
|
+
get: g
|
|
34
35
|
/******/
|
|
35
36
|
});
|
|
36
37
|
}, h.n = function(v) {
|
|
@@ -52,12 +53,12 @@ function z() {
|
|
|
52
53
|
}([
|
|
53
54
|
/* 0 */
|
|
54
55
|
/***/
|
|
55
|
-
function(
|
|
56
|
+
function(w, _, h) {
|
|
56
57
|
function v(e, o) {
|
|
57
58
|
if (!(e instanceof o))
|
|
58
59
|
throw new TypeError("Cannot call a class as a function");
|
|
59
60
|
}
|
|
60
|
-
var s = h(5),
|
|
61
|
+
var s = h(5), g = h(1), u = g.toHex, f = g.ceilHeapSize, l = h(6), d = function(e) {
|
|
61
62
|
for (e += 9; e % 64 > 0; e += 1)
|
|
62
63
|
;
|
|
63
64
|
return e;
|
|
@@ -148,43 +149,43 @@ function z() {
|
|
|
148
149
|
return u(this.rawEnd().buffer);
|
|
149
150
|
}, e;
|
|
150
151
|
}();
|
|
151
|
-
|
|
152
|
+
w.exports = c, w.exports._core = s;
|
|
152
153
|
},
|
|
153
154
|
/* 1 */
|
|
154
155
|
/***/
|
|
155
|
-
function(
|
|
156
|
+
function(w, _) {
|
|
156
157
|
for (var h = new Array(256), v = 0; v < 256; v++)
|
|
157
158
|
h[v] = (v < 16 ? "0" : "") + v.toString(16);
|
|
158
|
-
|
|
159
|
-
for (var
|
|
160
|
-
u[f] = h[
|
|
159
|
+
w.exports.toHex = function(s) {
|
|
160
|
+
for (var g = new Uint8Array(s), u = new Array(s.byteLength), f = 0; f < u.length; f++)
|
|
161
|
+
u[f] = h[g[f]];
|
|
161
162
|
return u.join("");
|
|
162
|
-
},
|
|
163
|
-
var
|
|
163
|
+
}, w.exports.ceilHeapSize = function(s) {
|
|
164
|
+
var g = 0;
|
|
164
165
|
if (s <= 65536) return 65536;
|
|
165
166
|
if (s < 16777216)
|
|
166
|
-
for (
|
|
167
|
+
for (g = 1; g < s; g = g << 1)
|
|
167
168
|
;
|
|
168
169
|
else
|
|
169
|
-
for (
|
|
170
|
+
for (g = 16777216; g < s; g += 16777216)
|
|
170
171
|
;
|
|
171
|
-
return
|
|
172
|
-
},
|
|
173
|
-
var
|
|
174
|
-
return
|
|
172
|
+
return g;
|
|
173
|
+
}, w.exports.isDedicatedWorkerScope = function(s) {
|
|
174
|
+
var g = "WorkerGlobalScope" in s && s instanceof s.WorkerGlobalScope, u = "SharedWorkerGlobalScope" in s && s instanceof s.SharedWorkerGlobalScope, f = "ServiceWorkerGlobalScope" in s && s instanceof s.ServiceWorkerGlobalScope;
|
|
175
|
+
return g && !u && !f;
|
|
175
176
|
};
|
|
176
177
|
},
|
|
177
178
|
/* 2 */
|
|
178
179
|
/***/
|
|
179
|
-
function(
|
|
180
|
-
|
|
180
|
+
function(w, _, h) {
|
|
181
|
+
w.exports = function() {
|
|
181
182
|
var v = h(0), s = function(f, l, d) {
|
|
182
183
|
try {
|
|
183
184
|
return d(null, f.digest(l));
|
|
184
185
|
} catch (i) {
|
|
185
186
|
return d(i);
|
|
186
187
|
}
|
|
187
|
-
},
|
|
188
|
+
}, g = function(f, l, d, i, r) {
|
|
188
189
|
var t = new self.FileReader();
|
|
189
190
|
t.onloadend = function() {
|
|
190
191
|
if (t.error)
|
|
@@ -197,7 +198,7 @@ function z() {
|
|
|
197
198
|
r(o);
|
|
198
199
|
return;
|
|
199
200
|
}
|
|
200
|
-
l < i.size ?
|
|
201
|
+
l < i.size ? g(f, l, d, i, r) : r(null, f.end());
|
|
201
202
|
}, t.readAsArrayBuffer(i.slice(l, l + d));
|
|
202
203
|
}, u = !0;
|
|
203
204
|
return self.onmessage = function(f) {
|
|
@@ -209,7 +210,7 @@ function z() {
|
|
|
209
210
|
var c = function(e, o) {
|
|
210
211
|
e ? self.postMessage({ id: i, error: e.name }) : self.postMessage({ id: i, hash: o });
|
|
211
212
|
};
|
|
212
|
-
l && s(t, l, c), d &&
|
|
213
|
+
l && s(t, l, c), d && g(t, 0, r, d, c);
|
|
213
214
|
}
|
|
214
215
|
}
|
|
215
216
|
}, function() {
|
|
@@ -219,8 +220,8 @@ function z() {
|
|
|
219
220
|
},
|
|
220
221
|
/* 3 */
|
|
221
222
|
/***/
|
|
222
|
-
function(
|
|
223
|
-
var v = h(4), s = h(0),
|
|
223
|
+
function(w, _, h) {
|
|
224
|
+
var v = h(4), s = h(0), g = h(7), u = h(2), f = h(1), l = f.isDedicatedWorkerScope, d = typeof self < "u" && l(self);
|
|
224
225
|
s.disableWorkerBehaviour = d ? u() : function() {
|
|
225
226
|
}, s.createWorker = function() {
|
|
226
227
|
var i = v(
|
|
@@ -230,11 +231,11 @@ function z() {
|
|
|
230
231
|
return i.terminate = function() {
|
|
231
232
|
URL.revokeObjectURL(i.objectURL), r.call(i);
|
|
232
233
|
}, i;
|
|
233
|
-
}, s.createHash =
|
|
234
|
+
}, s.createHash = g, w.exports = s;
|
|
234
235
|
},
|
|
235
236
|
/* 4 */
|
|
236
237
|
/***/
|
|
237
|
-
function(
|
|
238
|
+
function(w, _, h) {
|
|
238
239
|
function v(i) {
|
|
239
240
|
var r = {};
|
|
240
241
|
function t(e) {
|
|
@@ -286,7 +287,7 @@ function z() {
|
|
|
286
287
|
var c = t(t.s = ENTRY_MODULE);
|
|
287
288
|
return c.default || c;
|
|
288
289
|
}
|
|
289
|
-
var s = "[\\.|\\-|\\+|\\w|/|@]+",
|
|
290
|
+
var s = "[\\.|\\-|\\+|\\w|/|@]+", g = "\\((/\\*.*?\\*/)?s?.*?(" + s + ").*?\\)";
|
|
290
291
|
function u(i) {
|
|
291
292
|
return (i + "").replace(/[.?*+^$[\]\\(){}|-]/g, "\\$&");
|
|
292
293
|
}
|
|
@@ -295,9 +296,9 @@ function z() {
|
|
|
295
296
|
c[t] = [];
|
|
296
297
|
var e = r.toString(), o = e.match(/^function\s?\(\w+,\s*\w+,\s*(\w+)\)/);
|
|
297
298
|
if (!o) return c;
|
|
298
|
-
for (var n = o[1], p = new RegExp("(\\\\n|\\W)" + u(n) +
|
|
299
|
+
for (var n = o[1], p = new RegExp("(\\\\n|\\W)" + u(n) + g, "g"), a; a = p.exec(e); )
|
|
299
300
|
a[3] !== "dll-reference" && c[t].push(a[3]);
|
|
300
|
-
for (p = new RegExp("\\(" + u(n) + '\\("(dll-reference\\s(' + s + '))"\\)\\)' +
|
|
301
|
+
for (p = new RegExp("\\(" + u(n) + '\\("(dll-reference\\s(' + s + '))"\\)\\)' + g, "g"); a = p.exec(e); )
|
|
301
302
|
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
303
|
return c;
|
|
303
304
|
}
|
|
@@ -325,7 +326,7 @@ function z() {
|
|
|
325
326
|
}
|
|
326
327
|
return c;
|
|
327
328
|
}
|
|
328
|
-
|
|
329
|
+
w.exports = function(i, r) {
|
|
329
330
|
r = r || {};
|
|
330
331
|
var t = {
|
|
331
332
|
main: h.m
|
|
@@ -351,9 +352,9 @@ function z() {
|
|
|
351
352
|
},
|
|
352
353
|
/* 5 */
|
|
353
354
|
/***/
|
|
354
|
-
function(
|
|
355
|
-
|
|
356
|
-
var u = new v.Int32Array(
|
|
355
|
+
function(w, _) {
|
|
356
|
+
w.exports = function(v, s, g) {
|
|
357
|
+
var u = new v.Int32Array(g);
|
|
357
358
|
function f(l, d) {
|
|
358
359
|
l = l | 0, d = d | 0;
|
|
359
360
|
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;
|
|
@@ -377,7 +378,7 @@ function z() {
|
|
|
377
378
|
},
|
|
378
379
|
/* 6 */
|
|
379
380
|
/***/
|
|
380
|
-
function(
|
|
381
|
+
function(w, _) {
|
|
381
382
|
var h = this, v = void 0;
|
|
382
383
|
typeof self < "u" && typeof self.FileReaderSync < "u" && (v = new self.FileReaderSync());
|
|
383
384
|
var s = function(f, l, d, i, r, t) {
|
|
@@ -404,7 +405,7 @@ function z() {
|
|
|
404
405
|
l[t + n + 3 | 0] = f.charCodeAt(i + n);
|
|
405
406
|
}
|
|
406
407
|
}
|
|
407
|
-
},
|
|
408
|
+
}, g = function(f, l, d, i, r, t) {
|
|
408
409
|
var c = void 0, e = t % 4, o = (r + e) % 4, n = r - o;
|
|
409
410
|
switch (e) {
|
|
410
411
|
case 0:
|
|
@@ -453,15 +454,15 @@ function z() {
|
|
|
453
454
|
}
|
|
454
455
|
}
|
|
455
456
|
};
|
|
456
|
-
|
|
457
|
+
w.exports = function(f, l, d, i, r, t) {
|
|
457
458
|
if (typeof f == "string")
|
|
458
459
|
return s(f, l, d, i, r, t);
|
|
459
460
|
if (f instanceof Array || h && h.Buffer && h.Buffer.isBuffer(f))
|
|
460
|
-
return
|
|
461
|
+
return g(f, l, d, i, r, t);
|
|
461
462
|
if (f instanceof ArrayBuffer)
|
|
462
|
-
return
|
|
463
|
+
return g(new Uint8Array(f), l, d, i, r, t);
|
|
463
464
|
if (f.buffer instanceof ArrayBuffer)
|
|
464
|
-
return
|
|
465
|
+
return g(new Uint8Array(f.buffer, f.byteOffset, f.byteLength), l, d, i, r, t);
|
|
465
466
|
if (f instanceof Blob)
|
|
466
467
|
return u(f, l, d, i, r, t);
|
|
467
468
|
throw new Error("Unsupported data type.");
|
|
@@ -469,7 +470,7 @@ function z() {
|
|
|
469
470
|
},
|
|
470
471
|
/* 7 */
|
|
471
472
|
/***/
|
|
472
|
-
function(
|
|
473
|
+
function(w, _, h) {
|
|
473
474
|
var v = /* @__PURE__ */ function() {
|
|
474
475
|
function d(i, r) {
|
|
475
476
|
for (var t = 0; t < r.length; t++) {
|
|
@@ -485,9 +486,9 @@ function z() {
|
|
|
485
486
|
if (!(d instanceof i))
|
|
486
487
|
throw new TypeError("Cannot call a class as a function");
|
|
487
488
|
}
|
|
488
|
-
var
|
|
489
|
+
var g = h(0), u = h(1), f = u.toHex, l = function() {
|
|
489
490
|
function d() {
|
|
490
|
-
s(this, d), this._rusha = new
|
|
491
|
+
s(this, d), this._rusha = new g(), this._rusha.resetState();
|
|
491
492
|
}
|
|
492
493
|
return d.prototype.update = function(r) {
|
|
493
494
|
return this._rusha.append(r), this;
|
|
@@ -508,7 +509,7 @@ function z() {
|
|
|
508
509
|
}
|
|
509
510
|
}]), d;
|
|
510
511
|
}();
|
|
511
|
-
|
|
512
|
+
w.exports = function() {
|
|
512
513
|
return new l();
|
|
513
514
|
};
|
|
514
515
|
}
|
|
@@ -518,110 +519,114 @@ function z() {
|
|
|
518
519
|
});
|
|
519
520
|
}(L)), L.exports;
|
|
520
521
|
}
|
|
521
|
-
var
|
|
522
|
-
const
|
|
523
|
-
function
|
|
522
|
+
var $ = J();
|
|
523
|
+
const N = /* @__PURE__ */ P($), Y = new N(), R = (y) => /\.html?$/i.test(y), B = (y) => /\.zip$/i.test(y), O = (y) => y.startsWith(".") || y === "__MACOSX" || y === "node_modules", Z = (y) => y.split("/").some((m) => m && O(m)), k = (y) => y.startsWith("/") ? y : `/${y}`;
|
|
524
|
+
function E(y, m, w) {
|
|
524
525
|
return {
|
|
525
|
-
path: k(
|
|
526
|
-
size:
|
|
527
|
-
sha:
|
|
528
|
-
content:
|
|
529
|
-
name:
|
|
526
|
+
path: k(y),
|
|
527
|
+
size: m.byteLength,
|
|
528
|
+
sha: Y.digest(m),
|
|
529
|
+
content: m,
|
|
530
|
+
name: w
|
|
530
531
|
};
|
|
531
532
|
}
|
|
532
|
-
async function
|
|
533
|
-
const
|
|
534
|
-
return
|
|
533
|
+
async function W(y) {
|
|
534
|
+
const m = await new Promise((_, h) => y.file(_, h)), w = await m.arrayBuffer();
|
|
535
|
+
return E(y.fullPath, w, m.name);
|
|
535
536
|
}
|
|
536
|
-
async function
|
|
537
|
-
const
|
|
537
|
+
async function j(y) {
|
|
538
|
+
const m = y.createReader(), w = [];
|
|
538
539
|
for (; ; ) {
|
|
539
|
-
const
|
|
540
|
-
if (!
|
|
541
|
-
for (const h of
|
|
542
|
-
|
|
540
|
+
const _ = await new Promise((h, v) => m.readEntries(h, v));
|
|
541
|
+
if (!_.length) break;
|
|
542
|
+
for (const h of _)
|
|
543
|
+
O(h.name) || w.push(...h.isDirectory ? await j(h) : [await W(h)]);
|
|
543
544
|
}
|
|
544
|
-
return
|
|
545
|
+
return w;
|
|
545
546
|
}
|
|
546
|
-
async function
|
|
547
|
+
async function K(y) {
|
|
547
548
|
var h;
|
|
548
|
-
const
|
|
549
|
-
if (
|
|
550
|
-
return
|
|
551
|
-
const
|
|
549
|
+
const m = (h = y.files) == null ? void 0 : h[0];
|
|
550
|
+
if (y.files.length === 1 && m && B(m.name))
|
|
551
|
+
return I(m);
|
|
552
|
+
const _ = Array.from(y.items ?? []).map((v) => {
|
|
552
553
|
var s;
|
|
553
554
|
return (s = v.webkitGetAsEntry) == null ? void 0 : s.call(v);
|
|
554
555
|
}).filter(Boolean);
|
|
555
|
-
if (
|
|
556
|
+
if (_.length) {
|
|
557
|
+
if (_.length === 1 && !_[0].isDirectory && !R(_[0].name))
|
|
558
|
+
throw new U();
|
|
556
559
|
const v = await Promise.all(
|
|
557
|
-
|
|
558
|
-
(s) =>
|
|
560
|
+
_.map(
|
|
561
|
+
(s) => O(s.name) ? [] : s.isDirectory ? j(s) : W(s).then((g) => [g])
|
|
559
562
|
)
|
|
560
563
|
);
|
|
561
|
-
return
|
|
564
|
+
return M(v.flat());
|
|
562
565
|
}
|
|
563
|
-
return
|
|
566
|
+
return Q(y.files);
|
|
564
567
|
}
|
|
565
|
-
async function
|
|
566
|
-
const
|
|
567
|
-
if (
|
|
568
|
-
return
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
568
|
+
async function Q(y) {
|
|
569
|
+
const m = Array.from(y);
|
|
570
|
+
if (m.length === 1 && B(m[0].name))
|
|
571
|
+
return I(m[0]);
|
|
572
|
+
if (m.length === 1 && !R(m[0].name))
|
|
573
|
+
throw new U();
|
|
574
|
+
const w = [];
|
|
575
|
+
for (const _ of m) {
|
|
576
|
+
const h = _.webkitRelativePath || _.name;
|
|
577
|
+
w.push(E(h, await _.arrayBuffer(), _.name));
|
|
573
578
|
}
|
|
574
|
-
return
|
|
579
|
+
return M(w);
|
|
575
580
|
}
|
|
576
|
-
async function
|
|
577
|
-
const { unzip:
|
|
578
|
-
(v, s) =>
|
|
581
|
+
async function I(y) {
|
|
582
|
+
const { unzip: m } = await import("../../../../chunks/browser.D58rdxmc.js"), w = new Uint8Array(await y.arrayBuffer()), _ = await new Promise(
|
|
583
|
+
(v, s) => m(w, (g, u) => g ? s(g) : v(u))
|
|
579
584
|
), h = [];
|
|
580
|
-
for (const [v, s] of Object.entries(
|
|
581
|
-
if (v.endsWith("/") ||
|
|
582
|
-
const
|
|
585
|
+
for (const [v, s] of Object.entries(_)) {
|
|
586
|
+
if (v.endsWith("/") || Z(v)) continue;
|
|
587
|
+
const g = s.buffer.slice(
|
|
583
588
|
s.byteOffset,
|
|
584
589
|
s.byteOffset + s.byteLength
|
|
585
590
|
);
|
|
586
|
-
h.push(
|
|
591
|
+
h.push(E(v, g, v.split("/").pop()));
|
|
587
592
|
}
|
|
588
|
-
return
|
|
593
|
+
return M(h);
|
|
589
594
|
}
|
|
590
|
-
function
|
|
591
|
-
if (!
|
|
592
|
-
const
|
|
593
|
-
let
|
|
594
|
-
for (const h of
|
|
595
|
-
const v =
|
|
595
|
+
function M(y) {
|
|
596
|
+
if (!y.length) return y;
|
|
597
|
+
const m = (h) => k(h).split("/").slice(1);
|
|
598
|
+
let w = m(y[0].path).slice(0, -1);
|
|
599
|
+
for (const h of y) {
|
|
600
|
+
const v = m(h.path);
|
|
596
601
|
let s = 0;
|
|
597
|
-
for (; s <
|
|
598
|
-
|
|
602
|
+
for (; s < w.length && s < v.length - 1 && w[s] === v[s]; ) s++;
|
|
603
|
+
w = w.slice(0, s);
|
|
599
604
|
}
|
|
600
|
-
if (!
|
|
601
|
-
const
|
|
602
|
-
return
|
|
605
|
+
if (!w.length) return y;
|
|
606
|
+
const _ = "/" + w.join("/");
|
|
607
|
+
return y.map((h) => ({ ...h, path: k(h.path.slice(_.length)) }));
|
|
603
608
|
}
|
|
604
|
-
const
|
|
605
|
-
function
|
|
606
|
-
const
|
|
607
|
-
return
|
|
609
|
+
const F = (y) => y.filter((m) => R(m.name)), z = (y) => y.some((m) => /^index\.html?$/i.test(m.name));
|
|
610
|
+
function V(y) {
|
|
611
|
+
const m = F(y);
|
|
612
|
+
return z(m) ? null : m.length === 1 ? m[0].name : null;
|
|
608
613
|
}
|
|
609
|
-
function
|
|
610
|
-
const
|
|
611
|
-
return
|
|
614
|
+
function q(y) {
|
|
615
|
+
const m = F(y);
|
|
616
|
+
return m.length > 1 && !z(m);
|
|
612
617
|
}
|
|
613
|
-
function
|
|
614
|
-
const
|
|
615
|
-
return
|
|
616
|
-
if (
|
|
617
|
-
const
|
|
618
|
-
return { ...
|
|
619
|
-
}) :
|
|
618
|
+
function H(y) {
|
|
619
|
+
const m = V(y);
|
|
620
|
+
return m ? y.map((w) => {
|
|
621
|
+
if (w.name !== m) return w;
|
|
622
|
+
const _ = w.path.lastIndexOf("/"), h = _ === -1 ? "" : w.path.slice(0, _);
|
|
623
|
+
return { ...w, name: "index.html", path: k(`${h}/index.html`) };
|
|
624
|
+
}) : y;
|
|
620
625
|
}
|
|
621
626
|
export {
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
+
V as getSingleNonIndexHtmlFileName,
|
|
628
|
+
q as hasMultipleHtmlFilesWithoutIndex,
|
|
629
|
+
K as readDataTransfer,
|
|
630
|
+
Q as readFileList,
|
|
631
|
+
H as renameSingleNonIndexHtmlToIndex
|
|
627
632
|
};
|
package/package.json
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thrown when the user drops or picks a single loose file that Drop can't turn
|
|
3
|
+
* into a site on its own — anything that isn't a `.zip` (a site archive) or an
|
|
4
|
+
* HTML page (served as index.html). A folder, multiple files, a zip, or a lone
|
|
5
|
+
* HTML file are all fine; any other single file is rejected rather than
|
|
6
|
+
* deployed as a one-asset site (matches react-ui).
|
|
7
|
+
*/
|
|
8
|
+
export class UnsupportedDropError extends Error {
|
|
9
|
+
constructor() {
|
|
10
|
+
super('unsupported single file');
|
|
11
|
+
this.name = 'UnsupportedDropError';
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
1
15
|
/**
|
|
2
16
|
* Turn a raw deploy failure into copy a non-technical user can act on.
|
|
3
17
|
* The original message is still tracked via analytics — this is only for display.
|
|
@@ -5,6 +19,10 @@
|
|
|
5
19
|
export function humanizeDropError(err: unknown): string {
|
|
6
20
|
if (!(err instanceof Error)) return 'Something went wrong. Please try again.';
|
|
7
21
|
|
|
22
|
+
if (err instanceof UnsupportedDropError) {
|
|
23
|
+
return 'To deploy, drop a folder or a .zip file — or a single HTML page.';
|
|
24
|
+
}
|
|
25
|
+
|
|
8
26
|
if (err.message === 'Deploy did not become ready in time') {
|
|
9
27
|
return 'Your site is taking longer than expected to go live. Please try again in a moment.';
|
|
10
28
|
}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import Rusha from 'rusha';
|
|
2
2
|
import type { ProcessedFile } from './types';
|
|
3
|
+
import { UnsupportedDropError } from './errors';
|
|
3
4
|
|
|
4
5
|
/* eslint-disable @typescript-eslint/no-explicit-any -- webkit FileSystem entry APIs are untyped */
|
|
5
6
|
|
|
6
7
|
const rusha = new Rusha();
|
|
7
8
|
|
|
9
|
+
/** A file we can serve as a page: `.html` / `.htm` (a lone one becomes index.html). */
|
|
10
|
+
const isHtmlName = (name: string) => /\.html?$/i.test(name);
|
|
11
|
+
const isZipName = (name: string) => /\.zip$/i.test(name);
|
|
12
|
+
|
|
8
13
|
/** A single path segment we never deploy: dotfiles, macOS metadata, deps. */
|
|
9
14
|
const isJunkName = (name: string) =>
|
|
10
15
|
name.startsWith('.') || name === '__MACOSX' || name === 'node_modules';
|
|
@@ -58,12 +63,18 @@ async function readDirEntry(entry: any): Promise<ProcessedFile[]> {
|
|
|
58
63
|
export async function readDataTransfer(dt: DataTransfer): Promise<ProcessedFile[]> {
|
|
59
64
|
// single zip?
|
|
60
65
|
const first = dt.files?.[0];
|
|
61
|
-
if (dt.files.length === 1 && first &&
|
|
66
|
+
if (dt.files.length === 1 && first && isZipName(first.name)) {
|
|
62
67
|
return readZip(first);
|
|
63
68
|
}
|
|
64
69
|
const items = Array.from(dt.items ?? []);
|
|
65
70
|
const entries = items.map(i => i.webkitGetAsEntry?.()).filter(Boolean) as any[];
|
|
66
71
|
if (entries.length) {
|
|
72
|
+
// A single loose file that isn't a zip (handled above) or an HTML page
|
|
73
|
+
// can't stand up a site on its own — reject it rather than deploy one
|
|
74
|
+
// stray asset. A lone folder (isDirectory) or multiple entries are fine.
|
|
75
|
+
if (entries.length === 1 && !entries[0].isDirectory && !isHtmlName(entries[0].name)) {
|
|
76
|
+
throw new UnsupportedDropError();
|
|
77
|
+
}
|
|
67
78
|
const nested = await Promise.all(
|
|
68
79
|
entries.map(e =>
|
|
69
80
|
isJunkName(e.name) ? [] : e.isDirectory ? readDirEntry(e) : readFileEntry(e).then(f => [f])
|
|
@@ -79,9 +90,14 @@ export async function readDataTransfer(dt: DataTransfer): Promise<ProcessedFile[
|
|
|
79
90
|
|
|
80
91
|
export async function readFileList(files: FileList): Promise<ProcessedFile[]> {
|
|
81
92
|
const list = Array.from(files);
|
|
82
|
-
if (list.length === 1 &&
|
|
93
|
+
if (list.length === 1 && isZipName(list[0].name)) {
|
|
83
94
|
return readZip(list[0]);
|
|
84
95
|
}
|
|
96
|
+
// Same single-loose-file guard as the drag path (also the drag fallback when
|
|
97
|
+
// the entries API is unavailable): only a zip or an HTML page may stand alone.
|
|
98
|
+
if (list.length === 1 && !isHtmlName(list[0].name)) {
|
|
99
|
+
throw new UnsupportedDropError();
|
|
100
|
+
}
|
|
85
101
|
const out: ProcessedFile[] = [];
|
|
86
102
|
for (const file of list) {
|
|
87
103
|
const rel = (file as any).webkitRelativePath || file.name;
|
|
@@ -133,7 +149,7 @@ function normalizeFiles(files: ProcessedFile[]): ProcessedFile[] {
|
|
|
133
149
|
|
|
134
150
|
// --- index.html validation (UI can surface these as warnings) ---------------
|
|
135
151
|
|
|
136
|
-
const htmlFiles = (files: ProcessedFile[]) => files.filter(f =>
|
|
152
|
+
const htmlFiles = (files: ProcessedFile[]) => files.filter(f => isHtmlName(f.name));
|
|
137
153
|
const hasIndex = (html: ProcessedFile[]) => html.some(f => /^index\.html?$/i.test(f.name));
|
|
138
154
|
|
|
139
155
|
export function getSingleNonIndexHtmlFileName(files: ProcessedFile[]): string | null {
|