@prozilla-os/shared 1.3.0 → 1.4.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/README.md +3 -3
- package/dist/main.d.ts +304 -42
- package/dist/main.js +581 -265
- package/dist/main.js.map +1 -1
- package/package.json +8 -8
package/dist/main.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a = {
|
|
2
2
|
/**
|
|
3
3
|
* Foreground colors.
|
|
4
4
|
*/
|
|
@@ -32,29 +32,96 @@ const h = {
|
|
|
32
32
|
enterAltBuffer: "\x1B[?1049h",
|
|
33
33
|
exitAltBuffer: "\x1B[?1049l",
|
|
34
34
|
clear: "\x1B[2J",
|
|
35
|
+
clearLine: "\x1B[2K",
|
|
35
36
|
home: "\x1B[H"
|
|
36
37
|
},
|
|
38
|
+
/**
|
|
39
|
+
* Cursor controls.
|
|
40
|
+
*/
|
|
41
|
+
cursor: {
|
|
42
|
+
/** Changes the position of the cursor. */
|
|
43
|
+
position: (e, t) => `\x1B[${e};${t}H`,
|
|
44
|
+
hide: "\x1B[?25l",
|
|
45
|
+
show: "\x1B[?25h",
|
|
46
|
+
save: "\x1B[s",
|
|
47
|
+
restore: "\x1B[u"
|
|
48
|
+
},
|
|
49
|
+
/**
|
|
50
|
+
* Terminal input.
|
|
51
|
+
*/
|
|
52
|
+
input: {
|
|
53
|
+
/** Move cursor up. */
|
|
54
|
+
arrowUp: "\x1B[A",
|
|
55
|
+
/** Move cursor down. */
|
|
56
|
+
arrowDown: "\x1B[B",
|
|
57
|
+
/** Move cursor right. */
|
|
58
|
+
arrowRight: "\x1B[C",
|
|
59
|
+
/** Move cursor left. */
|
|
60
|
+
arrowLeft: "\x1B[D",
|
|
61
|
+
horizontalTab: " ",
|
|
62
|
+
lineFeed: `
|
|
63
|
+
`,
|
|
64
|
+
verticalTab: "\v",
|
|
65
|
+
formFeed: "\f",
|
|
66
|
+
carriageReturn: "\r",
|
|
67
|
+
backspace: "\b",
|
|
68
|
+
delete: "",
|
|
69
|
+
escape: "\x1B",
|
|
70
|
+
pageUp: "\x1B[5~",
|
|
71
|
+
pageDown: "\x1B[6~",
|
|
72
|
+
ctrlA: "",
|
|
73
|
+
ctrlB: "",
|
|
74
|
+
ctrlC: "",
|
|
75
|
+
ctrlD: "",
|
|
76
|
+
ctrlE: "",
|
|
77
|
+
ctrlF: "",
|
|
78
|
+
ctrlG: "\x07",
|
|
79
|
+
ctrlH: "\b",
|
|
80
|
+
ctrlI: " ",
|
|
81
|
+
ctrlJ: `
|
|
82
|
+
`,
|
|
83
|
+
ctrlK: "\v",
|
|
84
|
+
ctrlL: "\f",
|
|
85
|
+
ctrlM: "\r",
|
|
86
|
+
ctrlN: "",
|
|
87
|
+
ctrlO: "",
|
|
88
|
+
ctrlP: "",
|
|
89
|
+
ctrlQ: "",
|
|
90
|
+
ctrlR: "",
|
|
91
|
+
ctrlS: "",
|
|
92
|
+
ctrlT: "",
|
|
93
|
+
ctrlU: "",
|
|
94
|
+
ctrlV: "",
|
|
95
|
+
ctrlW: "",
|
|
96
|
+
ctrlX: "",
|
|
97
|
+
ctrlY: "",
|
|
98
|
+
ctrlZ: ""
|
|
99
|
+
},
|
|
37
100
|
/**
|
|
38
101
|
* Decorations.
|
|
39
102
|
*/
|
|
40
103
|
decoration: {
|
|
41
104
|
dim: "\x1B[2m",
|
|
42
105
|
bold: "\x1B[1m",
|
|
43
|
-
|
|
106
|
+
italic: "\x1B[3m",
|
|
107
|
+
underline: "\x1B[4m",
|
|
108
|
+
blink: "\x1B[5m",
|
|
109
|
+
invert: "\x1B[7m",
|
|
110
|
+
strike: "\x1B[9m"
|
|
44
111
|
},
|
|
45
112
|
reset: "\x1B[0m"
|
|
46
113
|
};
|
|
47
|
-
function
|
|
48
|
-
const
|
|
49
|
-
|
|
114
|
+
function E(e, t) {
|
|
115
|
+
const r = t.indexOf(e);
|
|
116
|
+
r !== -1 && t.splice(r, 1);
|
|
50
117
|
}
|
|
51
|
-
function
|
|
52
|
-
return
|
|
118
|
+
function Y(e) {
|
|
119
|
+
return e[Math.floor(Math.random() * e.length)];
|
|
53
120
|
}
|
|
54
|
-
function
|
|
55
|
-
return
|
|
121
|
+
function Z(e) {
|
|
122
|
+
return e.filter((t, r) => e.indexOf(t) === r);
|
|
56
123
|
}
|
|
57
|
-
const
|
|
124
|
+
const w = {
|
|
58
125
|
s: 1e3,
|
|
59
126
|
m: 1e3 * 60,
|
|
60
127
|
h: 1e3 * 60 * 60,
|
|
@@ -64,17 +131,17 @@ const m = {
|
|
|
64
131
|
y: 1e3 * 60 * 60 * 24 * 365,
|
|
65
132
|
c: 1e3 * 60 * 60 * 24 * 365 * 100
|
|
66
133
|
};
|
|
67
|
-
function
|
|
68
|
-
const
|
|
69
|
-
if (!
|
|
70
|
-
return
|
|
71
|
-
let
|
|
72
|
-
return
|
|
134
|
+
function S(e, t = 3, r = !1) {
|
|
135
|
+
const n = [], u = (l, g) => {
|
|
136
|
+
if (!r)
|
|
137
|
+
return l.join(", ");
|
|
138
|
+
let m = "", b = "";
|
|
139
|
+
return g ? b = "ago" : m = "in", [m, l.join(", "), b].join(" ").trim();
|
|
73
140
|
};
|
|
74
|
-
let
|
|
75
|
-
if (
|
|
76
|
-
return
|
|
77
|
-
const
|
|
141
|
+
let h = !1;
|
|
142
|
+
if (e < 0 && (e = -e, h = !0), Math.abs(e) < w.s)
|
|
143
|
+
return u(["less than a second"], h);
|
|
144
|
+
const p = [], y = {
|
|
78
145
|
s: "second",
|
|
79
146
|
m: "minute",
|
|
80
147
|
h: "hour",
|
|
@@ -82,24 +149,24 @@ function y(r, t = 3, e = !1) {
|
|
|
82
149
|
n: "month",
|
|
83
150
|
y: "year"
|
|
84
151
|
};
|
|
85
|
-
for (const [
|
|
86
|
-
if (
|
|
152
|
+
for (const [l, g] of Object.entries(w).reverse()) {
|
|
153
|
+
if (l === "w" || l === "c")
|
|
87
154
|
continue;
|
|
88
|
-
const
|
|
89
|
-
|
|
155
|
+
const m = Math.floor(e / g);
|
|
156
|
+
e -= m * g, m > 0 && p.push({ amount: m, label: m != 1 ? y[l] + "s" : y[l] });
|
|
90
157
|
}
|
|
91
|
-
for (let
|
|
92
|
-
if (
|
|
93
|
-
const
|
|
94
|
-
|
|
158
|
+
for (let l = 0; l < t; l++)
|
|
159
|
+
if (l < p.length) {
|
|
160
|
+
const g = p[l];
|
|
161
|
+
n.push(`${g.amount} ${g.label}`);
|
|
95
162
|
}
|
|
96
|
-
return
|
|
163
|
+
return n.length === 0 ? u(["less than a second"], h) : u(n, h);
|
|
97
164
|
}
|
|
98
|
-
function
|
|
99
|
-
const
|
|
100
|
-
return
|
|
165
|
+
function J(e, t = 3, r = !1) {
|
|
166
|
+
const n = e.valueOf() - Date.now();
|
|
167
|
+
return S(n, t, r);
|
|
101
168
|
}
|
|
102
|
-
class
|
|
169
|
+
class K {
|
|
103
170
|
#t = {};
|
|
104
171
|
/**
|
|
105
172
|
* Starts listening to an event.
|
|
@@ -107,8 +174,8 @@ class R {
|
|
|
107
174
|
* @param listener - The function to call when the event is emitted.
|
|
108
175
|
* @returns The listener.
|
|
109
176
|
*/
|
|
110
|
-
on(t,
|
|
111
|
-
return this.#t[t] === void 0 ? this.#t[t] = [
|
|
177
|
+
on(t, r) {
|
|
178
|
+
return this.#t[t] === void 0 ? this.#t[t] = [r] : this.#t[t].push(r), r;
|
|
112
179
|
}
|
|
113
180
|
/**
|
|
114
181
|
* Registers an event listener that is automatically removed when called.
|
|
@@ -116,140 +183,214 @@ class R {
|
|
|
116
183
|
* @param listener - The function to call once the event is emitted.
|
|
117
184
|
* @returns The wrapped listener.
|
|
118
185
|
*/
|
|
119
|
-
once(t,
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
});
|
|
123
|
-
return i;
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Starts listening to an event.
|
|
127
|
-
* @param event - The event to listen to.
|
|
128
|
-
* @param listener - The function to call when the event is emitted.
|
|
129
|
-
* @returns The wrapped listener.
|
|
130
|
-
*/
|
|
131
|
-
onAsync(t, e, i) {
|
|
132
|
-
return this.on(t, (...s) => {
|
|
133
|
-
e(...s).catch((u) => {
|
|
134
|
-
i ? i(u) : console.error(u);
|
|
135
|
-
});
|
|
136
|
-
});
|
|
186
|
+
once(t, r) {
|
|
187
|
+
const n = (...u) => (this.off(t, n), r(...u));
|
|
188
|
+
return this.on(t, n);
|
|
137
189
|
}
|
|
138
190
|
/**
|
|
139
191
|
* Removes an event listener.
|
|
140
192
|
* @param event - The event to remove the listener from.
|
|
141
193
|
* @param listener - The listener to remove.
|
|
142
194
|
*/
|
|
143
|
-
off(t,
|
|
144
|
-
|
|
195
|
+
off(t, r) {
|
|
196
|
+
const n = this.#t[t];
|
|
197
|
+
n !== void 0 && E(r, n);
|
|
145
198
|
}
|
|
146
199
|
/**
|
|
147
200
|
* Emits an event to all its listeners.
|
|
148
201
|
* @param event - The event to emit.
|
|
149
202
|
* @param args - The arguments to pass to the listeners.
|
|
150
203
|
*/
|
|
151
|
-
emit(t, ...
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
204
|
+
emit(t, ...r) {
|
|
205
|
+
const n = this.#t[t];
|
|
206
|
+
if (n !== void 0)
|
|
207
|
+
for (const u of n)
|
|
208
|
+
u(...r);
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Emits an event and waits for all listeners to resolve.
|
|
212
|
+
* @param event - The event to emit.
|
|
213
|
+
* @param args - The arguments to pass to the listeners.
|
|
214
|
+
*/
|
|
215
|
+
async emitAsync(t, ...r) {
|
|
216
|
+
const n = this.#t[t];
|
|
217
|
+
if (n === void 0)
|
|
218
|
+
return;
|
|
219
|
+
const u = n.map((h) => h(...r));
|
|
220
|
+
await Promise.all(u);
|
|
155
221
|
}
|
|
156
222
|
}
|
|
157
|
-
function
|
|
158
|
-
return
|
|
223
|
+
function G(e, t, r) {
|
|
224
|
+
return e < t ? t : e > r ? r : e;
|
|
159
225
|
}
|
|
160
|
-
function
|
|
161
|
-
return Math.random() * (t -
|
|
226
|
+
function Q(e, t) {
|
|
227
|
+
return Math.random() * (t - e) + e;
|
|
162
228
|
}
|
|
163
|
-
function
|
|
164
|
-
const
|
|
165
|
-
return Math.round(
|
|
229
|
+
function R(e, t) {
|
|
230
|
+
const r = Math.pow(10, t ?? 0);
|
|
231
|
+
return Math.round(e * r) / r;
|
|
166
232
|
}
|
|
167
|
-
function
|
|
168
|
-
return typeof
|
|
233
|
+
function O(e) {
|
|
234
|
+
return typeof e == "number" ? !0 : e.trim() === "" ? !1 : Number.isInteger(Number(e));
|
|
169
235
|
}
|
|
170
|
-
function
|
|
171
|
-
return typeof
|
|
236
|
+
function C(e) {
|
|
237
|
+
return typeof e == "number" ? !0 : e.trim() === "" ? !1 : !isNaN(Number(e));
|
|
172
238
|
}
|
|
173
|
-
function
|
|
174
|
-
return
|
|
239
|
+
function A(e, t = 0) {
|
|
240
|
+
return e !== void 0 && O(e) ? Number(e) : t;
|
|
175
241
|
}
|
|
176
|
-
function
|
|
177
|
-
return
|
|
242
|
+
function L(e, t = 0) {
|
|
243
|
+
return e !== void 0 && C(e) ? parseFloat(e) : t;
|
|
178
244
|
}
|
|
179
|
-
function
|
|
180
|
-
return
|
|
245
|
+
function _(e) {
|
|
246
|
+
return e.trim().toLowerCase() === "true";
|
|
181
247
|
}
|
|
182
|
-
function
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
248
|
+
function tt(e) {
|
|
249
|
+
return e.replace(/-([a-z])/g, (t, r) => r.toUpperCase());
|
|
250
|
+
}
|
|
251
|
+
function rt(e) {
|
|
252
|
+
if (!e.length) return "";
|
|
253
|
+
let t = e[0];
|
|
254
|
+
for (let r = 1; r < e.length; r++)
|
|
255
|
+
for (; e[r].indexOf(t) !== 0; )
|
|
187
256
|
if (t = t.substring(0, t.length - 1), t === "") return "";
|
|
188
257
|
return t;
|
|
189
258
|
}
|
|
190
|
-
class
|
|
259
|
+
class s {
|
|
191
260
|
/**
|
|
192
261
|
* Makes text black using {@link ANSI.fg.black}.
|
|
193
262
|
*/
|
|
194
263
|
static black(t) {
|
|
195
|
-
return
|
|
264
|
+
return s.#t(t, a.fg.black);
|
|
196
265
|
}
|
|
197
266
|
/**
|
|
198
267
|
* Makes text red using {@link ANSI.fg.red}.
|
|
199
268
|
*/
|
|
200
269
|
static red(t) {
|
|
201
|
-
return
|
|
270
|
+
return s.#t(t, a.fg.red);
|
|
202
271
|
}
|
|
203
272
|
/**
|
|
204
273
|
* Makes text green using {@link ANSI.fg.green}.
|
|
205
274
|
*/
|
|
206
275
|
static green(t) {
|
|
207
|
-
return
|
|
276
|
+
return s.#t(t, a.fg.green);
|
|
208
277
|
}
|
|
209
278
|
/**
|
|
210
279
|
* Makes text yellow using {@link ANSI.fg.yellow}.
|
|
211
280
|
*/
|
|
212
281
|
static yellow(t) {
|
|
213
|
-
return
|
|
282
|
+
return s.#t(t, a.fg.yellow);
|
|
214
283
|
}
|
|
215
284
|
/**
|
|
216
285
|
* Makes text blue using {@link ANSI.fg.blue}.
|
|
217
286
|
*/
|
|
218
287
|
static blue(t) {
|
|
219
|
-
return
|
|
288
|
+
return s.#t(t, a.fg.blue);
|
|
220
289
|
}
|
|
221
290
|
/**
|
|
222
291
|
* Makes text magenta using {@link ANSI.fg.magenta}.
|
|
223
292
|
*/
|
|
224
293
|
static magenta(t) {
|
|
225
|
-
return
|
|
294
|
+
return s.#t(t, a.fg.magenta);
|
|
226
295
|
}
|
|
227
296
|
/**
|
|
228
297
|
* Makes text cyan using {@link ANSI.fg.cyan}.
|
|
229
298
|
*/
|
|
230
299
|
static cyan(t) {
|
|
231
|
-
return
|
|
300
|
+
return s.#t(t, a.fg.cyan);
|
|
232
301
|
}
|
|
233
302
|
/**
|
|
234
303
|
* Makes text white using {@link ANSI.fg.white}.
|
|
235
304
|
*/
|
|
236
305
|
static white(t) {
|
|
237
|
-
return
|
|
306
|
+
return s.#t(t, a.fg.white);
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Sets background to black using {@link ANSI.bg.black}.
|
|
310
|
+
*/
|
|
311
|
+
static blackBackground(t) {
|
|
312
|
+
return s.#t(t, a.bg.black);
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Sets background to red using {@link ANSI.bg.red}.
|
|
316
|
+
*/
|
|
317
|
+
static redBackground(t) {
|
|
318
|
+
return s.#t(t, a.bg.red);
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Sets background to green using {@link ANSI.bg.green}.
|
|
322
|
+
*/
|
|
323
|
+
static greenBackground(t) {
|
|
324
|
+
return s.#t(t, a.bg.green);
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Sets background to yellow using {@link ANSI.bg.yellow}.
|
|
328
|
+
*/
|
|
329
|
+
static yellowBackground(t) {
|
|
330
|
+
return s.#t(t, a.bg.yellow);
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Sets background to blue using {@link ANSI.bg.blue}.
|
|
334
|
+
*/
|
|
335
|
+
static blueBackground(t) {
|
|
336
|
+
return s.#t(t, a.bg.blue);
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Sets background to magenta using {@link ANSI.bg.magenta}.
|
|
340
|
+
*/
|
|
341
|
+
static magentaBackground(t) {
|
|
342
|
+
return s.#t(t, a.bg.magenta);
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Sets background to cyan using {@link ANSI.bg.cyan}.
|
|
346
|
+
*/
|
|
347
|
+
static cyanBackground(t) {
|
|
348
|
+
return s.#t(t, a.bg.cyan);
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Sets background to white using {@link ANSI.bg.white}.
|
|
352
|
+
*/
|
|
353
|
+
static whiteBackground(t) {
|
|
354
|
+
return s.#t(t, a.bg.white);
|
|
238
355
|
}
|
|
239
356
|
/**
|
|
240
357
|
* Makes text bold using {@link ANSI.decoration.bold}.
|
|
241
358
|
*/
|
|
242
359
|
static bold(t) {
|
|
243
|
-
return
|
|
360
|
+
return s.#t(t, a.decoration.bold);
|
|
244
361
|
}
|
|
245
362
|
/**
|
|
246
363
|
* Makes text dim using {@link ANSI.decoration.dim}.
|
|
247
364
|
*/
|
|
248
365
|
static dim(t) {
|
|
249
|
-
return
|
|
366
|
+
return s.#t(t, a.decoration.dim);
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Makes text italic using {@link ANSI.decoration.italic}.
|
|
370
|
+
*/
|
|
371
|
+
static italic(t) {
|
|
372
|
+
return s.#t(t, a.decoration.italic);
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Underlines text using {@link ANSI.decoration.underline}.
|
|
376
|
+
*/
|
|
377
|
+
static underline(t) {
|
|
378
|
+
return s.#t(t, a.decoration.underline);
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Inverts foreground and background colors using {@link ANSI.decoration.invert}.
|
|
382
|
+
*/
|
|
383
|
+
static invert(t) {
|
|
384
|
+
return s.#t(t, a.decoration.invert);
|
|
250
385
|
}
|
|
251
|
-
|
|
252
|
-
|
|
386
|
+
/**
|
|
387
|
+
* Makes text strike through using {@link ANSI.decoration.strike}.
|
|
388
|
+
*/
|
|
389
|
+
static strike(t) {
|
|
390
|
+
return s.#t(t, a.decoration.strike);
|
|
391
|
+
}
|
|
392
|
+
static #t(t, r) {
|
|
393
|
+
return t = t.replaceAll(a.reset, a.reset + r), r + t + a.reset;
|
|
253
394
|
}
|
|
254
395
|
/**
|
|
255
396
|
* Removes all ANSI escape sequences.
|
|
@@ -264,8 +405,8 @@ class n {
|
|
|
264
405
|
return t.replace(/\u001b\[[0-9;]*m/g, "");
|
|
265
406
|
}
|
|
266
407
|
}
|
|
267
|
-
var
|
|
268
|
-
class
|
|
408
|
+
var M = /* @__PURE__ */ ((e) => (e[e.Debug = 0] = "Debug", e[e.Info = 1] = "Info", e[e.Success = 2] = "Success", e[e.Warning = 3] = "Warning", e[e.Error = 4] = "Error", e))(M || {});
|
|
409
|
+
class et {
|
|
269
410
|
/**
|
|
270
411
|
* The minimum log level or an array of log levels to enable.
|
|
271
412
|
*
|
|
@@ -288,13 +429,13 @@ class J {
|
|
|
288
429
|
* @default Ansi.cyan
|
|
289
430
|
* @see {@link Ansi.cyan}
|
|
290
431
|
*/
|
|
291
|
-
highlight =
|
|
432
|
+
highlight = s.cyan;
|
|
292
433
|
/**
|
|
293
434
|
* The function to use when emphasizing text.
|
|
294
435
|
* @default Ansi.bold
|
|
295
436
|
* @see {@link Ansi.bold}
|
|
296
437
|
*/
|
|
297
|
-
emphasize =
|
|
438
|
+
emphasize = s.bold;
|
|
298
439
|
/**
|
|
299
440
|
* The prefixes to prepend to logs.
|
|
300
441
|
* @default {
|
|
@@ -306,7 +447,19 @@ class J {
|
|
|
306
447
|
*/
|
|
307
448
|
prefix = {};
|
|
308
449
|
#t = 0;
|
|
309
|
-
#
|
|
450
|
+
#r = 0;
|
|
451
|
+
get errorCount() {
|
|
452
|
+
return this.#t;
|
|
453
|
+
}
|
|
454
|
+
set errorCount(t) {
|
|
455
|
+
this.#t = t;
|
|
456
|
+
}
|
|
457
|
+
get warningCount() {
|
|
458
|
+
return this.#r;
|
|
459
|
+
}
|
|
460
|
+
set warningCount(t) {
|
|
461
|
+
this.#r = t;
|
|
462
|
+
}
|
|
310
463
|
constructor(t) {
|
|
311
464
|
this.reset(), t !== void 0 && (Array.isArray(t) || typeof t == "number" ? this.level = t : (t.level !== void 0 && (this.level = t.level), t.prefix && (typeof t.prefix == "string" ? this.prefix.global = t.prefix : this.prefix = {
|
|
312
465
|
...this.prefix,
|
|
@@ -318,15 +471,15 @@ class J {
|
|
|
318
471
|
* Resets all properties to their default values.
|
|
319
472
|
*/
|
|
320
473
|
reset() {
|
|
321
|
-
return this.level = 0, this.indent = 0, this.indentString = " ", this.highlight =
|
|
322
|
-
1:
|
|
323
|
-
2:
|
|
324
|
-
3:
|
|
325
|
-
4:
|
|
326
|
-
}, this.#t = 0, this.#
|
|
474
|
+
return this.level = 0, this.indent = 0, this.indentString = " ", this.highlight = s.cyan, this.emphasize = s.bold, this.prefix = {
|
|
475
|
+
1: s.cyan("[info]"),
|
|
476
|
+
2: s.green("[success]"),
|
|
477
|
+
3: s.yellow("[warning]"),
|
|
478
|
+
4: s.red("[error]")
|
|
479
|
+
}, this.#t = 0, this.#r = 0, this;
|
|
327
480
|
}
|
|
328
|
-
indented(t,
|
|
329
|
-
return
|
|
481
|
+
indented(t, r = 1, n) {
|
|
482
|
+
return n !== void 0 && !this.isLevelEnabled(n) ? this : (this.indent + r < 0 && (r = -this.indent), this.tab(r), typeof t == "function" ? t() : Array.isArray(t) ? this.lines(t, n) : this.log(t, n), this.shiftTab(r), this);
|
|
330
483
|
}
|
|
331
484
|
/**
|
|
332
485
|
* Increases the level of indentation.
|
|
@@ -342,10 +495,10 @@ class J {
|
|
|
342
495
|
shiftTab(t = 1) {
|
|
343
496
|
return this.indent -= t, this.indent < 0 && (this.indent = 0), this;
|
|
344
497
|
}
|
|
345
|
-
setPrefix(t,
|
|
498
|
+
setPrefix(t, r) {
|
|
346
499
|
return typeof t == "string" ? this.prefix = {
|
|
347
500
|
global: t
|
|
348
|
-
} : typeof t == "object" ? this.prefix = t : this.prefix[t] =
|
|
501
|
+
} : typeof t == "object" ? this.prefix = t : this.prefix[t] = r, this;
|
|
349
502
|
}
|
|
350
503
|
// ===== Logging status messages =====
|
|
351
504
|
/**
|
|
@@ -360,33 +513,33 @@ class J {
|
|
|
360
513
|
* @param message - The status message.
|
|
361
514
|
*/
|
|
362
515
|
pending(t) {
|
|
363
|
-
return this.info(
|
|
516
|
+
return this.info(s.yellow(t));
|
|
364
517
|
}
|
|
365
518
|
/**
|
|
366
519
|
* Logs an error message.
|
|
367
520
|
* @param message - The error message or reason.
|
|
368
521
|
* @param details - The details of the error message.
|
|
369
522
|
*/
|
|
370
|
-
error(t, ...
|
|
523
|
+
error(t, ...r) {
|
|
371
524
|
return this.#t++, this.isLevelEnabled(
|
|
372
525
|
4
|
|
373
526
|
/* Error */
|
|
374
527
|
) ? (typeof t == "string" ? this.statusMessage(
|
|
375
|
-
|
|
376
|
-
|
|
528
|
+
s.red(t),
|
|
529
|
+
r,
|
|
377
530
|
4
|
|
378
531
|
/* Error */
|
|
379
|
-
) : console.error(t, ...
|
|
532
|
+
) : console.error(t, ...r), this) : this;
|
|
380
533
|
}
|
|
381
534
|
/**
|
|
382
535
|
* Logs a warning message.
|
|
383
536
|
* @param message - The warning message.
|
|
384
537
|
* @param details - The details of the warning message.
|
|
385
538
|
*/
|
|
386
|
-
warn(t, ...
|
|
387
|
-
return this.#
|
|
388
|
-
|
|
389
|
-
|
|
539
|
+
warn(t, ...r) {
|
|
540
|
+
return this.#r++, this.statusMessage(
|
|
541
|
+
s.yellow(t),
|
|
542
|
+
r,
|
|
390
543
|
3
|
|
391
544
|
/* Warning */
|
|
392
545
|
);
|
|
@@ -396,10 +549,10 @@ class J {
|
|
|
396
549
|
* @param message - The success message.
|
|
397
550
|
* @param details - The details of the success message.
|
|
398
551
|
*/
|
|
399
|
-
success(t, ...
|
|
552
|
+
success(t, ...r) {
|
|
400
553
|
return this.statusMessage(
|
|
401
|
-
|
|
402
|
-
|
|
554
|
+
s.green(t),
|
|
555
|
+
r,
|
|
403
556
|
2
|
|
404
557
|
/* Success */
|
|
405
558
|
);
|
|
@@ -409,10 +562,10 @@ class J {
|
|
|
409
562
|
* @param message - The info message.
|
|
410
563
|
* @param details - The details of the info message.
|
|
411
564
|
*/
|
|
412
|
-
info(t, ...
|
|
565
|
+
info(t, ...r) {
|
|
413
566
|
return this.statusMessage(
|
|
414
567
|
t,
|
|
415
|
-
|
|
568
|
+
r,
|
|
416
569
|
1
|
|
417
570
|
/* Info */
|
|
418
571
|
);
|
|
@@ -423,23 +576,23 @@ class J {
|
|
|
423
576
|
* @param details - The details of the status message.
|
|
424
577
|
* @param level - The log level.
|
|
425
578
|
*/
|
|
426
|
-
statusMessage(t,
|
|
427
|
-
let
|
|
428
|
-
if (
|
|
429
|
-
const
|
|
430
|
-
|
|
431
|
-
` +
|
|
579
|
+
statusMessage(t, r, n) {
|
|
580
|
+
let u = t;
|
|
581
|
+
if (r.length) {
|
|
582
|
+
const h = this.indentString ? this.indentString.repeat(this.indent + 1) : " ";
|
|
583
|
+
u += `
|
|
584
|
+
` + r.map((p) => h + String(p)).join(`
|
|
432
585
|
`);
|
|
433
586
|
}
|
|
434
|
-
return this.text(
|
|
587
|
+
return this.text(u, n);
|
|
435
588
|
}
|
|
436
589
|
/**
|
|
437
590
|
* Logs the amount of errors and warnings that have been logged since the previous call to this function or the creation of this logger.
|
|
438
591
|
*/
|
|
439
592
|
summary() {
|
|
440
|
-
const t = `${this.#t} error${this.#t != 1 ? "s" : ""}`,
|
|
441
|
-
let
|
|
442
|
-
return this.#t > 0 ?
|
|
593
|
+
const t = `${this.#t} error${this.#t != 1 ? "s" : ""}`, r = `${this.#r} warning${this.#r != 1 ? "s" : ""}`;
|
|
594
|
+
let n = `Found ${t} and ${r}`;
|
|
595
|
+
return this.#t > 0 ? n = s.red(n) : this.#r > 0 ? n = s.yellow(n) : n = s.green(n), this.text(n), this.#t = 0, this.#r = 0, this;
|
|
443
596
|
}
|
|
444
597
|
// ===== Logging text =====
|
|
445
598
|
/**
|
|
@@ -450,8 +603,8 @@ class J {
|
|
|
450
603
|
* @param value - The value of the parameter.
|
|
451
604
|
* @param level - The log level.
|
|
452
605
|
*/
|
|
453
|
-
parameter(t,
|
|
454
|
-
return this.text(`${t}: ${this.emphasize(String(
|
|
606
|
+
parameter(t, r, n) {
|
|
607
|
+
return this.text(`${t}: ${this.emphasize(String(r))}`, n);
|
|
455
608
|
}
|
|
456
609
|
/**
|
|
457
610
|
* Logs properties as a list of key-value pairs.
|
|
@@ -459,9 +612,9 @@ class J {
|
|
|
459
612
|
* @param level - The log level.
|
|
460
613
|
* @see {@link value()}
|
|
461
614
|
*/
|
|
462
|
-
properties(t,
|
|
463
|
-
for (const [
|
|
464
|
-
this.value(`- ${
|
|
615
|
+
properties(t, r) {
|
|
616
|
+
for (const [n, u] of Object.entries(t))
|
|
617
|
+
this.value(`- ${n}`, u, r);
|
|
465
618
|
return this;
|
|
466
619
|
}
|
|
467
620
|
/**
|
|
@@ -472,62 +625,62 @@ class J {
|
|
|
472
625
|
* @param value - The value.
|
|
473
626
|
* @param level - The log level.
|
|
474
627
|
*/
|
|
475
|
-
value(t,
|
|
476
|
-
return this.text(`${t}: ${this.highlight(String(
|
|
628
|
+
value(t, r, n) {
|
|
629
|
+
return this.text(`${t}: ${this.highlight(String(r))}`, n);
|
|
477
630
|
}
|
|
478
631
|
/**
|
|
479
632
|
* Logs emphasized text.
|
|
480
633
|
* @param text - The text to log.
|
|
481
634
|
* @param level - The log level.
|
|
482
635
|
*/
|
|
483
|
-
emphasized(t,
|
|
484
|
-
return this.text(this.emphasize(t),
|
|
636
|
+
emphasized(t, r) {
|
|
637
|
+
return this.text(this.emphasize(t), r);
|
|
485
638
|
}
|
|
486
639
|
/**
|
|
487
640
|
* Logs highlighted text.
|
|
488
641
|
* @param text - The text to log.
|
|
489
642
|
* @param level - The log level.
|
|
490
643
|
*/
|
|
491
|
-
highlighted(t,
|
|
492
|
-
return this.text(this.highlight(t),
|
|
644
|
+
highlighted(t, r) {
|
|
645
|
+
return this.text(this.highlight(t), r);
|
|
493
646
|
}
|
|
494
647
|
/**
|
|
495
648
|
* Logs each item on a new line.
|
|
496
649
|
* @param lines - The items to log.
|
|
497
650
|
* @param level - The log level.
|
|
498
651
|
*/
|
|
499
|
-
lines(t,
|
|
500
|
-
return t.map(String).forEach((
|
|
652
|
+
lines(t, r) {
|
|
653
|
+
return t.map(String).forEach((n) => this.text(n, r)), this;
|
|
501
654
|
}
|
|
502
655
|
/**
|
|
503
656
|
* Logs a message.
|
|
504
657
|
* @param message - The message to log.
|
|
505
658
|
* @param level - The log level.
|
|
506
659
|
*/
|
|
507
|
-
log(t,
|
|
508
|
-
return this.text(String(t),
|
|
660
|
+
log(t, r) {
|
|
661
|
+
return this.text(String(t), r);
|
|
509
662
|
}
|
|
510
663
|
/**
|
|
511
664
|
* Logs text using this logger's format.
|
|
512
665
|
* @param text - The text to log.
|
|
513
666
|
* @param level - The log level.
|
|
514
667
|
*/
|
|
515
|
-
text(t,
|
|
516
|
-
if (!this.isLevelEnabled(
|
|
668
|
+
text(t, r = 0) {
|
|
669
|
+
if (!this.isLevelEnabled(r))
|
|
517
670
|
return this;
|
|
518
|
-
const
|
|
519
|
-
switch (
|
|
671
|
+
const n = this.format(this.applyPrefix(t, r));
|
|
672
|
+
switch (r) {
|
|
520
673
|
case 1:
|
|
521
|
-
console.info(
|
|
674
|
+
console.info(n);
|
|
522
675
|
break;
|
|
523
676
|
case 3:
|
|
524
|
-
console.warn(
|
|
677
|
+
console.warn(n);
|
|
525
678
|
break;
|
|
526
679
|
case 4:
|
|
527
|
-
console.error(
|
|
680
|
+
console.error(n);
|
|
528
681
|
break;
|
|
529
682
|
default:
|
|
530
|
-
console.log(
|
|
683
|
+
console.log(n);
|
|
531
684
|
break;
|
|
532
685
|
}
|
|
533
686
|
return this;
|
|
@@ -559,81 +712,81 @@ class J {
|
|
|
559
712
|
* @param text - The text to apply the prefix to.
|
|
560
713
|
* @param level - The log level.
|
|
561
714
|
*/
|
|
562
|
-
applyPrefix(t,
|
|
563
|
-
const
|
|
564
|
-
return
|
|
715
|
+
applyPrefix(t, r) {
|
|
716
|
+
const n = r ? this.prefix[r] : this.prefix.global;
|
|
717
|
+
return n ? `${n} ${t}` : t;
|
|
565
718
|
}
|
|
566
719
|
}
|
|
567
|
-
function
|
|
568
|
-
return `# ${
|
|
720
|
+
function N(e) {
|
|
721
|
+
return `# ${e}`;
|
|
569
722
|
}
|
|
570
|
-
function
|
|
571
|
-
return `## ${
|
|
723
|
+
function D(e) {
|
|
724
|
+
return `## ${e}`;
|
|
572
725
|
}
|
|
573
|
-
function
|
|
574
|
-
return `### ${
|
|
726
|
+
function T(e) {
|
|
727
|
+
return `### ${e}`;
|
|
575
728
|
}
|
|
576
|
-
function
|
|
577
|
-
return `#### ${
|
|
729
|
+
function z(e) {
|
|
730
|
+
return `#### ${e}`;
|
|
578
731
|
}
|
|
579
|
-
function
|
|
580
|
-
return `##### ${
|
|
732
|
+
function F(e) {
|
|
733
|
+
return `##### ${e}`;
|
|
581
734
|
}
|
|
582
|
-
function
|
|
583
|
-
return `###### ${
|
|
735
|
+
function P(e) {
|
|
736
|
+
return `###### ${e}`;
|
|
584
737
|
}
|
|
585
|
-
function
|
|
586
|
-
return `**${
|
|
738
|
+
function I(e) {
|
|
739
|
+
return `**${e}**`;
|
|
587
740
|
}
|
|
588
|
-
function
|
|
589
|
-
return `*${
|
|
741
|
+
function j(e) {
|
|
742
|
+
return `*${e}*`;
|
|
590
743
|
}
|
|
591
|
-
function
|
|
592
|
-
return `\`${
|
|
744
|
+
function q(e) {
|
|
745
|
+
return `\`${e}\``;
|
|
593
746
|
}
|
|
594
|
-
function
|
|
595
|
-
return `\`\`\`${
|
|
747
|
+
function U(e) {
|
|
748
|
+
return `\`\`\`${e}\`\`\``;
|
|
596
749
|
}
|
|
597
|
-
function
|
|
598
|
-
return `~~${
|
|
750
|
+
function H(e) {
|
|
751
|
+
return `~~${e}~~`;
|
|
599
752
|
}
|
|
600
|
-
function
|
|
601
|
-
return `[${
|
|
753
|
+
function V(e, t) {
|
|
754
|
+
return `[${e}](${t})`;
|
|
602
755
|
}
|
|
603
|
-
function
|
|
604
|
-
return `> ${
|
|
756
|
+
function W(e) {
|
|
757
|
+
return `> ${e}`;
|
|
605
758
|
}
|
|
606
|
-
function
|
|
759
|
+
function X() {
|
|
607
760
|
return "---";
|
|
608
761
|
}
|
|
609
|
-
const
|
|
762
|
+
const nt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
610
763
|
__proto__: null,
|
|
611
|
-
bold:
|
|
612
|
-
code:
|
|
613
|
-
codeBlock:
|
|
614
|
-
heading1:
|
|
615
|
-
heading2:
|
|
616
|
-
heading3:
|
|
617
|
-
heading4:
|
|
618
|
-
heading5:
|
|
619
|
-
heading6:
|
|
620
|
-
horizontalRule:
|
|
621
|
-
italic:
|
|
622
|
-
link:
|
|
623
|
-
quote:
|
|
624
|
-
strikethrough:
|
|
764
|
+
bold: I,
|
|
765
|
+
code: q,
|
|
766
|
+
codeBlock: U,
|
|
767
|
+
heading1: N,
|
|
768
|
+
heading2: D,
|
|
769
|
+
heading3: T,
|
|
770
|
+
heading4: z,
|
|
771
|
+
heading5: F,
|
|
772
|
+
heading6: P,
|
|
773
|
+
horizontalRule: X,
|
|
774
|
+
italic: j,
|
|
775
|
+
link: V,
|
|
776
|
+
quote: W,
|
|
777
|
+
strikethrough: H
|
|
625
778
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
626
|
-
class
|
|
779
|
+
class d {
|
|
627
780
|
x;
|
|
628
781
|
y;
|
|
629
|
-
constructor(t,
|
|
630
|
-
this.x = t, this.y =
|
|
782
|
+
constructor(t, r) {
|
|
783
|
+
this.x = t, this.y = r ?? t;
|
|
631
784
|
}
|
|
632
785
|
static get ZERO() {
|
|
633
|
-
return new
|
|
786
|
+
return new d(0, 0);
|
|
634
787
|
}
|
|
635
788
|
get clone() {
|
|
636
|
-
return new
|
|
789
|
+
return new d(this.x, this.y);
|
|
637
790
|
}
|
|
638
791
|
get magnitude() {
|
|
639
792
|
return this.getDistance(this);
|
|
@@ -644,8 +797,8 @@ class a {
|
|
|
644
797
|
setY(t) {
|
|
645
798
|
return this.y = t, this;
|
|
646
799
|
}
|
|
647
|
-
set(t,
|
|
648
|
-
return this.x = t, this.y =
|
|
800
|
+
set(t, r) {
|
|
801
|
+
return this.x = t, this.y = r, this;
|
|
649
802
|
}
|
|
650
803
|
round() {
|
|
651
804
|
return this.x = Math.round(this.x), this.y = Math.round(this.y), this;
|
|
@@ -657,82 +810,245 @@ class a {
|
|
|
657
810
|
scale(t) {
|
|
658
811
|
return this.multiply(t);
|
|
659
812
|
}
|
|
660
|
-
getDistanceSquared(t,
|
|
661
|
-
const
|
|
662
|
-
return
|
|
813
|
+
getDistanceSquared(t, r) {
|
|
814
|
+
const n = d.parseVector(t, r), u = this.x - n.x, h = this.y - n.y;
|
|
815
|
+
return u * u + h * h;
|
|
663
816
|
}
|
|
664
|
-
getDistance(t,
|
|
665
|
-
const
|
|
666
|
-
return Math.sqrt(this.getDistanceSquared(
|
|
817
|
+
getDistance(t, r) {
|
|
818
|
+
const n = d.parseVector(t, r);
|
|
819
|
+
return Math.sqrt(this.getDistanceSquared(n.x, n.y));
|
|
667
820
|
}
|
|
668
|
-
add(t,
|
|
669
|
-
const
|
|
670
|
-
return this.x +=
|
|
821
|
+
add(t, r) {
|
|
822
|
+
const n = d.parseVector(t, r);
|
|
823
|
+
return this.x += n.x, this.y += n.y, this;
|
|
671
824
|
}
|
|
672
|
-
subtract(t,
|
|
673
|
-
const
|
|
674
|
-
return this.x -=
|
|
825
|
+
subtract(t, r) {
|
|
826
|
+
const n = d.parseVector(t, r);
|
|
827
|
+
return this.x -= n.x, this.y -= n.y, this;
|
|
675
828
|
}
|
|
676
|
-
multiply(t,
|
|
677
|
-
const
|
|
678
|
-
return this.x *=
|
|
829
|
+
multiply(t, r) {
|
|
830
|
+
const n = d.parseVector(t, r);
|
|
831
|
+
return this.x *= n.x, this.y *= n.y, this;
|
|
679
832
|
}
|
|
680
|
-
divide(t,
|
|
681
|
-
const
|
|
682
|
-
return this.x /=
|
|
833
|
+
divide(t, r) {
|
|
834
|
+
const n = d.parseVector(t, r);
|
|
835
|
+
return this.x /= n.x, this.y /= n.y, this;
|
|
683
836
|
}
|
|
684
|
-
lerp(t,
|
|
685
|
-
return this.x += (t.x - this.x) *
|
|
837
|
+
lerp(t, r) {
|
|
838
|
+
return this.x += (t.x - this.x) * r, this.y += (t.y - this.y) * r, this;
|
|
686
839
|
}
|
|
687
|
-
static sum(t,
|
|
688
|
-
return t.clone.add(
|
|
840
|
+
static sum(t, r) {
|
|
841
|
+
return t.clone.add(r);
|
|
689
842
|
}
|
|
690
|
-
static difference(t,
|
|
691
|
-
return t.clone.subtract(
|
|
843
|
+
static difference(t, r) {
|
|
844
|
+
return t.clone.subtract(r);
|
|
692
845
|
}
|
|
693
|
-
static product(t,
|
|
694
|
-
return t.clone.multiply(
|
|
846
|
+
static product(t, r) {
|
|
847
|
+
return t.clone.multiply(r);
|
|
695
848
|
}
|
|
696
|
-
static division(t,
|
|
697
|
-
return t.clone.divide(
|
|
849
|
+
static division(t, r) {
|
|
850
|
+
return t.clone.divide(r);
|
|
698
851
|
}
|
|
699
|
-
static scale(t,
|
|
700
|
-
return t.clone.scale(
|
|
852
|
+
static scale(t, r) {
|
|
853
|
+
return t.clone.scale(r);
|
|
701
854
|
}
|
|
702
855
|
static normalize(t) {
|
|
703
856
|
return t.clone.normalize();
|
|
704
857
|
}
|
|
705
|
-
static lerp(t,
|
|
706
|
-
return t.clone.lerp(
|
|
858
|
+
static lerp(t, r, n) {
|
|
859
|
+
return t.clone.lerp(r, n);
|
|
860
|
+
}
|
|
861
|
+
static from({ x: t, y: r }) {
|
|
862
|
+
return new d(t, r);
|
|
863
|
+
}
|
|
864
|
+
static parseVector(t, r) {
|
|
865
|
+
return t instanceof d ? (r = t.y, t = t.x) : r === void 0 && (r = t), { x: t, y: r };
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
class k {
|
|
869
|
+
/**
|
|
870
|
+
* Returns `true` if this result is a {@link Result.Success}.
|
|
871
|
+
*/
|
|
872
|
+
isOk() {
|
|
873
|
+
return !1;
|
|
874
|
+
}
|
|
875
|
+
/**
|
|
876
|
+
* Returns `true` if this result is a {@link Result.Failure}.
|
|
877
|
+
*/
|
|
878
|
+
isError() {
|
|
879
|
+
return !1;
|
|
707
880
|
}
|
|
708
|
-
|
|
709
|
-
|
|
881
|
+
/**
|
|
882
|
+
* Executes a callback for side effects if this result is a {@link Result.Success}.
|
|
883
|
+
*/
|
|
884
|
+
ifOk(t) {
|
|
885
|
+
return this.isOk() && t(this.value), this;
|
|
710
886
|
}
|
|
711
|
-
|
|
712
|
-
|
|
887
|
+
/**
|
|
888
|
+
* Executes a callback for side effects if this result is a {@link Result.Failure}.
|
|
889
|
+
*/
|
|
890
|
+
ifError(t) {
|
|
891
|
+
return this.isError() && t(this.error), this;
|
|
713
892
|
}
|
|
714
893
|
}
|
|
894
|
+
var v;
|
|
895
|
+
((e) => {
|
|
896
|
+
class t extends k {
|
|
897
|
+
constructor(i) {
|
|
898
|
+
super(), this.value = i;
|
|
899
|
+
}
|
|
900
|
+
value;
|
|
901
|
+
isOk() {
|
|
902
|
+
return !0;
|
|
903
|
+
}
|
|
904
|
+
map(i) {
|
|
905
|
+
return n(i(this.value));
|
|
906
|
+
}
|
|
907
|
+
mapError(i) {
|
|
908
|
+
return n(this.value);
|
|
909
|
+
}
|
|
910
|
+
next(i) {
|
|
911
|
+
return i(this.value);
|
|
912
|
+
}
|
|
913
|
+
orElse(i) {
|
|
914
|
+
return this;
|
|
915
|
+
}
|
|
916
|
+
unwrapOr(i) {
|
|
917
|
+
return this.value;
|
|
918
|
+
}
|
|
919
|
+
match(i, c) {
|
|
920
|
+
return i(this.value);
|
|
921
|
+
}
|
|
922
|
+
filter(i, c) {
|
|
923
|
+
return i(this.value) ? n(this.value) : u(c(this.value));
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
e.Success = t;
|
|
927
|
+
class r extends k {
|
|
928
|
+
constructor(i) {
|
|
929
|
+
super(), this.error = i;
|
|
930
|
+
}
|
|
931
|
+
error;
|
|
932
|
+
isError() {
|
|
933
|
+
return !0;
|
|
934
|
+
}
|
|
935
|
+
map(i) {
|
|
936
|
+
return u(this.error);
|
|
937
|
+
}
|
|
938
|
+
mapError(i) {
|
|
939
|
+
return u(i(this.error));
|
|
940
|
+
}
|
|
941
|
+
next(i) {
|
|
942
|
+
return u(this.error);
|
|
943
|
+
}
|
|
944
|
+
orElse(i) {
|
|
945
|
+
return i(this.error);
|
|
946
|
+
}
|
|
947
|
+
unwrapOr(i) {
|
|
948
|
+
return i;
|
|
949
|
+
}
|
|
950
|
+
match(i, c) {
|
|
951
|
+
return c(this.error);
|
|
952
|
+
}
|
|
953
|
+
filter(i, c) {
|
|
954
|
+
return u(this.error);
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
e.Failure = r;
|
|
958
|
+
function n(o) {
|
|
959
|
+
return new t(o);
|
|
960
|
+
}
|
|
961
|
+
e.ok = n;
|
|
962
|
+
function u(o) {
|
|
963
|
+
return new r(o);
|
|
964
|
+
}
|
|
965
|
+
e.error = u;
|
|
966
|
+
function h(o, i) {
|
|
967
|
+
try {
|
|
968
|
+
return n(o());
|
|
969
|
+
} catch (c) {
|
|
970
|
+
return u(i ? i(c) : c);
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
e.wrap = h;
|
|
974
|
+
function p(o, i) {
|
|
975
|
+
return o != null ? n(o) : u(i);
|
|
976
|
+
}
|
|
977
|
+
e.nonNullOr = p;
|
|
978
|
+
function y(o, i) {
|
|
979
|
+
return o != null ? n(o) : i();
|
|
980
|
+
}
|
|
981
|
+
e.nonNullOrElse = y;
|
|
982
|
+
function l(o, i, c) {
|
|
983
|
+
let f = o;
|
|
984
|
+
for (; i(f); ) {
|
|
985
|
+
const x = c(f);
|
|
986
|
+
if (x.isError())
|
|
987
|
+
return x;
|
|
988
|
+
f = x.value;
|
|
989
|
+
}
|
|
990
|
+
return n(f);
|
|
991
|
+
}
|
|
992
|
+
e.repeat = l;
|
|
993
|
+
function g(o, i, c) {
|
|
994
|
+
let f = c;
|
|
995
|
+
for (const x of o) {
|
|
996
|
+
const B = i(f, x);
|
|
997
|
+
if (B.isError())
|
|
998
|
+
return B;
|
|
999
|
+
f = B.value;
|
|
1000
|
+
}
|
|
1001
|
+
return n(f);
|
|
1002
|
+
}
|
|
1003
|
+
e.reduce = g;
|
|
1004
|
+
function m(o) {
|
|
1005
|
+
const i = [];
|
|
1006
|
+
for (const c of o) {
|
|
1007
|
+
if (c.isError())
|
|
1008
|
+
return u(c.error);
|
|
1009
|
+
i.push(c.value);
|
|
1010
|
+
}
|
|
1011
|
+
return n(i);
|
|
1012
|
+
}
|
|
1013
|
+
e.all = m;
|
|
1014
|
+
function b(o, i, c) {
|
|
1015
|
+
for (const f of o) {
|
|
1016
|
+
const x = i(f);
|
|
1017
|
+
if (x.isOk())
|
|
1018
|
+
return x;
|
|
1019
|
+
}
|
|
1020
|
+
return c;
|
|
1021
|
+
}
|
|
1022
|
+
e.any = b;
|
|
1023
|
+
function $(o, i, c, f) {
|
|
1024
|
+
return i(o) ? n(c(o)) : u(f(o));
|
|
1025
|
+
}
|
|
1026
|
+
e.require = $;
|
|
1027
|
+
})(v || (v = {}));
|
|
715
1028
|
export {
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
1029
|
+
a as ANSI,
|
|
1030
|
+
s as Ansi,
|
|
1031
|
+
k as BaseResult,
|
|
1032
|
+
K as EventEmitter,
|
|
1033
|
+
M as LogLevel,
|
|
1034
|
+
et as Logger,
|
|
1035
|
+
nt as Markdown,
|
|
1036
|
+
v as Result,
|
|
1037
|
+
d as Vector2,
|
|
1038
|
+
G as clamp,
|
|
1039
|
+
J as formatRelativeTime,
|
|
1040
|
+
S as formatTime,
|
|
1041
|
+
rt as getLongestCommonPrefix,
|
|
1042
|
+
O as isValidInteger,
|
|
1043
|
+
C as isValidNumber,
|
|
1044
|
+
tt as kebabToCamelCase,
|
|
1045
|
+
_ as parseBool,
|
|
1046
|
+
L as parseOptionalFloat,
|
|
1047
|
+
A as parseOptionalInteger,
|
|
1048
|
+
Y as randomFromArray,
|
|
1049
|
+
Q as randomRange,
|
|
1050
|
+
Z as removeDuplicatesFromArray,
|
|
1051
|
+
E as removeFromArray,
|
|
1052
|
+
R as round
|
|
737
1053
|
};
|
|
738
1054
|
//# sourceMappingURL=main.js.map
|