@kubb/core 3.16.2 → 3.16.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.
Files changed (106) hide show
  1. package/dist/FileManager-Dk759iZ3.js +918 -0
  2. package/dist/FileManager-Dk759iZ3.js.map +1 -0
  3. package/dist/FileManager-DsRjYJa_.cjs +1031 -0
  4. package/dist/FileManager-DsRjYJa_.cjs.map +1 -0
  5. package/dist/PluginManager-1jPxuyQK.d.ts +511 -0
  6. package/dist/PluginManager-Cvj5AlsU.d.cts +511 -0
  7. package/dist/chunk-DWy1uDak.cjs +39 -0
  8. package/dist/chunk-DbvY3SJr.js +33 -0
  9. package/dist/fs-BacxV1CO.js +87 -0
  10. package/dist/fs-BacxV1CO.js.map +1 -0
  11. package/dist/fs-BazSaf2y.cjs +129 -0
  12. package/dist/fs-BazSaf2y.cjs.map +1 -0
  13. package/dist/fs.cjs +15 -39
  14. package/dist/fs.d.cts +2 -19
  15. package/dist/fs.d.ts +2 -19
  16. package/dist/fs.js +4 -3
  17. package/dist/index-BKHQGQVq.d.ts +140 -0
  18. package/dist/index-BfD6z1P5.d.cts +141 -0
  19. package/dist/index-Cb4pChs8.d.ts +180 -0
  20. package/dist/index-D2ptHzfn.d.cts +180 -0
  21. package/dist/index.cjs +997 -1077
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.d.cts +107 -89
  24. package/dist/index.d.ts +107 -89
  25. package/dist/index.js +1020 -864
  26. package/dist/index.js.map +1 -1
  27. package/dist/logger-BxvJpQMX.cjs +1115 -0
  28. package/dist/logger-BxvJpQMX.cjs.map +1 -0
  29. package/dist/logger-Cs45J4yy.js +1085 -0
  30. package/dist/logger-Cs45J4yy.js.map +1 -0
  31. package/dist/logger-OWS6fqk0.d.cts +69 -0
  32. package/dist/logger-xcdTETKy.d.ts +69 -0
  33. package/dist/logger.cjs +6 -24
  34. package/dist/logger.d.cts +2 -3
  35. package/dist/logger.d.ts +2 -3
  36. package/dist/logger.js +4 -4
  37. package/dist/mocks.cjs +49 -65
  38. package/dist/mocks.cjs.map +1 -1
  39. package/dist/mocks.d.cts +6 -6
  40. package/dist/mocks.d.ts +6 -6
  41. package/dist/mocks.js +48 -59
  42. package/dist/mocks.js.map +1 -1
  43. package/dist/prompt-DwEAzq0q.js +853 -0
  44. package/dist/prompt-DwEAzq0q.js.map +1 -0
  45. package/dist/prompt-qiwl6Be9.cjs +855 -0
  46. package/dist/prompt-qiwl6Be9.cjs.map +1 -0
  47. package/dist/transformers-B3CHtwuB.cjs +948 -0
  48. package/dist/transformers-B3CHtwuB.cjs.map +1 -0
  49. package/dist/transformers-CJqBQFIl.js +829 -0
  50. package/dist/transformers-CJqBQFIl.js.map +1 -0
  51. package/dist/transformers.cjs +33 -88
  52. package/dist/transformers.d.cts +75 -54
  53. package/dist/transformers.d.ts +75 -54
  54. package/dist/transformers.js +4 -3
  55. package/dist/utils.cjs +20 -73
  56. package/dist/utils.d.cts +5 -126
  57. package/dist/utils.d.ts +5 -126
  58. package/dist/utils.js +6 -5
  59. package/dist/write-CLTPlucv.js +42 -0
  60. package/dist/write-CLTPlucv.js.map +1 -0
  61. package/dist/write-l_NzIqyy.cjs +48 -0
  62. package/dist/write-l_NzIqyy.cjs.map +1 -0
  63. package/package.json +25 -32
  64. package/src/BarrelManager.ts +1 -0
  65. package/src/PromiseManager.ts +1 -7
  66. package/src/build.ts +9 -11
  67. package/src/index.ts +5 -5
  68. package/src/logger.ts +10 -10
  69. package/src/utils/FunctionParams.ts +3 -1
  70. package/src/utils/TreeNode.ts +3 -1
  71. package/dist/PluginManager-E3SghPP9.d.cts +0 -458
  72. package/dist/PluginManager-PDmRCu9k.d.ts +0 -458
  73. package/dist/chunk-4V7HK7PT.js +0 -1199
  74. package/dist/chunk-4V7HK7PT.js.map +0 -1
  75. package/dist/chunk-BHSTNFNQ.cjs +0 -701
  76. package/dist/chunk-BHSTNFNQ.cjs.map +0 -1
  77. package/dist/chunk-CAZ37TGB.js +0 -918
  78. package/dist/chunk-CAZ37TGB.js.map +0 -1
  79. package/dist/chunk-E4XLCCPK.cjs +0 -170
  80. package/dist/chunk-E4XLCCPK.cjs.map +0 -1
  81. package/dist/chunk-GBYHPDPK.js +0 -595
  82. package/dist/chunk-GBYHPDPK.js.map +0 -1
  83. package/dist/chunk-L3A3DTAX.cjs +0 -1074
  84. package/dist/chunk-L3A3DTAX.cjs.map +0 -1
  85. package/dist/chunk-MCNA6SYG.cjs +0 -1231
  86. package/dist/chunk-MCNA6SYG.cjs.map +0 -1
  87. package/dist/chunk-YRPOID7E.js +0 -157
  88. package/dist/chunk-YRPOID7E.js.map +0 -1
  89. package/dist/fs.cjs.map +0 -1
  90. package/dist/fs.js.map +0 -1
  91. package/dist/logger-BWq-oJU_.d.cts +0 -63
  92. package/dist/logger-BWq-oJU_.d.ts +0 -63
  93. package/dist/logger.cjs.map +0 -1
  94. package/dist/logger.js.map +0 -1
  95. package/dist/parser-C1vOjVEd.d.ts +0 -41
  96. package/dist/parser-D6vU1kA9.d.cts +0 -41
  97. package/dist/prompt-ELTHGQK6.js +0 -753
  98. package/dist/prompt-ELTHGQK6.js.map +0 -1
  99. package/dist/prompt-U7M5G25C.cjs +0 -761
  100. package/dist/prompt-U7M5G25C.cjs.map +0 -1
  101. package/dist/transformers.cjs.map +0 -1
  102. package/dist/transformers.js.map +0 -1
  103. package/dist/types-CA8nQKwM.d.cts +0 -132
  104. package/dist/types-CA8nQKwM.d.ts +0 -132
  105. package/dist/utils.cjs.map +0 -1
  106. package/dist/utils.js.map +0 -1
