@prozilla-os/shared 1.4.0 → 1.5.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.
@@ -0,0 +1,857 @@
1
+ import { i as x, m as N } from "./object.utils-xiWGUq8N.js";
2
+ const s = {
3
+ /**
4
+ * Foreground colors.
5
+ */
6
+ fg: {
7
+ black: "\x1B[30m",
8
+ red: "\x1B[31m",
9
+ green: "\x1B[32m",
10
+ yellow: "\x1B[33m",
11
+ blue: "\x1B[34m",
12
+ magenta: "\x1B[35m",
13
+ cyan: "\x1B[36m",
14
+ white: "\x1B[37m"
15
+ },
16
+ /**
17
+ * Background colors.
18
+ */
19
+ bg: {
20
+ black: "\x1B[40m",
21
+ red: "\x1B[41m",
22
+ green: "\x1B[42m",
23
+ yellow: "\x1B[43m",
24
+ blue: "\x1B[44m",
25
+ magenta: "\x1B[45m",
26
+ cyan: "\x1B[46m",
27
+ white: "\x1B[47m"
28
+ },
29
+ /**
30
+ * Screen buffer and clearing controls.
31
+ */
32
+ screen: {
33
+ enterAltBuffer: "\x1B[?1049h",
34
+ exitAltBuffer: "\x1B[?1049l",
35
+ clear: "\x1B[2J",
36
+ clearLine: "\x1B[2K",
37
+ home: "\x1B[H"
38
+ },
39
+ /**
40
+ * Cursor controls.
41
+ */
42
+ cursor: {
43
+ /** Changes the position of the cursor. */
44
+ position: (r, t) => `\x1B[${r};${t}H`,
45
+ hide: "\x1B[?25l",
46
+ show: "\x1B[?25h",
47
+ save: "\x1B[s",
48
+ restore: "\x1B[u"
49
+ },
50
+ /**
51
+ * Terminal input.
52
+ */
53
+ input: {
54
+ /** Move cursor up. */
55
+ arrowUp: "\x1B[A",
56
+ /** Move cursor down. */
57
+ arrowDown: "\x1B[B",
58
+ /** Move cursor right. */
59
+ arrowRight: "\x1B[C",
60
+ /** Move cursor left. */
61
+ arrowLeft: "\x1B[D",
62
+ horizontalTab: " ",
63
+ lineFeed: `
64
+ `,
65
+ verticalTab: "\v",
66
+ formFeed: "\f",
67
+ carriageReturn: "\r",
68
+ backspace: "\b",
69
+ delete: "",
70
+ escape: "\x1B",
71
+ pageUp: "\x1B[5~",
72
+ pageDown: "\x1B[6~",
73
+ ctrlA: "",
74
+ ctrlB: "",
75
+ ctrlC: "",
76
+ ctrlD: "",
77
+ ctrlE: "",
78
+ ctrlF: "",
79
+ ctrlG: "\x07",
80
+ ctrlH: "\b",
81
+ ctrlI: " ",
82
+ ctrlJ: `
83
+ `,
84
+ ctrlK: "\v",
85
+ ctrlL: "\f",
86
+ ctrlM: "\r",
87
+ ctrlN: "",
88
+ ctrlO: "",
89
+ ctrlP: "",
90
+ ctrlQ: "",
91
+ ctrlR: "",
92
+ ctrlS: "",
93
+ ctrlT: "",
94
+ ctrlU: "",
95
+ ctrlV: "",
96
+ ctrlW: "",
97
+ ctrlX: "",
98
+ ctrlY: "",
99
+ ctrlZ: ""
100
+ },
101
+ /**
102
+ * Decorations.
103
+ */
104
+ decoration: {
105
+ dim: "\x1B[2m",
106
+ bold: "\x1B[1m",
107
+ italic: "\x1B[3m",
108
+ underline: "\x1B[4m",
109
+ blink: "\x1B[5m",
110
+ invert: "\x1B[7m",
111
+ strike: "\x1B[9m"
112
+ },
113
+ reset: "\x1B[0m"
114
+ };
115
+ class o {
116
+ /**
117
+ * Makes text black using {@link ANSI.fg.black}.
118
+ */
119
+ static black(t) {
120
+ return o.apply(t, s.fg.black);
121
+ }
122
+ /**
123
+ * Makes text red using {@link ANSI.fg.red}.
124
+ */
125
+ static red(t) {
126
+ return o.apply(t, s.fg.red);
127
+ }
128
+ /**
129
+ * Makes text green using {@link ANSI.fg.green}.
130
+ */
131
+ static green(t) {
132
+ return o.apply(t, s.fg.green);
133
+ }
134
+ /**
135
+ * Makes text yellow using {@link ANSI.fg.yellow}.
136
+ */
137
+ static yellow(t) {
138
+ return o.apply(t, s.fg.yellow);
139
+ }
140
+ /**
141
+ * Makes text blue using {@link ANSI.fg.blue}.
142
+ */
143
+ static blue(t) {
144
+ return o.apply(t, s.fg.blue);
145
+ }
146
+ /**
147
+ * Makes text magenta using {@link ANSI.fg.magenta}.
148
+ */
149
+ static magenta(t) {
150
+ return o.apply(t, s.fg.magenta);
151
+ }
152
+ /**
153
+ * Makes text cyan using {@link ANSI.fg.cyan}.
154
+ */
155
+ static cyan(t) {
156
+ return o.apply(t, s.fg.cyan);
157
+ }
158
+ /**
159
+ * Makes text white using {@link ANSI.fg.white}.
160
+ */
161
+ static white(t) {
162
+ return o.apply(t, s.fg.white);
163
+ }
164
+ /**
165
+ * Sets background to black using {@link ANSI.bg.black}.
166
+ */
167
+ static blackBackground(t) {
168
+ return o.apply(t, s.bg.black);
169
+ }
170
+ /**
171
+ * Sets background to red using {@link ANSI.bg.red}.
172
+ */
173
+ static redBackground(t) {
174
+ return o.apply(t, s.bg.red);
175
+ }
176
+ /**
177
+ * Sets background to green using {@link ANSI.bg.green}.
178
+ */
179
+ static greenBackground(t) {
180
+ return o.apply(t, s.bg.green);
181
+ }
182
+ /**
183
+ * Sets background to yellow using {@link ANSI.bg.yellow}.
184
+ */
185
+ static yellowBackground(t) {
186
+ return o.apply(t, s.bg.yellow);
187
+ }
188
+ /**
189
+ * Sets background to blue using {@link ANSI.bg.blue}.
190
+ */
191
+ static blueBackground(t) {
192
+ return o.apply(t, s.bg.blue);
193
+ }
194
+ /**
195
+ * Sets background to magenta using {@link ANSI.bg.magenta}.
196
+ */
197
+ static magentaBackground(t) {
198
+ return o.apply(t, s.bg.magenta);
199
+ }
200
+ /**
201
+ * Sets background to cyan using {@link ANSI.bg.cyan}.
202
+ */
203
+ static cyanBackground(t) {
204
+ return o.apply(t, s.bg.cyan);
205
+ }
206
+ /**
207
+ * Sets background to white using {@link ANSI.bg.white}.
208
+ */
209
+ static whiteBackground(t) {
210
+ return o.apply(t, s.bg.white);
211
+ }
212
+ /**
213
+ * Makes text bold using {@link ANSI.decoration.bold}.
214
+ */
215
+ static bold(t) {
216
+ return o.apply(t, s.decoration.bold);
217
+ }
218
+ /**
219
+ * Makes text dim using {@link ANSI.decoration.dim}.
220
+ */
221
+ static dim(t) {
222
+ return o.apply(t, s.decoration.dim);
223
+ }
224
+ /**
225
+ * Makes text italic using {@link ANSI.decoration.italic}.
226
+ */
227
+ static italic(t) {
228
+ return o.apply(t, s.decoration.italic);
229
+ }
230
+ /**
231
+ * Underlines text using {@link ANSI.decoration.underline}.
232
+ */
233
+ static underline(t) {
234
+ return o.apply(t, s.decoration.underline);
235
+ }
236
+ /**
237
+ * Inverts foreground and background colors using {@link ANSI.decoration.invert}.
238
+ */
239
+ static invert(t) {
240
+ return o.apply(t, s.decoration.invert);
241
+ }
242
+ /**
243
+ * Makes text strike through using {@link ANSI.decoration.strike}.
244
+ */
245
+ static strike(t) {
246
+ return o.apply(t, s.decoration.strike);
247
+ }
248
+ static apply(t, e) {
249
+ return t = t.replaceAll(s.reset, s.reset + e), e + t + s.reset;
250
+ }
251
+ /**
252
+ * Removes all ANSI escape sequences.
253
+ */
254
+ static strip(t) {
255
+ return t.replace(/\u001b\[[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, "");
256
+ }
257
+ /**
258
+ * Removes ANSI escape sequences for colors and background colors (SGR).
259
+ */
260
+ static stripColors(t) {
261
+ return t.replace(/\u001b\[[0-9;]*m/g, "");
262
+ }
263
+ }
264
+ const B = /* @__PURE__ */ Symbol("inspectionContext"), D = /* @__PURE__ */ Symbol.for("react.element"), R = /* @__PURE__ */ Symbol.for("react.fragment"), m = {
265
+ depth: 2,
266
+ maxArrayLength: 100,
267
+ maxStringLength: 80,
268
+ breakLength: 60,
269
+ compact: !0,
270
+ sortKeys: !1,
271
+ singleQuotes: !1,
272
+ spaceAfterComma: !0,
273
+ plugins: [],
274
+ colors: {
275
+ string: s.fg.green,
276
+ number: s.fg.yellow,
277
+ boolean: s.fg.yellow,
278
+ null: s.decoration.dim + s.fg.yellow,
279
+ undefined: s.decoration.dim + s.fg.yellow,
280
+ bigint: s.fg.yellow,
281
+ symbol: s.fg.green,
282
+ function: s.fg.blue,
283
+ key: s.fg.white,
284
+ date: s.fg.magenta,
285
+ regExp: s.fg.cyan,
286
+ error: s.fg.red,
287
+ htmlTag: s.fg.red,
288
+ reactComponent: s.fg.yellow,
289
+ delimiter: s.fg.cyan
290
+ }
291
+ };
292
+ function p(r, t) {
293
+ const e = u(r, t);
294
+ if (typeof e == "string")
295
+ return e;
296
+ if (r === null)
297
+ return e.token("null", "null");
298
+ if (r === void 0)
299
+ return e.token("undefined", "undefined");
300
+ if (typeof r == "boolean")
301
+ return e.token(String(r), "boolean");
302
+ if (typeof r == "number") {
303
+ let n;
304
+ return Number.isNaN(r) ? n = "NaN" : Number.isFinite(r) ? n = String(r) : n = r > 0 ? "Infinity" : "-Infinity", e.token(n, "number");
305
+ }
306
+ if (typeof r == "bigint")
307
+ return e.token(r + "n", "bigint");
308
+ if (typeof r == "string")
309
+ return F(r, e);
310
+ if (typeof r == "symbol")
311
+ return e.token(r.toString(), "symbol");
312
+ if (typeof r == "function")
313
+ return P(r, e);
314
+ if (E(r))
315
+ return w(r, e);
316
+ if (Array.isArray(r))
317
+ return j(r, e);
318
+ if (r instanceof Date)
319
+ return e.token(r.toISOString(), "date");
320
+ if (r instanceof RegExp)
321
+ return e.token(r.toString(), "regExp");
322
+ if (r instanceof Error)
323
+ return O(r, e);
324
+ if (r instanceof Map)
325
+ return M(r, e);
326
+ if (r instanceof Set)
327
+ return K(r, e);
328
+ if (r instanceof Promise)
329
+ return e.token("Promise { <pending> }", "function");
330
+ if (x(r))
331
+ return I(r, e);
332
+ for (const n of e.plugins)
333
+ if (n.fallback) {
334
+ const i = n.fallback(r, e);
335
+ if (i !== void 0)
336
+ return i;
337
+ }
338
+ return Object.prototype.toString.call(r);
339
+ }
340
+ function J(r, t, e, n) {
341
+ const i = u(r, n);
342
+ if (typeof i == "string")
343
+ return i;
344
+ const a = i.token(r.name || "(anonymous)", "function"), c = t.map((g) => p(g, i.fork())).join(i.separator()), f = p(e, i.fork()), l = i.colors ? o.dim("→") : "→";
345
+ return `${a}(${c}) ${l} ${f}`;
346
+ }
347
+ function w(r, t) {
348
+ const e = u(r, t);
349
+ if (typeof e == "string")
350
+ return e;
351
+ let n, i = !1;
352
+ if (typeof r.type == "string")
353
+ n = e.token(r.type, "htmlTag");
354
+ else if (r.type === R)
355
+ n = "", i = !0;
356
+ else {
357
+ if (x(r.type) || typeof r.type == "function") {
358
+ let y = r.type.name;
359
+ "displayName" in r.type && r.type.displayName && (y = r.type.displayName), n = String(y);
360
+ } else
361
+ n = String(r.type);
362
+ n = e.token(n, "reactComponent");
363
+ }
364
+ const a = [];
365
+ let c = [];
366
+ if (r.props && x(r.props)) {
367
+ const y = Object.keys(r.props);
368
+ e.sortKeys && y.sort();
369
+ for (const $ of y) {
370
+ const d = r.props[$];
371
+ $ === "children" ? c = (Array.isArray(d) ? d : [d]).map((T) => z(T, e)) : a.push(A($, d, e));
372
+ }
373
+ }
374
+ const f = e.delimiter("<"), l = e.delimiter(">"), g = e.delimiter("/"), h = a.length ? " " + a.join(" ") : "";
375
+ return c.length || i ? `${f}${n}${h}${l}${c.join("")}${f}${g}${n}${l}` : `${f}${n}${h}${g}${l}`;
376
+ }
377
+ function z(r, t) {
378
+ return r == null || typeof r == "boolean" ? "" : typeof r == "string" ? r : typeof r == "number" ? r.toString() : E(r) ? w(r, t.fork()) : "";
379
+ }
380
+ function A(r, t, e) {
381
+ return `${e.token(r, "key")}={${p(t, e.fork())}}`;
382
+ }
383
+ function F(r, t) {
384
+ const e = u(r, t);
385
+ if (typeof e == "string")
386
+ return e;
387
+ const n = r.length > e.maxStringLength, i = n ? r.slice(0, e.maxStringLength) : r;
388
+ let a = JSON.stringify(i);
389
+ e.singleQuotes && (a = a.replace(/\\"/g, '"').replace(/'/g, "\\'"));
390
+ const c = e.token(a.slice(1, -1), "string"), f = e.delimiter(e.singleQuotes ? "'" : '"'), l = f + c + f;
391
+ return n ? l + e.token("...", "null") : l;
392
+ }
393
+ function P(r, t) {
394
+ const e = u(r, t);
395
+ if (typeof e == "string")
396
+ return e;
397
+ const n = r.name || "(anonymous)";
398
+ return e.token(`[Function: ${n}]`, "function");
399
+ }
400
+ function j(r, t) {
401
+ const e = u(r, t);
402
+ if (typeof e == "string")
403
+ return e;
404
+ const n = b(r, e, `[Array(${r.length})]`);
405
+ if (n !== null)
406
+ return n;
407
+ const i = [], a = Math.min(r.length, e.maxArrayLength);
408
+ for (let c = 0; c < a; c++)
409
+ i.push(p(r[c], e.fork()));
410
+ if (r.length > e.maxArrayLength) {
411
+ const c = r.length - e.maxArrayLength;
412
+ i.push(e.token(`... ${c} more item${c !== 1 ? "s" : ""}`, "null"));
413
+ }
414
+ return k(i, e, "[", "]");
415
+ }
416
+ function I(r, t) {
417
+ const e = u(r, t);
418
+ if (typeof e == "string")
419
+ return e;
420
+ const n = b(r, e, "[Object]");
421
+ if (n !== null)
422
+ return n;
423
+ let i = Object.keys(r);
424
+ if (e.sortKeys && (i = i.sort()), !i.length)
425
+ return e.delimiter("{}");
426
+ const a = i.map((l) => {
427
+ const g = e.token(l, "key"), h = p(r[l], e.fork());
428
+ return `${g}${e.delimiter(":")} ${h}`;
429
+ }), c = e.delimiter("{") + " ", f = " " + e.delimiter("}");
430
+ return k(a, e, c, f);
431
+ }
432
+ function M(r, t) {
433
+ const e = u(r, t);
434
+ if (typeof e == "string")
435
+ return e;
436
+ const n = b(r, e, `Map(${r.size})`);
437
+ if (n !== null)
438
+ return n;
439
+ if (r.size === 0)
440
+ return "Map(0) {}";
441
+ const i = [];
442
+ for (const [a, c] of r) {
443
+ const f = e.fork();
444
+ i.push(`${p(a, f)} => ${p(c, f)}`);
445
+ }
446
+ return k(i, e, `Map(${r.size}) { `, " }");
447
+ }
448
+ function K(r, t) {
449
+ const e = u(r, t);
450
+ if (typeof e == "string")
451
+ return e;
452
+ const n = b(r, e, `Set(${r.size})`);
453
+ if (n !== null)
454
+ return n;
455
+ if (r.size === 0)
456
+ return "Set(0) {}";
457
+ const i = [];
458
+ for (const a of r)
459
+ i.push(p(a, e.fork()));
460
+ return k(i, e, `Set(${r.size}) { `, " }");
461
+ }
462
+ function O(r, t) {
463
+ const e = u(r, t);
464
+ if (typeof e == "string")
465
+ return e;
466
+ const n = r.name || "Error";
467
+ return e.token(r.message ? `${n}: ${r.message}` : n, "error");
468
+ }
469
+ function b(r, t, e) {
470
+ return t.seen.has(r) ? t.token("[Circular]", "null") : t.currentDepth > t.depth ? t.token(e, "null") : (t.seen.add(r), null);
471
+ }
472
+ function k(r, t, e, n) {
473
+ const i = `${e}${r.join(t.separator())}${n}`;
474
+ if (!t.compact && o.strip(i).length > t.breakLength) {
475
+ const a = " ".repeat(t.currentDepth + 1), c = " ".repeat(t.currentDepth), f = e.replace(/\s+$/, ""), l = r.map((h) => `${a}${h}`).join(`,
476
+ `), g = n.replace(/^\s+/, "");
477
+ return `${f}
478
+ ${l}
479
+ ${c}${g}`;
480
+ }
481
+ return i;
482
+ }
483
+ function u(r, t) {
484
+ let e;
485
+ if (t && H(t))
486
+ e = t;
487
+ else {
488
+ e = {
489
+ // TODO: Fix mergeDeep so plugins and colors don't have to be duplicated here
490
+ ...t ? N(m, { plugins: m.plugins, colors: m.colors, ...t }) : m,
491
+ [B]: !0,
492
+ currentDepth: 0,
493
+ seen: /* @__PURE__ */ new WeakSet(),
494
+ color: (n, i) => e.colors && i ? o.apply(n, i) : n,
495
+ token: (n, i) => i !== void 0 && e.colors ? e.color(n, e.colors[i]) : n,
496
+ delimiter: (n) => e.token(n, "delimiter"),
497
+ separator: () => e.spaceAfterComma ? e.delimiter(",") + " " : e.delimiter(","),
498
+ fork: () => S(e)
499
+ };
500
+ for (const n of e.plugins)
501
+ n.config && n.config(e);
502
+ }
503
+ for (const n of e.plugins)
504
+ if (n.first) {
505
+ const i = n.first(r, e);
506
+ if (i !== void 0)
507
+ return i;
508
+ }
509
+ return e;
510
+ }
511
+ function S(r) {
512
+ const t = { ...r, currentDepth: r.currentDepth + 1 };
513
+ return t.fork = () => S(t), t;
514
+ }
515
+ function H(r) {
516
+ return B in r;
517
+ }
518
+ function E(r) {
519
+ return x(r) && "$$typeof" in r && r.$$typeof === D;
520
+ }
521
+ var Q = /* @__PURE__ */ ((r) => (r[r.Debug = 0] = "Debug", r[r.Info = 1] = "Info", r[r.Success = 2] = "Success", r[r.Warning = 3] = "Warning", r[r.Error = 4] = "Error", r))(Q || {});
522
+ class C {
523
+ /**
524
+ * The minimum log level or an array of log levels to enable.
525
+ *
526
+ * `undefined` enables all log levels. An array enables all log levels in that array. A single level enables that log level and the ones above.
527
+ * @default LogLevel.Debug
528
+ */
529
+ level;
530
+ /**
531
+ * The current level of indentation.
532
+ * @default 0
533
+ */
534
+ indent = 0;
535
+ /**
536
+ * The string to use for indentation.
537
+ * @default "\t"
538
+ */
539
+ indentString;
540
+ /**
541
+ * The function to use when highlighting text.
542
+ * @default Ansi.cyan
543
+ * @see {@link Ansi.cyan}
544
+ */
545
+ highlight = o.cyan;
546
+ /**
547
+ * The function to use when emphasizing text.
548
+ * @default Ansi.bold
549
+ * @see {@link Ansi.bold}
550
+ */
551
+ emphasize = o.bold;
552
+ /**
553
+ * The prefixes to prepend to logs.
554
+ * @default {
555
+ [LogLevel.Info]: Ansi.cyan("[info]"),
556
+ [LogLevel.Success]: Ansi.green("[success]"),
557
+ [LogLevel.Warning]: Ansi.yellow("[warning]"),
558
+ [LogLevel.Error]: Ansi.red("[error]"),
559
+ }
560
+ */
561
+ prefix = {};
562
+ /**
563
+ * The function to use to turn values into strings.
564
+ * @see {@link createStringifier}
565
+ * @default Logger.createStringifier("pretty")
566
+ */
567
+ stringify = C.createStringifier("pretty");
568
+ #t = 0;
569
+ #e = 0;
570
+ get errorCount() {
571
+ return this.#t;
572
+ }
573
+ set errorCount(t) {
574
+ this.#t = t;
575
+ }
576
+ get warningCount() {
577
+ return this.#e;
578
+ }
579
+ set warningCount(t) {
580
+ this.#e = t;
581
+ }
582
+ constructor(t) {
583
+ 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 = {
584
+ ...this.prefix,
585
+ ...t.prefix
586
+ })));
587
+ }
588
+ // ===== Modifying state =====
589
+ /**
590
+ * Resets all properties to their default values.
591
+ */
592
+ reset() {
593
+ return this.level = 0, this.indent = 0, this.indentString = " ", this.highlight = o.cyan, this.emphasize = o.bold, this.prefix = {
594
+ 1: o.cyan("[info]"),
595
+ 2: o.green("[success]"),
596
+ 3: o.yellow("[warning]"),
597
+ 4: o.red("[error]")
598
+ }, this.#t = 0, this.#e = 0, this;
599
+ }
600
+ indented(t, e = 1, n) {
601
+ return n !== void 0 && !this.isLevelEnabled(n) ? this : (this.indent + e < 0 && (e = -this.indent), this.tab(e), typeof t == "function" ? t() : Array.isArray(t) ? this.lines(t, n) : this.log(t, n), this.shiftTab(e), this);
602
+ }
603
+ /**
604
+ * Increases the level of indentation.
605
+ * @param amount - The amount to increase the level of indentation with.
606
+ */
607
+ tab(t = 1) {
608
+ return this.indent += t, this.indent < 0 && (this.indent = 0), this;
609
+ }
610
+ /**
611
+ * Decreases the level of indentation.
612
+ * @param amount - The amount to decrease the level of indentation with.
613
+ */
614
+ shiftTab(t = 1) {
615
+ return this.indent -= t, this.indent < 0 && (this.indent = 0), this;
616
+ }
617
+ setPrefix(t, e) {
618
+ return typeof t == "string" ? this.prefix = {
619
+ global: t
620
+ } : typeof t == "object" ? this.prefix = t : this.prefix[t] = e, this;
621
+ }
622
+ // ===== Logging status messages =====
623
+ /**
624
+ * Logs an info message about a URL being fetched.
625
+ * @param url - The URL being fetched.
626
+ */
627
+ fetching(t) {
628
+ return this.pending(`Fetching: ${this.highlight(t)}`);
629
+ }
630
+ /**
631
+ * Logs an info message that implies a pending state.
632
+ * @param message - The status message.
633
+ */
634
+ pending(t) {
635
+ return this.info(o.yellow(t));
636
+ }
637
+ /**
638
+ * Logs an error message.
639
+ * @param message - The error message or reason.
640
+ * @param details - The details of the error message.
641
+ */
642
+ error(t, ...e) {
643
+ return this.#t++, this.isLevelEnabled(
644
+ 4
645
+ /* Error */
646
+ ) ? (typeof t == "string" ? this.statusMessage(
647
+ o.red(t),
648
+ e,
649
+ 4
650
+ /* Error */
651
+ ) : console.error(t, ...e), this) : this;
652
+ }
653
+ /**
654
+ * Logs a warning message.
655
+ * @param message - The warning message.
656
+ * @param details - The details of the warning message.
657
+ */
658
+ warn(t, ...e) {
659
+ return this.#e++, this.statusMessage(
660
+ o.yellow(t),
661
+ e,
662
+ 3
663
+ /* Warning */
664
+ );
665
+ }
666
+ /**
667
+ * Logs a success message.
668
+ * @param message - The success message.
669
+ * @param details - The details of the success message.
670
+ */
671
+ success(t, ...e) {
672
+ return this.statusMessage(
673
+ o.green(t),
674
+ e,
675
+ 2
676
+ /* Success */
677
+ );
678
+ }
679
+ /**
680
+ * Logs an info message.
681
+ * @param message - The info message.
682
+ * @param details - The details of the info message.
683
+ */
684
+ info(t, ...e) {
685
+ return this.statusMessage(
686
+ t,
687
+ e,
688
+ 1
689
+ /* Info */
690
+ );
691
+ }
692
+ /**
693
+ * Logs a status message.
694
+ * @param message - The status message.
695
+ * @param details - The details of the status message.
696
+ * @param level - The log level.
697
+ */
698
+ statusMessage(t, e, n) {
699
+ let i = t;
700
+ if (e.length) {
701
+ const a = this.indentString ? this.indentString.repeat(this.indent + 1) : " ";
702
+ i += `
703
+ ` + e.map((c) => a + this.stringify(c)).join(`
704
+ `);
705
+ }
706
+ return this.text(i, n);
707
+ }
708
+ /**
709
+ * Logs the amount of errors and warnings that have been logged since the previous call to this function or the creation of this logger.
710
+ */
711
+ summary() {
712
+ const t = `${this.#t} error${this.#t != 1 ? "s" : ""}`, e = `${this.#e} warning${this.#e != 1 ? "s" : ""}`;
713
+ let n = `Found ${t} and ${e}`;
714
+ return this.#t > 0 ? n = o.red(n) : this.#e > 0 ? n = o.yellow(n) : n = o.green(n), this.text(n), this.#t = 0, this.#e = 0, this;
715
+ }
716
+ // ===== Logging text =====
717
+ /**
718
+ * Logs a labeled parameter.
719
+ *
720
+ * The value is emphasized using {@link emphasize}.
721
+ * @param label - The label of the parameter.
722
+ * @param value - The value of the parameter.
723
+ * @param level - The log level.
724
+ */
725
+ parameter(t, e, n) {
726
+ return this.text(`${t}: ${this.emphasize(this.stringify(e))}`, n);
727
+ }
728
+ /**
729
+ * Logs properties as a list of key-value pairs.
730
+ * @param properties - The properties to log.
731
+ * @param level - The log level.
732
+ * @see {@link value()}
733
+ */
734
+ properties(t, e) {
735
+ for (const [n, i] of Object.entries(t))
736
+ this.value(`- ${n}`, i, e);
737
+ return this;
738
+ }
739
+ /**
740
+ * Logs a labeled value.
741
+ *
742
+ * The value is highlighted using {@link highlight}.
743
+ * @param label - The label of the value.
744
+ * @param value - The value.
745
+ * @param level - The log level.
746
+ */
747
+ value(t, e, n) {
748
+ return this.text(`${t}: ${this.highlight(this.stringify(e))}`, n);
749
+ }
750
+ /**
751
+ * Logs emphasized text.
752
+ * @param text - The text to log.
753
+ * @param level - The log level.
754
+ */
755
+ emphasized(t, e) {
756
+ return this.text(this.emphasize(t), e);
757
+ }
758
+ /**
759
+ * Logs highlighted text.
760
+ * @param text - The text to log.
761
+ * @param level - The log level.
762
+ */
763
+ highlighted(t, e) {
764
+ return this.text(this.highlight(t), e);
765
+ }
766
+ /**
767
+ * Logs each item on a new line.
768
+ * @param lines - The items to log.
769
+ * @param level - The log level.
770
+ */
771
+ lines(t, e) {
772
+ return t.map(this.stringify.bind(this)).forEach((n) => this.text(n, e)), this;
773
+ }
774
+ /**
775
+ * Logs a message.
776
+ * @param message - The message to log.
777
+ * @param level - The log level.
778
+ */
779
+ log(t, e) {
780
+ return this.text(this.stringify(t), e);
781
+ }
782
+ /**
783
+ * Logs text using this logger's format.
784
+ * @param text - The text to log.
785
+ * @param level - The log level.
786
+ */
787
+ text(t, e = 0) {
788
+ if (!this.isLevelEnabled(e))
789
+ return this;
790
+ const n = this.format(this.applyPrefix(t, e));
791
+ switch (e) {
792
+ case 1:
793
+ console.info(n);
794
+ break;
795
+ case 3:
796
+ console.warn(n);
797
+ break;
798
+ case 4:
799
+ console.error(n);
800
+ break;
801
+ default:
802
+ console.log(n);
803
+ break;
804
+ }
805
+ return this;
806
+ }
807
+ /**
808
+ * Logs an newline character.
809
+ */
810
+ newLine() {
811
+ return console.log(), this;
812
+ }
813
+ /**
814
+ * Checks if the given log level is enabled.
815
+ * @param level - The log level to check.
816
+ */
817
+ isLevelEnabled(t) {
818
+ return this.level === void 0 ? !0 : Array.isArray(this.level) ? this.level.includes(t) : this.level <= t;
819
+ }
820
+ // ===== Formatting strings =====
821
+ /**
822
+ * Formats text using this logger's formatting properties.
823
+ * @param text - The text to format.
824
+ */
825
+ format(t) {
826
+ return this.indentString ? this.applyPrefix(this.indentString.repeat(this.indent) + t) : this.applyPrefix(t);
827
+ }
828
+ /**
829
+ * Prepends a prefix to text.
830
+ * @param text - The text to apply the prefix to.
831
+ * @param level - The log level.
832
+ */
833
+ applyPrefix(t, e) {
834
+ const n = e ? this.prefix[e] : this.prefix.global;
835
+ return n ? `${n} ${t}` : t;
836
+ }
837
+ static createStringifier(t = "basic", e) {
838
+ return t === "basic" ? String : (n) => typeof n == "string" ? n : p(n, e);
839
+ }
840
+ }
841
+ export {
842
+ s as A,
843
+ Q as L,
844
+ o as a,
845
+ C as b,
846
+ j as c,
847
+ O as d,
848
+ P as e,
849
+ J as f,
850
+ M as g,
851
+ I as h,
852
+ p as i,
853
+ w as j,
854
+ K as k,
855
+ F as l
856
+ };
857
+ //# sourceMappingURL=index-PU_xBoDn.js.map