@innei/pretty-logger-core 0.3.2 → 0.3.4

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/index.mjs CHANGED
@@ -1,372 +1,305 @@
1
- // consola.instance.ts
2
- import { isDevelopment as isDevelopment2 } from "std-env";
3
-
4
- // consola/index.ts
5
- import { isCI as isCI2, isDebug, isTest } from "std-env";
6
-
7
- // consola/consola.ts
1
+ import { isCI, isDebug, isDevelopment, isTest } from "std-env";
8
2
  import { defu } from "defu";
3
+ import { formatWithOptions } from "node:util";
4
+ import path, { dirname, sep } from "node:path";
5
+ import * as tty from "node:tty";
6
+ import * as fs from "node:fs";
7
+ import { createWriteStream } from "node:fs";
8
+ import { CronJob } from "cron";
9
+ import picocolors from "picocolors";
10
+ import EventEmitter from "node:events";
11
+
12
+ //#region rolldown:runtime
13
+ var __create = Object.create;
14
+ var __defProp = Object.defineProperty;
15
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
16
+ var __getOwnPropNames = Object.getOwnPropertyNames;
17
+ var __getProtoOf = Object.getPrototypeOf;
18
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
19
+ var __commonJS = (cb, mod) => function() {
20
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
21
+ };
22
+ var __copyProps = (to, from, except, desc) => {
23
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
24
+ key = keys[i];
25
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
26
+ get: ((k) => from[k]).bind(null, key),
27
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
28
+ });
29
+ }
30
+ return to;
31
+ };
32
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
33
+ value: mod,
34
+ enumerable: true
35
+ }) : target, mod));
9
36
 