@@ -1,1231 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkE4XLCCPK_cjs = require('./chunk-E4XLCCPK.cjs');
4
- var seedrandom = require('seedrandom');
5
- var tty = require('tty');
6
- var events = require('events');
7
- var path = require('path');
8
- var util = require('util');
9
- var g$1 = require('process');
10
-
11
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
12
-
13
- function _interopNamespace(e) {
14
- if (e && e.__esModule) return e;
15
- var n = Object.create(null);
16
- if (e) {
17
- Object.keys(e).forEach(function (k) {
18
- if (k !== 'default') {
19
- var d = Object.getOwnPropertyDescriptor(e, k);
20
- Object.defineProperty(n, k, d.get ? d : {
21
- enumerable: true,
22
- get: function () { return e[k]; }
23
- });
24
- }
25
- });
26
- }
27
- n.default = e;
28
- return Object.freeze(n);
29
- }
30
-
31
- var seedrandom__default = /*#__PURE__*/_interopDefault(seedrandom);
32
- var tty__namespace = /*#__PURE__*/_interopNamespace(tty);
33
- var g$1__default = /*#__PURE__*/_interopDefault(g$1);
34
-
35
- var {
36
- env = {},
37
- argv = [],
38
- platform = ""
39
- } = typeof process === "undefined" ? {} : process;
40
- var isDisabled = "NO_COLOR" in env || argv.includes("--no-color");
41
- var isForced = "FORCE_COLOR" in env || argv.includes("--color");
42
- var isWindows = platform === "win32";
43
- var isDumbTerminal = env.TERM === "dumb";
44
- var isCompatibleTerminal = tty__namespace && tty__namespace.isatty && tty__namespace.isatty(1) && env.TERM && !isDumbTerminal;
45
- var isCI = "CI" in env && ("GITHUB_ACTIONS" in env || "GITLAB_CI" in env || "CIRCLECI" in env);
46
- var isColorSupported = !isDisabled && (isForced || isWindows && !isDumbTerminal || isCompatibleTerminal || isCI);
47
- 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)) {
48
- return head + (next < 0 ? tail : replaceClose(next, tail, close, replace));
49
- }
50
- function clearBleed(index, string, open, close, replace) {
51
- return index < 0 ? open + string + close : open + replaceClose(index, string, close, replace) + close;
52
- }
53
- function filterEmpty(open, close, replace = open, at = open.length + 1) {
54
- return (string) => string || !(string === "" || string === void 0) ? clearBleed(
55
- ("" + string).indexOf(close, at),
56
- string,
57
- open,
58
- close,
59
- replace
60
- ) : "";
61
- }
62
- function init(open, close, replace) {
63
- return filterEmpty(`\x1B[${open}m`, `\x1B[${close}m`, replace);
64
- }
65
- var colorDefs = {
66
- reset: init(0, 0),
67
- bold: init(1, 22, "\x1B[22m\x1B[1m"),
68
- dim: init(2, 22, "\x1B[22m\x1B[2m"),
69
- italic: init(3, 23),
70
- underline: init(4, 24),
71
- inverse: init(7, 27),
72
- hidden: init(8, 28),
73
- strikethrough: init(9, 29),
74
- black: init(30, 39),
75
- red: init(31, 39),
76
- green: init(32, 39),
77
- yellow: init(33, 39),
78
- blue: init(34, 39),
79
- magenta: init(35, 39),
80
- cyan: init(36, 39),
81
- white: init(37, 39),
82
- gray: init(90, 39),
83
- bgBlack: init(40, 49),
84
- bgRed: init(41, 49),
85
- bgGreen: init(42, 49),
86
- bgYellow: init(43, 49),
87
- bgBlue: init(44, 49),
88
- bgMagenta: init(45, 49),
89
- bgCyan: init(46, 49),
90
- bgWhite: init(47, 49),
91
- blackBright: init(90, 39),
92
- redBright: init(91, 39),
93
- greenBright: init(92, 39),
94
- yellowBright: init(93, 39),
95
- blueBright: init(94, 39),
96
- magentaBright: init(95, 39),
97
- cyanBright: init(96, 39),
98
- whiteBright: init(97, 39),
99
- bgBlackBright: init(100, 49),
100
- bgRedBright: init(101, 49),
101
- bgGreenBright: init(102, 49),
102
- bgYellowBright: init(103, 49),
103
- bgBlueBright: init(104, 49),
104
- bgMagentaBright: init(105, 49),
105
- bgCyanBright: init(106, 49),
106
- bgWhiteBright: init(107, 49)
107
- };
108
- function createColors(useColor = isColorSupported) {
109
- return useColor ? colorDefs : Object.fromEntries(Object.keys(colorDefs).map((key) => [key, String]));
110
- }
111
- var colors = createColors();
112
- function getColor(color, fallback = "reset") {
113
- return colors[color] || colors[fallback];
114
- }
115
- var ansiRegex = [
116
- String.raw`[\u001B\u009B][[\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\d\/#&.:=?%@~_]+)*|[a-zA-Z\d]+(?:;[-a-zA-Z\d\/#&.:=?%@~_]*)*)?\u0007)`,
117
- String.raw`(?:(?:\d{1,4}(?:;\d{0,4})*)?[\dA-PR-TZcf-nq-uy=><~]))`
118
- ].join("|");
119
- function stripAnsi(text) {
120
- return text.replace(new RegExp(ansiRegex, "g"), "");
121
- }
122
- var boxStylePresets = {
123
- solid: {
124
- tl: "\u250C",
125
- tr: "\u2510",
126
- bl: "\u2514",
127
- br: "\u2518",
128
- h: "\u2500",
129
- v: "\u2502"
130
- },
131
- double: {
132
- tl: "\u2554",
133
- tr: "\u2557",
134
- bl: "\u255A",
135
- br: "\u255D",
136
- h: "\u2550",
137
- v: "\u2551"
138
- },
139
- doubleSingle: {
140
- tl: "\u2553",
141
- tr: "\u2556",
142
- bl: "\u2559",
143
- br: "\u255C",
144
- h: "\u2500",
145
- v: "\u2551"
146
- },
147
- doubleSingleRounded: {
148
- tl: "\u256D",
149
- tr: "\u256E",
150
- bl: "\u2570",
151
- br: "\u256F",
152
- h: "\u2500",
153
- v: "\u2551"
154
- },
155
- singleThick: {
156
- tl: "\u250F",
157
- tr: "\u2513",
158
- bl: "\u2517",
159
- br: "\u251B",
160
- h: "\u2501",
161
- v: "\u2503"
162
- },
163
- singleDouble: {
164
- tl: "\u2552",
165
- tr: "\u2555",
166
- bl: "\u2558",
167
- br: "\u255B",
168
- h: "\u2550",
169
- v: "\u2502"
170
- },
171
- singleDoubleRounded: {
172
- tl: "\u256D",
173
- tr: "\u256E",
174
- bl: "\u2570",
175
- br: "\u256F",
176
- h: "\u2550",
177
- v: "\u2502"
178
- },
179
- rounded: {
180
- tl: "\u256D",
181
- tr: "\u256E",
182
- bl: "\u2570",
183
- br: "\u256F",
184
- h: "\u2500",
185
- v: "\u2502"
186
- }
187
- };
188
- var defaultStyle = {
189
- borderColor: "white",
190
- borderStyle: "rounded",
191
- valign: "center",
192
- padding: 2,
193
- marginLeft: 1,
194
- marginTop: 1,
195
- marginBottom: 1
196
- };
197
- function box(text, _opts = {}) {
198
- const opts = {
199
- ..._opts,
200
- style: {
201
- ...defaultStyle,
202
- ..._opts.style
203
- }
204
- };
205
- const textLines = text.split("\n");
206
- const boxLines = [];
207
- const _color = getColor(opts.style.borderColor);
208
- const borderStyle = {
209
- ...typeof opts.style.borderStyle === "string" ? boxStylePresets[opts.style.borderStyle] || boxStylePresets.solid : opts.style.borderStyle
210
- };
211
- if (_color) {
212
- for (const key in borderStyle) {
213
- borderStyle[key] = _color(
214
- borderStyle[key]
215
- );
216
- }
217
- }
218
- const paddingOffset = opts.style.padding % 2 === 0 ? opts.style.padding : opts.style.padding + 1;
219
- const height = textLines.length + paddingOffset;
220
- const width = Math.max(
221
- ...textLines.map((line) => stripAnsi(line).length),
222
- opts.title ? stripAnsi(opts.title).length : 0
223
- ) + paddingOffset;
224
- const widthOffset = width + paddingOffset;
225
- const leftSpace = opts.style.marginLeft > 0 ? " ".repeat(opts.style.marginLeft) : "";
226
- if (opts.style.marginTop > 0) {
227
- boxLines.push("".repeat(opts.style.marginTop));
228
- }
229
- if (opts.title) {
230
- const title = _color ? _color(opts.title) : opts.title;
231
- const left = borderStyle.h.repeat(
232
- Math.floor((width - stripAnsi(opts.title).length) / 2)
233
- );
234
- const right = borderStyle.h.repeat(
235
- width - stripAnsi(opts.title).length - stripAnsi(left).length + paddingOffset
236
- );
237
- boxLines.push(
238
- `${leftSpace}${borderStyle.tl}${left}${title}${right}${borderStyle.tr}`
239
- );
240
- } else {
241
- boxLines.push(
242
- `${leftSpace}${borderStyle.tl}${borderStyle.h.repeat(widthOffset)}${borderStyle.tr}`
243
- );
244
- }
245
- const valignOffset = opts.style.valign === "center" ? Math.floor((height - textLines.length) / 2) : opts.style.valign === "top" ? height - textLines.length - paddingOffset : height - textLines.length;
246
- for (let i2 = 0; i2 < height; i2++) {
247
- if (i2 < valignOffset || i2 >= valignOffset + textLines.length) {
248
- boxLines.push(
249
- `${leftSpace}${borderStyle.v}${" ".repeat(widthOffset)}${borderStyle.v}`
250
- );
251
- } else {
252
- const line = textLines[i2 - valignOffset];
253
- const left = " ".repeat(paddingOffset);
254
- const right = " ".repeat(width - stripAnsi(line).length);
255
- boxLines.push(
256
- `${leftSpace}${borderStyle.v}${left}${line}${right}${borderStyle.v}`
257
- );
258
- }
259
- }
260
- boxLines.push(
261
- `${leftSpace}${borderStyle.bl}${borderStyle.h.repeat(widthOffset)}${borderStyle.br}`
262
- );
263
- if (opts.style.marginBottom > 0) {
264
- boxLines.push("".repeat(opts.style.marginBottom));
265
- }
266
- return boxLines.join("\n");
267
- }
268
- var EventEmitter = class {
269
- constructor() {
270
- this.#emitter.setMaxListeners(100);
271
- }
272
- #emitter = new events.EventEmitter();
273
- emit(eventName, ...eventArg) {
274
- this.#emitter.emit(eventName, ...eventArg);
275
- }
276
- on(eventName, handler) {
277
- this.#emitter.on(eventName, handler);
278
- }
279
- off(eventName, handler) {
280
- this.#emitter.off(eventName, handler);
281
- }
282
- removeAll() {
283
- this.#emitter.removeAllListeners();
284
- }
285
- };
286
-
287
- // ../../node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/core.mjs
288
- var LogLevels = {
289
- fatal: 0,
290
- error: 0,
291
- warn: 1,
292
- log: 2,
293
- info: 3,
294
- success: 3,
295
- fail: 3,
296
- debug: 4,
297
- trace: 5,
298
- verbose: Number.POSITIVE_INFINITY
299
- };
300
- var LogTypes = {
301
- // Silent
302
- silent: {
303
- level: -1
304
- },
305
- // Level 0
306
- fatal: {
307
- level: LogLevels.fatal
308
- },
309
- error: {
310
- level: LogLevels.error
311
- },
312
- // Level 1
313
- warn: {
314
- level: LogLevels.warn
315
- },
316
- // Level 2
317
- log: {
318
- level: LogLevels.log
319
- },
320
- // Level 3
321
- info: {
322
- level: LogLevels.info
323
- },
324
- success: {
325
- level: LogLevels.success
326
- },
327
- fail: {
328
- level: LogLevels.fail
329
- },
330
- ready: {
331
- level: LogLevels.info
332
- },
333
- start: {
334
- level: LogLevels.info
335
- },
336
- box: {
337
- level: LogLevels.info
338
- },
339
- // Level 4
340
- debug: {
341
- level: LogLevels.debug
342
- },
343
- // Level 5
344
- trace: {
345
- level: LogLevels.trace
346
- },
347
- // Verbose
348
- verbose: {
349
- level: LogLevels.verbose
350
- }
351
- };
352
- function isPlainObject$1(value) {
353
- if (value === null || typeof value !== "object") {
354
- return false;
355
- }
356
- const prototype = Object.getPrototypeOf(value);
357
- if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
358
- return false;
359
- }
360
- if (Symbol.iterator in value) {
361
- return false;
362
- }
363
- if (Symbol.toStringTag in value) {
364
- return Object.prototype.toString.call(value) === "[object Module]";
365
- }
366
- return true;
367
- }
368
- function _defu(baseObject, defaults, namespace = ".", merger) {
369
- if (!isPlainObject$1(defaults)) {
370
- return _defu(baseObject, {}, namespace);
371
- }
372
- const object = Object.assign({}, defaults);
373
- for (const key in baseObject) {
374
- if (key === "__proto__" || key === "constructor") {
375
- continue;
376
- }
377
- const value = baseObject[key];
378
- if (value === null || value === void 0) {
379
- continue;
380
- }
381
- if (Array.isArray(value) && Array.isArray(object[key])) {
382
- object[key] = [...value, ...object[key]];
383
- } else if (isPlainObject$1(value) && isPlainObject$1(object[key])) {
384
- object[key] = _defu(
385
- value,
386
- object[key],
387
- (namespace ? `${namespace}.` : "") + key.toString());
388
- } else {
389
- object[key] = value;
390
- }
391
- }
392
- return object;
393
- }
394
- function createDefu(merger) {
395
- return (...arguments_) => (
396
- // eslint-disable-next-line unicorn/no-array-reduce
397
- arguments_.reduce((p, c2) => _defu(p, c2, ""), {})
398
- );
399
- }
400
- var defu = createDefu();
401
- function isPlainObject(obj) {
402
- return Object.prototype.toString.call(obj) === "[object Object]";
403
- }
404
- function isLogObj(arg) {
405
- if (!isPlainObject(arg)) {
406
- return false;
407
- }
408
- if (!arg.message && !arg.args) {
409
- return false;
410
- }
411
- if (arg.stack) {
412
- return false;
413
- }
414
- return true;
415
- }
416
- var paused = false;
417
- var queue = [];
418
- var Consola = class _Consola {
419
- options;
420
- _lastLog;
421
- _mockFn;
422
- /**
423
- * Creates an instance of Consola with specified options or defaults.
424
- *
425
- * @param {Partial<ConsolaOptions>} [options={}] - Configuration options for the Consola instance.
426
- */
427
- constructor(options = {}) {
428
- const types = options.types || LogTypes;
429
- this.options = defu(
430
- {
431
- ...options,
432
- defaults: { ...options.defaults },
433
- level: _normalizeLogLevel(options.level, types),
434
- reporters: [...options.reporters || []]
435
- },
436
- {
437
- types: LogTypes,
438
- throttle: 1e3,
439
- throttleMin: 5,
440
- formatOptions: {
441
- date: true,
442
- colors: false,
443
- compact: true
444
- }
445
- }
446
- );
447
- for (const type in types) {
448
- const defaults = {
449
- type,
450
- ...this.options.defaults,
451
- ...types[type]
452
- };
453
- this[type] = this._wrapLogFn(defaults);
454
- this[type].raw = this._wrapLogFn(
455
- defaults,
456
- true
457
- );
458
- }
459
- if (this.options.mockFn) {
460
- this.mockTypes();
461
- }
462
- this._lastLog = {};
463
- }
464
- /**
465
- * Gets the current log level of the Consola instance.
466
- *
467
- * @returns {number} The current log level.
468
- */
469
- get level() {
470
- return this.options.level;
471
- }
472
- /**
473
- * Sets the minimum log level that will be output by the instance.
474
- *
475
- * @param {number} level - The new log level to set.
476
- */
477
- set level(level) {
478
- this.options.level = _normalizeLogLevel(
479
- level,
480
- this.options.types,
481
- this.options.level
482
- );
483
- }
484
- /**
485
- * Displays a prompt to the user and returns the response.
486
- * Throw an error if `prompt` is not supported by the current configuration.
487
- *
488
- * @template T
489
- * @param {string} message - The message to display in the prompt.
490
- * @param {T} [opts] - Optional options for the prompt. See {@link PromptOptions}.
491
- * @returns {promise<T>} A promise that infer with the prompt options. See {@link PromptOptions}.
492
- */
493
- prompt(message, opts) {
494
- if (!this.options.prompt) {
495
- throw new Error("prompt is not supported!");
496
- }
497
- return this.options.prompt(message, opts);
498
- }
499
- /**
500
- * Creates a new instance of Consola, inheriting options from the current instance, with possible overrides.
501
- *
502
- * @param {Partial<ConsolaOptions>} options - Optional overrides for the new instance. See {@link ConsolaOptions}.
503
- * @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
504
- */
505
- create(options) {
506
- const instance = new _Consola({
507
- ...this.options,
508
- ...options
509
- });
510
- if (this._mockFn) {
511
- instance.mockTypes(this._mockFn);
512
- }
513
- return instance;
514
- }
515
- /**
516
- * Creates a new Consola instance with the specified default log object properties.
517
- *
518
- * @param {InputLogObject} defaults - Default properties to include in any log from the new instance. See {@link InputLogObject}.
519
- * @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
520
- */
521
- withDefaults(defaults) {
522
- return this.create({
523
- ...this.options,
524
- defaults: {
525
- ...this.options.defaults,
526
- ...defaults
527
- }
528
- });
529
- }
530
- /**
531
- * Creates a new Consola instance with a specified tag, which will be included in every log.
532
- *
533
- * @param {string} tag - The tag to include in each log of the new instance.
534
- * @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
535
- */
536
- withTag(tag) {
537
- return this.withDefaults({
538
- tag: this.options.defaults.tag ? this.options.defaults.tag + ":" + tag : tag
539
- });
540
- }
541
- /**
542
- * Adds a custom reporter to the Consola instance.
543
- * Reporters will be called for each log message, depending on their implementation and log level.
544
- *
545
- * @param {ConsolaReporter} reporter - The reporter to add. See {@link ConsolaReporter}.
546
- * @returns {Consola} The current Consola instance.
547
- */
548
- addReporter(reporter) {
549
- this.options.reporters.push(reporter);
550
- return this;
551
- }
552
- /**
553
- * Removes a custom reporter from the Consola instance.
554
- * If no reporter is specified, all reporters will be removed.
555
- *
556
- * @param {ConsolaReporter} reporter - The reporter to remove. See {@link ConsolaReporter}.
557
- * @returns {Consola} The current Consola instance.
558
- */
559
- removeReporter(reporter) {
560
- if (reporter) {
561
- const i2 = this.options.reporters.indexOf(reporter);
562
- if (i2 !== -1) {
563
- return this.options.reporters.splice(i2, 1);
564
- }
565
- } else {
566
- this.options.reporters.splice(0);
567
- }
568
- return this;
569
- }
570
- /**
571
- * Replaces all reporters of the Consola instance with the specified array of reporters.
572
- *
573
- * @param {ConsolaReporter[]} reporters - The new reporters to set. See {@link ConsolaReporter}.
574
- * @returns {Consola} The current Consola instance.
575
- */
576
- setReporters(reporters) {
577
- this.options.reporters = Array.isArray(reporters) ? reporters : [reporters];
578
- return this;
579
- }
580
- wrapAll() {
581
- this.wrapConsole();
582
- this.wrapStd();
583
- }
584
- restoreAll() {
585
- this.restoreConsole();
586
- this.restoreStd();
587
- }
588
- /**
589
- * Overrides console methods with Consola logging methods for consistent logging.
590
- */
591
- wrapConsole() {
592
- for (const type in this.options.types) {
593
- if (!console["__" + type]) {
594
- console["__" + type] = console[type];
595
- }
596
- console[type] = this[type].raw;
597
- }
598
- }
599
- /**
600
- * Restores the original console methods, removing Consola overrides.
601
- */
602
- restoreConsole() {
603
- for (const type in this.options.types) {
604
- if (console["__" + type]) {
605
- console[type] = console["__" + type];
606
- delete console["__" + type];
607
- }
608
- }
609
- }
610
- /**
611
- * Overrides standard output and error streams to redirect them through Consola.
612
- */
613
- wrapStd() {
614
- this._wrapStream(this.options.stdout, "log");
615
- this._wrapStream(this.options.stderr, "log");
616
- }
617
- _wrapStream(stream, type) {
618
- if (!stream) {
619
- return;
620
- }
621
- if (!stream.__write) {
622
- stream.__write = stream.write;
623
- }
624
- stream.write = (data) => {
625
- this[type].raw(String(data).trim());
626
- };
627
- }
628
- /**
629
- * Restores the original standard output and error streams, removing the Consola redirection.
630
- */
631
- restoreStd() {
632
- this._restoreStream(this.options.stdout);
633
- this._restoreStream(this.options.stderr);
634
- }
635
- _restoreStream(stream) {
636
- if (!stream) {
637
- return;
638
- }
639
- if (stream.__write) {
640
- stream.write = stream.__write;
641
- delete stream.__write;
642
- }
643
- }
644
- /**
645
- * Pauses logging, queues incoming logs until resumed.
646
- */
647
- pauseLogs() {
648
- paused = true;
649
- }
650
- /**
651
- * Resumes logging, processing any queued logs.
652
- */
653
- resumeLogs() {
654
- paused = false;
655
- const _queue = queue.splice(0);
656
- for (const item of _queue) {
657
- item[0]._logFn(item[1], item[2]);
658
- }
659
- }
660
- /**
661
- * Replaces logging methods with mocks if a mock function is provided.
662
- *
663
- * @param {ConsolaOptions["mockFn"]} mockFn - The function to use for mocking logging methods. See {@link ConsolaOptions["mockFn"]}.
664
- */
665
- mockTypes(mockFn) {
666
- const _mockFn = mockFn || this.options.mockFn;
667
- this._mockFn = _mockFn;
668
- if (typeof _mockFn !== "function") {
669
- return;
670
- }
671
- for (const type in this.options.types) {
672
- this[type] = _mockFn(type, this.options.types[type]) || this[type];
673
- this[type].raw = this[type];
674
- }
675
- }
676
- _wrapLogFn(defaults, isRaw) {
677
- return (...args) => {
678
- if (paused) {
679
- queue.push([this, defaults, args, isRaw]);
680
- return;
681
- }
682
- return this._logFn(defaults, args, isRaw);
683
- };
684
- }
685
- _logFn(defaults, args, isRaw) {
686
- if ((defaults.level || 0) > this.level) {
687
- return false;
688
- }
689
- const logObj = {
690
- date: /* @__PURE__ */ new Date(),
691
- args: [],
692
- ...defaults,
693
- level: _normalizeLogLevel(defaults.level, this.options.types)
694
- };
695
- if (!isRaw && args.length === 1 && isLogObj(args[0])) {
696
- Object.assign(logObj, args[0]);
697
- } else {
698
- logObj.args = [...args];
699
- }
700
- if (logObj.message) {
701
- logObj.args.unshift(logObj.message);
702
- delete logObj.message;
703
- }
704
- if (logObj.additional) {
705
- if (!Array.isArray(logObj.additional)) {
706
- logObj.additional = logObj.additional.split("\n");
707
- }
708
- logObj.args.push("\n" + logObj.additional.join("\n"));
709
- delete logObj.additional;
710
- }
711
- logObj.type = typeof logObj.type === "string" ? logObj.type.toLowerCase() : "log";
712
- logObj.tag = typeof logObj.tag === "string" ? logObj.tag : "";
713
- const resolveLog = (newLog = false) => {
714
- const repeated = (this._lastLog.count || 0) - this.options.throttleMin;
715
- if (this._lastLog.object && repeated > 0) {
716
- const args2 = [...this._lastLog.object.args];
717
- if (repeated > 1) {
718
- args2.push(`(repeated ${repeated} times)`);
719
- }
720
- this._log({ ...this._lastLog.object, args: args2 });
721
- this._lastLog.count = 1;
722
- }
723
- if (newLog) {
724
- this._lastLog.object = logObj;
725
- this._log(logObj);
726
- }
727
- };
728
- clearTimeout(this._lastLog.timeout);
729
- const diffTime = this._lastLog.time && logObj.date ? logObj.date.getTime() - this._lastLog.time.getTime() : 0;
730
- this._lastLog.time = logObj.date;
731
- if (diffTime < this.options.throttle) {
732
- try {
733
- const serializedLog = JSON.stringify([
734
- logObj.type,
735
- logObj.tag,
736
- logObj.args
737
- ]);
738
- const isSameLog = this._lastLog.serialized === serializedLog;
739
- this._lastLog.serialized = serializedLog;
740
- if (isSameLog) {
741
- this._lastLog.count = (this._lastLog.count || 0) + 1;
742
- if (this._lastLog.count > this.options.throttleMin) {
743
- this._lastLog.timeout = setTimeout(
744
- resolveLog,
745
- this.options.throttle
746
- );
747
- return;
748
- }
749
- }
750
- } catch {
751
- }
752
- }
753
- resolveLog(true);
754
- }
755
- _log(logObj) {
756
- for (const reporter of this.options.reporters) {
757
- reporter.log(logObj, {
758
- options: this.options
759
- });
760
- }
761
- }
762
- };
763
- function _normalizeLogLevel(input, types = {}, defaultLevel = 3) {
764
- if (input === void 0) {
765
- return defaultLevel;
766
- }
767
- if (typeof input === "number") {
768
- return input;
769
- }
770
- if (types[input] && types[input].level !== void 0) {
771
- return types[input].level;
772
- }
773
- return defaultLevel;
774
- }
775
- Consola.prototype.add = Consola.prototype.addReporter;
776
- Consola.prototype.remove = Consola.prototype.removeReporter;
777
- Consola.prototype.clear = Consola.prototype.removeReporter;
778
- Consola.prototype.withScope = Consola.prototype.withTag;
779
- Consola.prototype.mock = Consola.prototype.mockTypes;
780
- Consola.prototype.pause = Consola.prototype.pauseLogs;
781
- Consola.prototype.resume = Consola.prototype.resumeLogs;
782
- function createConsola(options = {}) {
783
- return new Consola(options);
784
- }
785
- function parseStack(stack, message) {
786
- const cwd = process.cwd() + path.sep;
787
- const lines = stack.split("\n").splice(message.split("\n").length).map((l2) => l2.trim().replace("file://", "").replace(cwd, ""));
788
- return lines;
789
- }
790
- function writeStream(data, stream) {
791
- const write2 = stream.__write || stream.write;
792
- return write2.call(stream, data);
793
- }
794
- var bracket = (x) => x ? `[${x}]` : "";
795
- var BasicReporter = class {
796
- formatStack(stack, message, opts) {
797
- const indent = " ".repeat((opts?.errorLevel || 0) + 1);
798
- return indent + parseStack(stack, message).join(`
799
- ${indent}`);
800
- }
801
- formatError(err, opts) {
802
- const message = err.message ?? util.formatWithOptions(opts, err);
803
- const stack = err.stack ? this.formatStack(err.stack, message, opts) : "";
804
- const level = opts?.errorLevel || 0;
805
- const causedPrefix = level > 0 ? `${" ".repeat(level)}[cause]: ` : "";
806
- const causedError = err.cause ? "\n\n" + this.formatError(err.cause, { ...opts, errorLevel: level + 1 }) : "";
807
- return causedPrefix + message + "\n" + stack + causedError;
808
- }
809
- formatArgs(args, opts) {
810
- const _args = args.map((arg) => {
811
- if (arg && typeof arg.stack === "string") {
812
- return this.formatError(arg, opts);
813
- }
814
- return arg;
815
- });
816
- return util.formatWithOptions(opts, ..._args);
817
- }
818
- formatDate(date, opts) {
819
- return opts.date ? date.toLocaleTimeString() : "";
820
- }
821
- filterAndJoin(arr) {
822
- return arr.filter(Boolean).join(" ");
823
- }
824
- formatLogObj(logObj, opts) {
825
- const message = this.formatArgs(logObj.args, opts);
826
- if (logObj.type === "box") {
827
- return "\n" + [
828
- bracket(logObj.tag),
829
- logObj.title && logObj.title,
830
- ...message.split("\n")
831
- ].filter(Boolean).map((l2) => " > " + l2).join("\n") + "\n";
832
- }
833
- return this.filterAndJoin([
834
- bracket(logObj.type),
835
- bracket(logObj.tag),
836
- message
837
- ]);
838
- }
839
- log(logObj, ctx) {
840
- const line = this.formatLogObj(logObj, {
841
- columns: ctx.options.stdout.columns || 0,
842
- ...ctx.options.formatOptions
843
- });
844
- return writeStream(
845
- line + "\n",
846
- logObj.level < 2 ? ctx.options.stderr || process.stderr : ctx.options.stdout || process.stdout
847
- );
848
- }
849
- };
850
- var r = /* @__PURE__ */ Object.create(null);
851
- var i = (e) => globalThis.process?.env || undefined || globalThis.Deno?.env.toObject() || globalThis.__env__ || (e ? r : globalThis);
852
- var o = new Proxy(r, { get(e, s2) {
853
- return i()[s2] ?? r[s2];
854
- }, has(e, s2) {
855
- const E = i();
856
- return s2 in E || s2 in r;
857
- }, set(e, s2, E) {
858
- const B = i(true);
859
- return B[s2] = E, true;
860
- }, deleteProperty(e, s2) {
861
- if (!s2) return false;
862
- const E = i(true);
863
- return delete E[s2], true;
864
- }, ownKeys() {
865
- const e = i(true);
866
- return Object.keys(e);
867
- } });
868
- var t = typeof process < "u" && process.env && process.env.NODE_ENV || "";
869
- var f = [["APPVEYOR"], ["AWS_AMPLIFY", "AWS_APP_ID", { ci: true }], ["AZURE_PIPELINES", "SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"], ["AZURE_STATIC", "INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN"], ["APPCIRCLE", "AC_APPCIRCLE"], ["BAMBOO", "bamboo_planKey"], ["BITBUCKET", "BITBUCKET_COMMIT"], ["BITRISE", "BITRISE_IO"], ["BUDDY", "BUDDY_WORKSPACE_ID"], ["BUILDKITE"], ["CIRCLE", "CIRCLECI"], ["CIRRUS", "CIRRUS_CI"], ["CLOUDFLARE_PAGES", "CF_PAGES", { ci: true }], ["CODEBUILD", "CODEBUILD_BUILD_ARN"], ["CODEFRESH", "CF_BUILD_ID"], ["DRONE"], ["DRONE", "DRONE_BUILD_EVENT"], ["DSARI"], ["GITHUB_ACTIONS"], ["GITLAB", "GITLAB_CI"], ["GITLAB", "CI_MERGE_REQUEST_ID"], ["GOCD", "GO_PIPELINE_LABEL"], ["LAYERCI"], ["HUDSON", "HUDSON_URL"], ["JENKINS", "JENKINS_URL"], ["MAGNUM"], ["NETLIFY"], ["NETLIFY", "NETLIFY_LOCAL", { ci: false }], ["NEVERCODE"], ["RENDER"], ["SAIL", "SAILCI"], ["SEMAPHORE"], ["SCREWDRIVER"], ["SHIPPABLE"], ["SOLANO", "TDDIUM"], ["STRIDER"], ["TEAMCITY", "TEAMCITY_VERSION"], ["TRAVIS"], ["VERCEL", "NOW_BUILDER"], ["VERCEL", "VERCEL", { ci: false }], ["VERCEL", "VERCEL_ENV", { ci: false }], ["APPCENTER", "APPCENTER_BUILD_ID"], ["CODESANDBOX", "CODESANDBOX_SSE", { ci: false }], ["CODESANDBOX", "CODESANDBOX_HOST", { ci: false }], ["STACKBLITZ"], ["STORMKIT"], ["CLEAVR"], ["ZEABUR"], ["CODESPHERE", "CODESPHERE_APP_ID", { ci: true }], ["RAILWAY", "RAILWAY_PROJECT_ID"], ["RAILWAY", "RAILWAY_SERVICE_ID"], ["DENO-DEPLOY", "DENO_DEPLOYMENT_ID"], ["FIREBASE_APP_HOSTING", "FIREBASE_APP_HOSTING", { ci: true }]];
870
- function b() {
871
- if (globalThis.process?.env) for (const e of f) {
872
- const s2 = e[1] || e[0];
873
- if (globalThis.process?.env[s2]) return { name: e[0].toLowerCase(), ...e[2] };
874
- }
875
- return globalThis.process?.env?.SHELL === "/bin/jsh" && globalThis.process?.versions?.webcontainer ? { name: "stackblitz", ci: false } : { name: "", ci: false };
876
- }
877
- var l = b();
878
- l.name;
879
- function n(e) {
880
- return e ? e !== "false" : false;
881
- }
882
- var I = globalThis.process?.platform || "";
883
- var T = n(o.CI) || l.ci !== false;
884
- var a = n(globalThis.process?.stdout && globalThis.process?.stdout.isTTY);
885
- var g = n(o.DEBUG);
886
- var R = t === "test" || n(o.TEST);
887
- n(o.MINIMAL) || T || R || !a;
888
- var A = /^win/i.test(I);
889
- !n(o.NO_COLOR) && (n(o.FORCE_COLOR) || (a || A) && o.TERM !== "dumb" || T);
890
- var C = (globalThis.process?.versions?.node || "").replace(/^v/, "") || null;
891
- Number(C?.split(".")[0]) || null;
892
- var y = globalThis.process || /* @__PURE__ */ Object.create(null);
893
- var _ = { versions: {} };
894
- new Proxy(y, { get(e, s2) {
895
- if (s2 === "env") return o;
896
- if (s2 in e) return e[s2];
897
- if (s2 in _) return _[s2];
898
- } });
899
- var c = globalThis.process?.release?.name === "node";
900
- var O = !!globalThis.Bun || !!globalThis.process?.versions?.bun;
901
- var D = !!globalThis.Deno;
902
- var L = !!globalThis.fastly;
903
- var S = !!globalThis.Netlify;
904
- var u = !!globalThis.EdgeRuntime;
905
- var N = globalThis.navigator?.userAgent === "Cloudflare-Workers";
906
- var F = [[S, "netlify"], [u, "edge-light"], [N, "workerd"], [L, "fastly"], [D, "deno"], [O, "bun"], [c, "node"]];
907
- function G() {
908
- const e = F.find((s2) => s2[0]);
909
- if (e) return { name: e[1] };
910
- }
911
- var P = G();
912
- P?.name || "";
913
- function ansiRegex2({ onlyFirst = false } = {}) {
914
- const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
915
- const pattern = [
916
- `[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?${ST})`,
917
- "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"
918
- ].join("|");
919
- return new RegExp(pattern, onlyFirst ? void 0 : "g");
920
- }
921
- var regex = ansiRegex2();
922
- function stripAnsi2(string) {
923
- if (typeof string !== "string") {
924
- throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
925
- }
926
- return string.replace(regex, "");
927
- }
928
- function isAmbiguous(x) {
929
- 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;
930
- }
931
- function isFullWidth(x) {
932
- return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
933
- }
934
- function isWide(x) {
935
- 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;
936
- }
937
- function validate(codePoint) {
938
- if (!Number.isSafeInteger(codePoint)) {
939
- throw new TypeError(`Expected a code point, got \`${typeof codePoint}\`.`);
940
- }
941
- }
942
- function eastAsianWidth(codePoint, { ambiguousAsWide = false } = {}) {
943
- validate(codePoint);
944
- if (isFullWidth(codePoint) || isWide(codePoint) || ambiguousAsWide && isAmbiguous(codePoint)) {
945
- return 2;
946
- }
947
- return 1;
948
- }
949
- var emojiRegex = () => {
950
- 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;
951
- };
952
- var segmenter = globalThis.Intl?.Segmenter ? new Intl.Segmenter() : { segment: (str) => str.split("") };
953
- var defaultIgnorableCodePointRegex = new RegExp("^\\p{Default_Ignorable_Code_Point}$", "u");
954
- function stringWidth$1(string, options = {}) {
955
- if (typeof string !== "string" || string.length === 0) {
956
- return 0;
957
- }
958
- const {
959
- ambiguousIsNarrow = true,
960
- countAnsiEscapeCodes = false
961
- } = options;
962
- if (!countAnsiEscapeCodes) {
963
- string = stripAnsi2(string);
964
- }
965
- if (string.length === 0) {
966
- return 0;
967
- }
968
- let width = 0;
969
- const eastAsianWidthOptions = { ambiguousAsWide: !ambiguousIsNarrow };
970
- for (const { segment: character } of segmenter.segment(string)) {
971
- const codePoint = character.codePointAt(0);
972
- if (codePoint <= 31 || codePoint >= 127 && codePoint <= 159) {
973
- continue;
974
- }
975
- if (codePoint >= 8203 && codePoint <= 8207 || codePoint === 65279) {
976
- continue;
977
- }
978
- if (codePoint >= 768 && codePoint <= 879 || codePoint >= 6832 && codePoint <= 6911 || codePoint >= 7616 && codePoint <= 7679 || codePoint >= 8400 && codePoint <= 8447 || codePoint >= 65056 && codePoint <= 65071) {
979
- continue;
980
- }
981
- if (codePoint >= 55296 && codePoint <= 57343) {
982
- continue;
983
- }
984
- if (codePoint >= 65024 && codePoint <= 65039) {
985
- continue;
986
- }
987
- if (defaultIgnorableCodePointRegex.test(character)) {
988
- continue;
989
- }
990
- if (emojiRegex().test(character)) {
991
- width += 2;
992
- continue;
993
- }
994
- width += eastAsianWidth(codePoint, eastAsianWidthOptions);
995
- }
996
- return width;
997
- }
998
- function isUnicodeSupported() {
999
- const { env: env2 } = g$1__default.default;
1000
- const { TERM, TERM_PROGRAM } = env2;
1001
- if (g$1__default.default.platform !== "win32") {
1002
- return TERM !== "linux";
1003
- }
1004
- return Boolean(env2.WT_SESSION) || Boolean(env2.TERMINUS_SUBLIME) || env2.ConEmuTask === "{cmd::Cmder}" || TERM_PROGRAM === "Terminus-Sublime" || TERM_PROGRAM === "vscode" || TERM === "xterm-256color" || TERM === "alacritty" || TERM === "rxvt-unicode" || TERM === "rxvt-unicode-256color" || env2.TERMINAL_EMULATOR === "JetBrains-JediTerm";
1005
- }
1006
- var TYPE_COLOR_MAP = {
1007
- info: "cyan",
1008
- fail: "red",
1009
- success: "green",
1010
- ready: "green",
1011
- start: "magenta"
1012
- };
1013
- var LEVEL_COLOR_MAP = {
1014
- 0: "red",
1015
- 1: "yellow"
1016
- };
1017
- var unicode = isUnicodeSupported();
1018
- var s = (c2, fallback) => unicode ? c2 : fallback;
1019
- var TYPE_ICONS = {
1020
- error: s("\u2716", "\xD7"),
1021
- fatal: s("\u2716", "\xD7"),
1022
- ready: s("\u2714", "\u221A"),
1023
- warn: s("\u26A0", "\u203C"),
1024
- info: s("\u2139", "i"),
1025
- success: s("\u2714", "\u221A"),
1026
- debug: s("\u2699", "D"),
1027
- trace: s("\u2192", "\u2192"),
1028
- fail: s("\u2716", "\xD7"),
1029
- start: s("\u25D0", "o"),
1030
- log: ""
1031
- };
1032
- function stringWidth(str) {
1033
- const hasICU = typeof Intl === "object";
1034
- if (!hasICU || !Intl.Segmenter) {
1035
- return stripAnsi(str).length;
1036
- }
1037
- return stringWidth$1(str);
1038
- }
1039
- var FancyReporter = class extends BasicReporter {
1040
- formatStack(stack, message, opts) {
1041
- const indent = " ".repeat((opts?.errorLevel || 0) + 1);
1042
- return `
1043
- ${indent}` + parseStack(stack, message).map(
1044
- (line) => " " + line.replace(/^at +/, (m) => colors.gray(m)).replace(/\((.+)\)/, (_2, m) => `(${colors.cyan(m)})`)
1045
- ).join(`
1046
- ${indent}`);
1047
- }
1048
- formatType(logObj, isBadge, opts) {
1049
- const typeColor = TYPE_COLOR_MAP[logObj.type] || LEVEL_COLOR_MAP[logObj.level] || "gray";
1050
- if (isBadge) {
1051
- return getBgColor(typeColor)(
1052
- colors.black(` ${logObj.type.toUpperCase()} `)
1053
- );
1054
- }
1055
- const _type = typeof TYPE_ICONS[logObj.type] === "string" ? TYPE_ICONS[logObj.type] : logObj.icon || logObj.type;
1056
- return _type ? getColor2(typeColor)(_type) : "";
1057
- }
1058
- formatLogObj(logObj, opts) {
1059
- const [message, ...additional] = this.formatArgs(logObj.args, opts).split(
1060
- "\n"
1061
- );
1062
- if (logObj.type === "box") {
1063
- return box(
1064
- characterFormat(
1065
- message + (additional.length > 0 ? "\n" + additional.join("\n") : "")
1066
- ),
1067
- {
1068
- title: logObj.title ? characterFormat(logObj.title) : void 0,
1069
- style: logObj.style
1070
- }
1071
- );
1072
- }
1073
- const date = this.formatDate(logObj.date, opts);
1074
- const coloredDate = date && colors.gray(date);
1075
- const isBadge = logObj.badge ?? logObj.level < 2;
1076
- const type = this.formatType(logObj, isBadge, opts);
1077
- const tag = logObj.tag ? colors.gray(logObj.tag) : "";
1078
- let line;
1079
- const left = this.filterAndJoin([type, characterFormat(message)]);
1080
- const right = this.filterAndJoin(opts.columns ? [tag, coloredDate] : [tag]);
1081
- const space = (opts.columns || 0) - stringWidth(left) - stringWidth(right) - 2;
1082
- line = space > 0 && (opts.columns || 0) >= 80 ? left + " ".repeat(space) + right : (right ? `${colors.gray(`[${right}]`)} ` : "") + left;
1083
- line += characterFormat(
1084
- additional.length > 0 ? "\n" + additional.join("\n") : ""
1085
- );
1086
- if (logObj.type === "trace") {
1087
- const _err = new Error("Trace: " + logObj.message);
1088
- line += this.formatStack(_err.stack || "", _err.message);
1089
- }
1090
- return isBadge ? "\n" + line + "\n" : line;
1091
- }
1092
- };
1093
- function characterFormat(str) {
1094
- return str.replace(/`([^`]+)`/gm, (_2, m) => colors.cyan(m)).replace(/\s+_([^_]+)_\s+/gm, (_2, m) => ` ${colors.underline(m)} `);
1095
- }
1096
- function getColor2(color = "white") {
1097
- return colors[color] || colors.white;
1098
- }
1099
- function getBgColor(color = "bgWhite") {
1100
- return colors[`bg${color[0].toUpperCase()}${color.slice(1)}`] || colors.bgWhite;
1101
- }
1102
- function createConsola2(options = {}) {
1103
- let level = _getDefaultLogLevel();
1104
- if (process.env.CONSOLA_LEVEL) {
1105
- level = Number.parseInt(process.env.CONSOLA_LEVEL) ?? level;
1106
- }
1107
- const consola2 = createConsola({
1108
- level,
1109
- defaults: { level },
1110
- stdout: process.stdout,
1111
- stderr: process.stderr,
1112
- prompt: (...args) => import('./prompt-U7M5G25C.cjs').then((m) => m.prompt(...args)),
1113
- reporters: options.reporters || [
1114
- options.fancy ?? !(T || R) ? new FancyReporter() : new BasicReporter()
1115
- ],
1116
- ...options
1117
- });
1118
- return consola2;
1119
- }
1120
- function _getDefaultLogLevel() {
1121
- if (g) {
1122
- return LogLevels.debug;
1123
- }
1124
- if (R) {
1125
- return LogLevels.warn;
1126
- }
1127
- return LogLevels.info;
1128
- }
1129
- var consola = createConsola2();
1130
-
1131
- // src/logger.ts
1132
- var LogMapper = {
1133
- silent: Number.NEGATIVE_INFINITY,
1134
- info: 3,
1135
- debug: 4
1136
- };
1137
- function createLogger({ logLevel = 3, name, consola: _consola } = {}) {
1138
- const events = new EventEmitter();
1139
- const startDate = Date.now();
1140
- const cachedLogs = /* @__PURE__ */ new Set();
1141
- const consola2 = _consola || createConsola2({
1142
- level: logLevel,
1143
- formatOptions: {
1144
- colors: true,
1145
- date: true,
1146
- columns: 80,
1147
- compact: logLevel !== LogMapper.debug
1148
- }
1149
- }).withTag(name ? randomCliColour(name) : "");
1150
- consola2?.wrapConsole();
1151
- events.on("start", (message) => {
1152
- consola2.start(message);
1153
- });
1154
- events.on("success", (message) => {
1155
- consola2.success(message);
1156
- });
1157
- events.on("warning", (message) => {
1158
- consola2.warn(colors.yellow(message));
1159
- });
1160
- events.on("info", (message) => {
1161
- consola2.info(colors.yellow(message));
1162
- });
1163
- events.on("debug", (message) => {
1164
- if (message.logs.join("\n\n").length <= 100 && logLevel === LogMapper.debug) {
1165
- console.log(message.logs.join("\n\n"));
1166
- }
1167
- cachedLogs.add(message);
1168
- });
1169
- events.on("error", (message, cause) => {
1170
- const error = new Error(message || "Something went wrong");
1171
- error.cause = cause;
1172
- throw error;
1173
- });
1174
- if (consola2) {
1175
- consola2.level = logLevel;
1176
- }
1177
- const logger = {
1178
- name,
1179
- logLevel,
1180
- consola: consola2,
1181
- on(...args) {
1182
- return events.on(...args);
1183
- },
1184
- emit(...args) {
1185
- return events.emit(...args);
1186
- },
1187
- async writeLogs() {
1188
- const files = {};
1189
- cachedLogs.forEach((log) => {
1190
- const fileName = path.resolve(process.cwd(), ".kubb", log.fileName || `kubb-${startDate}.log`);
1191
- if (!files[fileName]) {
1192
- files[fileName] = [];
1193
- }
1194
- files[fileName] = [...files[fileName], `[${log.date.toLocaleString()}]: ${log.logs.join("\n\n")}`];
1195
- });
1196
- await Promise.all(
1197
- Object.entries(files).map(async ([fileName, logs]) => {
1198
- return chunkE4XLCCPK_cjs.write(fileName, logs.join("\n"));
1199
- })
1200
- );
1201
- return Object.keys(files);
1202
- }
1203
- };
1204
- return logger;
1205
- }
1206
- function randomColour(text) {
1207
- if (!text) {
1208
- return "white";
1209
- }
1210
- const defaultColours = ["black", "red", "green", "yellow", "blue", "red", "green", "magenta", "cyan", "gray"];
1211
- const random = seedrandom__default.default(text);
1212
- const colour = defaultColours.at(Math.floor(random() * defaultColours.length)) || "white";
1213
- return colour;
1214
- }
1215
- function randomCliColour(text) {
1216
- if (!text) {
1217
- return "";
1218
- }
1219
- const colour = randomColour(text);
1220
- return colors[colour]?.(text);
1221
- }
1222
-
1223
- exports.EventEmitter = EventEmitter;
1224
- exports.LogMapper = LogMapper;
1225
- exports.colors = colors;
1226
- exports.consola = consola;
1227
- exports.createLogger = createLogger;
1228
- exports.randomCliColour = randomCliColour;
1229
- exports.randomColour = randomColour;
1230
- //# sourceMappingURL=chunk-MCNA6SYG.cjs.map
1231
- //# sourceMappingURL=chunk-MCNA6SYG.cjs.map