@likec4/log 1.17.1 → 1.19.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.
@@ -1,1369 +0,0 @@
1
- 'use strict';
2
-
3
- const node_util = require('node:util');
4
- const node_path = require('node:path');
5
- const process$1 = require('node:process');
6
- const tty = require('node:tty');
7
-
8
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
9
-
10
- function _interopNamespaceCompat(e) {
11
- if (e && typeof e === 'object' && 'default' in e) return e;
12
- const n = Object.create(null);
13
- if (e) {
14
- for (const k in e) {
15
- n[k] = e[k];
16
- }
17
- }
18
- n.default = e;
19
- return n;
20
- }
21
-
22
- const process$1__default = /*#__PURE__*/_interopDefaultCompat(process$1);
23
- const tty__namespace = /*#__PURE__*/_interopNamespaceCompat(tty);
24
-
25
- const LogLevels = {
26
- silent: Number.NEGATIVE_INFINITY,
27
- fatal: 0,
28
- error: 0,
29
- warn: 1,
30
- log: 2,
31
- info: 3,
32
- success: 3,
33
- fail: 3,
34
- ready: 3,
35
- start: 3,
36
- box: 3,
37
- debug: 4,
38
- trace: 5,
39
- verbose: Number.POSITIVE_INFINITY
40
- };
41
- const LogTypes = {
42
- // Silent
43
- silent: {
44
- level: -1
45
- },
46
- // Level 0
47
- fatal: {
48
- level: LogLevels.fatal
49
- },
50
- error: {
51
- level: LogLevels.error
52
- },
53
- // Level 1
54
- warn: {
55
- level: LogLevels.warn
56
- },
57
- // Level 2
58
- log: {
59
- level: LogLevels.log
60
- },
61
- // Level 3
62
- info: {
63
- level: LogLevels.info
64
- },
65
- success: {
66
- level: LogLevels.success
67
- },
68
- fail: {
69
- level: LogLevels.fail
70
- },
71
- ready: {
72
- level: LogLevels.info
73
- },
74
- start: {
75
- level: LogLevels.info
76
- },
77
- box: {
78
- level: LogLevels.info
79
- },
80
- // Level 4
81
- debug: {
82
- level: LogLevels.debug
83
- },
84
- // Level 5
85
- trace: {
86
- level: LogLevels.trace
87
- },
88
- // Verbose
89
- verbose: {
90
- level: LogLevels.verbose
91
- }
92
- };
93
-
94
- function isObject(value) {
95
- return value !== null && typeof value === "object";
96
- }
97
- function _defu(baseObject, defaults, namespace = ".", merger) {
98
- if (!isObject(defaults)) {
99
- return _defu(baseObject, {}, namespace);
100
- }
101
- const object = Object.assign({}, defaults);
102
- for (const key in baseObject) {
103
- if (key === "__proto__" || key === "constructor") {
104
- continue;
105
- }
106
- const value = baseObject[key];
107
- if (value === null || value === void 0) {
108
- continue;
109
- }
110
- if (Array.isArray(value) && Array.isArray(object[key])) {
111
- object[key] = [...value, ...object[key]];
112
- } else if (isObject(value) && isObject(object[key])) {
113
- object[key] = _defu(
114
- value,
115
- object[key],
116
- (namespace ? `${namespace}.` : "") + key.toString());
117
- } else {
118
- object[key] = value;
119
- }
120
- }
121
- return object;
122
- }
123
- function createDefu(merger) {
124
- return (...arguments_) => (
125
- // eslint-disable-next-line unicorn/no-array-reduce
126
- arguments_.reduce((p, c) => _defu(p, c, ""), {})
127
- );
128
- }
129
- const defu = createDefu();
130
-
131
- function isPlainObject(obj) {
132
- return Object.prototype.toString.call(obj) === "[object Object]";
133
- }
134
- function isLogObj(arg) {
135
- if (!isPlainObject(arg)) {
136
- return false;
137
- }
138
- if (!arg.message && !arg.args) {
139
- return false;
140
- }
141
- if (arg.stack) {
142
- return false;
143
- }
144
- return true;
145
- }
146
-
147
- let paused = false;
148
- const queue = [];
149
- class Consola {
150
- constructor(options = {}) {
151
- const types = options.types || LogTypes;
152
- this.options = defu(
153
- {
154
- ...options,
155
- defaults: { ...options.defaults },
156
- level: _normalizeLogLevel(options.level, types),
157
- reporters: [...options.reporters || []]
158
- },
159
- {
160
- types: LogTypes,
161
- throttle: 1e3,
162
- throttleMin: 5,
163
- formatOptions: {
164
- date: true,
165
- colors: false,
166
- compact: true
167
- }
168
- }
169
- );
170
- for (const type in types) {
171
- const defaults = {
172
- type,
173
- ...this.options.defaults,
174
- ...types[type]
175
- };
176
- this[type] = this._wrapLogFn(defaults);
177
- this[type].raw = this._wrapLogFn(
178
- defaults,
179
- true
180
- );
181
- }
182
- if (this.options.mockFn) {
183
- this.mockTypes();
184
- }
185
- this._lastLog = {};
186
- }
187
- get level() {
188
- return this.options.level;
189
- }
190
- set level(level) {
191
- this.options.level = _normalizeLogLevel(
192
- level,
193
- this.options.types,
194
- this.options.level
195
- );
196
- }
197
- prompt(message, opts) {
198
- if (!this.options.prompt) {
199
- throw new Error("prompt is not supported!");
200
- }
201
- return this.options.prompt(message, opts);
202
- }
203
- create(options) {
204
- const instance = new Consola({
205
- ...this.options,
206
- ...options
207
- });
208
- if (this._mockFn) {
209
- instance.mockTypes(this._mockFn);
210
- }
211
- return instance;
212
- }
213
- withDefaults(defaults) {
214
- return this.create({
215
- ...this.options,
216
- defaults: {
217
- ...this.options.defaults,
218
- ...defaults
219
- }
220
- });
221
- }
222
- withTag(tag) {
223
- return this.withDefaults({
224
- tag: this.options.defaults.tag ? this.options.defaults.tag + ":" + tag : tag
225
- });
226
- }
227
- addReporter(reporter) {
228
- this.options.reporters.push(reporter);
229
- return this;
230
- }
231
- removeReporter(reporter) {
232
- if (reporter) {
233
- const i = this.options.reporters.indexOf(reporter);
234
- if (i >= 0) {
235
- return this.options.reporters.splice(i, 1);
236
- }
237
- } else {
238
- this.options.reporters.splice(0);
239
- }
240
- return this;
241
- }
242
- setReporters(reporters) {
243
- this.options.reporters = Array.isArray(reporters) ? reporters : [reporters];
244
- return this;
245
- }
246
- wrapAll() {
247
- this.wrapConsole();
248
- this.wrapStd();
249
- }
250
- restoreAll() {
251
- this.restoreConsole();
252
- this.restoreStd();
253
- }
254
- wrapConsole() {
255
- for (const type in this.options.types) {
256
- if (!console["__" + type]) {
257
- console["__" + type] = console[type];
258
- }
259
- console[type] = this[type].raw;
260
- }
261
- }
262
- restoreConsole() {
263
- for (const type in this.options.types) {
264
- if (console["__" + type]) {
265
- console[type] = console["__" + type];
266
- delete console["__" + type];
267
- }
268
- }
269
- }
270
- wrapStd() {
271
- this._wrapStream(this.options.stdout, "log");
272
- this._wrapStream(this.options.stderr, "log");
273
- }
274
- _wrapStream(stream, type) {
275
- if (!stream) {
276
- return;
277
- }
278
- if (!stream.__write) {
279
- stream.__write = stream.write;
280
- }
281
- stream.write = (data) => {
282
- this[type].raw(String(data).trim());
283
- };
284
- }
285
- restoreStd() {
286
- this._restoreStream(this.options.stdout);
287
- this._restoreStream(this.options.stderr);
288
- }
289
- _restoreStream(stream) {
290
- if (!stream) {
291
- return;
292
- }
293
- if (stream.__write) {
294
- stream.write = stream.__write;
295
- delete stream.__write;
296
- }
297
- }
298
- pauseLogs() {
299
- paused = true;
300
- }
301
- resumeLogs() {
302
- paused = false;
303
- const _queue = queue.splice(0);
304
- for (const item of _queue) {
305
- item[0]._logFn(item[1], item[2]);
306
- }
307
- }
308
- mockTypes(mockFn) {
309
- const _mockFn = mockFn || this.options.mockFn;
310
- this._mockFn = _mockFn;
311
- if (typeof _mockFn !== "function") {
312
- return;
313
- }
314
- for (const type in this.options.types) {
315
- this[type] = _mockFn(type, this.options.types[type]) || this[type];
316
- this[type].raw = this[type];
317
- }
318
- }
319
- _wrapLogFn(defaults, isRaw) {
320
- return (...args) => {
321
- if (paused) {
322
- queue.push([this, defaults, args, isRaw]);
323
- return;
324
- }
325
- return this._logFn(defaults, args, isRaw);
326
- };
327
- }
328
- _logFn(defaults, args, isRaw) {
329
- if ((defaults.level || 0) > this.level) {
330
- return false;
331
- }
332
- const logObj = {
333
- date: /* @__PURE__ */ new Date(),
334
- args: [],
335
- ...defaults,
336
- level: _normalizeLogLevel(defaults.level, this.options.types)
337
- };
338
- if (!isRaw && args.length === 1 && isLogObj(args[0])) {
339
- Object.assign(logObj, args[0]);
340
- } else {
341
- logObj.args = [...args];
342
- }
343
- if (logObj.message) {
344
- logObj.args.unshift(logObj.message);
345
- delete logObj.message;
346
- }
347
- if (logObj.additional) {
348
- if (!Array.isArray(logObj.additional)) {
349
- logObj.additional = logObj.additional.split("\n");
350
- }
351
- logObj.args.push("\n" + logObj.additional.join("\n"));
352
- delete logObj.additional;
353
- }
354
- logObj.type = typeof logObj.type === "string" ? logObj.type.toLowerCase() : "log";
355
- logObj.tag = typeof logObj.tag === "string" ? logObj.tag : "";
356
- const resolveLog = (newLog = false) => {
357
- const repeated = (this._lastLog.count || 0) - this.options.throttleMin;
358
- if (this._lastLog.object && repeated > 0) {
359
- const args2 = [...this._lastLog.object.args];
360
- if (repeated > 1) {
361
- args2.push(`(repeated ${repeated} times)`);
362
- }
363
- this._log({ ...this._lastLog.object, args: args2 });
364
- this._lastLog.count = 1;
365
- }
366
- if (newLog) {
367
- this._lastLog.object = logObj;
368
- this._log(logObj);
369
- }
370
- };
371
- clearTimeout(this._lastLog.timeout);
372
- const diffTime = this._lastLog.time && logObj.date ? logObj.date.getTime() - this._lastLog.time.getTime() : 0;
373
- this._lastLog.time = logObj.date;
374
- if (diffTime < this.options.throttle) {
375
- try {
376
- const serializedLog = JSON.stringify([
377
- logObj.type,
378
- logObj.tag,
379
- logObj.args
380
- ]);
381
- const isSameLog = this._lastLog.serialized === serializedLog;
382
- this._lastLog.serialized = serializedLog;
383
- if (isSameLog) {
384
- this._lastLog.count = (this._lastLog.count || 0) + 1;
385
- if (this._lastLog.count > this.options.throttleMin) {
386
- this._lastLog.timeout = setTimeout(
387
- resolveLog,
388
- this.options.throttle
389
- );
390
- return;
391
- }
392
- }
393
- } catch {
394
- }
395
- }
396
- resolveLog(true);
397
- }
398
- _log(logObj) {
399
- for (const reporter of this.options.reporters) {
400
- reporter.log(logObj, {
401
- options: this.options
402
- });
403
- }
404
- }
405
- }
406
- function _normalizeLogLevel(input, types = {}, defaultLevel = 3) {
407
- if (input === void 0) {
408
- return defaultLevel;
409
- }
410
- if (typeof input === "number") {
411
- return input;
412
- }
413
- if (types[input] && types[input].level !== void 0) {
414
- return types[input].level;
415
- }
416
- return defaultLevel;
417
- }
418
- Consola.prototype.add = Consola.prototype.addReporter;
419
- Consola.prototype.remove = Consola.prototype.removeReporter;
420
- Consola.prototype.clear = Consola.prototype.removeReporter;
421
- Consola.prototype.withScope = Consola.prototype.withTag;
422
- Consola.prototype.mock = Consola.prototype.mockTypes;
423
- Consola.prototype.pause = Consola.prototype.pauseLogs;
424
- Consola.prototype.resume = Consola.prototype.resumeLogs;
425
- function createConsola$1(options = {}) {
426
- return new Consola(options);
427
- }
428
-
429
- function parseStack(stack) {
430
- const cwd = process.cwd() + node_path.sep;
431
- const lines = stack.split("\n").splice(1).map((l) => l.trim().replace("file://", "").replace(cwd, ""));
432
- return lines;
433
- }
434
-
435
- function writeStream(data, stream) {
436
- const write = stream.__write || stream.write;
437
- return write.call(stream, data);
438
- }
439
-
440
- const bracket = (x) => x ? `[${x}]` : "";
441
- class BasicReporter {
442
- formatStack(stack, opts) {
443
- return " " + parseStack(stack).join("\n ");
444
- }
445
- formatArgs(args, opts) {
446
- const _args = args.map((arg) => {
447
- if (arg && typeof arg.stack === "string") {
448
- return arg.message + "\n" + this.formatStack(arg.stack, opts);
449
- }
450
- return arg;
451
- });
452
- return node_util.formatWithOptions(opts, ..._args);
453
- }
454
- formatDate(date, opts) {
455
- return opts.date ? date.toLocaleTimeString() : "";
456
- }
457
- filterAndJoin(arr) {
458
- return arr.filter(Boolean).join(" ");
459
- }
460
- formatLogObj(logObj, opts) {
461
- const message = this.formatArgs(logObj.args, opts);
462
- if (logObj.type === "box") {
463
- return "\n" + [
464
- bracket(logObj.tag),
465
- logObj.title && logObj.title,
466
- ...message.split("\n")
467
- ].filter(Boolean).map((l) => " > " + l).join("\n") + "\n";
468
- }
469
- return this.filterAndJoin([
470
- bracket(logObj.type),
471
- bracket(logObj.tag),
472
- message
473
- ]);
474
- }
475
- log(logObj, ctx) {
476
- const line = this.formatLogObj(logObj, {
477
- columns: ctx.options.stdout.columns || 0,
478
- ...ctx.options.formatOptions
479
- });
480
- return writeStream(
481
- line + "\n",
482
- logObj.level < 2 ? ctx.options.stderr || process.stderr : ctx.options.stdout || process.stdout
483
- );
484
- }
485
- }
486
-
487
- const {
488
- env = {},
489
- argv = [],
490
- platform = ""
491
- } = typeof process === "undefined" ? {} : process;
492
- const isDisabled = "NO_COLOR" in env || argv.includes("--no-color");
493
- const isForced = "FORCE_COLOR" in env || argv.includes("--color");
494
- const isWindows = platform === "win32";
495
- const isDumbTerminal = env.TERM === "dumb";
496
- const isCompatibleTerminal = tty__namespace && tty__namespace.isatty && tty__namespace.isatty(1) && env.TERM && !isDumbTerminal;
497
- const isCI$1 = "CI" in env && ("GITHUB_ACTIONS" in env || "GITLAB_CI" in env || "CIRCLECI" in env);
498
- const isColorSupported = !isDisabled && (isForced || isWindows && !isDumbTerminal || isCompatibleTerminal || isCI$1);
499
- 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)) {
500
- return head + (next < 0 ? tail : replaceClose(next, tail, close, replace));
501
- }
502
- function clearBleed(index, string, open, close, replace) {
503
- return index < 0 ? open + string + close : open + replaceClose(index, string, close, replace) + close;
504
- }
505
- function filterEmpty(open, close, replace = open, at = open.length + 1) {
506
- return (string) => string || !(string === "" || string === void 0) ? clearBleed(
507
- ("" + string).indexOf(close, at),
508
- string,
509
- open,
510
- close,
511
- replace
512
- ) : "";
513
- }
514
- function init(open, close, replace) {
515
- return filterEmpty(`\x1B[${open}m`, `\x1B[${close}m`, replace);
516
- }
517
- const colorDefs = {
518
- reset: init(0, 0),
519
- bold: init(1, 22, "\x1B[22m\x1B[1m"),
520
- dim: init(2, 22, "\x1B[22m\x1B[2m"),
521
- italic: init(3, 23),
522
- underline: init(4, 24),
523
- inverse: init(7, 27),
524
- hidden: init(8, 28),
525
- strikethrough: init(9, 29),
526
- black: init(30, 39),
527
- red: init(31, 39),
528
- green: init(32, 39),
529
- yellow: init(33, 39),
530
- blue: init(34, 39),
531
- magenta: init(35, 39),
532
- cyan: init(36, 39),
533
- white: init(37, 39),
534
- gray: init(90, 39),
535
- bgBlack: init(40, 49),
536
- bgRed: init(41, 49),
537
- bgGreen: init(42, 49),
538
- bgYellow: init(43, 49),
539
- bgBlue: init(44, 49),
540
- bgMagenta: init(45, 49),
541
- bgCyan: init(46, 49),
542
- bgWhite: init(47, 49),
543
- blackBright: init(90, 39),
544
- redBright: init(91, 39),
545
- greenBright: init(92, 39),
546
- yellowBright: init(93, 39),
547
- blueBright: init(94, 39),
548
- magentaBright: init(95, 39),
549
- cyanBright: init(96, 39),
550
- whiteBright: init(97, 39),
551
- bgBlackBright: init(100, 49),
552
- bgRedBright: init(101, 49),
553
- bgGreenBright: init(102, 49),
554
- bgYellowBright: init(103, 49),
555
- bgBlueBright: init(104, 49),
556
- bgMagentaBright: init(105, 49),
557
- bgCyanBright: init(106, 49),
558
- bgWhiteBright: init(107, 49)
559
- };
560
- function createColors(useColor = isColorSupported) {
561
- return useColor ? colorDefs : Object.fromEntries(Object.keys(colorDefs).map((key) => [key, String]));
562
- }
563
- const colors = createColors();
564
- function getColor$1(color, fallback = "reset") {
565
- return colors[color] || colors[fallback];
566
- }
567
-
568
- const ansiRegex$1 = [
569
- "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
570
- "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"
571
- ].join("|");
572
- function stripAnsi$1(text) {
573
- return text.replace(new RegExp(ansiRegex$1, "g"), "");
574
- }
575
-
576
- const boxStylePresets = {
577
- solid: {
578
- tl: "\u250C",
579
- tr: "\u2510",
580
- bl: "\u2514",
581
- br: "\u2518",
582
- h: "\u2500",
583
- v: "\u2502"
584
- },
585
- double: {
586
- tl: "\u2554",
587
- tr: "\u2557",
588
- bl: "\u255A",
589
- br: "\u255D",
590
- h: "\u2550",
591
- v: "\u2551"
592
- },
593
- doubleSingle: {
594
- tl: "\u2553",
595
- tr: "\u2556",
596
- bl: "\u2559",
597
- br: "\u255C",
598
- h: "\u2500",
599
- v: "\u2551"
600
- },
601
- doubleSingleRounded: {
602
- tl: "\u256D",
603
- tr: "\u256E",
604
- bl: "\u2570",
605
- br: "\u256F",
606
- h: "\u2500",
607
- v: "\u2551"
608
- },
609
- singleThick: {
610
- tl: "\u250F",
611
- tr: "\u2513",
612
- bl: "\u2517",
613
- br: "\u251B",
614
- h: "\u2501",
615
- v: "\u2503"
616
- },
617
- singleDouble: {
618
- tl: "\u2552",
619
- tr: "\u2555",
620
- bl: "\u2558",
621
- br: "\u255B",
622
- h: "\u2550",
623
- v: "\u2502"
624
- },
625
- singleDoubleRounded: {
626
- tl: "\u256D",
627
- tr: "\u256E",
628
- bl: "\u2570",
629
- br: "\u256F",
630
- h: "\u2550",
631
- v: "\u2502"
632
- },
633
- rounded: {
634
- tl: "\u256D",
635
- tr: "\u256E",
636
- bl: "\u2570",
637
- br: "\u256F",
638
- h: "\u2500",
639
- v: "\u2502"
640
- }
641
- };
642
- const defaultStyle = {
643
- borderColor: "white",
644
- borderStyle: "rounded",
645
- valign: "center",
646
- padding: 2,
647
- marginLeft: 1,
648
- marginTop: 1,
649
- marginBottom: 1
650
- };
651
- function box(text, _opts = {}) {
652
- const opts = {
653
- ..._opts,
654
- style: {
655
- ...defaultStyle,
656
- ..._opts.style
657
- }
658
- };
659
- const textLines = text.split("\n");
660
- const boxLines = [];
661
- const _color = getColor$1(opts.style.borderColor);
662
- const borderStyle = {
663
- ...typeof opts.style.borderStyle === "string" ? boxStylePresets[opts.style.borderStyle] || boxStylePresets.solid : opts.style.borderStyle
664
- };
665
- if (_color) {
666
- for (const key in borderStyle) {
667
- borderStyle[key] = _color(
668
- borderStyle[key]
669
- );
670
- }
671
- }
672
- const paddingOffset = opts.style.padding % 2 === 0 ? opts.style.padding : opts.style.padding + 1;
673
- const height = textLines.length + paddingOffset;
674
- const width = Math.max(...textLines.map((line) => line.length)) + paddingOffset;
675
- const widthOffset = width + paddingOffset;
676
- const leftSpace = opts.style.marginLeft > 0 ? " ".repeat(opts.style.marginLeft) : "";
677
- if (opts.style.marginTop > 0) {
678
- boxLines.push("".repeat(opts.style.marginTop));
679
- }
680
- if (opts.title) {
681
- const left = borderStyle.h.repeat(
682
- Math.floor((width - stripAnsi$1(opts.title).length) / 2)
683
- );
684
- const right = borderStyle.h.repeat(
685
- width - stripAnsi$1(opts.title).length - stripAnsi$1(left).length + paddingOffset
686
- );
687
- boxLines.push(
688
- `${leftSpace}${borderStyle.tl}${left}${opts.title}${right}${borderStyle.tr}`
689
- );
690
- } else {
691
- boxLines.push(
692
- `${leftSpace}${borderStyle.tl}${borderStyle.h.repeat(widthOffset)}${borderStyle.tr}`
693
- );
694
- }
695
- const valignOffset = opts.style.valign === "center" ? Math.floor((height - textLines.length) / 2) : opts.style.valign === "top" ? height - textLines.length - paddingOffset : height - textLines.length;
696
- for (let i = 0; i < height; i++) {
697
- if (i < valignOffset || i >= valignOffset + textLines.length) {
698
- boxLines.push(
699
- `${leftSpace}${borderStyle.v}${" ".repeat(widthOffset)}${borderStyle.v}`
700
- );
701
- } else {
702
- const line = textLines[i - valignOffset];
703
- const left = " ".repeat(paddingOffset);
704
- const right = " ".repeat(width - stripAnsi$1(line).length);
705
- boxLines.push(
706
- `${leftSpace}${borderStyle.v}${left}${line}${right}${borderStyle.v}`
707
- );
708
- }
709
- }
710
- boxLines.push(
711
- `${leftSpace}${borderStyle.bl}${borderStyle.h.repeat(widthOffset)}${borderStyle.br}`
712
- );
713
- if (opts.style.marginBottom > 0) {
714
- boxLines.push("".repeat(opts.style.marginBottom));
715
- }
716
- return boxLines.join("\n");
717
- }
718
-
719
- const providers = [
720
- ["APPVEYOR"],
721
- ["AZURE_PIPELINES", "SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"],
722
- ["AZURE_STATIC", "INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN"],
723
- ["APPCIRCLE", "AC_APPCIRCLE"],
724
- ["BAMBOO", "bamboo_planKey"],
725
- ["BITBUCKET", "BITBUCKET_COMMIT"],
726
- ["BITRISE", "BITRISE_IO"],
727
- ["BUDDY", "BUDDY_WORKSPACE_ID"],
728
- ["BUILDKITE"],
729
- ["CIRCLE", "CIRCLECI"],
730
- ["CIRRUS", "CIRRUS_CI"],
731
- ["CLOUDFLARE_PAGES", "CF_PAGES", { ci: true }],
732
- ["CODEBUILD", "CODEBUILD_BUILD_ARN"],
733
- ["CODEFRESH", "CF_BUILD_ID"],
734
- ["DRONE"],
735
- ["DRONE", "DRONE_BUILD_EVENT"],
736
- ["DSARI"],
737
- ["GITHUB_ACTIONS"],
738
- ["GITLAB", "GITLAB_CI"],
739
- ["GITLAB", "CI_MERGE_REQUEST_ID"],
740
- ["GOCD", "GO_PIPELINE_LABEL"],
741
- ["LAYERCI"],
742
- ["HUDSON", "HUDSON_URL"],
743
- ["JENKINS", "JENKINS_URL"],
744
- ["MAGNUM"],
745
- ["NETLIFY"],
746
- ["NETLIFY", "NETLIFY_LOCAL", { ci: false }],
747
- ["NEVERCODE"],
748
- ["RENDER"],
749
- ["SAIL", "SAILCI"],
750
- ["SEMAPHORE"],
751
- ["SCREWDRIVER"],
752
- ["SHIPPABLE"],
753
- ["SOLANO", "TDDIUM"],
754
- ["STRIDER"],
755
- ["TEAMCITY", "TEAMCITY_VERSION"],
756
- ["TRAVIS"],
757
- ["VERCEL", "NOW_BUILDER"],
758
- ["APPCENTER", "APPCENTER_BUILD_ID"],
759
- ["CODESANDBOX", "CODESANDBOX_SSE", { ci: false }],
760
- ["STACKBLITZ"],
761
- ["STORMKIT"],
762
- ["CLEAVR"]
763
- ];
764
- function detectProvider(env) {
765
- for (const provider of providers) {
766
- const envName = provider[1] || provider[0];
767
- if (env[envName]) {
768
- return {
769
- name: provider[0].toLowerCase(),
770
- ...provider[2]
771
- };
772
- }
773
- }
774
- if (env.SHELL && env.SHELL === "/bin/jsh") {
775
- return {
776
- name: "stackblitz",
777
- ci: false
778
- };
779
- }
780
- return {
781
- name: "",
782
- ci: false
783
- };
784
- }
785
-
786
- const processShim = typeof process !== "undefined" ? process : {};
787
- const envShim = processShim.env || {};
788
- const providerInfo = detectProvider(envShim);
789
- const nodeENV = typeof process !== "undefined" && process.env && process.env.NODE_ENV || "";
790
- processShim.platform;
791
- providerInfo.name;
792
- const isCI = toBoolean(envShim.CI) || providerInfo.ci !== false;
793
- const hasTTY = toBoolean(processShim.stdout && processShim.stdout.isTTY);
794
- const isDebug = toBoolean(envShim.DEBUG);
795
- const isTest = nodeENV === "test" || toBoolean(envShim.TEST);
796
- toBoolean(envShim.MINIMAL) || isCI || isTest || !hasTTY;
797
- function toBoolean(val) {
798
- return val ? val !== "false" : false;
799
- }
800
-
801
- function ansiRegex({onlyFirst = false} = {}) {
802
- const pattern = [
803
- '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)',
804
- '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'
805
- ].join('|');
806
-
807
- return new RegExp(pattern, onlyFirst ? undefined : 'g');
808
- }
809
-
810
- const regex = ansiRegex();
811
-
812
- function stripAnsi(string) {
813
- if (typeof string !== 'string') {
814
- throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
815
- }
816
-
817
- // Even though the regex is global, we don't need to reset the `.lastIndex`
818
- // because unlike `.exec()` and `.test()`, `.replace()` does it automatically
819
- // and doing it manually has a performance penalty.
820
- return string.replace(regex, '');
821
- }
822
-
823
- function getDefaultExportFromCjs (x) {
824
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
825
- }
826
-
827
- var eastasianwidth = {exports: {}};
828
-
829
- (function (module) {
830
- var eaw = {};
831
-
832
- {
833
- module.exports = eaw;
834
- }
835
-
836
- eaw.eastAsianWidth = function(character) {
837
- var x = character.charCodeAt(0);
838
- var y = (character.length == 2) ? character.charCodeAt(1) : 0;
839
- var codePoint = x;
840
- if ((0xD800 <= x && x <= 0xDBFF) && (0xDC00 <= y && y <= 0xDFFF)) {
841
- x &= 0x3FF;
842
- y &= 0x3FF;
843
- codePoint = (x << 10) | y;
844
- codePoint += 0x10000;
845
- }
846
-
847
- if ((0x3000 == codePoint) ||
848
- (0xFF01 <= codePoint && codePoint <= 0xFF60) ||
849
- (0xFFE0 <= codePoint && codePoint <= 0xFFE6)) {
850
- return 'F';
851
- }
852
- if ((0x20A9 == codePoint) ||
853
- (0xFF61 <= codePoint && codePoint <= 0xFFBE) ||
854
- (0xFFC2 <= codePoint && codePoint <= 0xFFC7) ||
855
- (0xFFCA <= codePoint && codePoint <= 0xFFCF) ||
856
- (0xFFD2 <= codePoint && codePoint <= 0xFFD7) ||
857
- (0xFFDA <= codePoint && codePoint <= 0xFFDC) ||
858
- (0xFFE8 <= codePoint && codePoint <= 0xFFEE)) {
859
- return 'H';
860
- }
861
- if ((0x1100 <= codePoint && codePoint <= 0x115F) ||
862
- (0x11A3 <= codePoint && codePoint <= 0x11A7) ||
863
- (0x11FA <= codePoint && codePoint <= 0x11FF) ||
864
- (0x2329 <= codePoint && codePoint <= 0x232A) ||
865
- (0x2E80 <= codePoint && codePoint <= 0x2E99) ||
866
- (0x2E9B <= codePoint && codePoint <= 0x2EF3) ||
867
- (0x2F00 <= codePoint && codePoint <= 0x2FD5) ||
868
- (0x2FF0 <= codePoint && codePoint <= 0x2FFB) ||
869
- (0x3001 <= codePoint && codePoint <= 0x303E) ||
870
- (0x3041 <= codePoint && codePoint <= 0x3096) ||
871
- (0x3099 <= codePoint && codePoint <= 0x30FF) ||
872
- (0x3105 <= codePoint && codePoint <= 0x312D) ||
873
- (0x3131 <= codePoint && codePoint <= 0x318E) ||
874
- (0x3190 <= codePoint && codePoint <= 0x31BA) ||
875
- (0x31C0 <= codePoint && codePoint <= 0x31E3) ||
876
- (0x31F0 <= codePoint && codePoint <= 0x321E) ||
877
- (0x3220 <= codePoint && codePoint <= 0x3247) ||
878
- (0x3250 <= codePoint && codePoint <= 0x32FE) ||
879
- (0x3300 <= codePoint && codePoint <= 0x4DBF) ||
880
- (0x4E00 <= codePoint && codePoint <= 0xA48C) ||
881
- (0xA490 <= codePoint && codePoint <= 0xA4C6) ||
882
- (0xA960 <= codePoint && codePoint <= 0xA97C) ||
883
- (0xAC00 <= codePoint && codePoint <= 0xD7A3) ||
884
- (0xD7B0 <= codePoint && codePoint <= 0xD7C6) ||
885
- (0xD7CB <= codePoint && codePoint <= 0xD7FB) ||
886
- (0xF900 <= codePoint && codePoint <= 0xFAFF) ||
887
- (0xFE10 <= codePoint && codePoint <= 0xFE19) ||
888
- (0xFE30 <= codePoint && codePoint <= 0xFE52) ||
889
- (0xFE54 <= codePoint && codePoint <= 0xFE66) ||
890
- (0xFE68 <= codePoint && codePoint <= 0xFE6B) ||
891
- (0x1B000 <= codePoint && codePoint <= 0x1B001) ||
892
- (0x1F200 <= codePoint && codePoint <= 0x1F202) ||
893
- (0x1F210 <= codePoint && codePoint <= 0x1F23A) ||
894
- (0x1F240 <= codePoint && codePoint <= 0x1F248) ||
895
- (0x1F250 <= codePoint && codePoint <= 0x1F251) ||
896
- (0x20000 <= codePoint && codePoint <= 0x2F73F) ||
897
- (0x2B740 <= codePoint && codePoint <= 0x2FFFD) ||
898
- (0x30000 <= codePoint && codePoint <= 0x3FFFD)) {
899
- return 'W';
900
- }
901
- if ((0x0020 <= codePoint && codePoint <= 0x007E) ||
902
- (0x00A2 <= codePoint && codePoint <= 0x00A3) ||
903
- (0x00A5 <= codePoint && codePoint <= 0x00A6) ||
904
- (0x00AC == codePoint) ||
905
- (0x00AF == codePoint) ||
906
- (0x27E6 <= codePoint && codePoint <= 0x27ED) ||
907
- (0x2985 <= codePoint && codePoint <= 0x2986)) {
908
- return 'Na';
909
- }
910
- if ((0x00A1 == codePoint) ||
911
- (0x00A4 == codePoint) ||
912
- (0x00A7 <= codePoint && codePoint <= 0x00A8) ||
913
- (0x00AA == codePoint) ||
914
- (0x00AD <= codePoint && codePoint <= 0x00AE) ||
915
- (0x00B0 <= codePoint && codePoint <= 0x00B4) ||
916
- (0x00B6 <= codePoint && codePoint <= 0x00BA) ||
917
- (0x00BC <= codePoint && codePoint <= 0x00BF) ||
918
- (0x00C6 == codePoint) ||
919
- (0x00D0 == codePoint) ||
920
- (0x00D7 <= codePoint && codePoint <= 0x00D8) ||
921
- (0x00DE <= codePoint && codePoint <= 0x00E1) ||
922
- (0x00E6 == codePoint) ||
923
- (0x00E8 <= codePoint && codePoint <= 0x00EA) ||
924
- (0x00EC <= codePoint && codePoint <= 0x00ED) ||
925
- (0x00F0 == codePoint) ||
926
- (0x00F2 <= codePoint && codePoint <= 0x00F3) ||
927
- (0x00F7 <= codePoint && codePoint <= 0x00FA) ||
928
- (0x00FC == codePoint) ||
929
- (0x00FE == codePoint) ||
930
- (0x0101 == codePoint) ||
931
- (0x0111 == codePoint) ||
932
- (0x0113 == codePoint) ||
933
- (0x011B == codePoint) ||
934
- (0x0126 <= codePoint && codePoint <= 0x0127) ||
935
- (0x012B == codePoint) ||
936
- (0x0131 <= codePoint && codePoint <= 0x0133) ||
937
- (0x0138 == codePoint) ||
938
- (0x013F <= codePoint && codePoint <= 0x0142) ||
939
- (0x0144 == codePoint) ||
940
- (0x0148 <= codePoint && codePoint <= 0x014B) ||
941
- (0x014D == codePoint) ||
942
- (0x0152 <= codePoint && codePoint <= 0x0153) ||
943
- (0x0166 <= codePoint && codePoint <= 0x0167) ||
944
- (0x016B == codePoint) ||
945
- (0x01CE == codePoint) ||
946
- (0x01D0 == codePoint) ||
947
- (0x01D2 == codePoint) ||
948
- (0x01D4 == codePoint) ||
949
- (0x01D6 == codePoint) ||
950
- (0x01D8 == codePoint) ||
951
- (0x01DA == codePoint) ||
952
- (0x01DC == codePoint) ||
953
- (0x0251 == codePoint) ||
954
- (0x0261 == codePoint) ||
955
- (0x02C4 == codePoint) ||
956
- (0x02C7 == codePoint) ||
957
- (0x02C9 <= codePoint && codePoint <= 0x02CB) ||
958
- (0x02CD == codePoint) ||
959
- (0x02D0 == codePoint) ||
960
- (0x02D8 <= codePoint && codePoint <= 0x02DB) ||
961
- (0x02DD == codePoint) ||
962
- (0x02DF == codePoint) ||
963
- (0x0300 <= codePoint && codePoint <= 0x036F) ||
964
- (0x0391 <= codePoint && codePoint <= 0x03A1) ||
965
- (0x03A3 <= codePoint && codePoint <= 0x03A9) ||
966
- (0x03B1 <= codePoint && codePoint <= 0x03C1) ||
967
- (0x03C3 <= codePoint && codePoint <= 0x03C9) ||
968
- (0x0401 == codePoint) ||
969
- (0x0410 <= codePoint && codePoint <= 0x044F) ||
970
- (0x0451 == codePoint) ||
971
- (0x2010 == codePoint) ||
972
- (0x2013 <= codePoint && codePoint <= 0x2016) ||
973
- (0x2018 <= codePoint && codePoint <= 0x2019) ||
974
- (0x201C <= codePoint && codePoint <= 0x201D) ||
975
- (0x2020 <= codePoint && codePoint <= 0x2022) ||
976
- (0x2024 <= codePoint && codePoint <= 0x2027) ||
977
- (0x2030 == codePoint) ||
978
- (0x2032 <= codePoint && codePoint <= 0x2033) ||
979
- (0x2035 == codePoint) ||
980
- (0x203B == codePoint) ||
981
- (0x203E == codePoint) ||
982
- (0x2074 == codePoint) ||
983
- (0x207F == codePoint) ||
984
- (0x2081 <= codePoint && codePoint <= 0x2084) ||
985
- (0x20AC == codePoint) ||
986
- (0x2103 == codePoint) ||
987
- (0x2105 == codePoint) ||
988
- (0x2109 == codePoint) ||
989
- (0x2113 == codePoint) ||
990
- (0x2116 == codePoint) ||
991
- (0x2121 <= codePoint && codePoint <= 0x2122) ||
992
- (0x2126 == codePoint) ||
993
- (0x212B == codePoint) ||
994
- (0x2153 <= codePoint && codePoint <= 0x2154) ||
995
- (0x215B <= codePoint && codePoint <= 0x215E) ||
996
- (0x2160 <= codePoint && codePoint <= 0x216B) ||
997
- (0x2170 <= codePoint && codePoint <= 0x2179) ||
998
- (0x2189 == codePoint) ||
999
- (0x2190 <= codePoint && codePoint <= 0x2199) ||
1000
- (0x21B8 <= codePoint && codePoint <= 0x21B9) ||
1001
- (0x21D2 == codePoint) ||
1002
- (0x21D4 == codePoint) ||
1003
- (0x21E7 == codePoint) ||
1004
- (0x2200 == codePoint) ||
1005
- (0x2202 <= codePoint && codePoint <= 0x2203) ||
1006
- (0x2207 <= codePoint && codePoint <= 0x2208) ||
1007
- (0x220B == codePoint) ||
1008
- (0x220F == codePoint) ||
1009
- (0x2211 == codePoint) ||
1010
- (0x2215 == codePoint) ||
1011
- (0x221A == codePoint) ||
1012
- (0x221D <= codePoint && codePoint <= 0x2220) ||
1013
- (0x2223 == codePoint) ||
1014
- (0x2225 == codePoint) ||
1015
- (0x2227 <= codePoint && codePoint <= 0x222C) ||
1016
- (0x222E == codePoint) ||
1017
- (0x2234 <= codePoint && codePoint <= 0x2237) ||
1018
- (0x223C <= codePoint && codePoint <= 0x223D) ||
1019
- (0x2248 == codePoint) ||
1020
- (0x224C == codePoint) ||
1021
- (0x2252 == codePoint) ||
1022
- (0x2260 <= codePoint && codePoint <= 0x2261) ||
1023
- (0x2264 <= codePoint && codePoint <= 0x2267) ||
1024
- (0x226A <= codePoint && codePoint <= 0x226B) ||
1025
- (0x226E <= codePoint && codePoint <= 0x226F) ||
1026
- (0x2282 <= codePoint && codePoint <= 0x2283) ||
1027
- (0x2286 <= codePoint && codePoint <= 0x2287) ||
1028
- (0x2295 == codePoint) ||
1029
- (0x2299 == codePoint) ||
1030
- (0x22A5 == codePoint) ||
1031
- (0x22BF == codePoint) ||
1032
- (0x2312 == codePoint) ||
1033
- (0x2460 <= codePoint && codePoint <= 0x24E9) ||
1034
- (0x24EB <= codePoint && codePoint <= 0x254B) ||
1035
- (0x2550 <= codePoint && codePoint <= 0x2573) ||
1036
- (0x2580 <= codePoint && codePoint <= 0x258F) ||
1037
- (0x2592 <= codePoint && codePoint <= 0x2595) ||
1038
- (0x25A0 <= codePoint && codePoint <= 0x25A1) ||
1039
- (0x25A3 <= codePoint && codePoint <= 0x25A9) ||
1040
- (0x25B2 <= codePoint && codePoint <= 0x25B3) ||
1041
- (0x25B6 <= codePoint && codePoint <= 0x25B7) ||
1042
- (0x25BC <= codePoint && codePoint <= 0x25BD) ||
1043
- (0x25C0 <= codePoint && codePoint <= 0x25C1) ||
1044
- (0x25C6 <= codePoint && codePoint <= 0x25C8) ||
1045
- (0x25CB == codePoint) ||
1046
- (0x25CE <= codePoint && codePoint <= 0x25D1) ||
1047
- (0x25E2 <= codePoint && codePoint <= 0x25E5) ||
1048
- (0x25EF == codePoint) ||
1049
- (0x2605 <= codePoint && codePoint <= 0x2606) ||
1050
- (0x2609 == codePoint) ||
1051
- (0x260E <= codePoint && codePoint <= 0x260F) ||
1052
- (0x2614 <= codePoint && codePoint <= 0x2615) ||
1053
- (0x261C == codePoint) ||
1054
- (0x261E == codePoint) ||
1055
- (0x2640 == codePoint) ||
1056
- (0x2642 == codePoint) ||
1057
- (0x2660 <= codePoint && codePoint <= 0x2661) ||
1058
- (0x2663 <= codePoint && codePoint <= 0x2665) ||
1059
- (0x2667 <= codePoint && codePoint <= 0x266A) ||
1060
- (0x266C <= codePoint && codePoint <= 0x266D) ||
1061
- (0x266F == codePoint) ||
1062
- (0x269E <= codePoint && codePoint <= 0x269F) ||
1063
- (0x26BE <= codePoint && codePoint <= 0x26BF) ||
1064
- (0x26C4 <= codePoint && codePoint <= 0x26CD) ||
1065
- (0x26CF <= codePoint && codePoint <= 0x26E1) ||
1066
- (0x26E3 == codePoint) ||
1067
- (0x26E8 <= codePoint && codePoint <= 0x26FF) ||
1068
- (0x273D == codePoint) ||
1069
- (0x2757 == codePoint) ||
1070
- (0x2776 <= codePoint && codePoint <= 0x277F) ||
1071
- (0x2B55 <= codePoint && codePoint <= 0x2B59) ||
1072
- (0x3248 <= codePoint && codePoint <= 0x324F) ||
1073
- (0xE000 <= codePoint && codePoint <= 0xF8FF) ||
1074
- (0xFE00 <= codePoint && codePoint <= 0xFE0F) ||
1075
- (0xFFFD == codePoint) ||
1076
- (0x1F100 <= codePoint && codePoint <= 0x1F10A) ||
1077
- (0x1F110 <= codePoint && codePoint <= 0x1F12D) ||
1078
- (0x1F130 <= codePoint && codePoint <= 0x1F169) ||
1079
- (0x1F170 <= codePoint && codePoint <= 0x1F19A) ||
1080
- (0xE0100 <= codePoint && codePoint <= 0xE01EF) ||
1081
- (0xF0000 <= codePoint && codePoint <= 0xFFFFD) ||
1082
- (0x100000 <= codePoint && codePoint <= 0x10FFFD)) {
1083
- return 'A';
1084
- }
1085
-
1086
- return 'N';
1087
- };
1088
-
1089
- eaw.characterLength = function(character) {
1090
- var code = this.eastAsianWidth(character);
1091
- if (code == 'F' || code == 'W' || code == 'A') {
1092
- return 2;
1093
- } else {
1094
- return 1;
1095
- }
1096
- };
1097
-
1098
- // Split a string considering surrogate-pairs.
1099
- function stringToArray(string) {
1100
- return string.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g) || [];
1101
- }
1102
-
1103
- eaw.length = function(string) {
1104
- var characters = stringToArray(string);
1105
- var len = 0;
1106
- for (var i = 0; i < characters.length; i++) {
1107
- len = len + this.characterLength(characters[i]);
1108
- }
1109
- return len;
1110
- };
1111
-
1112
- eaw.slice = function(text, start, end) {
1113
- textLen = eaw.length(text);
1114
- start = start ? start : 0;
1115
- end = end ? end : 1;
1116
- if (start < 0) {
1117
- start = textLen + start;
1118
- }
1119
- if (end < 0) {
1120
- end = textLen + end;
1121
- }
1122
- var result = '';
1123
- var eawLen = 0;
1124
- var chars = stringToArray(text);
1125
- for (var i = 0; i < chars.length; i++) {
1126
- var char = chars[i];
1127
- var charLen = eaw.length(char);
1128
- if (eawLen >= start - (charLen == 2 ? 1 : 0)) {
1129
- if (eawLen + charLen <= end) {
1130
- result += char;
1131
- } else {
1132
- break;
1133
- }
1134
- }
1135
- eawLen += charLen;
1136
- }
1137
- return result;
1138
- };
1139
- } (eastasianwidth));
1140
-
1141
- var eastasianwidthExports = eastasianwidth.exports;
1142
- const eastAsianWidth = /*@__PURE__*/getDefaultExportFromCjs(eastasianwidthExports);
1143
-
1144
- const emojiRegex = () => {
1145
- // https://mths.be/emoji
1146
- 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\u26D3\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](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?|[\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]|\u26F9(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\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])?|[\uDFC3\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\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-\uDDF5\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]|\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(?:[\uDC08\uDC26](?:\u200D\u2B1B)?|[\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-\uDEB6](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?|[\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-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC15(?:\u200D\uD83E\uDDBA)?|\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-\uDDB3\uDDBC\uDDBD])|\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-\uDDB3\uDDBC\uDDBD]|\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-\uDDB3\uDDBC\uDDBD]|\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-\uDDB3\uDDBC\uDDBD]|\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-\uDDB3\uDDBC\uDDBD]|\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-\uDDB3\uDDBC\uDDBD]|\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-\uDDB3\uDDBC\uDDBD])|\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-\uDDB3\uDDBC\uDDBD]|\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-\uDDB3\uDDBC\uDDBD]|\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-\uDDB3\uDDBC\uDDBD]|\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-\uDDB3\uDDBC\uDDBD]|\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-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE])))?))?|\uDC6F(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDD75(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\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-\uDE88\uDE90-\uDEBD\uDEBF-\uDEC2\uDECE-\uDEDB\uDEE0-\uDEE8]|\uDD3C(?:\u200D[\u2640\u2642]\uFE0F?|\uD83C[\uDFFB-\uDFFF])?|\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-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1))|\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-\uDDB3\uDDBC\uDDBD]|\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-\uDDB3\uDDBC\uDDBD]|\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-\uDDB3\uDDBC\uDDBD]|\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-\uDDB3\uDDBC\uDDBD]|\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-\uDDB3\uDDBC\uDDBD]|\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;
1147
- };
1148
-
1149
- function stringWidth$1(string, options) {
1150
- if (typeof string !== 'string' || string.length === 0) {
1151
- return 0;
1152
- }
1153
-
1154
- options = {
1155
- ambiguousIsNarrow: true,
1156
- countAnsiEscapeCodes: false,
1157
- ...options,
1158
- };
1159
-
1160
- if (!options.countAnsiEscapeCodes) {
1161
- string = stripAnsi(string);
1162
- }
1163
-
1164
- if (string.length === 0) {
1165
- return 0;
1166
- }
1167
-
1168
- const ambiguousCharacterWidth = options.ambiguousIsNarrow ? 1 : 2;
1169
- let width = 0;
1170
-
1171
- for (const {segment: character} of new Intl.Segmenter().segment(string)) {
1172
- const codePoint = character.codePointAt(0);
1173
-
1174
- // Ignore control characters
1175
- if (codePoint <= 0x1F || (codePoint >= 0x7F && codePoint <= 0x9F)) {
1176
- continue;
1177
- }
1178
-
1179
- // Ignore combining characters
1180
- if (codePoint >= 0x3_00 && codePoint <= 0x3_6F) {
1181
- continue;
1182
- }
1183
-
1184
- if (emojiRegex().test(character)) {
1185
- width += 2;
1186
- continue;
1187
- }
1188
-
1189
- const code = eastAsianWidth.eastAsianWidth(character);
1190
- switch (code) {
1191
- case 'F':
1192
- case 'W': {
1193
- width += 2;
1194
- break;
1195
- }
1196
-
1197
- case 'A': {
1198
- width += ambiguousCharacterWidth;
1199
- break;
1200
- }
1201
-
1202
- default: {
1203
- width += 1;
1204
- }
1205
- }
1206
- }
1207
-
1208
- return width;
1209
- }
1210
-
1211
- function isUnicodeSupported() {
1212
- if (process$1__default.platform !== 'win32') {
1213
- return process$1__default.env.TERM !== 'linux'; // Linux console (kernel)
1214
- }
1215
-
1216
- return Boolean(process$1__default.env.CI)
1217
- || Boolean(process$1__default.env.WT_SESSION) // Windows Terminal
1218
- || Boolean(process$1__default.env.TERMINUS_SUBLIME) // Terminus (<0.2.27)
1219
- || process$1__default.env.ConEmuTask === '{cmd::Cmder}' // ConEmu and cmder
1220
- || process$1__default.env.TERM_PROGRAM === 'Terminus-Sublime'
1221
- || process$1__default.env.TERM_PROGRAM === 'vscode'
1222
- || process$1__default.env.TERM === 'xterm-256color'
1223
- || process$1__default.env.TERM === 'alacritty'
1224
- || process$1__default.env.TERMINAL_EMULATOR === 'JetBrains-JediTerm';
1225
- }
1226
-
1227
- const TYPE_COLOR_MAP = {
1228
- info: "cyan",
1229
- fail: "red",
1230
- success: "green",
1231
- ready: "green",
1232
- start: "magenta"
1233
- };
1234
- const LEVEL_COLOR_MAP = {
1235
- 0: "red",
1236
- 1: "yellow"
1237
- };
1238
- const unicode = isUnicodeSupported();
1239
- const s = (c, fallback) => unicode ? c : fallback;
1240
- const TYPE_ICONS = {
1241
- error: s("\u2716", "\xD7"),
1242
- fatal: s("\u2716", "\xD7"),
1243
- ready: s("\u2714", "\u221A"),
1244
- warn: s("\u26A0", "\u203C"),
1245
- info: s("\u2139", "i"),
1246
- success: s("\u2714", "\u221A"),
1247
- debug: s("\u2699", "D"),
1248
- trace: s("\u2192", "\u2192"),
1249
- fail: s("\u2716", "\xD7"),
1250
- start: s("\u25D0", "o"),
1251
- log: ""
1252
- };
1253
- function stringWidth(str) {
1254
- if (!Intl.Segmenter) {
1255
- return stripAnsi$1(str).length;
1256
- }
1257
- return stringWidth$1(str);
1258
- }
1259
- class FancyReporter extends BasicReporter {
1260
- formatStack(stack) {
1261
- return "\n" + parseStack(stack).map(
1262
- (line) => " " + line.replace(/^at +/, (m) => colors.gray(m)).replace(/\((.+)\)/, (_, m) => `(${colors.cyan(m)})`)
1263
- ).join("\n");
1264
- }
1265
- formatType(logObj, isBadge, opts) {
1266
- const typeColor = TYPE_COLOR_MAP[logObj.type] || LEVEL_COLOR_MAP[logObj.level] || "gray";
1267
- if (isBadge) {
1268
- return getBgColor(typeColor)(
1269
- colors.black(` ${logObj.type.toUpperCase()} `)
1270
- );
1271
- }
1272
- const _type = typeof TYPE_ICONS[logObj.type] === "string" ? TYPE_ICONS[logObj.type] : logObj.icon || logObj.type;
1273
- return _type ? getColor(typeColor)(_type) : "";
1274
- }
1275
- formatLogObj(logObj, opts) {
1276
- const [message, ...additional] = this.formatArgs(logObj.args, opts).split(
1277
- "\n"
1278
- );
1279
- if (logObj.type === "box") {
1280
- return box(
1281
- characterFormat(
1282
- message + (additional.length > 0 ? "\n" + additional.join("\n") : "")
1283
- ),
1284
- {
1285
- title: logObj.title ? characterFormat(logObj.title) : void 0,
1286
- style: logObj.style
1287
- }
1288
- );
1289
- }
1290
- const date = this.formatDate(logObj.date, opts);
1291
- const coloredDate = date && colors.gray(date);
1292
- const isBadge = logObj.badge ?? logObj.level < 2;
1293
- const type = this.formatType(logObj, isBadge, opts);
1294
- const tag = logObj.tag ? colors.gray(logObj.tag) : "";
1295
- let line;
1296
- const left = this.filterAndJoin([type, characterFormat(message)]);
1297
- const right = this.filterAndJoin(opts.columns ? [tag, coloredDate] : [tag]);
1298
- const space = (opts.columns || 0) - stringWidth(left) - stringWidth(right) - 2;
1299
- line = space > 0 && (opts.columns || 0) >= 80 ? left + " ".repeat(space) + right : (right ? `${colors.gray(`[${right}]`)} ` : "") + left;
1300
- line += characterFormat(
1301
- additional.length > 0 ? "\n" + additional.join("\n") : ""
1302
- );
1303
- if (logObj.type === "trace") {
1304
- const _err = new Error("Trace: " + logObj.message);
1305
- line += this.formatStack(_err.stack || "");
1306
- }
1307
- return isBadge ? "\n" + line + "\n" : line;
1308
- }
1309
- }
1310
- function characterFormat(str) {
1311
- return str.replace(/`([^`]+)`/gm, (_, m) => colors.cyan(m)).replace(/\s+_([^_]+)_\s+/gm, (_, m) => ` ${colors.underline(m)} `);
1312
- }
1313
- function getColor(color = "white") {
1314
- return colors[color] || colors.white;
1315
- }
1316
- function getBgColor(color = "bgWhite") {
1317
- return colors[`bg${color[0].toUpperCase()}${color.slice(1)}`] || colors.bgWhite;
1318
- }
1319
-
1320
- function createConsola(options = {}) {
1321
- let level = _getDefaultLogLevel$1();
1322
- if (process.env.CONSOLA_LEVEL) {
1323
- level = Number.parseInt(process.env.CONSOLA_LEVEL) ?? level;
1324
- }
1325
- const consola2 = createConsola$1({
1326
- level,
1327
- defaults: { level },
1328
- stdout: process.stdout,
1329
- stderr: process.stderr,
1330
- prompt: (...args) => import('../chunks/prompt.cjs').then((m) => m.prompt(...args)),
1331
- reporters: options.reporters || [
1332
- options.fancy ?? !(isCI || isTest) ? new FancyReporter() : new BasicReporter()
1333
- ],
1334
- ...options
1335
- });
1336
- return consola2;
1337
- }
1338
- function _getDefaultLogLevel$1() {
1339
- if (isDebug) {
1340
- return LogLevels.debug;
1341
- }
1342
- if (isTest) {
1343
- return LogLevels.warn;
1344
- }
1345
- return LogLevels.info;
1346
- }
1347
- createConsola();
1348
-
1349
- function _getDefaultLogLevel() {
1350
- return LogLevels.debug;
1351
- }
1352
- const level = _getDefaultLogLevel();
1353
- const consola = createConsola({
1354
- level,
1355
- defaults: {
1356
- level
1357
- },
1358
- formatOptions: {
1359
- colors: true,
1360
- compact: false,
1361
- date: false
1362
- }
1363
- });
1364
-
1365
- exports.LogLevels = LogLevels;
1366
- exports.colors = colors;
1367
- exports.consola = consola;
1368
- exports.getDefaultExportFromCjs = getDefaultExportFromCjs;
1369
- exports.isUnicodeSupported = isUnicodeSupported;