10
- // consola/constants.ts
11
- var LogLevels = {
12
- silent: Number.NEGATIVE_INFINITY,
13
- fatal: 0,
14
- error: 0,
15
- warn: 1,
16
- log: 2,
17
- info: 3,
18
- success: 3,
19
- fail: 3,
20
- ready: 3,
21
- start: 3,
22
- box: 3,
23
- debug: 4,
24
- trace: 5,
25
- verbose: Number.POSITIVE_INFINITY
37
+ //#endregion
38
+ //#region consola/constants.ts
39
+ const LogLevels = {
40
+ silent: Number.NEGATIVE_INFINITY,
41
+ fatal: 0,
42
+ error: 0,
43
+ warn: 1,
44
+ log: 2,
45
+ info: 3,
46
+ success: 3,
47
+ fail: 3,
48
+ ready: 3,
49
+ start: 3,
50
+ box: 3,
51
+ debug: 4,
52
+ trace: 5,
53
+ verbose: Number.POSITIVE_INFINITY
26
54
  };
27
- var LogTypes = {
28
- // Silent
29
- silent: {
30
- level: -1
31
- },
32
- // Level 0
33
- fatal: {
34
- level: LogLevels.fatal
35
- },
36
- error: {
37
- level: LogLevels.error
38
- },
39
- // Level 1
40
- warn: {
41
- level: LogLevels.warn
42
- },
43
- // Level 2
44
- log: {
45
- level: LogLevels.log
46
- },
47
- // Level 3
48
- info: {
49
- level: LogLevels.info
50
- },
51
- success: {
52
- level: LogLevels.success
53
- },
54
- fail: {
55
- level: LogLevels.fail
56
- },
57
- ready: {
58
- level: LogLevels.info
59
- },
60
- start: {
61
- level: LogLevels.info
62
- },
63
- box: {
64
- level: LogLevels.info
65
- },
66
- // Level 4
67
- debug: {
68
- level: LogLevels.debug
69
- },
70
- // Level 5
71
- trace: {
72
- level: LogLevels.trace
73
- },
74
- // Verbose
75
- verbose: {
76
- level: LogLevels.verbose
77
- }
55
+ const LogTypes = {
56
+ silent: { level: -1 },
57
+ fatal: { level: LogLevels.fatal },
58
+ error: { level: LogLevels.error },
59
+ warn: { level: LogLevels.warn },
60
+ log: { level: LogLevels.log },
61
+ info: { level: LogLevels.info },
62
+ success: { level: LogLevels.success },
63
+ fail: { level: LogLevels.fail },
64
+ ready: { level: LogLevels.info },
65
+ start: { level: LogLevels.info },
66
+ box: { level: LogLevels.info },
67
+ debug: { level: LogLevels.debug },
68
+ trace: { level: LogLevels.trace },
69
+ verbose: { level: LogLevels.verbose }
78
70
  };
79
71
 
80
- // consola/utils/log.ts
72
+ //#endregion
73
+ //#region consola/utils/log.ts
81
74
  function isPlainObject(obj) {
82
- return Object.prototype.toString.call(obj) === "[object Object]";
75
+ return Object.prototype.toString.call(obj) === "[object Object]";
83
76
  }
84
77
  function isLogObj(arg) {
85
- if (!isPlainObject(arg)) {
86
- return false;
87
- }
88
- if (!arg.message && !arg.args) {
89
- return false;
90
- }
91
- if (arg.stack) {
92
- return false;
93
- }
94
- return true;
78
+ if (!isPlainObject(arg)) return false;
79
+ if (!arg.message && !arg.args) return false;
80
+ if (arg.stack) return false;
81
+ return true;
95
82
  }
96
83
 
97
- // consola/consola.ts
98
- var paused = false;
99
- var queue = [];
100
- var Consola = class _Consola {
101
- constructor(options = {}) {
102
- const types = options.types || LogTypes;
103
- this.options = defu(
104
- {
105
- ...options,
106
- defaults: { ...options.defaults },
107
- level: _normalizeLogLevel(options.level, types),
108
- reporters: [...options.reporters || []]
109
- },
110
- {
111
- types: LogTypes,
112
- throttle: 1e3,
113
- throttleMin: 5,
114
- formatOptions: {
115
- date: true,
116
- colors: false,
117
- compact: true
118
- }
119
- }
120
- );
121
- for (const type in types) {
122
- const defaults = {
123
- type,
124
- ...this.options.defaults,
125
- ...types[type]
126
- };
127
- this[type] = this._wrapLogFn(defaults);
128
- this[type].raw = this._wrapLogFn(
129
- defaults,
130
- true
131
- );
132
- }
133
- if (this.options.mockFn) {
134
- this.mockTypes();
135
- }
136
- this._lastLog = {};
137
- }
138
- get level() {
139
- return this.options.level;
140
- }
141
- set level(level) {
142
- this.options.level = _normalizeLogLevel(
143
- level,
144
- this.options.types,
145
- this.options.level
146
- );
147
- }
148
- create(options) {
149
- const instance = new _Consola({
150
- ...this.options,
151
- ...options
152
- });
153
- if (this._mockFn) {
154
- instance.mockTypes(this._mockFn);
155
- }
156
- return instance;
157
- }
158
- withDefaults(defaults) {
159
- return this.create({
160
- ...this.options,
161
- defaults: {
162
- ...this.options.defaults,
163
- ...defaults
164
- }
165
- });
166
- }
167
- withTag(tag) {
168
- return this.withDefaults({
169
- tag: this.options.defaults.tag ? `${this.options.defaults.tag}:${tag}` : tag
170
- });
171
- }
172
- addReporter(reporter) {
173
- this.options.reporters.push(reporter);
174
- return this;
175
- }
176
- removeReporter(reporter) {
177
- if (reporter) {
178
- const i = this.options.reporters.indexOf(reporter);
179
- if (i >= 0) {
180
- return this.options.reporters.splice(i, 1);
181
- }
182
- } else {
183
- this.options.reporters.splice(0);
184
- }
185
- return this;
186
- }
187
- setReporters(reporters) {
188
- this.options.reporters = Array.isArray(reporters) ? reporters : [reporters];
189
- return this;
190
- }
191
- wrapAll() {
192
- this.wrapConsole();
193
- this.wrapStd();
194
- }
195
- restoreAll() {
196
- this.restoreConsole();
197
- this.restoreStd();
198
- }
199
- wrapConsole() {
200
- for (const type in this.options.types) {
201
- if (!console[`__${type}`]) {
202
- ;
203
- console[`__${type}`] = console[type];
204
- }
205
- ;
206
- console[type] = this[type].raw;
207
- }
208
- }
209
- restoreConsole() {
210
- for (const type in this.options.types) {
211
- if (console[`__${type}`]) {
212
- ;
213
- console[type] = console[`__${type}`];
214
- delete console[`__${type}`];
215
- }
216
- }
217
- }
218
- wrapStd() {
219
- this._wrapStream(this.options.stdout, "log");
220
- this._wrapStream(this.options.stderr, "log");
221
- }
222
- _wrapStream(stream, type) {
223
- if (!stream) {
224
- return;
225
- }
226
- if (!stream.__write) {
227
- ;
228
- stream.__write = stream.write;
229
- }
230
- ;
231
- stream.write = (data) => {
232
- ;
233
- this[type].raw(String(data).trim());
234
- };
235
- }
236
- restoreStd() {
237
- this._restoreStream(this.options.stdout);
238
- this._restoreStream(this.options.stderr);
239
- }
240
- _restoreStream(stream) {
241
- if (!stream) {
242
- return;
243
- }
244
- if (stream.__write) {
245
- stream.write = stream.__write;
246
- delete stream.__write;
247
- }
248
- }
249
- pauseLogs() {
250
- paused = true;
251
- }
252
- resumeLogs() {
253
- paused = false;
254
- const _queue = queue.splice(0);
255
- for (const item of _queue) {
256
- item[0]._logFn(item[1], item[2]);
257
- }
258
- }
259
- mockTypes(mockFn) {
260
- const _mockFn = mockFn || this.options.mockFn;
261
- this._mockFn = _mockFn;
262
- if (typeof _mockFn !== "function") {
263
- return;
264
- }
265
- for (const type in this.options.types) {
266
- ;
267
- this[type] = _mockFn(type, this.options.types[type]) || this[type];
268
- this[type].raw = this[type];
269
- }
270
- }
271
- _wrapLogFn(defaults, isRaw) {
272
- return (...args) => {
273
- if (paused) {
274
- queue.push([this, defaults, args, isRaw]);
275
- return;
276
- }
277
- return this._logFn(defaults, args, isRaw);
278
- };
279
- }
280
- _logFn(defaults, args, isRaw) {
281
- if ((defaults.level || 0) > this.level) {
282
- return false;
283
- }
284
- const logObj = {
285
- date: /* @__PURE__ */ new Date(),
286
- args: [],
287
- ...defaults,
288
- level: _normalizeLogLevel(defaults.level, this.options.types)
289
- };
290
- if (!isRaw && args.length === 1 && isLogObj(args[0])) {
291
- Object.assign(logObj, args[0]);
292
- } else {
293
- logObj.args = [...args];
294
- }
295
- if (logObj.message) {
296
- logObj.args.unshift(logObj.message);
297
- delete logObj.message;
298
- }
299
- if (logObj.additional) {
300
- if (!Array.isArray(logObj.additional)) {
301
- logObj.additional = logObj.additional.split("\n");
302
- }
303
- logObj.args.push(`
304
- ${logObj.additional.join("\n")}`);
305
- delete logObj.additional;
306
- }
307
- logObj.type = typeof logObj.type === "string" ? logObj.type.toLowerCase() : "log";
308
- logObj.tag = typeof logObj.tag === "string" ? logObj.tag : "";
309
- const resolveLog = (newLog = false) => {
310
- const repeated = (this._lastLog.count || 0) - this.options.throttleMin;
311
- if (this._lastLog.object && repeated > 0) {
312
- const args2 = [...this._lastLog.object.args];
313
- if (repeated > 1) {
314
- args2.push(`(repeated ${repeated} times)`);
315
- }
316
- this._log({ ...this._lastLog.object, args: args2 });
317
- this._lastLog.count = 1;
318
- }
319
- if (newLog) {
320
- this._lastLog.object = logObj;
321
- this._log(logObj);
322
- }
323
- };
324
- clearTimeout(this._lastLog.timeout);
325
- const diffTime = this._lastLog.time && logObj.date ? logObj.date.getTime() - this._lastLog.time.getTime() : 0;
326
- this._lastLog.time = logObj.date;
327
- if (diffTime < this.options.throttle) {
328
- try {
329
- const serializedLog = JSON.stringify([
330
- logObj.type,
331
- logObj.tag,
332
- logObj.args
333
- ]);
334
- const isSameLog = this._lastLog.serialized === serializedLog;
335
- this._lastLog.serialized = serializedLog;
336
- if (isSameLog) {
337
- this._lastLog.count = (this._lastLog.count || 0) + 1;
338
- if (this._lastLog.count > this.options.throttleMin) {
339
- this._lastLog.timeout = setTimeout(
340
- resolveLog,
341
- this.options.throttle
342
- );
343
- return;
344
- }
345
- }
346
- } catch {
347
- }
348
- }
349
- resolveLog(true);
350
- }
351
- _log(logObj) {
352
- for (const reporter of this.options.reporters) {
353
- reporter.log(logObj, {
354
- options: this.options
355
- });
356
- }
357
- }
84
+ //#endregion
85
+ //#region consola/consola.ts
86
+ let paused = false;
87
+ const queue = [];
88
+ var Consola = class Consola {
89
+ constructor(options = {}) {
90
+ const types = options.types || LogTypes;
91
+ this.options = defu({
92
+ ...options,
93
+ defaults: { ...options.defaults },
94
+ level: _normalizeLogLevel(options.level, types),
95
+ reporters: [...options.reporters || []]
96
+ }, {
97
+ types: LogTypes,
98
+ throttle: 1e3,
99
+ throttleMin: 5,
100
+ formatOptions: {
101
+ date: true,
102
+ colors: false,
103
+ compact: true
104
+ }
105
+ });
106
+ for (const type in types) {
107
+ const defaults = {
108
+ type,
109
+ ...this.options.defaults,
110
+ ...types[type]
111
+ };
112
+ this[type] = this._wrapLogFn(defaults);
113
+ this[type].raw = this._wrapLogFn(defaults, true);
114
+ }
115
+ if (this.options.mockFn) this.mockTypes();
116
+ this._lastLog = {};
117
+ }
118
+ get level() {
119
+ return this.options.level;
120
+ }
121
+ set level(level) {
122
+ this.options.level = _normalizeLogLevel(level, this.options.types, this.options.level);
123
+ }
124
+ create(options) {
125
+ const instance = new Consola({
126
+ ...this.options,
127
+ ...options
128
+ });
129
+ if (this._mockFn) instance.mockTypes(this._mockFn);
130
+ return instance;
131
+ }
132
+ withDefaults(defaults) {
133
+ return this.create({
134
+ ...this.options,
135
+ defaults: {
136
+ ...this.options.defaults,
137
+ ...defaults
138
+ }
139
+ });
140
+ }
141
+ withTag(tag) {
142
+ return this.withDefaults({ tag: this.options.defaults.tag ? `${this.options.defaults.tag}:${tag}` : tag });
143
+ }
144
+ addReporter(reporter) {
145
+ this.options.reporters.push(reporter);
146
+ return this;
147
+ }
148
+ removeReporter(reporter) {
149
+ if (reporter) {
150
+ const i = this.options.reporters.indexOf(reporter);
151
+ if (i !== -1) return this.options.reporters.splice(i, 1);
152
+ } else this.options.reporters.splice(0);
153
+ return this;
154
+ }
155
+ setReporters(reporters) {
156
+ this.options.reporters = Array.isArray(reporters) ? reporters : [reporters];
157
+ return this;
158
+ }
159
+ wrapAll() {
160
+ this.wrapConsole();
161
+ this.wrapStd();
162
+ }
163
+ restoreAll() {
164
+ this.restoreConsole();
165
+ this.restoreStd();
166
+ }
167
+ wrapConsole() {
168
+ for (const type in this.options.types) {
169
+ if (!console[`__${type}`]) console[`__${type}`] = console[type];
170
+ console[type] = this[type].raw;
171
+ }
172
+ }
173
+ restoreConsole() {
174
+ for (const type in this.options.types) if (console[`__${type}`]) {
175
+ console[type] = console[`__${type}`];
176
+ delete console[`__${type}`];
177
+ }
178
+ }
179
+ wrapStd() {
180
+ this._wrapStream(this.options.stdout, "log");
181
+ this._wrapStream(this.options.stderr, "log");
182
+ }
183
+ _wrapStream(stream, type) {
184
+ if (!stream) return;
185
+ if (!stream.__write) stream.__write = stream.write;
186
+ stream.write = (data) => {
187
+ this[type].raw(String(data).trim());
188
+ };
189
+ }
190
+ restoreStd() {
191
+ this._restoreStream(this.options.stdout);
192
+ this._restoreStream(this.options.stderr);
193
+ }
194
+ _restoreStream(stream) {
195
+ if (!stream) return;
196
+ if (stream.__write) {
197
+ stream.write = stream.__write;
198
+ delete stream.__write;
199
+ }
200
+ }
201
+ pauseLogs() {
202
+ paused = true;
203
+ }
204
+ resumeLogs() {
205
+ paused = false;
206
+ const _queue = queue.splice(0);
207
+ for (const item of _queue) item[0]._logFn(item[1], item[2]);
208
+ }
209
+ mockTypes(mockFn) {
210
+ const _mockFn = mockFn || this.options.mockFn;
211
+ this._mockFn = _mockFn;
212
+ if (typeof _mockFn !== "function") return;
213
+ for (const type in this.options.types) {
214
+ this[type] = _mockFn(type, this.options.types[type]) || this[type];
215
+ this[type].raw = this[type];
216
+ }
217
+ }
218
+ _wrapLogFn(defaults, isRaw) {
219
+ return (...args) => {
220
+ if (paused) {
221
+ queue.push([
222
+ this,
223
+ defaults,
224
+ args,
225
+ isRaw
226
+ ]);
227
+ return;
228
+ }
229
+ return this._logFn(defaults, args, isRaw);
230
+ };
231
+ }
232
+ _logFn(defaults, args, isRaw) {
233
+ if ((defaults.level || 0) > this.level) return false;
234
+ const logObj = {
235
+ date: new Date(),
236
+ args: [],
237
+ ...defaults,
238
+ level: _normalizeLogLevel(defaults.level, this.options.types)
239
+ };
240
+ if (!isRaw && args.length === 1 && isLogObj(args[0])) Object.assign(logObj, args[0]);
241
+ else logObj.args = [...args];
242
+ if (logObj.message) {
243
+ logObj.args.unshift(logObj.message);
244
+ delete logObj.message;
245
+ }
246
+ if (logObj.additional) {
247
+ if (!Array.isArray(logObj.additional)) logObj.additional = logObj.additional.split("\n");
248
+ logObj.args.push(`\n${logObj.additional.join("\n")}`);
249
+ delete logObj.additional;
250
+ }
251
+ logObj.type = typeof logObj.type === "string" ? logObj.type.toLowerCase() : "log";
252
+ logObj.tag = typeof logObj.tag === "string" ? logObj.tag : "";
253
+ /**
254
+ * @param newLog false if the throttle expired and
255
+ * we don't want to log a duplicate
256
+ */
257
+ const resolveLog = (newLog = false) => {
258
+ const repeated = (this._lastLog.count || 0) - this.options.throttleMin;
259
+ if (this._lastLog.object && repeated > 0) {
260
+ const args$1 = [...this._lastLog.object.args];
261
+ if (repeated > 1) args$1.push(`(repeated ${repeated} times)`);
262
+ this._log({
263
+ ...this._lastLog.object,
264
+ args: args$1
265
+ });
266
+ this._lastLog.count = 1;
267
+ }
268
+ if (newLog) {
269
+ this._lastLog.object = logObj;
270
+ this._log(logObj);
271
+ }
272
+ };
273
+ clearTimeout(this._lastLog.timeout);
274
+ const diffTime = this._lastLog.time && logObj.date ? logObj.date.getTime() - this._lastLog.time.getTime() : 0;
275
+ this._lastLog.time = logObj.date;
276
+ if (diffTime < this.options.throttle) try {
277
+ const serializedLog = JSON.stringify([
278
+ logObj.type,
279
+ logObj.tag,
280
+ logObj.args
281
+ ]);
282
+ const isSameLog = this._lastLog.serialized === serializedLog;
283
+ this._lastLog.serialized = serializedLog;
284
+ if (isSameLog) {
285
+ this._lastLog.count = (this._lastLog.count || 0) + 1;
286
+ if (this._lastLog.count > this.options.throttleMin) {
287
+ this._lastLog.timeout = setTimeout(resolveLog, this.options.throttle);
288
+ return;
289
+ }
290
+ }
291
+ } catch {}
292
+ resolveLog(true);
293
+ }
294
+ _log(logObj) {
295
+ for (const reporter of this.options.reporters) reporter.log(logObj, { options: this.options });
296
+ }
358
297
  };
359
298
  function _normalizeLogLevel(input, types = {}, defaultLevel = 3) {
360
- if (input === void 0) {
361
- return defaultLevel;
362
- }
363
- if (typeof input === "number") {
364
- return input;
365
- }
366
- if (types[input] && types[input].level !== void 0) {
367
- return types[input].level;
368
- }
369
- return defaultLevel;
299
+ if (input === void 0) return defaultLevel;
300
+ if (typeof input === "number") return input;
301
+ if (types[input] && types[input].level !== void 0) return types[input].level;
302
+ return defaultLevel;
370
303
  }
371
304
  Consola.prototype.add = Consola.prototype.addReporter;
372
305
  Consola.prototype.remove = Consola.prototype.removeReporter;
@@ -375,680 +308,612 @@ Consola.prototype.withScope = Consola.prototype.withTag;
375
308
  Consola.prototype.mock = Consola.prototype.mockTypes;
376
309
  Consola.prototype.pause = Consola.prototype.pauseLogs;
377
310
  Consola.prototype.resume = Consola.prototype.resumeLogs;
378
- function createConsola(options = {}) {
379
- return new Consola(options);
311
+ function createConsola$1(options = {}) {
312
+ return new Consola(options);
380
313
  }
381
314
 
382
- // consola/reporters/basic.ts
383
- import { formatWithOptions } from "util";
384
-
385
- // consola/utils/error.ts
386
- import { sep } from "path";
315
+ //#endregion
316
+ //#region consola/utils/error.ts
387
317
  function parseStack(stack) {
388
- const cwd = process.cwd() + sep;
389
- const lines = stack.split("\n").splice(1).map((l) => l.trim().replace("file://", "").replace(cwd, ""));
390
- return lines;
318
+ const cwd = process.cwd() + sep;
319
+ const lines = stack.split("\n").splice(1).map((l) => l.trim().replace("file://", "").replace(cwd, ""));
320
+ return lines;
391
321
  }
392
322
 
393
- // consola/utils/stream.ts
323
+ //#endregion
324
+ //#region consola/utils/stream.ts
394
325
  function writeStream(data, stream) {
395
- const write = stream.__write || stream.write;
396
- return write.call(stream, data);
326
+ const write = stream.__write || stream.write;
327
+ return write.call(stream, data);
397
328
  }
398
329
 
399
- // consola/reporters/basic.ts
400
- var bracket = (x) => x ? `[${x}]` : "";
330
+ //#endregion
331
+ //#region consola/reporters/basic.ts
332
+ const bracket = (x) => x ? `[${x}]` : "";
401
333
  var BasicReporter = class {
402
- formatStack(stack, opts) {
403
- return ` ${parseStack(stack).join("\n ")}`;
404
- }
405
- formatArgs(args, opts) {
406
- const _args = args.map((arg) => {
407
- if (arg && typeof arg.stack === "string") {
408
- return `${arg.message}
409
- ${this.formatStack(arg.stack, opts)}`;
410
- }
411
- return arg;
412
- });
413
- return formatWithOptions(opts, ..._args);
414
- }
415
- formatDate(date, opts) {
416
- return opts.date ? date.toLocaleTimeString() : "";
417
- }
418
- filterAndJoin(arr) {
419
- return arr.filter(Boolean).join(" ");
420
- }
421
- formatLogObj(logObj, opts) {
422
- const message = this.formatArgs(logObj.args, opts);
423
- if (logObj.type === "box") {
424
- return `
425
- ${[
426
- bracket(logObj.tag),
427
- logObj.title && logObj.title,
428
- ...message.split("\n")
429
- ].filter(Boolean).map((l) => ` > ${l}`).join("\n")}
430
- `;
431
- }
432
- return this.filterAndJoin([
433
- bracket(logObj.type),
434
- bracket(logObj.tag),
435
- message
436
- ]);
437
- }
438
- log(logObj, ctx) {
439
- const line = this.formatLogObj(logObj, {
440
- columns: ctx.options.stdout.columns || 0,
441
- ...ctx.options.formatOptions
442
- });
443
- return writeStream(
444
- `${line}
445
- `,
446
- logObj.level < 2 ? ctx.options.stderr || process.stderr : ctx.options.stdout || process.stdout
447
- );
448
- }
334
+ formatStack(stack, _opts) {
335
+ return ` ${parseStack(stack).join("\n ")}`;
336
+ }
337
+ formatArgs(args, opts) {
338
+ const _args = args.map((arg) => {
339
+ if (arg && typeof arg.stack === "string") return `${arg.message}\n${this.formatStack(arg.stack, opts)}`;
340
+ return arg;
341
+ });
342
+ return formatWithOptions(opts, ..._args);
343
+ }
344
+ formatDate(date, opts) {
345
+ return opts.date ? date.toLocaleTimeString() : "";
346
+ }
347
+ filterAndJoin(arr) {
348
+ return arr.filter(Boolean).join(" ");
349
+ }
350
+ formatLogObj(logObj, opts) {
351
+ const message = this.formatArgs(logObj.args, opts);
352
+ if (logObj.type === "box") return `\n${[
353
+ bracket(logObj.tag),
354
+ logObj.title && logObj.title,
355
+ ...message.split("\n")
356
+ ].filter(Boolean).map((l) => ` > ${l}`).join("\n")}\n`;
357
+ return this.filterAndJoin([
358
+ bracket(logObj.type),
359
+ bracket(logObj.tag),
360
+ message
361
+ ]);
362
+ }
363
+ log(logObj, ctx) {
364
+ const line = this.formatLogObj(logObj, {
365
+ columns: ctx.options.stdout.columns || 0,
366
+ ...ctx.options.formatOptions
367
+ });
368
+ return writeStream(`${line}\n`, logObj.level < 2 ? ctx.options.stderr || process.stderr : ctx.options.stdout || process.stdout);
369
+ }
449
370
  };
450
371
 
451
- // consola/reporters/fancy.ts
452
- import _stringWidth from "string-width";
372
+ //#endregion
373
+ //#region ../../node_modules/.pnpm/ansi-regex@6.1.0/node_modules/ansi-regex/index.js
374
+ function ansiRegex$1({ onlyFirst = false } = {}) {
375
+ const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
376
+ const pattern = [`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?${ST})`, "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");
377
+ return new RegExp(pattern, onlyFirst ? void 0 : "g");
378
+ }
379
+
380
+ //#endregion
381
+ //#region ../../node_modules/.pnpm/strip-ansi@7.1.0/node_modules/strip-ansi/index.js
382
+ const regex = ansiRegex$1();
383
+ function stripAnsi$1(string) {
384
+ if (typeof string !== "string") throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
385
+ return string.replace(regex, "");
386
+ }
387
+
388
+ //#endregion
389
+ //#region ../../node_modules/.pnpm/get-east-asian-width@1.3.0/node_modules/get-east-asian-width/lookup.js
390
+ function isAmbiguous(x) {
391
+ return x === 161 || x === 164 || x === 167 || x === 168 || x === 170 || x === 173 || x === 174 || x >= 176 && x <= 180 || x >= 182 && x <= 186 || x >= 188 && x <= 191 || x === 198 || x === 208 || x === 215 || x === 216 || x >= 222 && x <= 225 || x === 230 || x >= 232 && x <= 234 || x === 236 || x === 237 || x === 240 || x === 242 || x === 243 || x >= 247 && x <= 250 || x === 252 || x === 254 || x === 257 || x === 273 || x === 275 || x === 283 || x === 294 || x === 295 || x === 299 || x >= 305 && x <= 307 || x === 312 || x >= 319 && x <= 322 || x === 324 || x >= 328 && x <= 331 || x === 333 || x === 338 || x === 339 || x === 358 || x === 359 || x === 363 || x === 462 || x === 464 || x === 466 || x === 468 || x === 470 || x === 472 || x === 474 || x === 476 || x === 593 || x === 609 || x === 708 || x === 711 || x >= 713 && x <= 715 || x === 717 || x === 720 || x >= 728 && x <= 731 || x === 733 || x === 735 || x >= 768 && x <= 879 || x >= 913 && x <= 929 || x >= 931 && x <= 937 || x >= 945 && x <= 961 || x >= 963 && x <= 969 || x === 1025 || x >= 1040 && x <= 1103 || x === 1105 || x === 8208 || x >= 8211 && x <= 8214 || x === 8216 || x === 8217 || x === 8220 || x === 8221 || x >= 8224 && x <= 8226 || x >= 8228 && x <= 8231 || x === 8240 || x === 8242 || x === 8243 || x === 8245 || x === 8251 || x === 8254 || x === 8308 || x === 8319 || x >= 8321 && x <= 8324 || x === 8364 || x === 8451 || x === 8453 || x === 8457 || x === 8467 || x === 8470 || x === 8481 || x === 8482 || x === 8486 || x === 8491 || x === 8531 || x === 8532 || x >= 8539 && x <= 8542 || x >= 8544 && x <= 8555 || x >= 8560 && x <= 8569 || x === 8585 || x >= 8592 && x <= 8601 || x === 8632 || x === 8633 || x === 8658 || x === 8660 || x === 8679 || x === 8704 || x === 8706 || x === 8707 || x === 8711 || x === 8712 || x === 8715 || x === 8719 || x === 8721 || x === 8725 || x === 8730 || x >= 8733 && x <= 8736 || x === 8739 || x === 8741 || x >= 8743 && x <= 8748 || x === 8750 || x >= 8756 && x <= 8759 || x === 8764 || x === 8765 || x === 8776 || x === 8780 || x === 8786 || x === 8800 || x === 8801 || x >= 8804 && x <= 8807 || x === 8810 || x === 8811 || x === 8814 || x === 8815 || x === 8834 || x === 8835 || x === 8838 || x === 8839 || x === 8853 || x === 8857 || x === 8869 || x === 8895 || x === 8978 || x >= 9312 && x <= 9449 || x >= 9451 && x <= 9547 || x >= 9552 && x <= 9587 || x >= 9600 && x <= 9615 || x >= 9618 && x <= 9621 || x === 9632 || x === 9633 || x >= 9635 && x <= 9641 || x === 9650 || x === 9651 || x === 9654 || x === 9655 || x === 9660 || x === 9661 || x === 9664 || x === 9665 || x >= 9670 && x <= 9672 || x === 9675 || x >= 9678 && x <= 9681 || x >= 9698 && x <= 9701 || x === 9711 || x === 9733 || x === 9734 || x === 9737 || x === 9742 || x === 9743 || x === 9756 || x === 9758 || x === 9792 || x === 9794 || x === 9824 || x === 9825 || x >= 9827 && x <= 9829 || x >= 9831 && x <= 9834 || x === 9836 || x === 9837 || x === 9839 || x === 9886 || x === 9887 || x === 9919 || x >= 9926 && x <= 9933 || x >= 9935 && x <= 9939 || x >= 9941 && x <= 9953 || x === 9955 || x === 9960 || x === 9961 || x >= 9963 && x <= 9969 || x === 9972 || x >= 9974 && x <= 9977 || x === 9979 || x === 9980 || x === 9982 || x === 9983 || x === 10045 || x >= 10102 && x <= 10111 || x >= 11094 && x <= 11097 || x >= 12872 && x <= 12879 || x >= 57344 && x <= 63743 || x >= 65024 && x <= 65039 || x === 65533 || x >= 127232 && x <= 127242 || x >= 127248 && x <= 127277 || x >= 127280 && x <= 127337 || x >= 127344 && x <= 127373 || x === 127375 || x === 127376 || x >= 127387 && x <= 127404 || x >= 917760 && x <= 917999 || x >= 983040 && x <= 1048573 || x >= 1048576 && x <= 1114109;
392
+ }
393
+ function isFullWidth(x) {
394
+ return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
395
+ }
396
+ function isWide(x) {
397
+ return x >= 4352 && x <= 4447 || x === 8986 || x === 8987 || x === 9001 || x === 9002 || x >= 9193 && x <= 9196 || x === 9200 || x === 9203 || x === 9725 || x === 9726 || x === 9748 || x === 9749 || x >= 9776 && x <= 9783 || x >= 9800 && x <= 9811 || x === 9855 || x >= 9866 && x <= 9871 || x === 9875 || x === 9889 || x === 9898 || x === 9899 || x === 9917 || x === 9918 || x === 9924 || x === 9925 || x === 9934 || x === 9940 || x === 9962 || x === 9970 || x === 9971 || x === 9973 || x === 9978 || x === 9981 || x === 9989 || x === 9994 || x === 9995 || x === 10024 || x === 10060 || x === 10062 || x >= 10067 && x <= 10069 || x === 10071 || x >= 10133 && x <= 10135 || x === 10160 || x === 10175 || x === 11035 || x === 11036 || x === 11088 || x === 11093 || x >= 11904 && x <= 11929 || x >= 11931 && x <= 12019 || x >= 12032 && x <= 12245 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12353 && x <= 12438 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12773 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 42124 || x >= 42128 && x <= 42182 || x >= 43360 && x <= 43388 || x >= 44032 && x <= 55203 || x >= 63744 && x <= 64255 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 94176 && x <= 94180 || x === 94192 || x === 94193 || x >= 94208 && x <= 100343 || x >= 100352 && x <= 101589 || x >= 101631 && x <= 101640 || x >= 110576 && x <= 110579 || x >= 110581 && x <= 110587 || x === 110589 || x === 110590 || x >= 110592 && x <= 110882 || x === 110898 || x >= 110928 && x <= 110930 || x === 110933 || x >= 110948 && x <= 110951 || x >= 110960 && x <= 111355 || x >= 119552 && x <= 119638 || x >= 119648 && x <= 119670 || x === 126980 || x === 127183 || x === 127374 || x >= 127377 && x <= 127386 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x === 127568 || x === 127569 || x >= 127584 && x <= 127589 || x >= 127744 && x <= 127776 || x >= 127789 && x <= 127797 || x >= 127799 && x <= 127868 || x >= 127870 && x <= 127891 || x >= 127904 && x <= 127946 || x >= 127951 && x <= 127955 || x >= 127968 && x <= 127984 || x === 127988 || x >= 127992 && x <= 128062 || x === 128064 || x >= 128066 && x <= 128252 || x >= 128255 && x <= 128317 || x >= 128331 && x <= 128334 || x >= 128336 && x <= 128359 || x === 128378 || x === 128405 || x === 128406 || x === 128420 || x >= 128507 && x <= 128591 || x >= 128640 && x <= 128709 || x === 128716 || x >= 128720 && x <= 128722 || x >= 128725 && x <= 128727 || x >= 128732 && x <= 128735 || x === 128747 || x === 128748 || x >= 128756 && x <= 128764 || x >= 128992 && x <= 129003 || x === 129008 || x >= 129292 && x <= 129338 || x >= 129340 && x <= 129349 || x >= 129351 && x <= 129535 || x >= 129648 && x <= 129660 || x >= 129664 && x <= 129673 || x >= 129679 && x <= 129734 || x >= 129742 && x <= 129756 || x >= 129759 && x <= 129769 || x >= 129776 && x <= 129784 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
398
+ }
399
+
400
+ //#endregion
401
+ //#region ../../node_modules/.pnpm/get-east-asian-width@1.3.0/node_modules/get-east-asian-width/index.js
402
+ function validate(codePoint) {
403
+ if (!Number.isSafeInteger(codePoint)) throw new TypeError(`Expected a code point, got \`${typeof codePoint}\`.`);
404
+ }
405
+ function eastAsianWidth(codePoint, { ambiguousAsWide = false } = {}) {
406
+ validate(codePoint);
407
+ if (isFullWidth(codePoint) || isWide(codePoint) || ambiguousAsWide && isAmbiguous(codePoint)) return 2;
408
+ return 1;
409
+ }
410
+
411
+ //#endregion
412
+ //#region ../../node_modules/.pnpm/emoji-regex@10.4.0/node_modules/emoji-regex/index.js
413
+ var require_emoji_regex = __commonJS({ "../../node_modules/.pnpm/emoji-regex@10.4.0/node_modules/emoji-regex/index.js"(exports, module) {
414
+ module.exports = () => {
415
+ return /[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE])))?))?|\uDC6F(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE89\uDE8F-\uDEC2\uDEC6\uDECE-\uDEDC\uDEDF-\uDEE9]|\uDD3C(?:\u200D[\u2640\u2642]\uFE0F?|\uD83C[\uDFFB-\uDFFF])?|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g;
416
+ };
417
+ } });
453
418
 
