@ztimson/utils 0.8.2 → 0.9.0
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/download.d.ts +0 -15
- package/dist/index.d.ts +1 -1
- package/dist/promise-progress.d.ts +9 -0
- package/dist/utils.cjs +1 -1
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.mjs +235 -248
- package/dist/utils.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/upload.d.ts +0 -7
package/dist/utils.mjs
CHANGED
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
function
|
|
1
|
+
var M = Object.defineProperty;
|
|
2
|
+
var U = (n, e, t) => e in n ? M(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
3
|
+
var c = (n, e, t) => (U(n, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4
|
+
function Y(n, e = !1) {
|
|
5
5
|
if (n == null)
|
|
6
6
|
throw new Error("Cannot clean a NULL value");
|
|
7
7
|
return Array.isArray(n) ? n = n.filter((t) => t != null) : Object.entries(n).forEach(([t, r]) => {
|
|
8
8
|
(e && r === void 0 || !e && r == null) && delete n[t];
|
|
9
9
|
}), n;
|
|
10
10
|
}
|
|
11
|
-
function
|
|
11
|
+
function _(n) {
|
|
12
12
|
return JSON.parse(JSON.stringify(n));
|
|
13
13
|
}
|
|
14
|
-
function
|
|
14
|
+
function A(n, e, t) {
|
|
15
15
|
if (!(n == null || !e))
|
|
16
|
-
return e.split(/[.[\]]/g).filter((r) => r.length).reduce((r,
|
|
17
|
-
if ((
|
|
16
|
+
return e.split(/[.[\]]/g).filter((r) => r.length).reduce((r, s, o, i) => {
|
|
17
|
+
if ((s[0] == '"' || s[0] == "'") && (s = s.slice(1, -1)), !(r != null && r.hasOwnProperty(s))) {
|
|
18
18
|
if (t == null)
|
|
19
19
|
return;
|
|
20
|
-
r[
|
|
20
|
+
r[s] = {};
|
|
21
21
|
}
|
|
22
|
-
return t !== void 0 &&
|
|
22
|
+
return t !== void 0 && o == i.length - 1 ? r[s] = t : r[s];
|
|
23
23
|
}, n);
|
|
24
24
|
}
|
|
25
|
-
function
|
|
25
|
+
function H(n, e, t = {}) {
|
|
26
26
|
if (typeof n == "object" && !Array.isArray(n)) {
|
|
27
27
|
for (const r of Object.keys(n)) {
|
|
28
|
-
const
|
|
29
|
-
typeof n[r] == "object" ?
|
|
28
|
+
const s = e ? e + "." + r : r;
|
|
29
|
+
typeof n[r] == "object" ? H(n[r], s, t) : t[s] = n[r];
|
|
30
30
|
}
|
|
31
31
|
return t;
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
function
|
|
34
|
+
function I(n, e, t = !1) {
|
|
35
35
|
if (n == null)
|
|
36
36
|
return t;
|
|
37
37
|
if (Array.isArray(e))
|
|
38
|
-
return e.findIndex((
|
|
38
|
+
return e.findIndex((s, o) => !I(n[o], e[o], t)) == -1;
|
|
39
39
|
const r = typeof e;
|
|
40
|
-
return r != typeof n ? !1 : r == "object" ? Object.keys(e).find((
|
|
40
|
+
return r != typeof n ? !1 : r == "object" ? Object.keys(e).find((s) => !I(n[s], e[s], t)) == null : r == "function" ? n.toString() == e.toString() : n == e;
|
|
41
41
|
}
|
|
42
|
-
function
|
|
42
|
+
function m(n, e) {
|
|
43
43
|
const t = typeof n, r = typeof e;
|
|
44
|
-
return t != "object" || n == null || r != "object" || e == null ? t == "function" && r == "function" ? n.toString() == e.toString() : n === e : Object.keys(n).length != Object.keys(e).length ? !1 : Object.keys(n).every((
|
|
44
|
+
return t != "object" || n == null || r != "object" || e == null ? t == "function" && r == "function" ? n.toString() == e.toString() : n === e : Object.keys(n).length != Object.keys(e).length ? !1 : Object.keys(n).every((o) => m(n[o], e[o]));
|
|
45
45
|
}
|
|
46
|
-
function
|
|
46
|
+
function tt(n, e) {
|
|
47
47
|
e.forEach((t) => {
|
|
48
48
|
Object.getOwnPropertyNames(t.prototype).forEach((r) => {
|
|
49
49
|
Object.defineProperty(
|
|
@@ -54,53 +54,53 @@ function ot(n, e) {
|
|
|
54
54
|
});
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
|
-
function
|
|
57
|
+
function et(n, e) {
|
|
58
58
|
let t = [];
|
|
59
|
-
return JSON.parse(JSON.stringify(n, (r,
|
|
60
|
-
if (typeof
|
|
61
|
-
if (t.includes(
|
|
59
|
+
return JSON.parse(JSON.stringify(n, (r, s) => {
|
|
60
|
+
if (typeof s == "object" && s !== null) {
|
|
61
|
+
if (t.includes(s))
|
|
62
62
|
return;
|
|
63
|
-
t.push(
|
|
63
|
+
t.push(s);
|
|
64
64
|
}
|
|
65
|
-
return
|
|
65
|
+
return s;
|
|
66
66
|
}, e));
|
|
67
67
|
}
|
|
68
|
-
function
|
|
68
|
+
function nt(n, e) {
|
|
69
69
|
return n.indexOf(e) === -1 && n.push(e), n;
|
|
70
70
|
}
|
|
71
|
-
function
|
|
72
|
-
return
|
|
73
|
-
...n.filter((t) => !e.includes((r) =>
|
|
74
|
-
...e.filter((t) => !n.includes((r) =>
|
|
71
|
+
function rt(n, e) {
|
|
72
|
+
return q([
|
|
73
|
+
...n.filter((t) => !e.includes((r) => m(t, r))),
|
|
74
|
+
...e.filter((t) => !n.includes((r) => m(t, r)))
|
|
75
75
|
]);
|
|
76
76
|
}
|
|
77
|
-
function
|
|
77
|
+
function st(n) {
|
|
78
78
|
return function(e, t) {
|
|
79
|
-
const r =
|
|
80
|
-
return typeof r != "string" || typeof
|
|
79
|
+
const r = A(e, n), s = A(t, n);
|
|
80
|
+
return typeof r != "string" || typeof s != "string" ? 1 : r.toLowerCase().localeCompare(s.toLowerCase());
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
|
-
function
|
|
84
|
-
return n.forEach((t) => Array.isArray(t) ?
|
|
83
|
+
function W(n, e = []) {
|
|
84
|
+
return n.forEach((t) => Array.isArray(t) ? W(t, e) : e.push(t)), e;
|
|
85
85
|
}
|
|
86
|
-
function
|
|
86
|
+
function ot(n, e = !1) {
|
|
87
87
|
return function(t, r) {
|
|
88
|
-
const
|
|
89
|
-
return typeof
|
|
88
|
+
const s = A(t, n), o = A(r, n);
|
|
89
|
+
return typeof s == "number" && typeof o == "number" ? (e ? -1 : 1) * (s - o) : s > o ? e ? -1 : 1 : s < o ? e ? 1 : -1 : 0;
|
|
90
90
|
};
|
|
91
91
|
}
|
|
92
|
-
function
|
|
93
|
-
return (t) =>
|
|
92
|
+
function it(n, e) {
|
|
93
|
+
return (t) => m(t[n], e);
|
|
94
94
|
}
|
|
95
|
-
function
|
|
95
|
+
function q(n) {
|
|
96
96
|
for (let e = n.length - 1; e >= 0; e--)
|
|
97
|
-
n.slice(0, e).find((t) =>
|
|
97
|
+
n.slice(0, e).find((t) => m(t, n[e])) && n.splice(e, 1);
|
|
98
98
|
return n;
|
|
99
99
|
}
|
|
100
|
-
function
|
|
100
|
+
function ct(n) {
|
|
101
101
|
return Array.isArray(n) ? n : [n];
|
|
102
102
|
}
|
|
103
|
-
class
|
|
103
|
+
class w extends Array {
|
|
104
104
|
get size() {
|
|
105
105
|
return this.length;
|
|
106
106
|
}
|
|
@@ -115,13 +115,13 @@ class A extends Array {
|
|
|
115
115
|
t != -1 && this.slice(t, 1);
|
|
116
116
|
}
|
|
117
117
|
difference(e) {
|
|
118
|
-
return new
|
|
118
|
+
return new w(this.reduce((t, r) => (e.has(r) || t.push(r), t), []));
|
|
119
119
|
}
|
|
120
120
|
has(e) {
|
|
121
121
|
return this.indexOf(e) != -1;
|
|
122
122
|
}
|
|
123
123
|
intersection(e) {
|
|
124
|
-
return new
|
|
124
|
+
return new w(this.reduce((t, r) => (e.has(r) && t.push(r), t), []));
|
|
125
125
|
}
|
|
126
126
|
isDisjointFrom(e) {
|
|
127
127
|
return this.intersection(e).size == 0;
|
|
@@ -133,32 +133,36 @@ class A extends Array {
|
|
|
133
133
|
return e.findIndex((t) => !this.has(t)) == -1;
|
|
134
134
|
}
|
|
135
135
|
symmetricDifference(e) {
|
|
136
|
-
return new
|
|
136
|
+
return new w([...this.difference(e), ...e.difference(this)]);
|
|
137
137
|
}
|
|
138
138
|
union(e) {
|
|
139
|
-
return new
|
|
139
|
+
return new w([...this, ...e]);
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
|
-
|
|
142
|
+
function ut(n, e) {
|
|
143
|
+
const t = document.createElement("a");
|
|
144
|
+
t.href = n, t.download = e, document.body.appendChild(t), t.click(), document.body.removeChild(t);
|
|
145
|
+
}
|
|
146
|
+
class $ {
|
|
143
147
|
constructor() {
|
|
144
|
-
|
|
148
|
+
c(this, "listeners", {});
|
|
145
149
|
}
|
|
146
150
|
static emit(e, ...t) {
|
|
147
151
|
(this.listeners["*"] || []).forEach((r) => r(e, ...t)), (this.listeners[e.toString()] || []).forEach((r) => r(...t));
|
|
148
152
|
}
|
|
149
153
|
static off(e, t) {
|
|
150
154
|
const r = e.toString();
|
|
151
|
-
this.listeners[r] = (this.listeners[r] || []).filter((
|
|
155
|
+
this.listeners[r] = (this.listeners[r] || []).filter((s) => s === t);
|
|
152
156
|
}
|
|
153
157
|
static on(e, t) {
|
|
154
|
-
var
|
|
158
|
+
var s;
|
|
155
159
|
const r = e.toString();
|
|
156
|
-
return this.listeners[r] || (this.listeners[r] = []), (
|
|
160
|
+
return this.listeners[r] || (this.listeners[r] = []), (s = this.listeners[r]) == null || s.push(t), () => this.off(e, t);
|
|
157
161
|
}
|
|
158
162
|
static once(e, t) {
|
|
159
163
|
return new Promise((r) => {
|
|
160
|
-
const
|
|
161
|
-
r(
|
|
164
|
+
const s = this.on(e, (...o) => {
|
|
165
|
+
r(o.length == 1 ? o[0] : o), t && t(...o), s();
|
|
162
166
|
});
|
|
163
167
|
});
|
|
164
168
|
}
|
|
@@ -174,51 +178,23 @@ class T {
|
|
|
174
178
|
}
|
|
175
179
|
once(e, t) {
|
|
176
180
|
return new Promise((r) => {
|
|
177
|
-
const
|
|
178
|
-
r(
|
|
181
|
+
const s = this.on(e, (...o) => {
|
|
182
|
+
r(o.length == 1 ? o[0] : o), t && t(...o), s();
|
|
179
183
|
});
|
|
180
184
|
});
|
|
181
185
|
}
|
|
182
186
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
const t = document.createElement("a");
|
|
186
|
-
t.href = n, t.download = e, document.body.appendChild(t), t.click(), document.body.removeChild(t);
|
|
187
|
-
}
|
|
188
|
-
function ft(n, e) {
|
|
189
|
-
const t = new T();
|
|
190
|
-
return fetch(n).then((r) => {
|
|
191
|
-
var w;
|
|
192
|
-
if (!r.ok)
|
|
193
|
-
return t.emit("failed", new Error(r.statusText));
|
|
194
|
-
const o = r.headers.get("Content-Length") || "0", s = parseInt(o, 10);
|
|
195
|
-
let i = [], d = 0;
|
|
196
|
-
const g = (w = r.body) == null ? void 0 : w.getReader();
|
|
197
|
-
g == null || g.read().then(function x(k) {
|
|
198
|
-
if (k.done) {
|
|
199
|
-
const m = new Blob(i);
|
|
200
|
-
if (e) {
|
|
201
|
-
const D = URL.createObjectURL(m);
|
|
202
|
-
J(D, e), URL.revokeObjectURL(D);
|
|
203
|
-
}
|
|
204
|
-
t.emit("complete", m);
|
|
205
|
-
} else {
|
|
206
|
-
const m = k.value;
|
|
207
|
-
i.push(m), d += m.length, t.emit("progress", d / s), g.read().then(x);
|
|
208
|
-
}
|
|
209
|
-
});
|
|
210
|
-
}).catch((r) => t.emit("failed", r)), t;
|
|
211
|
-
}
|
|
212
|
-
const p = class p {
|
|
187
|
+
c($, "listeners", {});
|
|
188
|
+
const d = class d {
|
|
213
189
|
constructor(e = {}) {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
this.opts = e, this.headers = e.headers || {}, e.interceptors && e.interceptors.forEach((t) =>
|
|
190
|
+
c(this, "interceptors", {});
|
|
191
|
+
c(this, "headers", {});
|
|
192
|
+
this.opts = e, this.headers = e.headers || {}, e.interceptors && e.interceptors.forEach((t) => d.addInterceptor(t));
|
|
217
193
|
}
|
|
218
194
|
static addInterceptor(e) {
|
|
219
|
-
const t = Object.keys(
|
|
220
|
-
return
|
|
221
|
-
|
|
195
|
+
const t = Object.keys(d.interceptors).length.toString();
|
|
196
|
+
return d.interceptors[t] = e, () => {
|
|
197
|
+
d.interceptors[t] = null;
|
|
222
198
|
};
|
|
223
199
|
}
|
|
224
200
|
addInterceptor(e) {
|
|
@@ -228,40 +204,40 @@ const p = class p {
|
|
|
228
204
|
};
|
|
229
205
|
}
|
|
230
206
|
async request(e = {}) {
|
|
231
|
-
var
|
|
207
|
+
var s, o;
|
|
232
208
|
if (!this.opts.url && !e.url)
|
|
233
209
|
throw new Error("URL needs to be set");
|
|
234
|
-
const t = ((
|
|
210
|
+
const t = ((s = e.url) != null && s.startsWith("http") ? e.url : (this.opts.url || "") + (e.url || "")).replace(/([^:]\/)\/+/g, "$1"), r = Y({
|
|
235
211
|
"Content-Type": e.body && !(e.body instanceof FormData) ? "application/json" : void 0,
|
|
236
|
-
...
|
|
212
|
+
...d.headers,
|
|
237
213
|
...this.headers,
|
|
238
214
|
...e.headers
|
|
239
215
|
});
|
|
240
216
|
return fetch(t, {
|
|
241
217
|
headers: r,
|
|
242
218
|
method: e.method || (e.body ? "POST" : "GET"),
|
|
243
|
-
body: (
|
|
219
|
+
body: (o = r["Content-Type"]) != null && o.startsWith("application/json") && e.body ? JSON.stringify(e.body) : e.body
|
|
244
220
|
}).then(async (i) => {
|
|
245
|
-
var
|
|
246
|
-
for (let
|
|
247
|
-
await new Promise((
|
|
221
|
+
var g, E;
|
|
222
|
+
for (let O of [...Object.values(d.interceptors), ...Object.values(this.interceptors)])
|
|
223
|
+
await new Promise((S) => O(i, () => S()));
|
|
248
224
|
if (!i.ok)
|
|
249
225
|
throw new Error(i.statusText);
|
|
250
|
-
return !e.skipConverting && ((
|
|
226
|
+
return !e.skipConverting && ((g = i.headers.get("Content-Type")) != null && g.startsWith("application/json")) ? await i.json() : !e.skipConverting && ((E = i.headers.get("Content-Type")) != null && E.startsWith("text/plain")) ? await i.text() : i;
|
|
251
227
|
});
|
|
252
228
|
}
|
|
253
229
|
};
|
|
254
|
-
|
|
255
|
-
let
|
|
256
|
-
|
|
230
|
+
c(d, "interceptors", {}), c(d, "headers", {});
|
|
231
|
+
let T = d;
|
|
232
|
+
T.addInterceptor((n, e) => {
|
|
257
233
|
if (n.status == 200)
|
|
258
234
|
return e();
|
|
259
|
-
throw n.status == 400 ? new
|
|
235
|
+
throw n.status == 400 ? new D(n.statusText) : n.status == 401 ? new k(n.statusText) : n.status == 403 ? new G(n.statusText) : n.status == 404 ? new j(n.statusText) : n.status == 500 ? new P(n.statusText) : new y(n.statusText, n.status);
|
|
260
236
|
});
|
|
261
|
-
class
|
|
237
|
+
class y extends Error {
|
|
262
238
|
constructor(t, r) {
|
|
263
239
|
super(t);
|
|
264
|
-
|
|
240
|
+
c(this, "_code");
|
|
265
241
|
r != null && (this._code = r);
|
|
266
242
|
}
|
|
267
243
|
get code() {
|
|
@@ -271,8 +247,8 @@ class E extends Error {
|
|
|
271
247
|
this._code = t;
|
|
272
248
|
}
|
|
273
249
|
static from(t) {
|
|
274
|
-
const r = Number(t.statusCode) ?? Number(t.code),
|
|
275
|
-
return Object.assign(
|
|
250
|
+
const r = Number(t.statusCode) ?? Number(t.code), s = new this(t.message || t.toString());
|
|
251
|
+
return Object.assign(s, {
|
|
276
252
|
stack: t.stack,
|
|
277
253
|
...t,
|
|
278
254
|
code: r ?? void 0
|
|
@@ -285,8 +261,8 @@ class E extends Error {
|
|
|
285
261
|
return this.message || super.toString();
|
|
286
262
|
}
|
|
287
263
|
}
|
|
288
|
-
|
|
289
|
-
class
|
|
264
|
+
c(y, "code", 500);
|
|
265
|
+
class D extends y {
|
|
290
266
|
constructor(e = "Bad Request") {
|
|
291
267
|
super(e);
|
|
292
268
|
}
|
|
@@ -294,8 +270,8 @@ class j extends E {
|
|
|
294
270
|
return e.constructor.code == this.code;
|
|
295
271
|
}
|
|
296
272
|
}
|
|
297
|
-
|
|
298
|
-
class
|
|
273
|
+
c(D, "code", 400);
|
|
274
|
+
class k extends y {
|
|
299
275
|
constructor(e = "Unauthorized") {
|
|
300
276
|
super(e);
|
|
301
277
|
}
|
|
@@ -303,8 +279,8 @@ class U extends E {
|
|
|
303
279
|
return e.constructor.code == this.code;
|
|
304
280
|
}
|
|
305
281
|
}
|
|
306
|
-
|
|
307
|
-
class
|
|
282
|
+
c(k, "code", 401);
|
|
283
|
+
class G extends y {
|
|
308
284
|
constructor(e = "Forbidden") {
|
|
309
285
|
super(e);
|
|
310
286
|
}
|
|
@@ -312,8 +288,8 @@ class M extends E {
|
|
|
312
288
|
return e.constructor.code == this.code;
|
|
313
289
|
}
|
|
314
290
|
}
|
|
315
|
-
|
|
316
|
-
class
|
|
291
|
+
c(G, "code", 403);
|
|
292
|
+
class j extends y {
|
|
317
293
|
constructor(e = "Not Found") {
|
|
318
294
|
super(e);
|
|
319
295
|
}
|
|
@@ -321,8 +297,8 @@ class P extends E {
|
|
|
321
297
|
return e.constructor.code == this.code;
|
|
322
298
|
}
|
|
323
299
|
}
|
|
324
|
-
|
|
325
|
-
class
|
|
300
|
+
c(j, "code", 404);
|
|
301
|
+
class P extends y {
|
|
326
302
|
constructor(e = "Internal Server Error") {
|
|
327
303
|
super(e);
|
|
328
304
|
}
|
|
@@ -330,8 +306,8 @@ class Y extends E {
|
|
|
330
306
|
return e.constructor.code == this.code;
|
|
331
307
|
}
|
|
332
308
|
}
|
|
333
|
-
|
|
334
|
-
const
|
|
309
|
+
c(P, "code", 500);
|
|
310
|
+
const x = {
|
|
335
311
|
CLEAR: "\x1B[0m",
|
|
336
312
|
BRIGHT: "\x1B[1m",
|
|
337
313
|
DIM: "\x1B[2m",
|
|
@@ -339,7 +315,7 @@ const B = {
|
|
|
339
315
|
BLINK: "\x1B[5m",
|
|
340
316
|
REVERSE: "\x1B[7m",
|
|
341
317
|
HIDDEN: "\x1B[8m"
|
|
342
|
-
},
|
|
318
|
+
}, B = {
|
|
343
319
|
BLACK: "\x1B[30m",
|
|
344
320
|
RED: "\x1B[31m",
|
|
345
321
|
GREEN: "\x1B[32m",
|
|
@@ -356,7 +332,7 @@ const B = {
|
|
|
356
332
|
LIGHT_MAGENTA: "\x1B[95m",
|
|
357
333
|
LIGHT_CYAN: "\x1B[96m",
|
|
358
334
|
WHITE: "\x1B[97m"
|
|
359
|
-
},
|
|
335
|
+
}, at = {
|
|
360
336
|
BLACK: "\x1B[40m",
|
|
361
337
|
RED: "\x1B[41m",
|
|
362
338
|
GREEN: "\x1B[42m",
|
|
@@ -367,17 +343,17 @@ const B = {
|
|
|
367
343
|
WHITE: "\x1B[47m",
|
|
368
344
|
GREY: "\x1B[100m"
|
|
369
345
|
};
|
|
370
|
-
var
|
|
371
|
-
const f = class f extends
|
|
346
|
+
var F = /* @__PURE__ */ ((n) => (n[n.ERROR = 0] = "ERROR", n[n.WARN = 1] = "WARN", n[n.INFO = 2] = "INFO", n[n.LOG = 3] = "LOG", n[n.DEBUG = 4] = "DEBUG", n))(F || {});
|
|
347
|
+
const f = class f extends $ {
|
|
372
348
|
constructor(e) {
|
|
373
349
|
super(), this.namespace = e;
|
|
374
350
|
}
|
|
375
|
-
pad(e, t, r,
|
|
376
|
-
const
|
|
351
|
+
pad(e, t, r, s = !1) {
|
|
352
|
+
const o = e.toString(), i = t - o.length;
|
|
377
353
|
if (i <= 0)
|
|
378
|
-
return
|
|
379
|
-
const
|
|
380
|
-
return
|
|
354
|
+
return o;
|
|
355
|
+
const g = Array(~~(i / r.length)).fill(r).join("");
|
|
356
|
+
return s ? o + g : g + o;
|
|
381
357
|
}
|
|
382
358
|
format(...e) {
|
|
383
359
|
const t = /* @__PURE__ */ new Date();
|
|
@@ -387,77 +363,77 @@ const f = class f extends T {
|
|
|
387
363
|
if (f.LOG_LEVEL < 4)
|
|
388
364
|
return;
|
|
389
365
|
const t = this.format(...e);
|
|
390
|
-
f.emit(4, t), console.debug(
|
|
366
|
+
f.emit(4, t), console.debug(B.LIGHT_GREY + t + x.CLEAR);
|
|
391
367
|
}
|
|
392
368
|
log(...e) {
|
|
393
369
|
if (f.LOG_LEVEL < 3)
|
|
394
370
|
return;
|
|
395
371
|
const t = this.format(...e);
|
|
396
|
-
f.emit(3, t), console.log(
|
|
372
|
+
f.emit(3, t), console.log(x.CLEAR + t);
|
|
397
373
|
}
|
|
398
374
|
info(...e) {
|
|
399
375
|
if (f.LOG_LEVEL < 2)
|
|
400
376
|
return;
|
|
401
377
|
const t = this.format(...e);
|
|
402
|
-
f.emit(2, t), console.info(
|
|
378
|
+
f.emit(2, t), console.info(B.BLUE + t + x.CLEAR);
|
|
403
379
|
}
|
|
404
380
|
warn(...e) {
|
|
405
381
|
if (f.LOG_LEVEL < 1)
|
|
406
382
|
return;
|
|
407
383
|
const t = this.format(...e);
|
|
408
|
-
f.emit(1, t), console.warn(
|
|
384
|
+
f.emit(1, t), console.warn(B.YELLOW + t + x.CLEAR);
|
|
409
385
|
}
|
|
410
386
|
error(...e) {
|
|
411
387
|
if (f.LOG_LEVEL < 0)
|
|
412
388
|
return;
|
|
413
389
|
const t = this.format(...e);
|
|
414
|
-
f.emit(0, t), console.error(
|
|
390
|
+
f.emit(0, t), console.error(B.RED + t + x.CLEAR);
|
|
415
391
|
}
|
|
416
392
|
};
|
|
417
|
-
|
|
418
|
-
let
|
|
419
|
-
function
|
|
393
|
+
c(f, "LOG_LEVEL", 4);
|
|
394
|
+
let L = f;
|
|
395
|
+
function ht(n, e) {
|
|
420
396
|
return n.length - n.replaceAll(e, "").length;
|
|
421
397
|
}
|
|
422
|
-
function
|
|
398
|
+
function lt(n) {
|
|
423
399
|
return Array(n).fill(null).map(() => Math.round(Math.random() * 15).toString(16)).join("");
|
|
424
400
|
}
|
|
425
|
-
const
|
|
426
|
-
function
|
|
401
|
+
const R = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", N = "0123456789", b = "~`!@#$%^&*()_-+={[}]|\\:;\"'<,>.?/", v = R + N + b;
|
|
402
|
+
function ft(n) {
|
|
427
403
|
const e = /(\+?1)?.*?(\d{3}).*?(\d{3}).*?(\d{4})/g.exec(n);
|
|
428
404
|
if (!e)
|
|
429
405
|
throw new Error(`Number cannot be parsed: ${n}`);
|
|
430
406
|
return `${e[1] ?? ""} (${e[2]}) ${e[3]}-${e[4]}`.trim();
|
|
431
407
|
}
|
|
432
|
-
function
|
|
408
|
+
function dt(n, e, t) {
|
|
433
409
|
return `${n.slice(0, t)}${e}${n.slice(t + 1)}`;
|
|
434
410
|
}
|
|
435
|
-
function
|
|
436
|
-
const
|
|
437
|
-
if (
|
|
438
|
-
return
|
|
439
|
-
const i = Array(~~(
|
|
440
|
-
return r ? i +
|
|
411
|
+
function gt(n, e, t, r = !0) {
|
|
412
|
+
const s = n.toString(), o = e - s.length;
|
|
413
|
+
if (o <= 0)
|
|
414
|
+
return s;
|
|
415
|
+
const i = Array(~~(o / t.length)).fill(t).join("");
|
|
416
|
+
return r ? i + s : s + i;
|
|
441
417
|
}
|
|
442
|
-
function
|
|
418
|
+
function pt(n, e = v) {
|
|
443
419
|
return Array(n).fill(null).map(() => {
|
|
444
420
|
const t = ~~(Math.random() * e.length);
|
|
445
421
|
return e[t];
|
|
446
422
|
}).join("");
|
|
447
423
|
}
|
|
448
|
-
function
|
|
424
|
+
function yt(n, e = !1, t = !1, r = !1) {
|
|
449
425
|
if (!e && !t && !r)
|
|
450
426
|
throw new Error("Must enable at least one: letters, numbers, symbols");
|
|
451
427
|
return Array(n).fill(null).map(() => {
|
|
452
|
-
let
|
|
428
|
+
let s;
|
|
453
429
|
do {
|
|
454
|
-
const
|
|
455
|
-
e &&
|
|
456
|
-
} while (!
|
|
457
|
-
return
|
|
430
|
+
const o = ~~(Math.random() * 3);
|
|
431
|
+
e && o == 0 ? s = R[~~(Math.random() * R.length)] : t && o == 1 ? s = N[~~(Math.random() * N.length)] : r && o == 2 && (s = b[~~(Math.random() * b.length)]);
|
|
432
|
+
} while (!s);
|
|
433
|
+
return s;
|
|
458
434
|
}).join("");
|
|
459
435
|
}
|
|
460
|
-
function
|
|
436
|
+
function Et(n, e) {
|
|
461
437
|
if (typeof e == "string" && (e = new RegExp(e, "g")), !e.global)
|
|
462
438
|
throw new TypeError("Regular expression must be global.");
|
|
463
439
|
let t = [], r;
|
|
@@ -465,86 +441,106 @@ function Bt(n, e) {
|
|
|
465
441
|
t.push(r);
|
|
466
442
|
return t;
|
|
467
443
|
}
|
|
468
|
-
function
|
|
469
|
-
var e =
|
|
444
|
+
function z(n) {
|
|
445
|
+
var e = J(V(Z(K(n), 8 * n.length)));
|
|
470
446
|
return e.toLowerCase();
|
|
471
447
|
}
|
|
472
|
-
function
|
|
473
|
-
for (var e, t = "0123456789ABCDEF", r = "",
|
|
474
|
-
e = n.charCodeAt(
|
|
448
|
+
function J(n) {
|
|
449
|
+
for (var e, t = "0123456789ABCDEF", r = "", s = 0; s < n.length; s++)
|
|
450
|
+
e = n.charCodeAt(s), r += t.charAt(e >>> 4 & 15) + t.charAt(15 & e);
|
|
475
451
|
return r;
|
|
476
452
|
}
|
|
477
|
-
function
|
|
453
|
+
function K(n) {
|
|
478
454
|
for (var e = Array(n.length >> 2), t = 0; t < e.length; t++)
|
|
479
455
|
e[t] = 0;
|
|
480
456
|
for (t = 0; t < 8 * n.length; t += 8)
|
|
481
457
|
e[t >> 5] |= (255 & n.charCodeAt(t / 8)) << t % 32;
|
|
482
458
|
return e;
|
|
483
459
|
}
|
|
484
|
-
function
|
|
460
|
+
function V(n) {
|
|
485
461
|
for (var e = "", t = 0; t < 32 * n.length; t += 8)
|
|
486
462
|
e += String.fromCharCode(n[t >> 5] >>> t % 32 & 255);
|
|
487
463
|
return e;
|
|
488
464
|
}
|
|
489
|
-
function
|
|
465
|
+
function Z(n, e) {
|
|
490
466
|
n[e >> 5] |= 128 << e % 32, n[14 + (e + 64 >>> 9 << 4)] = e;
|
|
491
|
-
for (var t = 1732584193, r = -271733879,
|
|
492
|
-
var
|
|
493
|
-
r =
|
|
467
|
+
for (var t = 1732584193, r = -271733879, s = -1732584194, o = 271733878, i = 0; i < n.length; i += 16) {
|
|
468
|
+
var g = t, E = r, O = s, S = o;
|
|
469
|
+
r = l(r = l(r = l(r = l(r = h(r = h(r = h(r = h(r = a(r = a(r = a(r = a(r = u(r = u(r = u(r = u(r, s = u(s, o = u(o, t = u(t, r, s, o, n[i + 0], 7, -680876936), r, s, n[i + 1], 12, -389564586), t, r, n[i + 2], 17, 606105819), o, t, n[i + 3], 22, -1044525330), s = u(s, o = u(o, t = u(t, r, s, o, n[i + 4], 7, -176418897), r, s, n[i + 5], 12, 1200080426), t, r, n[i + 6], 17, -1473231341), o, t, n[i + 7], 22, -45705983), s = u(s, o = u(o, t = u(t, r, s, o, n[i + 8], 7, 1770035416), r, s, n[i + 9], 12, -1958414417), t, r, n[i + 10], 17, -42063), o, t, n[i + 11], 22, -1990404162), s = u(s, o = u(o, t = u(t, r, s, o, n[i + 12], 7, 1804603682), r, s, n[i + 13], 12, -40341101), t, r, n[i + 14], 17, -1502002290), o, t, n[i + 15], 22, 1236535329), s = a(s, o = a(o, t = a(t, r, s, o, n[i + 1], 5, -165796510), r, s, n[i + 6], 9, -1069501632), t, r, n[i + 11], 14, 643717713), o, t, n[i + 0], 20, -373897302), s = a(s, o = a(o, t = a(t, r, s, o, n[i + 5], 5, -701558691), r, s, n[i + 10], 9, 38016083), t, r, n[i + 15], 14, -660478335), o, t, n[i + 4], 20, -405537848), s = a(s, o = a(o, t = a(t, r, s, o, n[i + 9], 5, 568446438), r, s, n[i + 14], 9, -1019803690), t, r, n[i + 3], 14, -187363961), o, t, n[i + 8], 20, 1163531501), s = a(s, o = a(o, t = a(t, r, s, o, n[i + 13], 5, -1444681467), r, s, n[i + 2], 9, -51403784), t, r, n[i + 7], 14, 1735328473), o, t, n[i + 12], 20, -1926607734), s = h(s, o = h(o, t = h(t, r, s, o, n[i + 5], 4, -378558), r, s, n[i + 8], 11, -2022574463), t, r, n[i + 11], 16, 1839030562), o, t, n[i + 14], 23, -35309556), s = h(s, o = h(o, t = h(t, r, s, o, n[i + 1], 4, -1530992060), r, s, n[i + 4], 11, 1272893353), t, r, n[i + 7], 16, -155497632), o, t, n[i + 10], 23, -1094730640), s = h(s, o = h(o, t = h(t, r, s, o, n[i + 13], 4, 681279174), r, s, n[i + 0], 11, -358537222), t, r, n[i + 3], 16, -722521979), o, t, n[i + 6], 23, 76029189), s = h(s, o = h(o, t = h(t, r, s, o, n[i + 9], 4, -640364487), r, s, n[i + 12], 11, -421815835), t, r, n[i + 15], 16, 530742520), o, t, n[i + 2], 23, -995338651), s = l(s, o = l(o, t = l(t, r, s, o, n[i + 0], 6, -198630844), r, s, n[i + 7], 10, 1126891415), t, r, n[i + 14], 15, -1416354905), o, t, n[i + 5], 21, -57434055), s = l(s, o = l(o, t = l(t, r, s, o, n[i + 12], 6, 1700485571), r, s, n[i + 3], 10, -1894986606), t, r, n[i + 10], 15, -1051523), o, t, n[i + 1], 21, -2054922799), s = l(s, o = l(o, t = l(t, r, s, o, n[i + 8], 6, 1873313359), r, s, n[i + 15], 10, -30611744), t, r, n[i + 6], 15, -1560198380), o, t, n[i + 13], 21, 1309151649), s = l(s, o = l(o, t = l(t, r, s, o, n[i + 4], 6, -145523070), r, s, n[i + 11], 10, -1120210379), t, r, n[i + 2], 15, 718787259), o, t, n[i + 9], 21, -343485551), t = p(t, g), r = p(r, E), s = p(s, O), o = p(o, S);
|
|
494
470
|
}
|
|
495
|
-
return Array(t, r,
|
|
471
|
+
return Array(t, r, s, o);
|
|
496
472
|
}
|
|
497
|
-
function
|
|
498
|
-
return
|
|
473
|
+
function C(n, e, t, r, s, o) {
|
|
474
|
+
return p(Q(p(p(e, n), p(r, o)), s), t);
|
|
499
475
|
}
|
|
500
|
-
function
|
|
501
|
-
return
|
|
476
|
+
function u(n, e, t, r, s, o, i) {
|
|
477
|
+
return C(e & t | ~e & r, n, e, s, o, i);
|
|
502
478
|
}
|
|
503
|
-
function
|
|
504
|
-
return
|
|
479
|
+
function a(n, e, t, r, s, o, i) {
|
|
480
|
+
return C(e & r | t & ~r, n, e, s, o, i);
|
|
505
481
|
}
|
|
506
|
-
function
|
|
507
|
-
return
|
|
482
|
+
function h(n, e, t, r, s, o, i) {
|
|
483
|
+
return C(e ^ t ^ r, n, e, s, o, i);
|
|
508
484
|
}
|
|
509
|
-
function
|
|
510
|
-
return
|
|
485
|
+
function l(n, e, t, r, s, o, i) {
|
|
486
|
+
return C(t ^ (e | ~r), n, e, s, o, i);
|
|
511
487
|
}
|
|
512
|
-
function
|
|
488
|
+
function p(n, e) {
|
|
513
489
|
var t = (65535 & n) + (65535 & e);
|
|
514
490
|
return (n >> 16) + (e >> 16) + (t >> 16) << 16 | 65535 & t;
|
|
515
491
|
}
|
|
516
|
-
function
|
|
492
|
+
function Q(n, e) {
|
|
517
493
|
return n << e | n >>> 32 - e;
|
|
518
494
|
}
|
|
519
|
-
function
|
|
495
|
+
function xt(n) {
|
|
520
496
|
return /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/.test(n);
|
|
521
497
|
}
|
|
522
|
-
function
|
|
498
|
+
function wt(n) {
|
|
523
499
|
return Object.entries(n).map(
|
|
524
500
|
([e, t]) => encodeURIComponent(e) + "=" + encodeURIComponent(t)
|
|
525
501
|
).join("&");
|
|
526
502
|
}
|
|
527
|
-
function
|
|
528
|
-
return n ? `https://www.gravatar.com/avatar/${
|
|
503
|
+
function mt(n, e = "mp") {
|
|
504
|
+
return n ? `https://www.gravatar.com/avatar/${z(n)}?d=${e}` : "";
|
|
529
505
|
}
|
|
530
|
-
function
|
|
506
|
+
function Bt(n) {
|
|
531
507
|
const e = new RegExp(
|
|
532
508
|
"(?:(?<protocol>[\\w\\d]+)\\:\\/\\/)?(?:(?<user>.+)\\@)?(?<host>(?<domain>[^:\\/\\?#@\\n]+)(?:\\:(?<port>\\d*))?)(?<path>\\/.*?)?(?:\\?(?<query>.*?))?(?:#(?<fragment>.*?))?$",
|
|
533
509
|
"gm"
|
|
534
510
|
).exec(n), t = (e == null ? void 0 : e.groups) ?? {}, r = t.domain.split(".");
|
|
535
511
|
if (t.port != null && (t.port = Number(t.port)), r.length > 2 && (t.domain = r.splice(-2, 2).join("."), t.subdomain = r.join(".")), t.query) {
|
|
536
|
-
const
|
|
537
|
-
|
|
538
|
-
const [
|
|
539
|
-
|
|
540
|
-
}), t.query =
|
|
512
|
+
const s = t.query.split("&"), o = {};
|
|
513
|
+
s.forEach((i) => {
|
|
514
|
+
const [g, E] = i.split("=");
|
|
515
|
+
o[g] = E;
|
|
516
|
+
}), t.query = o;
|
|
541
517
|
}
|
|
542
518
|
return t;
|
|
543
519
|
}
|
|
544
|
-
|
|
520
|
+
class At extends Promise {
|
|
521
|
+
constructor(t) {
|
|
522
|
+
super((r, s) => t(
|
|
523
|
+
(o) => r(o),
|
|
524
|
+
(o) => s(o),
|
|
525
|
+
(o) => this.progress = o
|
|
526
|
+
));
|
|
527
|
+
c(this, "listeners", []);
|
|
528
|
+
c(this, "_progress", 0);
|
|
529
|
+
}
|
|
530
|
+
get progress() {
|
|
531
|
+
return this._progress;
|
|
532
|
+
}
|
|
533
|
+
set progress(t) {
|
|
534
|
+
t != this._progress && (this._progress = t, this.listeners.forEach((r) => r(t)));
|
|
535
|
+
}
|
|
536
|
+
onProgress(t) {
|
|
537
|
+
return this.listeners.push(t), this;
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
function Ct(n) {
|
|
545
541
|
return (n instanceof Date ? n.getTime() : n) - (/* @__PURE__ */ new Date()).getTime();
|
|
546
542
|
}
|
|
547
|
-
function
|
|
543
|
+
function Ot(n) {
|
|
548
544
|
return new Promise((e) => setTimeout(e, n));
|
|
549
545
|
}
|
|
550
546
|
function St(n) {
|
|
@@ -558,63 +554,54 @@ function St(n) {
|
|
|
558
554
|
hour12: !0
|
|
559
555
|
}).format(e);
|
|
560
556
|
}
|
|
561
|
-
function bt(n, e) {
|
|
562
|
-
const t = new XMLHttpRequest(), r = new T(), o = new FormData();
|
|
563
|
-
return (Array.isArray(n) ? n : [n]).forEach((s) => o.append("file", s)), t.upload.addEventListener("progress", (s) => {
|
|
564
|
-
s.lengthComputable && r.emit("progress", s.loaded / s.total);
|
|
565
|
-
}), t.onreadystatechange = () => {
|
|
566
|
-
t.readyState === 4 && (t.status >= 200 && t.status < 300 ? r.emit("complete") : r.emit("failed", new Error(t.responseText)));
|
|
567
|
-
}, t.open("POST", e, !0), t.send(o), r;
|
|
568
|
-
}
|
|
569
557
|
export {
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
558
|
+
w as ASet,
|
|
559
|
+
D as BadRequestError,
|
|
560
|
+
at as CliBackground,
|
|
561
|
+
x as CliEffects,
|
|
562
|
+
B as CliForeground,
|
|
563
|
+
y as CustomError,
|
|
564
|
+
G as ForbiddenError,
|
|
565
|
+
P as InternalServerError,
|
|
566
|
+
F as LOG_LEVEL,
|
|
567
|
+
L as Logger,
|
|
568
|
+
j as NotFoundError,
|
|
569
|
+
At as PromiseProgress,
|
|
570
|
+
$ as TypedEmitter,
|
|
571
|
+
k as UnauthorizedError,
|
|
572
|
+
T as XHR,
|
|
573
|
+
nt as addUnique,
|
|
574
|
+
rt as arrayDiff,
|
|
575
|
+
st as caseInsensitiveSort,
|
|
576
|
+
Y as clean,
|
|
577
|
+
ht as countChars,
|
|
578
|
+
lt as createHex,
|
|
579
|
+
_ as deepCopy,
|
|
580
|
+
A as dotNotation,
|
|
581
|
+
ut as download,
|
|
582
|
+
it as findByProp,
|
|
583
|
+
W as flattenArr,
|
|
584
|
+
H as flattenObj,
|
|
585
|
+
wt as formEncode,
|
|
598
586
|
St as formatDate,
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
At as validateEmail
|
|
587
|
+
ft as formatPhoneNumber,
|
|
588
|
+
mt as gravatar,
|
|
589
|
+
I as includes,
|
|
590
|
+
dt as insertAt,
|
|
591
|
+
m as isEqual,
|
|
592
|
+
ct as makeArray,
|
|
593
|
+
q as makeUnique,
|
|
594
|
+
Et as matchAll,
|
|
595
|
+
z as md5,
|
|
596
|
+
tt as mixin,
|
|
597
|
+
gt as pad,
|
|
598
|
+
pt as randomString,
|
|
599
|
+
yt as randomStringBuilder,
|
|
600
|
+
et as sanitizedJSON,
|
|
601
|
+
Ot as sleep,
|
|
602
|
+
ot as sortByProp,
|
|
603
|
+
Ct as timeUntil,
|
|
604
|
+
Bt as urlParser,
|
|
605
|
+
xt as validateEmail
|
|
619
606
|
};
|
|
620
607
|
//# sourceMappingURL=utils.mjs.map
|