454
- // consola/utils/color.ts
455
- import * as tty from "tty";
456
- var {
457
- env = {},
458
- argv = [],
459
- platform = ""
460
- } = typeof process === "undefined" ? {} : process;
461
- var isDisabled = "NO_COLOR" in env || argv.includes("--no-color");
462
- var isForced = "FORCE_COLOR" in env || argv.includes("--color");
463
- var isWindows = platform === "win32";
464
- var isDumbTerminal = env.TERM === "dumb";
465
- var isCompatibleTerminal = tty && tty.isatty && tty.isatty(1) && env.TERM && !isDumbTerminal;
466
- var isCI = "CI" in env && ("GITHUB_ACTIONS" in env || "GITLAB_CI" in env || "CIRCLECI" in env);
467
- var isColorSupported = !isDisabled && (isForced || isWindows && !isDumbTerminal || isCompatibleTerminal || isCI);
419
+ //#endregion
420
+ //#region ../../node_modules/.pnpm/string-width@7.2.0/node_modules/string-width/index.js
421
+ var import_emoji_regex = __toESM(require_emoji_regex(), 1);
422
+ const segmenter = new Intl.Segmenter();
423
+ const defaultIgnorableCodePointRegex = /^\p{Default_Ignorable_Code_Point}$/u;
424
+ function stringWidth$1(string, options = {}) {
425
+ if (typeof string !== "string" || string.length === 0) return 0;
426
+ const { ambiguousIsNarrow = true, countAnsiEscapeCodes = false } = options;
427
+ if (!countAnsiEscapeCodes) string = stripAnsi$1(string);
428
+ if (string.length === 0) return 0;
429
+ let width = 0;
430
+ const eastAsianWidthOptions = { ambiguousAsWide: !ambiguousIsNarrow };
431
+ for (const { segment: character } of segmenter.segment(string)) {
432
+ const codePoint = character.codePointAt(0);
433
+ if (codePoint <= 31 || codePoint >= 127 && codePoint <= 159) continue;
434
+ if (codePoint >= 8203 && codePoint <= 8207 || codePoint === 65279) continue;
435
+ if (codePoint >= 768 && codePoint <= 879 || codePoint >= 6832 && codePoint <= 6911 || codePoint >= 7616 && codePoint <= 7679 || codePoint >= 8400 && codePoint <= 8447 || codePoint >= 65056 && codePoint <= 65071) continue;
436
+ if (codePoint >= 55296 && codePoint <= 57343) continue;
437
+ if (codePoint >= 65024 && codePoint <= 65039) continue;
438
+ if (defaultIgnorableCodePointRegex.test(character)) continue;
439
+ if ((0, import_emoji_regex.default)().test(character)) {
440
+ width += 2;
441
+ continue;
442
+ }
443
+ width += eastAsianWidth(codePoint, eastAsianWidthOptions);
444
+ }
445
+ return width;
446
+ }
447
+
448
+ //#endregion
449
+ //#region consola/utils/color.ts
450
+ const { env = {}, argv = [], platform = "" } = typeof process === "undefined" ? {} : process;
451
+ const isDisabled = "NO_COLOR" in env || argv.includes("--no-color");
452
+ const isForced = "FORCE_COLOR" in env || argv.includes("--color");
453
+ const isWindows = platform === "win32";
454
+ const isDumbTerminal = env.TERM === "dumb";
455
+ const isCompatibleTerminal = tty && tty.isatty && tty.isatty(1) && env.TERM && !isDumbTerminal;
456
+ const isCI$1 = "CI" in env && ("GITHUB_ACTIONS" in env || "GITLAB_CI" in env || "CIRCLECI" in env);
457
+ const isColorSupported = !isDisabled && (isForced || isWindows && !isDumbTerminal || isCompatibleTerminal || isCI$1);
468
458
  function replaceClose(index, string, close, replace, head = string.slice(0, Math.max(0, index)) + replace, tail = string.slice(Math.max(0, index + close.length)), next = tail.indexOf(close)) {
469
- return head + (next < 0 ? tail : replaceClose(next, tail, close, replace));
459
+ return head + (next < 0 ? tail : replaceClose(next, tail, close, replace));
470
460
  }
471
461
  function clearBleed(index, string, open, close, replace) {
472
- return index < 0 ? open + string + close : open + replaceClose(index, string, close, replace) + close;
462
+ return index < 0 ? open + string + close : open + replaceClose(index, string, close, replace) + close;
473
463
  }
474
464
  function filterEmpty(open, close, replace = open, at = open.length + 1) {
475
- return (string) => string || !(string === "" || string === void 0) ? clearBleed(`${string}`.indexOf(close, at), string, open, close, replace) : "";
465
+ return (string) => string || !(string === "" || string === void 0) ? clearBleed(`${string}`.indexOf(close, at), string, open, close, replace) : "";
476
466
  }
477
467
  function init(open, close, replace) {
478
- return filterEmpty(`\x1B[${open}m`, `\x1B[${close}m`, replace);
468
+ return filterEmpty(`\u001B[${open}m`, `\u001B[${close}m`, replace);
479
469
  }
480
- var colorDefs = {
481
- reset: init(0, 0),
482
- bold: init(1, 22, "\x1B[22m\x1B[1m"),
483
- dim: init(2, 22, "\x1B[22m\x1B[2m"),
484
- italic: init(3, 23),
485
- underline: init(4, 24),
486
- inverse: init(7, 27),
487
- hidden: init(8, 28),
488
- strikethrough: init(9, 29),
489
- black: init(30, 39),
490
- red: init(31, 39),
491
- green: init(32, 39),
492
- yellow: init(33, 39),
493
- blue: init(34, 39),
494
- magenta: init(35, 39),
495
- cyan: init(36, 39),
496
- white: init(37, 39),
497
- gray: init(90, 39),
498
- bgBlack: init(40, 49),
499
- bgRed: init(41, 49),
500
- bgGreen: init(42, 49),
501
- bgYellow: init(43, 49),
502
- bgBlue: init(44, 49),
503
- bgMagenta: init(45, 49),
504
- bgCyan: init(46, 49),
505
- bgWhite: init(47, 49),
506
- blackBright: init(90, 39),
507
- redBright: init(91, 39),
508
- greenBright: init(92, 39),
509
- yellowBright: init(93, 39),
510
- blueBright: init(94, 39),
511
- magentaBright: init(95, 39),
512
- cyanBright: init(96, 39),
513
- whiteBright: init(97, 39),
514
- bgBlackBright: init(100, 49),
515
- bgRedBright: init(101, 49),
516
- bgGreenBright: init(102, 49),
517
- bgYellowBright: init(103, 49),
518
- bgBlueBright: init(104, 49),
519
- bgMagentaBright: init(105, 49),
520
- bgCyanBright: init(106, 49),
521
- bgWhiteBright: init(107, 49)
470
+ const colorDefs = {
471
+ reset: init(0, 0),
472
+ bold: init(1, 22, "\x1B[22m\x1B[1m"),
473
+ dim: init(2, 22, "\x1B[22m\x1B[2m"),
474
+ italic: init(3, 23),
475
+ underline: init(4, 24),
476
+ inverse: init(7, 27),
477
+ hidden: init(8, 28),
478
+ strikethrough: init(9, 29),
479
+ black: init(30, 39),
480
+ red: init(31, 39),
481
+ green: init(32, 39),
482
+ yellow: init(33, 39),
483
+ blue: init(34, 39),
484
+ magenta: init(35, 39),
485
+ cyan: init(36, 39),
486
+ white: init(37, 39),
487
+ gray: init(90, 39),
488
+ bgBlack: init(40, 49),
489
+ bgRed: init(41, 49),
490
+ bgGreen: init(42, 49),
491
+ bgYellow: init(43, 49),
492
+ bgBlue: init(44, 49),
493
+ bgMagenta: init(45, 49),
494
+ bgCyan: init(46, 49),
495
+ bgWhite: init(47, 49),
496
+ blackBright: init(90, 39),
497
+ redBright: init(91, 39),
498
+ greenBright: init(92, 39),
499
+ yellowBright: init(93, 39),
500
+ blueBright: init(94, 39),
501
+ magentaBright: init(95, 39),
502
+ cyanBright: init(96, 39),
503
+ whiteBright: init(97, 39),
504
+ bgBlackBright: init(100, 49),
505
+ bgRedBright: init(101, 49),
506
+ bgGreenBright: init(102, 49),
507
+ bgYellowBright: init(103, 49),
508
+ bgBlueBright: init(104, 49),
509
+ bgMagentaBright: init(105, 49),
510
+ bgCyanBright: init(106, 49),
511
+ bgWhiteBright: init(107, 49)
522
512
  };
523
513
  function createColors(useColor = isColorSupported) {
524
- return useColor ? colorDefs : Object.fromEntries(Object.keys(colorDefs).map((key) => [key, String]));
514
+ return useColor ? colorDefs : Object.fromEntries(Object.keys(colorDefs).map((key) => [key, String]));
525
515
  }
526
- var colors = createColors();
527
- function getColor(color, fallback = "reset") {
528
- return colors[color] || colors[fallback];
516
+ const colors = createColors();
517
+ function getColor$1(color, fallback = "reset") {
518
+ return colors[color] || colors[fallback];
529
519
  }
530
520
 
531
- // consola/utils/string.ts
532
- var ansiRegex = [
533
- "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
534
- "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"
535
- ].join("|");
521
+ //#endregion
522
+ //#region consola/utils/string.ts
523
+ const ansiRegex = ["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)", "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");
536
524
  function stripAnsi(text) {
537
- return text.replace(new RegExp(ansiRegex, "g"), "");
525
+ return text.replaceAll(new RegExp(ansiRegex, "g"), "");
538
526
  }
539
527
 
540
- // consola/utils/box.ts
541
- var boxStylePresets = {
542
- solid: {
543
- tl: "\u250C",
544
- tr: "\u2510",
545
- bl: "\u2514",
546
- br: "\u2518",
547
- h: "\u2500",
548
- v: "\u2502"
549
- },
550
- double: {
551
- tl: "\u2554",
552
- tr: "\u2557",
553
- bl: "\u255A",
554
- br: "\u255D",
555
- h: "\u2550",
556
- v: "\u2551"
557
- },
558
- doubleSingle: {
559
- tl: "\u2553",
560
- tr: "\u2556",
561
- bl: "\u2559",
562
- br: "\u255C",
563
- h: "\u2500",
564
- v: "\u2551"
565
- },
566
- doubleSingleRounded: {
567
- tl: "\u256D",
568
- tr: "\u256E",
569
- bl: "\u2570",
570
- br: "\u256F",
571
- h: "\u2500",
572
- v: "\u2551"
573
- },
574
- singleThick: {
575
- tl: "\u250F",
576
- tr: "\u2513",
577
- bl: "\u2517",
578
- br: "\u251B",
579
- h: "\u2501",
580
- v: "\u2503"
581
- },
582
- singleDouble: {
583
- tl: "\u2552",
584
- tr: "\u2555",
585
- bl: "\u2558",
586
- br: "\u255B",
587
- h: "\u2550",
588
- v: "\u2502"
589
- },
590
- singleDoubleRounded: {
591
- tl: "\u256D",
592
- tr: "\u256E",
593
- bl: "\u2570",
594
- br: "\u256F",
595
- h: "\u2550",
596
- v: "\u2502"
597
- },
598
- rounded: {
599
- tl: "\u256D",
600
- tr: "\u256E",
601
- bl: "\u2570",
602
- br: "\u256F",
603
- h: "\u2500",
604
- v: "\u2502"
605
- }
528
+ //#endregion
529
+ //#region consola/utils/box.ts
530
+ const boxStylePresets = {
531
+ solid: {
532
+ tl: "",
533
+ tr: "",
534
+ bl: "",
535
+ br: "",
536
+ h: "",
537
+ v: "│"
538
+ },
539
+ double: {
540
+ tl: "",
541
+ tr: "",
542
+ bl: "",
543
+ br: "",
544
+ h: "",
545
+ v: "║"
546
+ },
547
+ doubleSingle: {
548
+ tl: "",
549
+ tr: "",
550
+ bl: "",
551
+ br: "",
552
+ h: "",
553
+ v: "║"
554
+ },
555
+ doubleSingleRounded: {
556
+ tl: "",
557
+ tr: "",
558
+ bl: "",
559
+ br: "",
560
+ h: "",
561
+ v: "║"
562
+ },
563
+ singleThick: {
564
+ tl: "",
565
+ tr: "",
566
+ bl: "",
567
+ br: "",
568
+ h: "",
569
+ v: "┃"
570
+ },
571
+ singleDouble: {
572
+ tl: "",
573
+ tr: "",
574
+ bl: "",
575
+ br: "",
576
+ h: "",
577
+ v: "│"
578
+ },
579
+ singleDoubleRounded: {
580
+ tl: "",
581
+ tr: "",
582
+ bl: "",
583
+ br: "",
584
+ h: "",
585
+ v: "│"
586
+ },
587
+ rounded: {
588
+ tl: "",
589
+ tr: "",
590
+ bl: "",
591
+ br: "",
592
+ h: "",
593
+ v: "│"
594
+ }
606
595
  };
607
- var defaultStyle = {
608
- borderColor: "white",
609
- borderStyle: "rounded",
610
- valign: "center",
611
- padding: 2,
612
- marginLeft: 1,
613
- marginTop: 1,
614
- marginBottom: 1
596
+ const defaultStyle = {
597
+ borderColor: "white",
598
+ borderStyle: "rounded",
599
+ valign: "center",
600
+ padding: 2,
601
+ marginLeft: 1,
602
+ marginTop: 1,
603
+ marginBottom: 1
615
604
  };
616
605
  function box(text, _opts = {}) {
617
- const opts = {
618
- ..._opts,
619
- style: {
620
- ...defaultStyle,
621
- ..._opts.style
622
- }
623
- };
624
- const textLines = text.split("\n");
625
- const boxLines = [];
626
- const _color = getColor(opts.style.borderColor);
627
- const borderStyle = {
628
- ...typeof opts.style.borderStyle === "string" ? boxStylePresets[opts.style.borderStyle] || boxStylePresets.solid : opts.style.borderStyle
629
- };
630
- if (_color) {
631
- for (const key in borderStyle) {
632
- borderStyle[key] = _color(
633
- borderStyle[key]
634
- );
635
- }
636
- }
637
- const paddingOffset = opts.style.padding % 2 === 0 ? opts.style.padding : opts.style.padding + 1;
638
- const height = textLines.length + paddingOffset;
639
- const width = Math.max(...textLines.map((line) => line.length)) + paddingOffset;
640
- const widthOffset = width + paddingOffset;
641
- const leftSpace = opts.style.marginLeft > 0 ? " ".repeat(opts.style.marginLeft) : "";
642
- if (opts.style.marginTop > 0) {
643
- boxLines.push("".repeat(opts.style.marginTop));
644
- }
645
- if (opts.title) {
646
- const left = borderStyle.h.repeat(
647
- Math.floor((width - stripAnsi(opts.title).length) / 2)
648
- );
649
- const right = borderStyle.h.repeat(
650
- width - stripAnsi(opts.title).length - stripAnsi(left).length + paddingOffset
651
- );
652
- boxLines.push(
653
- `${leftSpace}${borderStyle.tl}${left}${opts.title}${right}${borderStyle.tr}`
654
- );
655
- } else {
656
- boxLines.push(
657
- `${leftSpace}${borderStyle.tl}${borderStyle.h.repeat(widthOffset)}${borderStyle.tr}`
658
- );
659
- }
660
- const valignOffset = opts.style.valign === "center" ? Math.floor((height - textLines.length) / 2) : opts.style.valign === "top" ? height - textLines.length - paddingOffset : height - textLines.length;
661
- for (let i = 0; i < height; i++) {
662
- if (i < valignOffset || i >= valignOffset + textLines.length) {
663
- boxLines.push(
664
- `${leftSpace}${borderStyle.v}${" ".repeat(widthOffset)}${borderStyle.v}`
665
- );
666
- } else {
667
- const line = textLines[i - valignOffset];
668
- const left = " ".repeat(paddingOffset);
669
- const right = " ".repeat(width - stripAnsi(line).length);
670
- boxLines.push(
671
- `${leftSpace}${borderStyle.v}${left}${line}${right}${borderStyle.v}`
672
- );
673
- }
674
- }
675
- boxLines.push(
676
- `${leftSpace}${borderStyle.bl}${borderStyle.h.repeat(widthOffset)}${borderStyle.br}`
677
- );
678
- if (opts.style.marginBottom > 0) {
679
- boxLines.push("".repeat(opts.style.marginBottom));
680
- }
681
- return boxLines.join("\n");
606
+ const opts = {
607
+ ..._opts,
608
+ style: {
609
+ ...defaultStyle,
610
+ ..._opts.style
611
+ }
612
+ };
613
+ const textLines = text.split("\n");
614
+ const boxLines = [];
615
+ const _color = getColor$1(opts.style.borderColor);
616
+ const borderStyle = { ...typeof opts.style.borderStyle === "string" ? boxStylePresets[opts.style.borderStyle] || boxStylePresets.solid : opts.style.borderStyle };
617
+ if (_color) for (const key in borderStyle) borderStyle[key] = _color(borderStyle[key]);
618
+ const paddingOffset = opts.style.padding % 2 === 0 ? opts.style.padding : opts.style.padding + 1;
619
+ const height = textLines.length + paddingOffset;
620
+ const width = Math.max(...textLines.map((line) => line.length)) + paddingOffset;
621
+ const widthOffset = width + paddingOffset;
622
+ const leftSpace = opts.style.marginLeft > 0 ? " ".repeat(opts.style.marginLeft) : "";
623
+ if (opts.style.marginTop > 0) boxLines.push("".repeat(opts.style.marginTop));
624
+ if (opts.title) {
625
+ const left = borderStyle.h.repeat(Math.floor((width - stripAnsi(opts.title).length) / 2));
626
+ const right = borderStyle.h.repeat(width - stripAnsi(opts.title).length - stripAnsi(left).length + paddingOffset);
627
+ boxLines.push(`${leftSpace}${borderStyle.tl}${left}${opts.title}${right}${borderStyle.tr}`);
628
+ } else boxLines.push(`${leftSpace}${borderStyle.tl}${borderStyle.h.repeat(widthOffset)}${borderStyle.tr}`);
629
+ const valignOffset = opts.style.valign === "center" ? Math.floor((height - textLines.length) / 2) : opts.style.valign === "top" ? height - textLines.length - paddingOffset : height - textLines.length;
630
+ for (let i = 0; i < height; i++) if (i < valignOffset || i >= valignOffset + textLines.length) boxLines.push(`${leftSpace}${borderStyle.v}${" ".repeat(widthOffset)}${borderStyle.v}`);
631
+ else {
632
+ const line = textLines[i - valignOffset];
633
+ const left = " ".repeat(paddingOffset);
634
+ const right = " ".repeat(width - stripAnsi(line).length);
635
+ boxLines.push(`${leftSpace}${borderStyle.v}${left}${line}${right}${borderStyle.v}`);
636
+ }
637
+ boxLines.push(`${leftSpace}${borderStyle.bl}${borderStyle.h.repeat(widthOffset)}${borderStyle.br}`);
638
+ if (opts.style.marginBottom > 0) boxLines.push("".repeat(opts.style.marginBottom));
639
+ return boxLines.join("\n");
682
640
  }
683
641
 
684
- // consola/utils/tester.ts
642
+ //#endregion
643
+ //#region consola/utils/tester.ts
685
644
  function isUnicodeSupported() {
686
- if (process.platform !== "win32") {
687
- return process.env.TERM !== "linux";
688
- }
689
- return Boolean(process.env.WT_SESSION) || // Windows Terminal
690
- Boolean(process.env.TERMINUS_SUBLIME) || // Terminus (<0.2.27)
691
- process.env.ConEmuTask === "{cmd::Cmder}" || // ConEmu and cmder
692
- process.env.TERM_PROGRAM === "Terminus-Sublime" || process.env.TERM_PROGRAM === "vscode" || process.env.TERM === "xterm-256color" || process.env.TERM === "alacritty" || process.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
645
+ if (process.platform !== "win32") return process.env.TERM !== "linux";
646
+ return Boolean(process.env.WT_SESSION) || Boolean(process.env.TERMINUS_SUBLIME) || process.env.ConEmuTask === "{cmd::Cmder}" || process.env.TERM_PROGRAM === "Terminus-Sublime" || process.env.TERM_PROGRAM === "vscode" || process.env.TERM === "xterm-256color" || process.env.TERM === "alacritty" || process.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
693
647
  }
694
648
 
695
- // consola/reporters/fancy.ts
696
- var TYPE_COLOR_MAP = {
697
- info: "cyan",
698
- fail: "red",
699
- success: "green",
700
- ready: "green",
701
- start: "magenta"
649
+ //#endregion
650
+ //#region consola/reporters/fancy.ts
651
+ const TYPE_COLOR_MAP = {
652
+ info: "cyan",
653
+ fail: "red",
654
+ success: "green",
655
+ ready: "green",
656
+ start: "magenta"
702
657
  };
703
- var LEVEL_COLOR_MAP = {
704
- 0: "red",
705
- 1: "yellow"
658
+ const LEVEL_COLOR_MAP = {
659
+ 0: "red",
660
+ 1: "yellow"
706
661
  };
707
- var unicode = isUnicodeSupported();
708
- var s = (c, fallback) => unicode ? c : fallback;
709
- var TYPE_ICONS = {
710
- error: s("\u2716", "\xD7"),
711
- fatal: s("\u2716", "\xD7"),
712
- ready: s("\u2714", "\u221A"),
713
- warn: s("\u26A0", "\u203C"),
714
- info: s("\u2139", "i"),
715
- success: s("\u2714", "\u221A"),
716
- debug: s("\u2699", "D"),
717
- trace: s("\u2192", "\u2192"),
718
- fail: s("\u2716", "\xD7"),
719
- start: s("\u25D0", "o"),
720
- log: ""
662
+ const unicode = isUnicodeSupported();
663
+ const s = (c, fallback) => unicode ? c : fallback;
664
+ const TYPE_ICONS = {
665
+ error: s("", "×"),
666
+ fatal: s("", "×"),
667
+ ready: s("", ""),
668
+ warn: s("", ""),
669
+ info: s("", "i"),
670
+ success: s("", ""),
671
+ debug: s("", "D"),
672
+ trace: s("", ""),
673
+ fail: s("", "×"),
674
+ start: s("", "o"),
675
+ log: ""
721
676
  };
722
677
  function stringWidth(str) {
723
- if (!Intl.Segmenter) {
724
- return stripAnsi(str).length;
725
- }
726
- return _stringWidth(str);
678
+ if (!Intl.Segmenter) return stripAnsi(str).length;
679
+ return stringWidth$1(str);
727
680
  }
728
681
  var FancyReporter = class extends BasicReporter {
729
- formatStack(stack) {
730
- return `
731
- ${parseStack(stack).map(
732
- (line) => ` ${line.replace(/^at +/, (m) => colors.gray(m)).replace(/\((.+)\)/, (_, m) => `(${colors.cyan(m)})`)}`
733
- ).join("\n")}`;
734
- }
735
- formatType(logObj, isBadge, opts) {
736
- const typeColor = TYPE_COLOR_MAP[logObj.type] || LEVEL_COLOR_MAP[logObj.level] || "gray";
737
- if (isBadge) {
738
- return getBgColor(typeColor)(
739
- colors.black(` ${logObj.type.toUpperCase()} `)
740
- );
741
- }
742
- const _type = typeof TYPE_ICONS[logObj.type] === "string" ? TYPE_ICONS[logObj.type] : logObj.icon || logObj.type;
743
- return _type ? getColor2(typeColor)(_type) : "";
744
- }
745
- formatLogObj(logObj, opts) {
746
- const [message, ...additional] = this.formatArgs(logObj.args, opts).split(
747
- "\n"
748
- );
749
- if (logObj.type === "box") {
750
- return box(
751
- characterFormat(
752
- message + (additional.length > 0 ? `
753
- ${additional.join("\n")}` : "")
754
- ),
755
- {
756
- title: logObj.title ? characterFormat(logObj.title) : void 0,
757
- style: logObj.style
758
- }
759
- );
760
- }
761
- const date = this.formatDate(logObj.date, opts);
762
- const coloredDate = date && colors.gray(date);
763
- const isBadge = logObj.badge ?? logObj.level < 2;
764
- const type = this.formatType(logObj, isBadge, opts);
765
- const tag = logObj.tag ? colors.gray(logObj.tag) : "";
766
- let line;
767
- const left = this.filterAndJoin([type, characterFormat(message)]);
768
- const right = this.filterAndJoin(opts.columns ? [tag, coloredDate] : [tag]);
769
- const space = (opts.columns || 0) - stringWidth(left) - stringWidth(right) - 2;
770
- line = space > 0 && (opts.columns || 0) >= 80 ? left + " ".repeat(space) + right : (right ? `${colors.gray(`[${right}]`)} ` : "") + left;
771
- line += characterFormat(
772
- additional.length > 0 ? `
773
- ${additional.join("\n")}` : ""
774
- );
775
- if (logObj.type === "trace") {
776
- const _err = new Error(`Trace: ${logObj.message}`);
777
- line += this.formatStack(_err.stack || "");
778
- }
779
- return isBadge ? `
780
- ${line}
781
- ` : line;
782
- }
682
+ formatStack(stack) {
683
+ return `\n${parseStack(stack).map((line) => ` ${line.replace(/^at +/, (m) => colors.gray(m)).replace(/\((.+)\)/, (_, m) => `(${colors.cyan(m)})`)}`).join("\n")}`;
684
+ }
685
+ formatType(logObj, isBadge, _opts) {
686
+ const typeColor = TYPE_COLOR_MAP[logObj.type] || LEVEL_COLOR_MAP[logObj.level] || "gray";
687
+ if (isBadge) return getBgColor(typeColor)(colors.black(` ${logObj.type.toUpperCase()} `));
688
+ const _type = typeof TYPE_ICONS[logObj.type] === "string" ? TYPE_ICONS[logObj.type] : logObj.icon || logObj.type;
689
+ return _type ? getColor(typeColor)(_type) : "";
690
+ }
691
+ formatLogObj(logObj, opts) {
692
+ const [message, ...additional] = this.formatArgs(logObj.args, opts).split("\n");
693
+ if (logObj.type === "box") return box(characterFormat(message + (additional.length > 0 ? `\n${additional.join("\n")}` : "")), {
694
+ title: logObj.title ? characterFormat(logObj.title) : void 0,
695
+ style: logObj.style
696
+ });
697
+ const date = this.formatDate(logObj.date, opts);
698
+ const coloredDate = date && colors.gray(date);
699
+ const isBadge = logObj.badge ?? logObj.level < 2;
700
+ const type = this.formatType(logObj, isBadge, opts);
701
+ const tag = logObj.tag ? colors.gray(logObj.tag) : "";
702
+ let line;
703
+ const left = this.filterAndJoin([type, characterFormat(message)]);
704
+ const right = this.filterAndJoin(opts.columns ? [tag, coloredDate] : [tag]);
705
+ const space = (opts.columns || 0) - stringWidth(left) - stringWidth(right) - 2;
706
+ line = space > 0 && (opts.columns || 0) >= 80 ? left + " ".repeat(space) + right : (right ? `${colors.gray(`[${right}]`)} ` : "") + left;
707
+ line += characterFormat(additional.length > 0 ? `\n${additional.join("\n")}` : "");
708
+ if (logObj.type === "trace") {
709
+ const _err = new Error(`Trace: ${logObj.message}`);
710
+ line += this.formatStack(_err.stack || "");
711
+ }
712
+ return isBadge ? `\n${line}\n` : line;
713
+ }
783
714
  };
784
715
  function characterFormat(str) {
785
- return str.replace(/`([^`]+)`/gm, (_, m) => colors.cyan(m)).replace(/\s+_([^_]+)_\s+/gm, (_, m) => ` ${colors.underline(m)} `);
716
+ return str.replaceAll(/`([^`]+)`/g, (_, m) => colors.cyan(m)).replaceAll(/\s+_([^_]+)_\s+/g, (_, m) => ` ${colors.underline(m)} `);
786
717
  }
787
- function getColor2(color = "white") {
788
- return colors[color] || colors.white;
718
+ function getColor(color = "white") {
719
+ return colors[color] || colors.white;
789
720
  }
790
721
  function getBgColor(color = "bgWhite") {
791
- return colors[`bg${color[0].toUpperCase()}${color.slice(1)}`] || colors.bgWhite;
722
+ return colors[`bg${color[0].toUpperCase()}${color.slice(1)}`] || colors.bgWhite;
792
723
  }
793
724
 
794
- // consola/index.ts
795
- function createConsola2(options = {}) {
796
- let level = _getDefaultLogLevel();
797
- if (process.env.CONSOLA_LEVEL) {
798
- level = Number.parseInt(process.env.CONSOLA_LEVEL) ?? level;
799
- }
800
- const consola2 = createConsola({
801
- level,
802
- defaults: { level },
803
- stdout: process.stdout,
804
- stderr: process.stderr,
805
- reporters: options.reporters || [
806
- options.fancy ?? !(isCI2 || isTest) ? new FancyReporter() : new BasicReporter()
807
- ],
808
- ...options
809
- });
810
- return consola2;
725
+ //#endregion
726
+ //#region consola/index.ts
727
+ function createConsola(options = {}) {
728
+ let level = _getDefaultLogLevel();
729
+ if (process.env.CONSOLA_LEVEL) level = Number.parseInt(process.env.CONSOLA_LEVEL) ?? level;
730
+ const consola$1 = createConsola$1({
731
+ level,
732
+ defaults: { level },
733
+ stdout: process.stdout,
734
+ stderr: process.stderr,
735
+ reporters: options.reporters || [options.fancy ?? !(isCI || isTest) ? new FancyReporter() : new BasicReporter()],
736
+ ...options
737
+ });
738
+ return consola$1;
811
739
  }
812
740
  function _getDefaultLogLevel() {
813
- if (isDebug) {
814
- return LogLevels.debug;
815
- }
816
- if (isTest) {
817
- return LogLevels.warn;
818
- }
819
- return LogLevels.info;
741
+ if (isDebug) return LogLevels.debug;
742
+ if (isTest) return LogLevels.warn;
743
+ return LogLevels.info;
820
744
  }
821
- var consola = createConsola2();
822
-
823
- // consola/reporters/file.ts
824
- import { createWriteStream } from "fs";
825
- import * as fs from "fs";
826
- import { dirname } from "path";
827
- import { CronJob } from "cron";
745
+ const consola = createConsola();
828
746
 
829
- // tool.util.ts
830
- import path from "path";
831
- var getShortTime = (date) => {
832
- return Intl.DateTimeFormat("en-US", {
833
- timeStyle: "medium",
834
- hour12: false
835
- }).format(date);
836
- };
837
- var getShortDate = (date) => {
838
- return Intl.DateTimeFormat("en-US", {
839
- dateStyle: "short"
840
- }).format(date).replace(/\//g, "-");
841
- };
842
- var getLogFilePath = (logDir, formatString) => path.resolve(logDir, formatString.replace(/%d/g, getShortDate(/* @__PURE__ */ new Date())));
747
+ //#endregion
748
+ //#region tool.util.ts
749
+ function getShortTime(date) {
750
+ return Intl.DateTimeFormat("en-US", {
751
+ timeStyle: "medium",
752
+ hour12: false
753
+ }).format(date);
754
+ }
755
+ function getShortDate(date) {
756
+ return Intl.DateTimeFormat("en-US", { dateStyle: "short" }).format(date).replaceAll("/", "-");
757
+ }
758
+ function getLogFilePath(logDir, formatString) {
759
+ return path.resolve(logDir, formatString.replaceAll("%d", getShortDate(new Date())));
760
+ }
843
761
 
844
- // consola/reporters/logger.ts
845
- import picocolors from "picocolors";
846
- import { isDevelopment } from "std-env";
762
+ //#endregion
763
+ //#region consola/reporters/logger.ts
847
764
  var LoggerReporter = class extends FancyReporter {
848
- constructor() {
849
- super(...arguments);
850
- this.latestLogTime = Date.now();
851
- }
852
- formatDate(date, opts) {
853
- const isInVirtualTerminal = typeof opts.columns === "undefined";
854
- if (isDevelopment) {
855
- const now = Date.now();
856
- const delta = now - this.latestLogTime;
857
- this.latestLogTime = now;
858
- return `+${delta | 0}ms ${super.formatDate(date, opts)}`;
859
- }
860
- return isInVirtualTerminal ? "" : super.formatDate(date, opts);
861
- }
862
- formatLogObj(logObj, opts) {
863
- const isInVirtualTerminal = typeof opts.columns === "undefined";
864
- return isInVirtualTerminal ? `${picocolors.gray(getShortTime(/* @__PURE__ */ new Date()))} ${super.formatLogObj(logObj, opts).replace(/^\n/, "")}`.trimEnd() : super.formatLogObj(logObj, opts);
865
- }
765
+ constructor(..._args) {
766
+ super(..._args);
767
+ this.latestLogTime = Date.now();
768
+ }
769
+ formatDate(date, opts) {
770
+ const isInVirtualTerminal = opts.columns === void 0;
771
+ if (isDevelopment) {
772
+ const now = Date.now();
773
+ const delta = now - this.latestLogTime;
774
+ this.latestLogTime = now;
775
+ return `+${delta | 0}ms ${super.formatDate(date, opts)}`;
776
+ }
777
+ return isInVirtualTerminal ? "" : super.formatDate(date, opts);
778
+ }
779
+ formatLogObj(logObj, opts) {
780
+ const isInVirtualTerminal = opts.columns === void 0;
781
+ return isInVirtualTerminal ? `${picocolors.gray(getShortTime(new Date()))} ${super.formatLogObj(logObj, opts).replace(/^\n/, "")}`.trimEnd() : super.formatLogObj(logObj, opts);
782
+ }
866
783
  };
867
784
 
868
- // consola/reporters/file.ts
785
+ //#endregion
786
+ //#region consola/reporters/file.ts
869
787
  var FileReporter = class extends LoggerReporter {
870
- constructor(configs) {
871
- super();
872
- this.configs = configs;
873
- this.refreshWriteStream();
874
- this.scheduleRefreshWriteStream();
875
- }
876
- scheduleRefreshWriteStream() {
877
- const { cron = "0 0 * * *" } = this.configs;
878
- const job = new CronJob(cron, this.refreshWriteStream.bind(this));
879
- job.start();
880
- this.__job = job;
881
- }
882
- teardown() {
883
- this.__job?.stop();
884
- this.stdoutStream?.end();
885
- this.stderrStream?.end();
886
- }
887
- refreshWriteStream() {
888
- const {
889
- loggerDir,
890
- stderrFileFormat = "error.log",
891
- stdoutFileFormat = "stdout_%d.log"
892
- } = this.configs;
893
- const stdoutPath = getLogFilePath(loggerDir, stdoutFileFormat);
894
- const stderrPath = getLogFilePath(loggerDir, stderrFileFormat);
895
- createLoggerFileIfNotExist(stdoutPath);
896
- createLoggerFileIfNotExist(stderrPath);
897
- const options = {
898
- encoding: "utf-8",
899
- flags: "a+"
900
- };
901
- [this.stderrStream, this.stdoutStream].forEach((stream) => {
902
- stream?.end();
903
- });
904
- this.stdoutStream = createWriteStream(stdoutPath, options);
905
- this.stderrStream = createWriteStream(stderrPath, options);
906
- [this.stderrStream, this.stdoutStream].forEach((stream) => {
907
- writeStream(
908
- "\n========================================================\n",
909
- stream
910
- );
911
- });
912
- }
913
- log(logObj, ctx) {
914
- if (!this.stdoutStream || !this.stderrStream) {
915
- return;
916
- }
917
- const finalStdout = this.stdoutStream;
918
- const finalStderr = this.stderrStream || this.stdoutStream;
919
- const line = super.formatLogObj(logObj, {
920
- ...ctx.options.formatOptions,
921
- columns: void 0
922
- });
923
- if (this.configs.errWriteToStdout && logObj.level < 2) {
924
- writeStream(`${line}
925
- `, finalStdout);
926
- }
927
- return writeStream(
928
- `${line}
929
- `,
930
- logObj.level < 2 ? finalStderr : finalStdout
931
- );
932
- }
933
- };
934
- var createLoggerFileIfNotExist = (path2) => {
935
- const dirPath = dirname(path2);
936
- if (!fs.existsSync(dirPath)) {
937
- fs.mkdirSync(dirPath, { recursive: true });
938
- }
939
- if (!fs.existsSync(path2)) {
940
- fs.writeFileSync(path2, "", { flag: "wx" });
941
- }
788
+ constructor(configs) {
789
+ super();
790
+ this.configs = configs;
791
+ this.refreshWriteStream();
792
+ this.scheduleRefreshWriteStream();
793
+ }
794
+ scheduleRefreshWriteStream() {
795
+ const { cron = "0 0 * * *" } = this.configs;
796
+ const job = new CronJob(cron, this.refreshWriteStream.bind(this));
797
+ job.start();
798
+ this.__job = job;
799
+ }
800
+ teardown() {
801
+ this.__job?.stop();
802
+ this.stdoutStream?.end();
803
+ this.stderrStream?.end();
804
+ }
805
+ refreshWriteStream() {
806
+ const { loggerDir, stderrFileFormat = "error.log", stdoutFileFormat = "stdout_%d.log" } = this.configs;
807
+ const stdoutPath = getLogFilePath(loggerDir, stdoutFileFormat);
808
+ const stderrPath = getLogFilePath(loggerDir, stderrFileFormat);
809
+ createLoggerFileIfNotExist(stdoutPath);
810
+ createLoggerFileIfNotExist(stderrPath);
811
+ const options = {
812
+ encoding: "utf-8",
813
+ flags: "a+"
814
+ };
815
+ [this.stderrStream, this.stdoutStream].forEach((stream) => {
816
+ stream?.end();
817
+ });
818
+ this.stdoutStream = createWriteStream(stdoutPath, options);
819
+ this.stderrStream = createWriteStream(stderrPath, options);
820
+ [this.stderrStream, this.stdoutStream].forEach((stream) => {
821
+ writeStream("\n========================================================\n", stream);
822
+ });
823
+ }
824
+ log(logObj, ctx) {
825
+ if (!this.stdoutStream || !this.stderrStream) return;
826
+ const finalStdout = this.stdoutStream;
827
+ const finalStderr = this.stderrStream || this.stdoutStream;
828
+ const line = super.formatLogObj(logObj, {
829
+ ...ctx.options.formatOptions,
830
+ columns: void 0
831
+ });
832
+ if (this.configs.errWriteToStdout && logObj.level < 2) writeStream(`${line}\n`, finalStdout);
833
+ return writeStream(`${line}\n`, logObj.level < 2 ? finalStderr : finalStdout);
834
+ }
942
835
  };
836
+ function createLoggerFileIfNotExist(path$1) {
837
+ const dirPath = dirname(path$1);
838
+ if (!fs.existsSync(dirPath)) fs.mkdirSync(dirPath, { recursive: true });
839
+ if (!fs.existsSync(path$1)) fs.writeFileSync(path$1, "", { flag: "wx" });
840
+ }
943
841
 
944
- // consola/reporters/subscriber.ts
945
- import EventEmitter from "events";
946
- var wrapperSubscribers = (consola2) => {
947
- Object.assign(consola2, {
948
- onData: (handler) => SubscriberReporter.subscriber.on("log", handler),
949
- onStdOut: (handler) => SubscriberReporter.subscriber.on("stdout", handler),
950
- onStdErr: (handler) => SubscriberReporter.subscriber.on("stderr", handler)
951
- });
952
- return consola2;
953
- };
954
- var _SubscriberReporter = class _SubscriberReporter extends LoggerReporter {
955
- log(logObj, ctx) {
956
- const line = super.formatLogObj(logObj, ctx);
957
- const event = logObj.level < 2 ? "stderr" : "stdout";
958
- _SubscriberReporter.subscriber.emit(event, line);
959
- _SubscriberReporter.subscriber.emit("log", line);
960
- }
842
+ //#endregion
843
+ //#region consola/reporters/subscriber.ts
844
+ function wrapperSubscribers(consola$1) {
845
+ Object.assign(consola$1, {
846
+ onData: (handler) => SubscriberReporter.subscriber.on("log", handler),
847
+ onStdOut: (handler) => SubscriberReporter.subscriber.on("stdout", handler),
848
+ onStdErr: (handler) => SubscriberReporter.subscriber.on("stderr", handler)
849
+ });
850
+ return consola$1;
851
+ }
852
+ var SubscriberReporter = class SubscriberReporter extends LoggerReporter {
853
+ log(logObj, ctx) {
854
+ const line = super.formatLogObj(logObj, ctx);
855
+ const event = logObj.level < 2 ? "stderr" : "stdout";
856
+ SubscriberReporter.subscriber.emit(event, line);
857
+ SubscriberReporter.subscriber.emit("log", line);
858
+ }
961
859
  };
962
- _SubscriberReporter.subscriber = new EventEmitter();
963
- var SubscriberReporter = _SubscriberReporter;
860
+ SubscriberReporter.subscriber = new EventEmitter();
964
861
 
965
- // consola.instance.ts
966
- var createLoggerConsola = (options) => {
967
- const reporters = [
968
- new FancyReporter(),
969
- new SubscriberReporter()
970
- ];
971
- if (options?.writeToFile) {
972
- reporters.push(new FileReporter(options.writeToFile));
973
- }
974
- const consola2 = createConsola2({
975
- formatOptions: {
976
- date: true
977
- },
978
- reporters,
979
- level: isDevelopment2 ? LogLevels.trace : LogLevels.info,
980
- ...options
981
- });
982
- return wrapperSubscribers(consola2);
983
- };
862
+ //#endregion
863
+ //#region consola.instance.ts
864
+ function createLoggerConsola(options) {
865
+ const reporters = [new FancyReporter(), new SubscriberReporter()];
866
+ if (options?.writeToFile) reporters.push(new FileReporter(options.writeToFile));
867
+ const consola$1 = createConsola({
868
+ formatOptions: { date: true },
869
+ reporters,
870
+ level: isDevelopment ? LogLevels.trace : LogLevels.info,
871
+ ...options
872
+ });
873
+ return wrapperSubscribers(consola$1);
874
+ }
984
875
 
985
- // consola/reporters/browser.ts
876
+ //#endregion
877
+ //#region consola/reporters/browser.ts
986
878
  var BrowserReporter = class {
987
- constructor(options) {
988
- this.options = { ...options };
989
- this.defaultColor = "#7f8c8d";
990
- this.levelColorMap = {
991
- 0: "#c0392b",
992
- // Red
993
- 1: "#f39c12",
994
- // Yellow
995
- 3: "#00BCD4"
996
- // Cyan
997
- };
998
- this.typeColorMap = {
999
- success: "#2ecc71"
1000
- // Green
1001
- };
1002
- }
1003
- _getLogFn(level) {
1004
- if (level < 1) {
1005
- return console.__error || console.error;
1006
- }
1007
- if (level === 1) {
1008
- return console.__warn || console.warn;
1009
- }
1010
- return console.__log || console.log;
1011
- }
1012
- log(logObj) {
1013
- const consoleLogFn = this._getLogFn(logObj.level);
1014
- const type = logObj.type === "log" ? "" : logObj.type;
1015
- const tag = logObj.tag || "";
1016
- const color = this.typeColorMap[logObj.type] || this.levelColorMap[logObj.level] || this.defaultColor;
1017
- const style = `
879
+ constructor(options) {
880
+ this.options = { ...options };
881
+ this.defaultColor = "#7f8c8d";
882
+ this.levelColorMap = {
883
+ 0: "#c0392b",
884
+ 1: "#f39c12",
885
+ 3: "#00BCD4"
886
+ };
887
+ this.typeColorMap = { success: "#2ecc71" };
888
+ }
889
+ _getLogFn(level) {
890
+ if (level < 1) return console.__error || console.error;
891
+ if (level === 1) return console.__warn || console.warn;
892
+ return console.__log || console.log;
893
+ }
894
+ log(logObj) {
895
+ const consoleLogFn = this._getLogFn(logObj.level);
896
+ const type = logObj.type === "log" ? "" : logObj.type;
897
+ const tag = logObj.tag || "";
898
+ const color = this.typeColorMap[logObj.type] || this.levelColorMap[logObj.level] || this.defaultColor;
899
+ const style = `
1018
900
  background: ${color};
1019
901
  border-radius: 0.5em;
1020
902
  color: white;
1021
903
  font-weight: bold;
1022
904
  padding: 2px 0.5em;
1023
905
  `;
1024
- const badge = `%c${[tag, type].filter(Boolean).join(":")}`;
1025
- if (typeof logObj.args[0] === "string") {
1026
- consoleLogFn(
1027
- `${badge}%c ${logObj.args[0]}`,
1028
- style,
1029
- // Empty string as style resets to default console style
1030
- "",
1031
- ...logObj.args.slice(1)
1032
- );
1033
- } else {
1034
- consoleLogFn(badge, style, ...logObj.args);
1035
- }
1036
- }
1037
- };
1038
- export {
1039
- BasicReporter,
1040
- BrowserReporter,
1041
- Consola,
1042
- FancyReporter,
1043
- FileReporter,
1044
- LEVEL_COLOR_MAP,
1045
- LogLevels,
1046
- LogTypes,
1047
- LoggerReporter,
1048
- SubscriberReporter,
1049
- TYPE_COLOR_MAP,
1050
- consola,
1051
- createConsola2 as createConsola,
1052
- createLoggerConsola,
1053
- wrapperSubscribers
906
+ const badge = `%c${[tag, type].filter(Boolean).join(":")}`;
907
+ if (typeof logObj.args[0] === "string") consoleLogFn(
908
+ `${badge}%c ${logObj.args[0]}`,
909
+ style,
910
+ // Empty string as style resets to default console style
911
+ "",
912
+ ...logObj.args.slice(1)
913
+ );
914
+ else consoleLogFn(badge, style, ...logObj.args);
915
+ }
1054
916
  };
917
+
918
+ //#endregion
919
+ export { BasicReporter, BrowserReporter, Consola, FancyReporter, FileReporter, LEVEL_COLOR_MAP, LogLevels, LogTypes, LoggerReporter, SubscriberReporter, TYPE_COLOR_MAP, consola, createConsola, createLoggerConsola, wrapperSubscribers };