rolldown 0.10.2 → 0.10.3

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 (64) hide show
  1. package/bin/cli.js +1 -1
  2. package/dist/cjs/cli.cjs +772 -0
  3. package/dist/cjs/index.cjs +26 -0
  4. package/dist/cjs/parallel-plugin-worker.cjs +32 -0
  5. package/dist/{parallel-plugin.cjs → cjs/parallel-plugin.cjs} +2 -3
  6. package/dist/esm/cli.mjs +773 -0
  7. package/dist/esm/index.mjs +24 -0
  8. package/dist/esm/parallel-plugin-worker.mjs +33 -0
  9. package/dist/esm/parallel-plugin.mjs +9 -0
  10. package/dist/shared/chunk-WMSF1LUG.cjs +37 -0
  11. package/dist/shared/consola_36c0034f-ED9jtJgC.mjs +942 -0
  12. package/dist/shared/consola_36c0034f-RVbq7gBJ.cjs +945 -0
  13. package/dist/shared/prompt-Q6AgPcFh.cjs +859 -0
  14. package/dist/shared/prompt-uoOfg_gh.mjs +860 -0
  15. package/dist/shared/rolldown-7z0huS4W.mjs +49 -0
  16. package/dist/shared/rolldown-binding.wasi.cjs +26 -13
  17. package/dist/shared/rolldown-pt4wPK1i.cjs +48 -0
  18. package/dist/shared/utils_index-0Q22WhZL.cjs +5331 -0
  19. package/dist/shared/utils_index-Wfcc8MjH.mjs +5361 -0
  20. package/dist/shared/wasi-worker-browser.mjs +6 -7
  21. package/dist/shared/wasi-worker.mjs +5 -2
  22. package/package.json +52 -37
  23. package/dist/chunks/prompt.cjs +0 -443
  24. package/dist/chunks/prompt.cjs.map +0 -1
  25. package/dist/chunks/prompt.mjs +0 -436
  26. package/dist/chunks/prompt.mjs.map +0 -1
  27. package/dist/cli.cjs +0 -1961
  28. package/dist/cli.cjs.map +0 -1
  29. package/dist/cli.d.cts +0 -2
  30. package/dist/cli.d.mts +0 -2
  31. package/dist/cli.d.ts +0 -2
  32. package/dist/cli.mjs +0 -1939
  33. package/dist/cli.mjs.map +0 -1
  34. package/dist/index.cjs +0 -26
  35. package/dist/index.cjs.map +0 -1
  36. package/dist/index.d.cts +0 -66
  37. package/dist/index.d.mts +0 -66
  38. package/dist/index.d.ts +0 -66
  39. package/dist/index.mjs +0 -21
  40. package/dist/index.mjs.map +0 -1
  41. package/dist/parallel-plugin-worker.cjs +0 -34
  42. package/dist/parallel-plugin-worker.cjs.map +0 -1
  43. package/dist/parallel-plugin-worker.d.cts +0 -2
  44. package/dist/parallel-plugin-worker.d.mts +0 -2
  45. package/dist/parallel-plugin-worker.d.ts +0 -2
  46. package/dist/parallel-plugin-worker.mjs +0 -32
  47. package/dist/parallel-plugin-worker.mjs.map +0 -1
  48. package/dist/parallel-plugin.cjs.map +0 -1
  49. package/dist/parallel-plugin.d.cts +0 -12
  50. package/dist/parallel-plugin.d.mts +0 -12
  51. package/dist/parallel-plugin.d.ts +0 -12
  52. package/dist/parallel-plugin.mjs +0 -6
  53. package/dist/parallel-plugin.mjs.map +0 -1
  54. package/dist/shared/rolldown.1ea1dc1e.d.cts +0 -1160
  55. package/dist/shared/rolldown.1ea1dc1e.d.mts +0 -1160
  56. package/dist/shared/rolldown.1ea1dc1e.d.ts +0 -1160
  57. package/dist/shared/rolldown.4d4592d7.cjs +0 -348
  58. package/dist/shared/rolldown.4d4592d7.cjs.map +0 -1
  59. package/dist/shared/rolldown.65028ebe.cjs +0 -547
  60. package/dist/shared/rolldown.65028ebe.cjs.map +0 -1
  61. package/dist/shared/rolldown.7d1ce9fc.mjs +0 -546
  62. package/dist/shared/rolldown.7d1ce9fc.mjs.map +0 -1
  63. package/dist/shared/rolldown.b914368a.mjs +0 -340
  64. package/dist/shared/rolldown.b914368a.mjs.map +0 -1
package/dist/cli.cjs DELETED
@@ -1,1961 +0,0 @@
1
- 'use strict';
2
-
3
- const process$1 = require('node:process');
4
- const nodePath = require('node:path');
5
- const node_util = require('node:util');
6
- const tty = require('node:tty');
7
- const url = require('url');
8
- const node_perf_hooks = require('node:perf_hooks');
9
- require('node:url');
10
- const rolldown = require('./shared/rolldown.4d4592d7.cjs');
11
- require('./shared/rolldown.65028ebe.cjs');
12
- require('fs');
13
- require('path');
14
- require('node:worker_threads');
15
- require('node:os');
16
-
17
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
18
-
19
- function _interopNamespaceCompat(e) {
20
- if (e && typeof e === 'object' && 'default' in e) return e;
21
- const n = Object.create(null);
22
- if (e) {
23
- for (const k in e) {
24
- n[k] = e[k];
25
- }
26
- }
27
- n.default = e;
28
- return n;
29
- }
30
-
31
- const process$1__default = /*#__PURE__*/_interopDefaultCompat(process$1);
32
- const nodePath__default = /*#__PURE__*/_interopDefaultCompat(nodePath);
33
- const tty__namespace = /*#__PURE__*/_interopNamespaceCompat(tty);
34
-
35
- const LogLevels = {
36
- silent: Number.NEGATIVE_INFINITY,
37
- fatal: 0,
38
- error: 0,
39
- warn: 1,
40
- log: 2,
41
- info: 3,
42
- success: 3,
43
- fail: 3,
44
- ready: 3,
45
- start: 3,
46
- box: 3,
47
- debug: 4,
48
- trace: 5,
49
- verbose: Number.POSITIVE_INFINITY
50
- };
51
- const LogTypes = {
52
- // Silent
53
- silent: {
54
- level: -1
55
- },
56
- // Level 0
57
- fatal: {
58
- level: LogLevels.fatal
59
- },
60
- error: {
61
- level: LogLevels.error
62
- },
63
- // Level 1
64
- warn: {
65
- level: LogLevels.warn
66
- },
67
- // Level 2
68
- log: {
69
- level: LogLevels.log
70
- },
71
- // Level 3
72
- info: {
73
- level: LogLevels.info
74
- },
75
- success: {
76
- level: LogLevels.success
77
- },
78
- fail: {
79
- level: LogLevels.fail
80
- },
81
- ready: {
82
- level: LogLevels.info
83
- },
84
- start: {
85
- level: LogLevels.info
86
- },
87
- box: {
88
- level: LogLevels.info
89
- },
90
- // Level 4
91
- debug: {
92
- level: LogLevels.debug
93
- },
94
- // Level 5
95
- trace: {
96
- level: LogLevels.trace
97
- },
98
- // Verbose
99
- verbose: {
100
- level: LogLevels.verbose
101
- }
102
- };
103
-
104
- function isObject(value) {
105
- return value !== null && typeof value === "object";
106
- }
107
- function _defu(baseObject, defaults, namespace = ".", merger) {
108
- if (!isObject(defaults)) {
109
- return _defu(baseObject, {}, namespace, merger);
110
- }
111
- const object = Object.assign({}, defaults);
112
- for (const key in baseObject) {
113
- if (key === "__proto__" || key === "constructor") {
114
- continue;
115
- }
116
- const value = baseObject[key];
117
- if (value === null || value === void 0) {
118
- continue;
119
- }
120
- if (merger && merger(object, key, value, namespace)) {
121
- continue;
122
- }
123
- if (Array.isArray(value) && Array.isArray(object[key])) {
124
- object[key] = [...value, ...object[key]];
125
- } else if (isObject(value) && isObject(object[key])) {
126
- object[key] = _defu(
127
- value,
128
- object[key],
129
- (namespace ? `${namespace}.` : "") + key.toString(),
130
- merger
131
- );
132
- } else {
133
- object[key] = value;
134
- }
135
- }
136
- return object;
137
- }
138
- function createDefu(merger) {
139
- return (...arguments_) => (
140
- // eslint-disable-next-line unicorn/no-array-reduce
141
- arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
142
- );
143
- }
144
- const defu = createDefu();
145
-
146
- function isPlainObject(obj) {
147
- return Object.prototype.toString.call(obj) === "[object Object]";
148
- }
149
- function isLogObj(arg) {
150
- if (!isPlainObject(arg)) {
151
- return false;
152
- }
153
- if (!arg.message && !arg.args) {
154
- return false;
155
- }
156
- if (arg.stack) {
157
- return false;
158
- }
159
- return true;
160
- }
161
-
162
- let paused = false;
163
- const queue = [];
164
- class Consola {
165
- constructor(options = {}) {
166
- const types = options.types || LogTypes;
167
- this.options = defu(
168
- {
169
- ...options,
170
- defaults: { ...options.defaults },
171
- level: _normalizeLogLevel(options.level, types),
172
- reporters: [...options.reporters || []]
173
- },
174
- {
175
- types: LogTypes,
176
- throttle: 1e3,
177
- throttleMin: 5,
178
- formatOptions: {
179
- date: true,
180
- colors: false,
181
- compact: true
182
- }
183
- }
184
- );
185
- for (const type in types) {
186
- const defaults = {
187
- type,
188
- ...this.options.defaults,
189
- ...types[type]
190
- };
191
- this[type] = this._wrapLogFn(defaults);
192
- this[type].raw = this._wrapLogFn(
193
- defaults,
194
- true
195
- );
196
- }
197
- if (this.options.mockFn) {
198
- this.mockTypes();
199
- }
200
- this._lastLog = {};
201
- }
202
- get level() {
203
- return this.options.level;
204
- }
205
- set level(level) {
206
- this.options.level = _normalizeLogLevel(
207
- level,
208
- this.options.types,
209
- this.options.level
210
- );
211
- }
212
- prompt(message, opts) {
213
- if (!this.options.prompt) {
214
- throw new Error("prompt is not supported!");
215
- }
216
- return this.options.prompt(message, opts);
217
- }
218
- create(options) {
219
- const instance = new Consola({
220
- ...this.options,
221
- ...options
222
- });
223
- if (this._mockFn) {
224
- instance.mockTypes(this._mockFn);
225
- }
226
- return instance;
227
- }
228
- withDefaults(defaults) {
229
- return this.create({
230
- ...this.options,
231
- defaults: {
232
- ...this.options.defaults,
233
- ...defaults
234
- }
235
- });
236
- }
237
- withTag(tag) {
238
- return this.withDefaults({
239
- tag: this.options.defaults.tag ? this.options.defaults.tag + ":" + tag : tag
240
- });
241
- }
242
- addReporter(reporter) {
243
- this.options.reporters.push(reporter);
244
- return this;
245
- }
246
- removeReporter(reporter) {
247
- if (reporter) {
248
- const i = this.options.reporters.indexOf(reporter);
249
- if (i >= 0) {
250
- return this.options.reporters.splice(i, 1);
251
- }
252
- } else {
253
- this.options.reporters.splice(0);
254
- }
255
- return this;
256
- }
257
- setReporters(reporters) {
258
- this.options.reporters = Array.isArray(reporters) ? reporters : [reporters];
259
- return this;
260
- }
261
- wrapAll() {
262
- this.wrapConsole();
263
- this.wrapStd();
264
- }
265
- restoreAll() {
266
- this.restoreConsole();
267
- this.restoreStd();
268
- }
269
- wrapConsole() {
270
- for (const type in this.options.types) {
271
- if (!console["__" + type]) {
272
- console["__" + type] = console[type];
273
- }
274
- console[type] = this[type].raw;
275
- }
276
- }
277
- restoreConsole() {
278
- for (const type in this.options.types) {
279
- if (console["__" + type]) {
280
- console[type] = console["__" + type];
281
- delete console["__" + type];
282
- }
283
- }
284
- }
285
- wrapStd() {
286
- this._wrapStream(this.options.stdout, "log");
287
- this._wrapStream(this.options.stderr, "log");
288
- }
289
- _wrapStream(stream, type) {
290
- if (!stream) {
291
- return;
292
- }
293
- if (!stream.__write) {
294
- stream.__write = stream.write;
295
- }
296
- stream.write = (data) => {
297
- this[type].raw(String(data).trim());
298
- };
299
- }
300
- restoreStd() {
301
- this._restoreStream(this.options.stdout);
302
- this._restoreStream(this.options.stderr);
303
- }
304
- _restoreStream(stream) {
305
- if (!stream) {
306
- return;
307
- }
308
- if (stream.__write) {
309
- stream.write = stream.__write;
310
- delete stream.__write;
311
- }
312
- }
313
- pauseLogs() {
314
- paused = true;
315
- }
316
- resumeLogs() {
317
- paused = false;
318
- const _queue = queue.splice(0);
319
- for (const item of _queue) {
320
- item[0]._logFn(item[1], item[2]);
321
- }
322
- }
323
- mockTypes(mockFn) {
324
- const _mockFn = mockFn || this.options.mockFn;
325
- this._mockFn = _mockFn;
326
- if (typeof _mockFn !== "function") {
327
- return;
328
- }
329
- for (const type in this.options.types) {
330
- this[type] = _mockFn(type, this.options.types[type]) || this[type];
331
- this[type].raw = this[type];
332
- }
333
- }
334
- _wrapLogFn(defaults, isRaw) {
335
- return (...args) => {
336
- if (paused) {
337
- queue.push([this, defaults, args, isRaw]);
338
- return;
339
- }
340
- return this._logFn(defaults, args, isRaw);
341
- };
342
- }
343
- _logFn(defaults, args, isRaw) {
344
- if ((defaults.level || 0) > this.level) {
345
- return false;
346
- }
347
- const logObj = {
348
- date: /* @__PURE__ */ new Date(),
349
- args: [],
350
- ...defaults,
351
- level: _normalizeLogLevel(defaults.level, this.options.types)
352
- };
353
- if (!isRaw && args.length === 1 && isLogObj(args[0])) {
354
- Object.assign(logObj, args[0]);
355
- } else {
356
- logObj.args = [...args];
357
- }
358
- if (logObj.message) {
359
- logObj.args.unshift(logObj.message);
360
- delete logObj.message;
361
- }
362
- if (logObj.additional) {
363
- if (!Array.isArray(logObj.additional)) {
364
- logObj.additional = logObj.additional.split("\n");
365
- }
366
- logObj.args.push("\n" + logObj.additional.join("\n"));
367
- delete logObj.additional;
368
- }
369
- logObj.type = typeof logObj.type === "string" ? logObj.type.toLowerCase() : "log";
370
- logObj.tag = typeof logObj.tag === "string" ? logObj.tag : "";
371
- const resolveLog = (newLog = false) => {
372
- const repeated = (this._lastLog.count || 0) - this.options.throttleMin;
373
- if (this._lastLog.object && repeated > 0) {
374
- const args2 = [...this._lastLog.object.args];
375
- if (repeated > 1) {
376
- args2.push(`(repeated ${repeated} times)`);
377
- }
378
- this._log({ ...this._lastLog.object, args: args2 });
379
- this._lastLog.count = 1;
380
- }
381
- if (newLog) {
382
- this._lastLog.object = logObj;
383
- this._log(logObj);
384
- }
385
- };
386
- clearTimeout(this._lastLog.timeout);
387
- const diffTime = this._lastLog.time && logObj.date ? logObj.date.getTime() - this._lastLog.time.getTime() : 0;
388
- this._lastLog.time = logObj.date;
389
- if (diffTime < this.options.throttle) {
390
- try {
391
- const serializedLog = JSON.stringify([
392
- logObj.type,
393
- logObj.tag,
394
- logObj.args
395
- ]);
396
- const isSameLog = this._lastLog.serialized === serializedLog;
397
- this._lastLog.serialized = serializedLog;
398
- if (isSameLog) {
399
- this._lastLog.count = (this._lastLog.count || 0) + 1;
400
- if (this._lastLog.count > this.options.throttleMin) {
401
- this._lastLog.timeout = setTimeout(
402
- resolveLog,
403
- this.options.throttle
404
- );
405
- return;
406
- }
407
- }
408
- } catch {
409
- }
410
- }
411
- resolveLog(true);
412
- }
413
- _log(logObj) {
414
- for (const reporter of this.options.reporters) {
415
- reporter.log(logObj, {
416
- options: this.options
417
- });
418
- }
419
- }
420
- }
421
- function _normalizeLogLevel(input, types = {}, defaultLevel = 3) {
422
- if (input === void 0) {
423
- return defaultLevel;
424
- }
425
- if (typeof input === "number") {
426
- return input;
427
- }
428
- if (types[input] && types[input].level !== void 0) {
429
- return types[input].level;
430
- }
431
- return defaultLevel;
432
- }
433
- Consola.prototype.add = Consola.prototype.addReporter;
434
- Consola.prototype.remove = Consola.prototype.removeReporter;
435
- Consola.prototype.clear = Consola.prototype.removeReporter;
436
- Consola.prototype.withScope = Consola.prototype.withTag;
437
- Consola.prototype.mock = Consola.prototype.mockTypes;
438
- Consola.prototype.pause = Consola.prototype.pauseLogs;
439
- Consola.prototype.resume = Consola.prototype.resumeLogs;
440
- function createConsola$1(options = {}) {
441
- return new Consola(options);
442
- }
443
-
444
- function parseStack(stack) {
445
- const cwd = process.cwd() + nodePath.sep;
446
- const lines = stack.split("\n").splice(1).map((l) => l.trim().replace("file://", "").replace(cwd, ""));
447
- return lines;
448
- }
449
-
450
- function writeStream(data, stream) {
451
- const write = stream.__write || stream.write;
452
- return write.call(stream, data);
453
- }
454
-
455
- const bracket = (x) => x ? `[${x}]` : "";
456
- class BasicReporter {
457
- formatStack(stack, opts) {
458
- return " " + parseStack(stack).join("\n ");
459
- }
460
- formatArgs(args, opts) {
461
- const _args = args.map((arg) => {
462
- if (arg && typeof arg.stack === "string") {
463
- return arg.message + "\n" + this.formatStack(arg.stack, opts);
464
- }
465
- return arg;
466
- });
467
- return node_util.formatWithOptions(opts, ..._args);
468
- }
469
- formatDate(date, opts) {
470
- return opts.date ? date.toLocaleTimeString() : "";
471
- }
472
- filterAndJoin(arr) {
473
- return arr.filter(Boolean).join(" ");
474
- }
475
- formatLogObj(logObj, opts) {
476
- const message = this.formatArgs(logObj.args, opts);
477
- if (logObj.type === "box") {
478
- return "\n" + [
479
- bracket(logObj.tag),
480
- logObj.title && logObj.title,
481
- ...message.split("\n")
482
- ].filter(Boolean).map((l) => " > " + l).join("\n") + "\n";
483
- }
484
- return this.filterAndJoin([
485
- bracket(logObj.type),
486
- bracket(logObj.tag),
487
- message
488
- ]);
489
- }
490
- log(logObj, ctx) {
491
- const line = this.formatLogObj(logObj, {
492
- columns: ctx.options.stdout.columns || 0,
493
- ...ctx.options.formatOptions
494
- });
495
- return writeStream(
496
- line + "\n",
497
- logObj.level < 2 ? ctx.options.stderr || process.stderr : ctx.options.stdout || process.stdout
498
- );
499
- }
500
- }
501
-
502
- const {
503
- env = {},
504
- argv = [],
505
- platform = ""
506
- } = typeof process === "undefined" ? {} : process;
507
- const isDisabled = "NO_COLOR" in env || argv.includes("--no-color");
508
- const isForced = "FORCE_COLOR" in env || argv.includes("--color");
509
- const isWindows = platform === "win32";
510
- const isDumbTerminal = env.TERM === "dumb";
511
- const isCompatibleTerminal = tty__namespace && tty__namespace.isatty && tty__namespace.isatty(1) && env.TERM && !isDumbTerminal;
512
- const isCI$1 = "CI" in env && ("GITHUB_ACTIONS" in env || "GITLAB_CI" in env || "CIRCLECI" in env);
513
- const isColorSupported = !isDisabled && (isForced || isWindows && !isDumbTerminal || isCompatibleTerminal || isCI$1);
514
- 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)) {
515
- return head + (next < 0 ? tail : replaceClose(next, tail, close, replace));
516
- }
517
- function clearBleed(index, string, open, close, replace) {
518
- return index < 0 ? open + string + close : open + replaceClose(index, string, close, replace) + close;
519
- }
520
- function filterEmpty(open, close, replace = open, at = open.length + 1) {
521
- return (string) => string || !(string === "" || string === void 0) ? clearBleed(
522
- ("" + string).indexOf(close, at),
523
- string,
524
- open,
525
- close,
526
- replace
527
- ) : "";
528
- }
529
- function init(open, close, replace) {
530
- return filterEmpty(`\x1B[${open}m`, `\x1B[${close}m`, replace);
531
- }
532
- const colorDefs = {
533
- reset: init(0, 0),
534
- bold: init(1, 22, "\x1B[22m\x1B[1m"),
535
- dim: init(2, 22, "\x1B[22m\x1B[2m"),
536
- italic: init(3, 23),
537
- underline: init(4, 24),
538
- inverse: init(7, 27),
539
- hidden: init(8, 28),
540
- strikethrough: init(9, 29),
541
- black: init(30, 39),
542
- red: init(31, 39),
543
- green: init(32, 39),
544
- yellow: init(33, 39),
545
- blue: init(34, 39),
546
- magenta: init(35, 39),
547
- cyan: init(36, 39),
548
- white: init(37, 39),
549
- gray: init(90, 39),
550
- bgBlack: init(40, 49),
551
- bgRed: init(41, 49),
552
- bgGreen: init(42, 49),
553
- bgYellow: init(43, 49),
554
- bgBlue: init(44, 49),
555
- bgMagenta: init(45, 49),
556
- bgCyan: init(46, 49),
557
- bgWhite: init(47, 49),
558
- blackBright: init(90, 39),
559
- redBright: init(91, 39),
560
- greenBright: init(92, 39),
561
- yellowBright: init(93, 39),
562
- blueBright: init(94, 39),
563
- magentaBright: init(95, 39),
564
- cyanBright: init(96, 39),
565
- whiteBright: init(97, 39),
566
- bgBlackBright: init(100, 49),
567
- bgRedBright: init(101, 49),
568
- bgGreenBright: init(102, 49),
569
- bgYellowBright: init(103, 49),
570
- bgBlueBright: init(104, 49),
571
- bgMagentaBright: init(105, 49),
572
- bgCyanBright: init(106, 49),
573
- bgWhiteBright: init(107, 49)
574
- };
575
- function createColors(useColor = isColorSupported) {
576
- return useColor ? colorDefs : Object.fromEntries(Object.keys(colorDefs).map((key) => [key, String]));
577
- }
578
- const colors = createColors();
579
- function getColor$1(color, fallback = "reset") {
580
- return colors[color] || colors[fallback];
581
- }
582
-
583
- const ansiRegex$1 = [
584
- "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
585
- "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"
586
- ].join("|");
587
- function stripAnsi$1(text) {
588
- return text.replace(new RegExp(ansiRegex$1, "g"), "");
589
- }
590
-
591
- const boxStylePresets = {
592
- solid: {
593
- tl: "\u250C",
594
- tr: "\u2510",
595
- bl: "\u2514",
596
- br: "\u2518",
597
- h: "\u2500",
598
- v: "\u2502"
599
- },
600
- double: {
601
- tl: "\u2554",
602
- tr: "\u2557",
603
- bl: "\u255A",
604
- br: "\u255D",
605
- h: "\u2550",
606
- v: "\u2551"
607
- },
608
- doubleSingle: {
609
- tl: "\u2553",
610
- tr: "\u2556",
611
- bl: "\u2559",
612
- br: "\u255C",
613
- h: "\u2500",
614
- v: "\u2551"
615
- },
616
- doubleSingleRounded: {
617
- tl: "\u256D",
618
- tr: "\u256E",
619
- bl: "\u2570",
620
- br: "\u256F",
621
- h: "\u2500",
622
- v: "\u2551"
623
- },
624
- singleThick: {
625
- tl: "\u250F",
626
- tr: "\u2513",
627
- bl: "\u2517",
628
- br: "\u251B",
629
- h: "\u2501",
630
- v: "\u2503"
631
- },
632
- singleDouble: {
633
- tl: "\u2552",
634
- tr: "\u2555",
635
- bl: "\u2558",
636
- br: "\u255B",
637
- h: "\u2550",
638
- v: "\u2502"
639
- },
640
- singleDoubleRounded: {
641
- tl: "\u256D",
642
- tr: "\u256E",
643
- bl: "\u2570",
644
- br: "\u256F",
645
- h: "\u2550",
646
- v: "\u2502"
647
- },
648
- rounded: {
649
- tl: "\u256D",
650
- tr: "\u256E",
651
- bl: "\u2570",
652
- br: "\u256F",
653
- h: "\u2500",
654
- v: "\u2502"
655
- }
656
- };
657
- const defaultStyle = {
658
- borderColor: "white",
659
- borderStyle: "rounded",
660
- valign: "center",
661
- padding: 2,
662
- marginLeft: 1,
663
- marginTop: 1,
664
- marginBottom: 1
665
- };
666
- function box(text, _opts = {}) {
667
- const opts = {
668
- ..._opts,
669
- style: {
670
- ...defaultStyle,
671
- ..._opts.style
672
- }
673
- };
674
- const textLines = text.split("\n");
675
- const boxLines = [];
676
- const _color = getColor$1(opts.style.borderColor);
677
- const borderStyle = {
678
- ...typeof opts.style.borderStyle === "string" ? boxStylePresets[opts.style.borderStyle] || boxStylePresets.solid : opts.style.borderStyle
679
- };
680
- if (_color) {
681
- for (const key in borderStyle) {
682
- borderStyle[key] = _color(
683
- borderStyle[key]
684
- );
685
- }
686
- }
687
- const paddingOffset = opts.style.padding % 2 === 0 ? opts.style.padding : opts.style.padding + 1;
688
- const height = textLines.length + paddingOffset;
689
- const width = Math.max(...textLines.map((line) => line.length)) + paddingOffset;
690
- const widthOffset = width + paddingOffset;
691
- const leftSpace = opts.style.marginLeft > 0 ? " ".repeat(opts.style.marginLeft) : "";
692
- if (opts.style.marginTop > 0) {
693
- boxLines.push("".repeat(opts.style.marginTop));
694
- }
695
- if (opts.title) {
696
- const left = borderStyle.h.repeat(
697
- Math.floor((width - stripAnsi$1(opts.title).length) / 2)
698
- );
699
- const right = borderStyle.h.repeat(
700
- width - stripAnsi$1(opts.title).length - stripAnsi$1(left).length + paddingOffset
701
- );
702
- boxLines.push(
703
- `${leftSpace}${borderStyle.tl}${left}${opts.title}${right}${borderStyle.tr}`
704
- );
705
- } else {
706
- boxLines.push(
707
- `${leftSpace}${borderStyle.tl}${borderStyle.h.repeat(widthOffset)}${borderStyle.tr}`
708
- );
709
- }
710
- const valignOffset = opts.style.valign === "center" ? Math.floor((height - textLines.length) / 2) : opts.style.valign === "top" ? height - textLines.length - paddingOffset : height - textLines.length;
711
- for (let i = 0; i < height; i++) {
712
- if (i < valignOffset || i >= valignOffset + textLines.length) {
713
- boxLines.push(
714
- `${leftSpace}${borderStyle.v}${" ".repeat(widthOffset)}${borderStyle.v}`
715
- );
716
- } else {
717
- const line = textLines[i - valignOffset];
718
- const left = " ".repeat(paddingOffset);
719
- const right = " ".repeat(width - stripAnsi$1(line).length);
720
- boxLines.push(
721
- `${leftSpace}${borderStyle.v}${left}${line}${right}${borderStyle.v}`
722
- );
723
- }
724
- }
725
- boxLines.push(
726
- `${leftSpace}${borderStyle.bl}${borderStyle.h.repeat(widthOffset)}${borderStyle.br}`
727
- );
728
- if (opts.style.marginBottom > 0) {
729
- boxLines.push("".repeat(opts.style.marginBottom));
730
- }
731
- return boxLines.join("\n");
732
- }
733
-
734
- const providers = [
735
- ["APPVEYOR"],
736
- ["AZURE_PIPELINES", "SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"],
737
- ["AZURE_STATIC", "INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN"],
738
- ["APPCIRCLE", "AC_APPCIRCLE"],
739
- ["BAMBOO", "bamboo_planKey"],
740
- ["BITBUCKET", "BITBUCKET_COMMIT"],
741
- ["BITRISE", "BITRISE_IO"],
742
- ["BUDDY", "BUDDY_WORKSPACE_ID"],
743
- ["BUILDKITE"],
744
- ["CIRCLE", "CIRCLECI"],
745
- ["CIRRUS", "CIRRUS_CI"],
746
- ["CLOUDFLARE_PAGES", "CF_PAGES", { ci: true }],
747
- ["CODEBUILD", "CODEBUILD_BUILD_ARN"],
748
- ["CODEFRESH", "CF_BUILD_ID"],
749
- ["DRONE"],
750
- ["DRONE", "DRONE_BUILD_EVENT"],
751
- ["DSARI"],
752
- ["GITHUB_ACTIONS"],
753
- ["GITLAB", "GITLAB_CI"],
754
- ["GITLAB", "CI_MERGE_REQUEST_ID"],
755
- ["GOCD", "GO_PIPELINE_LABEL"],
756
- ["LAYERCI"],
757
- ["HUDSON", "HUDSON_URL"],
758
- ["JENKINS", "JENKINS_URL"],
759
- ["MAGNUM"],
760
- ["NETLIFY"],
761
- ["NETLIFY", "NETLIFY_LOCAL", { ci: false }],
762
- ["NEVERCODE"],
763
- ["RENDER"],
764
- ["SAIL", "SAILCI"],
765
- ["SEMAPHORE"],
766
- ["SCREWDRIVER"],
767
- ["SHIPPABLE"],
768
- ["SOLANO", "TDDIUM"],
769
- ["STRIDER"],
770
- ["TEAMCITY", "TEAMCITY_VERSION"],
771
- ["TRAVIS"],
772
- ["VERCEL", "NOW_BUILDER"],
773
- ["APPCENTER", "APPCENTER_BUILD_ID"],
774
- ["CODESANDBOX", "CODESANDBOX_SSE", { ci: false }],
775
- ["STACKBLITZ"],
776
- ["STORMKIT"],
777
- ["CLEAVR"]
778
- ];
779
- function detectProvider(env) {
780
- for (const provider of providers) {
781
- const envName = provider[1] || provider[0];
782
- if (env[envName]) {
783
- return {
784
- name: provider[0].toLowerCase(),
785
- ...provider[2]
786
- };
787
- }
788
- }
789
- if (env.SHELL && env.SHELL === "/bin/jsh") {
790
- return {
791
- name: "stackblitz",
792
- ci: false
793
- };
794
- }
795
- return {
796
- name: "",
797
- ci: false
798
- };
799
- }
800
-
801
- const processShim = typeof process !== "undefined" ? process : {};
802
- const envShim = processShim.env || {};
803
- const providerInfo = detectProvider(envShim);
804
- const nodeENV = typeof process !== "undefined" && process.env && process.env.NODE_ENV || "";
805
- processShim.platform;
806
- providerInfo.name;
807
- const isCI = toBoolean(envShim.CI) || providerInfo.ci !== false;
808
- const hasTTY = toBoolean(processShim.stdout && processShim.stdout.isTTY);
809
- const isDebug = toBoolean(envShim.DEBUG);
810
- const isTest = nodeENV === "test" || toBoolean(envShim.TEST);
811
- toBoolean(envShim.MINIMAL) || isCI || isTest || !hasTTY;
812
- function toBoolean(val) {
813
- return val ? val !== "false" : false;
814
- }
815
-
816
- function ansiRegex({onlyFirst = false} = {}) {
817
- const pattern = [
818
- '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)',
819
- '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'
820
- ].join('|');
821
-
822
- return new RegExp(pattern, onlyFirst ? undefined : 'g');
823
- }
824
-
825
- const regex = ansiRegex();
826
-
827
- function stripAnsi(string) {
828
- if (typeof string !== 'string') {
829
- throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
830
- }
831
-
832
- // Even though the regex is global, we don't need to reset the `.lastIndex`
833
- // because unlike `.exec()` and `.test()`, `.replace()` does it automatically
834
- // and doing it manually has a performance penalty.
835
- return string.replace(regex, '');
836
- }
837
-
838
- function getDefaultExportFromCjs (x) {
839
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
840
- }
841
-
842
- var eastasianwidth = {exports: {}};
843
-
844
- (function (module) {
845
- var eaw = {};
846
-
847
- {
848
- module.exports = eaw;
849
- }
850
-
851
- eaw.eastAsianWidth = function(character) {
852
- var x = character.charCodeAt(0);
853
- var y = (character.length == 2) ? character.charCodeAt(1) : 0;
854
- var codePoint = x;
855
- if ((0xD800 <= x && x <= 0xDBFF) && (0xDC00 <= y && y <= 0xDFFF)) {
856
- x &= 0x3FF;
857
- y &= 0x3FF;
858
- codePoint = (x << 10) | y;
859
- codePoint += 0x10000;
860
- }
861
-
862
- if ((0x3000 == codePoint) ||
863
- (0xFF01 <= codePoint && codePoint <= 0xFF60) ||
864
- (0xFFE0 <= codePoint && codePoint <= 0xFFE6)) {
865
- return 'F';
866
- }
867
- if ((0x20A9 == codePoint) ||
868
- (0xFF61 <= codePoint && codePoint <= 0xFFBE) ||
869
- (0xFFC2 <= codePoint && codePoint <= 0xFFC7) ||
870
- (0xFFCA <= codePoint && codePoint <= 0xFFCF) ||
871
- (0xFFD2 <= codePoint && codePoint <= 0xFFD7) ||
872
- (0xFFDA <= codePoint && codePoint <= 0xFFDC) ||
873
- (0xFFE8 <= codePoint && codePoint <= 0xFFEE)) {
874
- return 'H';
875
- }
876
- if ((0x1100 <= codePoint && codePoint <= 0x115F) ||
877
- (0x11A3 <= codePoint && codePoint <= 0x11A7) ||
878
- (0x11FA <= codePoint && codePoint <= 0x11FF) ||
879
- (0x2329 <= codePoint && codePoint <= 0x232A) ||
880
- (0x2E80 <= codePoint && codePoint <= 0x2E99) ||
881
- (0x2E9B <= codePoint && codePoint <= 0x2EF3) ||
882
- (0x2F00 <= codePoint && codePoint <= 0x2FD5) ||
883
- (0x2FF0 <= codePoint && codePoint <= 0x2FFB) ||
884
- (0x3001 <= codePoint && codePoint <= 0x303E) ||
885
- (0x3041 <= codePoint && codePoint <= 0x3096) ||
886
- (0x3099 <= codePoint && codePoint <= 0x30FF) ||
887
- (0x3105 <= codePoint && codePoint <= 0x312D) ||
888
- (0x3131 <= codePoint && codePoint <= 0x318E) ||
889
- (0x3190 <= codePoint && codePoint <= 0x31BA) ||
890
- (0x31C0 <= codePoint && codePoint <= 0x31E3) ||
891
- (0x31F0 <= codePoint && codePoint <= 0x321E) ||
892
- (0x3220 <= codePoint && codePoint <= 0x3247) ||
893
- (0x3250 <= codePoint && codePoint <= 0x32FE) ||
894
- (0x3300 <= codePoint && codePoint <= 0x4DBF) ||
895
- (0x4E00 <= codePoint && codePoint <= 0xA48C) ||
896
- (0xA490 <= codePoint && codePoint <= 0xA4C6) ||
897
- (0xA960 <= codePoint && codePoint <= 0xA97C) ||
898
- (0xAC00 <= codePoint && codePoint <= 0xD7A3) ||
899
- (0xD7B0 <= codePoint && codePoint <= 0xD7C6) ||
900
- (0xD7CB <= codePoint && codePoint <= 0xD7FB) ||
901
- (0xF900 <= codePoint && codePoint <= 0xFAFF) ||
902
- (0xFE10 <= codePoint && codePoint <= 0xFE19) ||
903
- (0xFE30 <= codePoint && codePoint <= 0xFE52) ||
904
- (0xFE54 <= codePoint && codePoint <= 0xFE66) ||
905
- (0xFE68 <= codePoint && codePoint <= 0xFE6B) ||
906
- (0x1B000 <= codePoint && codePoint <= 0x1B001) ||
907
- (0x1F200 <= codePoint && codePoint <= 0x1F202) ||
908
- (0x1F210 <= codePoint && codePoint <= 0x1F23A) ||
909
- (0x1F240 <= codePoint && codePoint <= 0x1F248) ||
910
- (0x1F250 <= codePoint && codePoint <= 0x1F251) ||
911
- (0x20000 <= codePoint && codePoint <= 0x2F73F) ||
912
- (0x2B740 <= codePoint && codePoint <= 0x2FFFD) ||
913
- (0x30000 <= codePoint && codePoint <= 0x3FFFD)) {
914
- return 'W';
915
- }
916
- if ((0x0020 <= codePoint && codePoint <= 0x007E) ||
917
- (0x00A2 <= codePoint && codePoint <= 0x00A3) ||
918
- (0x00A5 <= codePoint && codePoint <= 0x00A6) ||
919
- (0x00AC == codePoint) ||
920
- (0x00AF == codePoint) ||
921
- (0x27E6 <= codePoint && codePoint <= 0x27ED) ||
922
- (0x2985 <= codePoint && codePoint <= 0x2986)) {
923
- return 'Na';
924
- }
925
- if ((0x00A1 == codePoint) ||
926
- (0x00A4 == codePoint) ||
927
- (0x00A7 <= codePoint && codePoint <= 0x00A8) ||
928
- (0x00AA == codePoint) ||
929
- (0x00AD <= codePoint && codePoint <= 0x00AE) ||
930
- (0x00B0 <= codePoint && codePoint <= 0x00B4) ||
931
- (0x00B6 <= codePoint && codePoint <= 0x00BA) ||
932
- (0x00BC <= codePoint && codePoint <= 0x00BF) ||
933
- (0x00C6 == codePoint) ||
934
- (0x00D0 == codePoint) ||
935
- (0x00D7 <= codePoint && codePoint <= 0x00D8) ||
936
- (0x00DE <= codePoint && codePoint <= 0x00E1) ||
937
- (0x00E6 == codePoint) ||
938
- (0x00E8 <= codePoint && codePoint <= 0x00EA) ||
939
- (0x00EC <= codePoint && codePoint <= 0x00ED) ||
940
- (0x00F0 == codePoint) ||
941
- (0x00F2 <= codePoint && codePoint <= 0x00F3) ||
942
- (0x00F7 <= codePoint && codePoint <= 0x00FA) ||
943
- (0x00FC == codePoint) ||
944
- (0x00FE == codePoint) ||
945
- (0x0101 == codePoint) ||
946
- (0x0111 == codePoint) ||
947
- (0x0113 == codePoint) ||
948
- (0x011B == codePoint) ||
949
- (0x0126 <= codePoint && codePoint <= 0x0127) ||
950
- (0x012B == codePoint) ||
951
- (0x0131 <= codePoint && codePoint <= 0x0133) ||
952
- (0x0138 == codePoint) ||
953
- (0x013F <= codePoint && codePoint <= 0x0142) ||
954
- (0x0144 == codePoint) ||
955
- (0x0148 <= codePoint && codePoint <= 0x014B) ||
956
- (0x014D == codePoint) ||
957
- (0x0152 <= codePoint && codePoint <= 0x0153) ||
958
- (0x0166 <= codePoint && codePoint <= 0x0167) ||
959
- (0x016B == codePoint) ||
960
- (0x01CE == codePoint) ||
961
- (0x01D0 == codePoint) ||
962
- (0x01D2 == codePoint) ||
963
- (0x01D4 == codePoint) ||
964
- (0x01D6 == codePoint) ||
965
- (0x01D8 == codePoint) ||
966
- (0x01DA == codePoint) ||
967
- (0x01DC == codePoint) ||
968
- (0x0251 == codePoint) ||
969
- (0x0261 == codePoint) ||
970
- (0x02C4 == codePoint) ||
971
- (0x02C7 == codePoint) ||
972
- (0x02C9 <= codePoint && codePoint <= 0x02CB) ||
973
- (0x02CD == codePoint) ||
974
- (0x02D0 == codePoint) ||
975
- (0x02D8 <= codePoint && codePoint <= 0x02DB) ||
976
- (0x02DD == codePoint) ||
977
- (0x02DF == codePoint) ||
978
- (0x0300 <= codePoint && codePoint <= 0x036F) ||
979
- (0x0391 <= codePoint && codePoint <= 0x03A1) ||
980
- (0x03A3 <= codePoint && codePoint <= 0x03A9) ||
981
- (0x03B1 <= codePoint && codePoint <= 0x03C1) ||
982
- (0x03C3 <= codePoint && codePoint <= 0x03C9) ||
983
- (0x0401 == codePoint) ||
984
- (0x0410 <= codePoint && codePoint <= 0x044F) ||
985
- (0x0451 == codePoint) ||
986
- (0x2010 == codePoint) ||
987
- (0x2013 <= codePoint && codePoint <= 0x2016) ||
988
- (0x2018 <= codePoint && codePoint <= 0x2019) ||
989
- (0x201C <= codePoint && codePoint <= 0x201D) ||
990
- (0x2020 <= codePoint && codePoint <= 0x2022) ||
991
- (0x2024 <= codePoint && codePoint <= 0x2027) ||
992
- (0x2030 == codePoint) ||
993
- (0x2032 <= codePoint && codePoint <= 0x2033) ||
994
- (0x2035 == codePoint) ||
995
- (0x203B == codePoint) ||
996
- (0x203E == codePoint) ||
997
- (0x2074 == codePoint) ||
998
- (0x207F == codePoint) ||
999
- (0x2081 <= codePoint && codePoint <= 0x2084) ||
1000
- (0x20AC == codePoint) ||
1001
- (0x2103 == codePoint) ||
1002
- (0x2105 == codePoint) ||
1003
- (0x2109 == codePoint) ||
1004
- (0x2113 == codePoint) ||
1005
- (0x2116 == codePoint) ||
1006
- (0x2121 <= codePoint && codePoint <= 0x2122) ||
1007
- (0x2126 == codePoint) ||
1008
- (0x212B == codePoint) ||
1009
- (0x2153 <= codePoint && codePoint <= 0x2154) ||
1010
- (0x215B <= codePoint && codePoint <= 0x215E) ||
1011
- (0x2160 <= codePoint && codePoint <= 0x216B) ||
1012
- (0x2170 <= codePoint && codePoint <= 0x2179) ||
1013
- (0x2189 == codePoint) ||
1014
- (0x2190 <= codePoint && codePoint <= 0x2199) ||
1015
- (0x21B8 <= codePoint && codePoint <= 0x21B9) ||
1016
- (0x21D2 == codePoint) ||
1017
- (0x21D4 == codePoint) ||
1018
- (0x21E7 == codePoint) ||
1019
- (0x2200 == codePoint) ||
1020
- (0x2202 <= codePoint && codePoint <= 0x2203) ||
1021
- (0x2207 <= codePoint && codePoint <= 0x2208) ||
1022
- (0x220B == codePoint) ||
1023
- (0x220F == codePoint) ||
1024
- (0x2211 == codePoint) ||
1025
- (0x2215 == codePoint) ||
1026
- (0x221A == codePoint) ||
1027
- (0x221D <= codePoint && codePoint <= 0x2220) ||
1028
- (0x2223 == codePoint) ||
1029
- (0x2225 == codePoint) ||
1030
- (0x2227 <= codePoint && codePoint <= 0x222C) ||
1031
- (0x222E == codePoint) ||
1032
- (0x2234 <= codePoint && codePoint <= 0x2237) ||
1033
- (0x223C <= codePoint && codePoint <= 0x223D) ||
1034
- (0x2248 == codePoint) ||
1035
- (0x224C == codePoint) ||
1036
- (0x2252 == codePoint) ||
1037
- (0x2260 <= codePoint && codePoint <= 0x2261) ||
1038
- (0x2264 <= codePoint && codePoint <= 0x2267) ||
1039
- (0x226A <= codePoint && codePoint <= 0x226B) ||
1040
- (0x226E <= codePoint && codePoint <= 0x226F) ||
1041
- (0x2282 <= codePoint && codePoint <= 0x2283) ||
1042
- (0x2286 <= codePoint && codePoint <= 0x2287) ||
1043
- (0x2295 == codePoint) ||
1044
- (0x2299 == codePoint) ||
1045
- (0x22A5 == codePoint) ||
1046
- (0x22BF == codePoint) ||
1047
- (0x2312 == codePoint) ||
1048
- (0x2460 <= codePoint && codePoint <= 0x24E9) ||
1049
- (0x24EB <= codePoint && codePoint <= 0x254B) ||
1050
- (0x2550 <= codePoint && codePoint <= 0x2573) ||
1051
- (0x2580 <= codePoint && codePoint <= 0x258F) ||
1052
- (0x2592 <= codePoint && codePoint <= 0x2595) ||
1053
- (0x25A0 <= codePoint && codePoint <= 0x25A1) ||
1054
- (0x25A3 <= codePoint && codePoint <= 0x25A9) ||
1055
- (0x25B2 <= codePoint && codePoint <= 0x25B3) ||
1056
- (0x25B6 <= codePoint && codePoint <= 0x25B7) ||
1057
- (0x25BC <= codePoint && codePoint <= 0x25BD) ||
1058
- (0x25C0 <= codePoint && codePoint <= 0x25C1) ||
1059
- (0x25C6 <= codePoint && codePoint <= 0x25C8) ||
1060
- (0x25CB == codePoint) ||
1061
- (0x25CE <= codePoint && codePoint <= 0x25D1) ||
1062
- (0x25E2 <= codePoint && codePoint <= 0x25E5) ||
1063
- (0x25EF == codePoint) ||
1064
- (0x2605 <= codePoint && codePoint <= 0x2606) ||
1065
- (0x2609 == codePoint) ||
1066
- (0x260E <= codePoint && codePoint <= 0x260F) ||
1067
- (0x2614 <= codePoint && codePoint <= 0x2615) ||
1068
- (0x261C == codePoint) ||
1069
- (0x261E == codePoint) ||
1070
- (0x2640 == codePoint) ||
1071
- (0x2642 == codePoint) ||
1072
- (0x2660 <= codePoint && codePoint <= 0x2661) ||
1073
- (0x2663 <= codePoint && codePoint <= 0x2665) ||
1074
- (0x2667 <= codePoint && codePoint <= 0x266A) ||
1075
- (0x266C <= codePoint && codePoint <= 0x266D) ||
1076
- (0x266F == codePoint) ||
1077
- (0x269E <= codePoint && codePoint <= 0x269F) ||
1078
- (0x26BE <= codePoint && codePoint <= 0x26BF) ||
1079
- (0x26C4 <= codePoint && codePoint <= 0x26CD) ||
1080
- (0x26CF <= codePoint && codePoint <= 0x26E1) ||
1081
- (0x26E3 == codePoint) ||
1082
- (0x26E8 <= codePoint && codePoint <= 0x26FF) ||
1083
- (0x273D == codePoint) ||
1084
- (0x2757 == codePoint) ||
1085
- (0x2776 <= codePoint && codePoint <= 0x277F) ||
1086
- (0x2B55 <= codePoint && codePoint <= 0x2B59) ||
1087
- (0x3248 <= codePoint && codePoint <= 0x324F) ||
1088
- (0xE000 <= codePoint && codePoint <= 0xF8FF) ||
1089
- (0xFE00 <= codePoint && codePoint <= 0xFE0F) ||
1090
- (0xFFFD == codePoint) ||
1091
- (0x1F100 <= codePoint && codePoint <= 0x1F10A) ||
1092
- (0x1F110 <= codePoint && codePoint <= 0x1F12D) ||
1093
- (0x1F130 <= codePoint && codePoint <= 0x1F169) ||
1094
- (0x1F170 <= codePoint && codePoint <= 0x1F19A) ||
1095
- (0xE0100 <= codePoint && codePoint <= 0xE01EF) ||
1096
- (0xF0000 <= codePoint && codePoint <= 0xFFFFD) ||
1097
- (0x100000 <= codePoint && codePoint <= 0x10FFFD)) {
1098
- return 'A';
1099
- }
1100
-
1101
- return 'N';
1102
- };
1103
-
1104
- eaw.characterLength = function(character) {
1105
- var code = this.eastAsianWidth(character);
1106
- if (code == 'F' || code == 'W' || code == 'A') {
1107
- return 2;
1108
- } else {
1109
- return 1;
1110
- }
1111
- };
1112
-
1113
- // Split a string considering surrogate-pairs.
1114
- function stringToArray(string) {
1115
- return string.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g) || [];
1116
- }
1117
-
1118
- eaw.length = function(string) {
1119
- var characters = stringToArray(string);
1120
- var len = 0;
1121
- for (var i = 0; i < characters.length; i++) {
1122
- len = len + this.characterLength(characters[i]);
1123
- }
1124
- return len;
1125
- };
1126
-
1127
- eaw.slice = function(text, start, end) {
1128
- textLen = eaw.length(text);
1129
- start = start ? start : 0;
1130
- end = end ? end : 1;
1131
- if (start < 0) {
1132
- start = textLen + start;
1133
- }
1134
- if (end < 0) {
1135
- end = textLen + end;
1136
- }
1137
- var result = '';
1138
- var eawLen = 0;
1139
- var chars = stringToArray(text);
1140
- for (var i = 0; i < chars.length; i++) {
1141
- var char = chars[i];
1142
- var charLen = eaw.length(char);
1143
- if (eawLen >= start - (charLen == 2 ? 1 : 0)) {
1144
- if (eawLen + charLen <= end) {
1145
- result += char;
1146
- } else {
1147
- break;
1148
- }
1149
- }
1150
- eawLen += charLen;
1151
- }
1152
- return result;
1153
- };
1154
- } (eastasianwidth));
1155
-
1156
- var eastasianwidthExports = eastasianwidth.exports;
1157
- const eastAsianWidth = /*@__PURE__*/getDefaultExportFromCjs(eastasianwidthExports);
1158
-
1159
- const emojiRegex = () => {
1160
- // https://mths.be/emoji
1161
- 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;
1162
- };
1163
-
1164
- function stringWidth$1(string, options) {
1165
- if (typeof string !== 'string' || string.length === 0) {
1166
- return 0;
1167
- }
1168
-
1169
- options = {
1170
- ambiguousIsNarrow: true,
1171
- countAnsiEscapeCodes: false,
1172
- ...options,
1173
- };
1174
-
1175
- if (!options.countAnsiEscapeCodes) {
1176
- string = stripAnsi(string);
1177
- }
1178
-
1179
- if (string.length === 0) {
1180
- return 0;
1181
- }
1182
-
1183
- const ambiguousCharacterWidth = options.ambiguousIsNarrow ? 1 : 2;
1184
- let width = 0;
1185
-
1186
- for (const {segment: character} of new Intl.Segmenter().segment(string)) {
1187
- const codePoint = character.codePointAt(0);
1188
-
1189
- // Ignore control characters
1190
- if (codePoint <= 0x1F || (codePoint >= 0x7F && codePoint <= 0x9F)) {
1191
- continue;
1192
- }
1193
-
1194
- // Ignore combining characters
1195
- if (codePoint >= 0x3_00 && codePoint <= 0x3_6F) {
1196
- continue;
1197
- }
1198
-
1199
- if (emojiRegex().test(character)) {
1200
- width += 2;
1201
- continue;
1202
- }
1203
-
1204
- const code = eastAsianWidth.eastAsianWidth(character);
1205
- switch (code) {
1206
- case 'F':
1207
- case 'W': {
1208
- width += 2;
1209
- break;
1210
- }
1211
-
1212
- case 'A': {
1213
- width += ambiguousCharacterWidth;
1214
- break;
1215
- }
1216
-
1217
- default: {
1218
- width += 1;
1219
- }
1220
- }
1221
- }
1222
-
1223
- return width;
1224
- }
1225
-
1226
- function isUnicodeSupported() {
1227
- if (process$1__default.platform !== 'win32') {
1228
- return process$1__default.env.TERM !== 'linux'; // Linux console (kernel)
1229
- }
1230
-
1231
- return Boolean(process$1__default.env.CI)
1232
- || Boolean(process$1__default.env.WT_SESSION) // Windows Terminal
1233
- || Boolean(process$1__default.env.TERMINUS_SUBLIME) // Terminus (<0.2.27)
1234
- || process$1__default.env.ConEmuTask === '{cmd::Cmder}' // ConEmu and cmder
1235
- || process$1__default.env.TERM_PROGRAM === 'Terminus-Sublime'
1236
- || process$1__default.env.TERM_PROGRAM === 'vscode'
1237
- || process$1__default.env.TERM === 'xterm-256color'
1238
- || process$1__default.env.TERM === 'alacritty'
1239
- || process$1__default.env.TERMINAL_EMULATOR === 'JetBrains-JediTerm';
1240
- }
1241
-
1242
- const TYPE_COLOR_MAP = {
1243
- info: "cyan",
1244
- fail: "red",
1245
- success: "green",
1246
- ready: "green",
1247
- start: "magenta"
1248
- };
1249
- const LEVEL_COLOR_MAP = {
1250
- 0: "red",
1251
- 1: "yellow"
1252
- };
1253
- const unicode = isUnicodeSupported();
1254
- const s = (c, fallback) => unicode ? c : fallback;
1255
- const TYPE_ICONS = {
1256
- error: s("\u2716", "\xD7"),
1257
- fatal: s("\u2716", "\xD7"),
1258
- ready: s("\u2714", "\u221A"),
1259
- warn: s("\u26A0", "\u203C"),
1260
- info: s("\u2139", "i"),
1261
- success: s("\u2714", "\u221A"),
1262
- debug: s("\u2699", "D"),
1263
- trace: s("\u2192", "\u2192"),
1264
- fail: s("\u2716", "\xD7"),
1265
- start: s("\u25D0", "o"),
1266
- log: ""
1267
- };
1268
- function stringWidth(str) {
1269
- if (!Intl.Segmenter) {
1270
- return stripAnsi$1(str).length;
1271
- }
1272
- return stringWidth$1(str);
1273
- }
1274
- class FancyReporter extends BasicReporter {
1275
- formatStack(stack) {
1276
- return "\n" + parseStack(stack).map(
1277
- (line) => " " + line.replace(/^at +/, (m) => colors.gray(m)).replace(/\((.+)\)/, (_, m) => `(${colors.cyan(m)})`)
1278
- ).join("\n");
1279
- }
1280
- formatType(logObj, isBadge, opts) {
1281
- const typeColor = TYPE_COLOR_MAP[logObj.type] || LEVEL_COLOR_MAP[logObj.level] || "gray";
1282
- if (isBadge) {
1283
- return getBgColor(typeColor)(
1284
- colors.black(` ${logObj.type.toUpperCase()} `)
1285
- );
1286
- }
1287
- const _type = typeof TYPE_ICONS[logObj.type] === "string" ? TYPE_ICONS[logObj.type] : logObj.icon || logObj.type;
1288
- return _type ? getColor(typeColor)(_type) : "";
1289
- }
1290
- formatLogObj(logObj, opts) {
1291
- const [message, ...additional] = this.formatArgs(logObj.args, opts).split(
1292
- "\n"
1293
- );
1294
- if (logObj.type === "box") {
1295
- return box(
1296
- characterFormat(
1297
- message + (additional.length > 0 ? "\n" + additional.join("\n") : "")
1298
- ),
1299
- {
1300
- title: logObj.title ? characterFormat(logObj.title) : void 0,
1301
- style: logObj.style
1302
- }
1303
- );
1304
- }
1305
- const date = this.formatDate(logObj.date, opts);
1306
- const coloredDate = date && colors.gray(date);
1307
- const isBadge = logObj.badge ?? logObj.level < 2;
1308
- const type = this.formatType(logObj, isBadge, opts);
1309
- const tag = logObj.tag ? colors.gray(logObj.tag) : "";
1310
- let line;
1311
- const left = this.filterAndJoin([type, characterFormat(message)]);
1312
- const right = this.filterAndJoin(opts.columns ? [tag, coloredDate] : [tag]);
1313
- const space = (opts.columns || 0) - stringWidth(left) - stringWidth(right) - 2;
1314
- line = space > 0 && (opts.columns || 0) >= 80 ? left + " ".repeat(space) + right : (right ? `${colors.gray(`[${right}]`)} ` : "") + left;
1315
- line += characterFormat(
1316
- additional.length > 0 ? "\n" + additional.join("\n") : ""
1317
- );
1318
- if (logObj.type === "trace") {
1319
- const _err = new Error("Trace: " + logObj.message);
1320
- line += this.formatStack(_err.stack || "");
1321
- }
1322
- return isBadge ? "\n" + line + "\n" : line;
1323
- }
1324
- }
1325
- function characterFormat(str) {
1326
- return str.replace(/`([^`]+)`/gm, (_, m) => colors.cyan(m)).replace(/\s+_([^_]+)_\s+/gm, (_, m) => ` ${colors.underline(m)} `);
1327
- }
1328
- function getColor(color = "white") {
1329
- return colors[color] || colors.white;
1330
- }
1331
- function getBgColor(color = "bgWhite") {
1332
- return colors[`bg${color[0].toUpperCase()}${color.slice(1)}`] || colors.bgWhite;
1333
- }
1334
-
1335
- function createConsola(options = {}) {
1336
- let level = _getDefaultLogLevel();
1337
- if (process.env.CONSOLA_LEVEL) {
1338
- level = Number.parseInt(process.env.CONSOLA_LEVEL) ?? level;
1339
- }
1340
- const consola2 = createConsola$1({
1341
- level,
1342
- defaults: { level },
1343
- stdout: process.stdout,
1344
- stderr: process.stderr,
1345
- prompt: (...args) => import('./chunks/prompt.cjs').then((m) => m.prompt(...args)),
1346
- reporters: options.reporters || [
1347
- options.fancy ?? !(isCI || isTest) ? new FancyReporter() : new BasicReporter()
1348
- ],
1349
- ...options
1350
- });
1351
- return consola2;
1352
- }
1353
- function _getDefaultLogLevel() {
1354
- if (isDebug) {
1355
- return LogLevels.debug;
1356
- }
1357
- if (isTest) {
1358
- return LogLevels.warn;
1359
- }
1360
- return LogLevels.info;
1361
- }
1362
- const consola = createConsola();
1363
-
1364
- function toArray(val) {
1365
- if (Array.isArray(val)) {
1366
- return val;
1367
- }
1368
- return val === void 0 ? [] : [val];
1369
- }
1370
- function formatLineColumns(lines, linePrefix = "") {
1371
- const maxLengh = [];
1372
- for (const line of lines) {
1373
- for (const [i, element] of line.entries()) {
1374
- maxLengh[i] = Math.max(maxLengh[i] || 0, element.length);
1375
- }
1376
- }
1377
- return lines.map(
1378
- (l) => l.map(
1379
- (c, i) => linePrefix + c[i === 0 ? "padStart" : "padEnd"](maxLengh[i])
1380
- ).join(" ")
1381
- ).join("\n");
1382
- }
1383
- function resolveValue(input) {
1384
- return typeof input === "function" ? input() : input;
1385
- }
1386
- class CLIError extends Error {
1387
- constructor(message, code) {
1388
- super(message);
1389
- this.code = code;
1390
- this.name = "CLIError";
1391
- }
1392
- }
1393
-
1394
- const NUMBER_CHAR_RE = /\d/;
1395
- const STR_SPLITTERS = ["-", "_", "/", "."];
1396
- function isUppercase(char = "") {
1397
- if (NUMBER_CHAR_RE.test(char)) {
1398
- return void 0;
1399
- }
1400
- return char !== char.toLowerCase();
1401
- }
1402
- function splitByCase(str, separators) {
1403
- const splitters = separators ?? STR_SPLITTERS;
1404
- const parts = [];
1405
- if (!str || typeof str !== "string") {
1406
- return parts;
1407
- }
1408
- let buff = "";
1409
- let previousUpper;
1410
- let previousSplitter;
1411
- for (const char of str) {
1412
- const isSplitter = splitters.includes(char);
1413
- if (isSplitter === true) {
1414
- parts.push(buff);
1415
- buff = "";
1416
- previousUpper = void 0;
1417
- continue;
1418
- }
1419
- const isUpper = isUppercase(char);
1420
- if (previousSplitter === false) {
1421
- if (previousUpper === false && isUpper === true) {
1422
- parts.push(buff);
1423
- buff = char;
1424
- previousUpper = isUpper;
1425
- continue;
1426
- }
1427
- if (previousUpper === true && isUpper === false && buff.length > 1) {
1428
- const lastChar = buff.at(-1);
1429
- parts.push(buff.slice(0, Math.max(0, buff.length - 1)));
1430
- buff = lastChar + char;
1431
- previousUpper = isUpper;
1432
- continue;
1433
- }
1434
- }
1435
- buff += char;
1436
- previousUpper = isUpper;
1437
- previousSplitter = isSplitter;
1438
- }
1439
- parts.push(buff);
1440
- return parts;
1441
- }
1442
- function upperFirst(str) {
1443
- return str ? str[0].toUpperCase() + str.slice(1) : "";
1444
- }
1445
- function lowerFirst(str) {
1446
- return str ? str[0].toLowerCase() + str.slice(1) : "";
1447
- }
1448
- function pascalCase(str, opts) {
1449
- return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => upperFirst(opts?.normalize ? p.toLowerCase() : p)).join("") : "";
1450
- }
1451
- function camelCase(str, opts) {
1452
- return lowerFirst(pascalCase(str || "", opts));
1453
- }
1454
- function kebabCase(str, joiner) {
1455
- return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => p.toLowerCase()).join(joiner ?? "-") : "";
1456
- }
1457
-
1458
- function toArr(any) {
1459
- return any == void 0 ? [] : Array.isArray(any) ? any : [any];
1460
- }
1461
- function toVal(out, key, val, opts) {
1462
- let x;
1463
- const old = out[key];
1464
- const nxt = ~opts.string.indexOf(key) ? val == void 0 || val === true ? "" : String(val) : typeof val === "boolean" ? val : ~opts.boolean.indexOf(key) ? val === "false" ? false : val === "true" || (out._.push((x = +val, x * 0 === 0) ? x : val), !!val) : (x = +val, x * 0 === 0) ? x : val;
1465
- out[key] = old == void 0 ? nxt : Array.isArray(old) ? old.concat(nxt) : [old, nxt];
1466
- }
1467
- function parseRawArgs(args = [], opts = {}) {
1468
- let k;
1469
- let arr;
1470
- let arg;
1471
- let name;
1472
- let val;
1473
- const out = { _: [] };
1474
- let i = 0;
1475
- let j = 0;
1476
- let idx = 0;
1477
- const len = args.length;
1478
- const alibi = opts.alias !== void 0;
1479
- const strict = opts.unknown !== void 0;
1480
- const defaults = opts.default !== void 0;
1481
- opts.alias = opts.alias || {};
1482
- opts.string = toArr(opts.string);
1483
- opts.boolean = toArr(opts.boolean);
1484
- if (alibi) {
1485
- for (k in opts.alias) {
1486
- arr = opts.alias[k] = toArr(opts.alias[k]);
1487
- for (i = 0; i < arr.length; i++) {
1488
- (opts.alias[arr[i]] = arr.concat(k)).splice(i, 1);
1489
- }
1490
- }
1491
- }
1492
- for (i = opts.boolean.length; i-- > 0; ) {
1493
- arr = opts.alias[opts.boolean[i]] || [];
1494
- for (j = arr.length; j-- > 0; ) {
1495
- opts.boolean.push(arr[j]);
1496
- }
1497
- }
1498
- for (i = opts.string.length; i-- > 0; ) {
1499
- arr = opts.alias[opts.string[i]] || [];
1500
- for (j = arr.length; j-- > 0; ) {
1501
- opts.string.push(arr[j]);
1502
- }
1503
- }
1504
- if (defaults) {
1505
- for (k in opts.default) {
1506
- name = typeof opts.default[k];
1507
- arr = opts.alias[k] = opts.alias[k] || [];
1508
- if (opts[name] !== void 0) {
1509
- opts[name].push(k);
1510
- for (i = 0; i < arr.length; i++) {
1511
- opts[name].push(arr[i]);
1512
- }
1513
- }
1514
- }
1515
- }
1516
- const keys = strict ? Object.keys(opts.alias) : [];
1517
- for (i = 0; i < len; i++) {
1518
- arg = args[i];
1519
- if (arg === "--") {
1520
- out._ = out._.concat(args.slice(++i));
1521
- break;
1522
- }
1523
- for (j = 0; j < arg.length; j++) {
1524
- if (arg.charCodeAt(j) !== 45) {
1525
- break;
1526
- }
1527
- }
1528
- if (j === 0) {
1529
- out._.push(arg);
1530
- } else if (arg.substring(j, j + 3) === "no-") {
1531
- name = arg.slice(Math.max(0, j + 3));
1532
- if (strict && !~keys.indexOf(name)) {
1533
- return opts.unknown(arg);
1534
- }
1535
- out[name] = false;
1536
- } else {
1537
- for (idx = j + 1; idx < arg.length; idx++) {
1538
- if (arg.charCodeAt(idx) === 61) {
1539
- break;
1540
- }
1541
- }
1542
- name = arg.substring(j, idx);
1543
- val = arg.slice(Math.max(0, ++idx)) || i + 1 === len || ("" + args[i + 1]).charCodeAt(0) === 45 || args[++i];
1544
- arr = j === 2 ? [name] : name;
1545
- for (idx = 0; idx < arr.length; idx++) {
1546
- name = arr[idx];
1547
- if (strict && !~keys.indexOf(name)) {
1548
- return opts.unknown("-".repeat(j) + name);
1549
- }
1550
- toVal(out, name, idx + 1 < arr.length || val, opts);
1551
- }
1552
- }
1553
- }
1554
- if (defaults) {
1555
- for (k in opts.default) {
1556
- if (out[k] === void 0) {
1557
- out[k] = opts.default[k];
1558
- }
1559
- }
1560
- }
1561
- if (alibi) {
1562
- for (k in out) {
1563
- arr = opts.alias[k] || [];
1564
- while (arr.length > 0) {
1565
- out[arr.shift()] = out[k];
1566
- }
1567
- }
1568
- }
1569
- return out;
1570
- }
1571
-
1572
- function parseArgs$1(rawArgs, argsDef) {
1573
- const parseOptions = {
1574
- boolean: [],
1575
- string: [],
1576
- mixed: [],
1577
- alias: {},
1578
- default: {}
1579
- };
1580
- const args = resolveArgs(argsDef);
1581
- for (const arg of args) {
1582
- if (arg.type === "positional") {
1583
- continue;
1584
- }
1585
- if (arg.type === "string") {
1586
- parseOptions.string.push(arg.name);
1587
- } else if (arg.type === "boolean") {
1588
- parseOptions.boolean.push(arg.name);
1589
- }
1590
- if (arg.default !== void 0) {
1591
- parseOptions.default[arg.name] = arg.default;
1592
- }
1593
- if (arg.alias) {
1594
- parseOptions.alias[arg.name] = arg.alias;
1595
- }
1596
- }
1597
- const parsed = parseRawArgs(rawArgs, parseOptions);
1598
- const [...positionalArguments] = parsed._;
1599
- const parsedArgsProxy = new Proxy(parsed, {
1600
- get(target, prop) {
1601
- return target[prop] ?? target[camelCase(prop)] ?? target[kebabCase(prop)];
1602
- }
1603
- });
1604
- for (const [, arg] of args.entries()) {
1605
- if (arg.type === "positional") {
1606
- const nextPositionalArgument = positionalArguments.shift();
1607
- if (nextPositionalArgument !== void 0) {
1608
- parsedArgsProxy[arg.name] = nextPositionalArgument;
1609
- } else if (arg.default === void 0 && arg.required !== false) {
1610
- throw new CLIError(
1611
- `Missing required positional argument: ${arg.name.toUpperCase()}`,
1612
- "EARG"
1613
- );
1614
- } else {
1615
- parsedArgsProxy[arg.name] = arg.default;
1616
- }
1617
- } else if (arg.required && parsedArgsProxy[arg.name] === void 0) {
1618
- throw new CLIError(`Missing required argument: --${arg.name}`, "EARG");
1619
- }
1620
- }
1621
- return parsedArgsProxy;
1622
- }
1623
- function resolveArgs(argsDef) {
1624
- const args = [];
1625
- for (const [name, argDef] of Object.entries(argsDef || {})) {
1626
- args.push({
1627
- ...argDef,
1628
- name,
1629
- alias: toArray(argDef.alias)
1630
- });
1631
- }
1632
- return args;
1633
- }
1634
-
1635
- function defineCommand(def) {
1636
- return def;
1637
- }
1638
- async function runCommand(cmd, opts) {
1639
- const cmdArgs = await resolveValue(cmd.args || {});
1640
- const parsedArgs = parseArgs$1(opts.rawArgs, cmdArgs);
1641
- const context = {
1642
- rawArgs: opts.rawArgs,
1643
- args: parsedArgs,
1644
- data: opts.data,
1645
- cmd
1646
- };
1647
- if (typeof cmd.setup === "function") {
1648
- await cmd.setup(context);
1649
- }
1650
- let result;
1651
- try {
1652
- const subCommands = await resolveValue(cmd.subCommands);
1653
- if (subCommands && Object.keys(subCommands).length > 0) {
1654
- const subCommandArgIndex = opts.rawArgs.findIndex(
1655
- (arg) => !arg.startsWith("-")
1656
- );
1657
- const subCommandName = opts.rawArgs[subCommandArgIndex];
1658
- if (subCommandName) {
1659
- if (!subCommands[subCommandName]) {
1660
- throw new CLIError(
1661
- `Unknown command \`${subCommandName}\``,
1662
- "E_UNKNOWN_COMMAND"
1663
- );
1664
- }
1665
- const subCommand = await resolveValue(subCommands[subCommandName]);
1666
- if (subCommand) {
1667
- await runCommand(subCommand, {
1668
- rawArgs: opts.rawArgs.slice(subCommandArgIndex + 1)
1669
- });
1670
- }
1671
- } else if (!cmd.run) {
1672
- throw new CLIError(`No command specified.`, "E_NO_COMMAND");
1673
- }
1674
- }
1675
- if (typeof cmd.run === "function") {
1676
- result = await cmd.run(context);
1677
- }
1678
- } finally {
1679
- if (typeof cmd.cleanup === "function") {
1680
- await cmd.cleanup(context);
1681
- }
1682
- }
1683
- return { result };
1684
- }
1685
- async function resolveSubCommand(cmd, rawArgs, parent) {
1686
- const subCommands = await resolveValue(cmd.subCommands);
1687
- if (subCommands && Object.keys(subCommands).length > 0) {
1688
- const subCommandArgIndex = rawArgs.findIndex((arg) => !arg.startsWith("-"));
1689
- const subCommandName = rawArgs[subCommandArgIndex];
1690
- const subCommand = await resolveValue(subCommands[subCommandName]);
1691
- if (subCommand) {
1692
- return resolveSubCommand(
1693
- subCommand,
1694
- rawArgs.slice(subCommandArgIndex + 1),
1695
- cmd
1696
- );
1697
- }
1698
- }
1699
- return [cmd, parent];
1700
- }
1701
-
1702
- async function showUsage(cmd, parent) {
1703
- try {
1704
- consola.log(await renderUsage(cmd, parent) + "\n");
1705
- } catch (error) {
1706
- consola.error(error);
1707
- }
1708
- }
1709
- async function renderUsage(cmd, parent) {
1710
- const cmdMeta = await resolveValue(cmd.meta || {});
1711
- const cmdArgs = resolveArgs(await resolveValue(cmd.args || {}));
1712
- const parentMeta = await resolveValue(parent?.meta || {});
1713
- const commandName = `${parentMeta.name ? `${parentMeta.name} ` : ""}` + (cmdMeta.name || process.argv[1]);
1714
- const argLines = [];
1715
- const posLines = [];
1716
- const commandsLines = [];
1717
- const usageLine = [];
1718
- for (const arg of cmdArgs) {
1719
- if (arg.type === "positional") {
1720
- const name = arg.name.toUpperCase();
1721
- const isRequired = arg.required !== false && arg.default === void 0;
1722
- const defaultHint = arg.default ? `="${arg.default}"` : "";
1723
- posLines.push([
1724
- "`" + name + defaultHint + "`",
1725
- arg.description || "",
1726
- arg.valueHint ? `<${arg.valueHint}>` : ""
1727
- ]);
1728
- usageLine.push(isRequired ? `<${name}>` : `[${name}]`);
1729
- } else {
1730
- const isRequired = arg.required === true && arg.default === void 0;
1731
- const argStr = (arg.type === "boolean" && arg.default === true ? [
1732
- ...(arg.alias || []).map((a) => `--no-${a}`),
1733
- `--no-${arg.name}`
1734
- ].join(", ") : [...(arg.alias || []).map((a) => `-${a}`), `--${arg.name}`].join(
1735
- ", "
1736
- )) + (arg.type === "string" && (arg.valueHint || arg.default) ? `=${arg.valueHint ? `<${arg.valueHint}>` : `"${arg.default || ""}"`}` : "");
1737
- argLines.push([
1738
- "`" + argStr + (isRequired ? " (required)" : "") + "`",
1739
- arg.description || ""
1740
- ]);
1741
- if (isRequired) {
1742
- usageLine.push(argStr);
1743
- }
1744
- }
1745
- }
1746
- if (cmd.subCommands) {
1747
- const commandNames = [];
1748
- const subCommands = await resolveValue(cmd.subCommands);
1749
- for (const [name, sub] of Object.entries(subCommands)) {
1750
- const subCmd = await resolveValue(sub);
1751
- const meta = await resolveValue(subCmd?.meta);
1752
- commandsLines.push([`\`${name}\``, meta?.description || ""]);
1753
- commandNames.push(name);
1754
- }
1755
- usageLine.push(commandNames.join("|"));
1756
- }
1757
- const usageLines = [];
1758
- const version = cmdMeta.version || parentMeta.version;
1759
- usageLines.push(
1760
- colors.gray(
1761
- `${cmdMeta.description} (${commandName + (version ? ` v${version}` : "")})`
1762
- ),
1763
- ""
1764
- );
1765
- const hasOptions = argLines.length > 0 || posLines.length > 0;
1766
- usageLines.push(
1767
- `${colors.underline(colors.bold("USAGE"))} \`${commandName}${hasOptions ? " [OPTIONS]" : ""} ${usageLine.join(" ")}\``,
1768
- ""
1769
- );
1770
- if (posLines.length > 0) {
1771
- usageLines.push(colors.underline(colors.bold("ARGUMENTS")), "");
1772
- usageLines.push(formatLineColumns(posLines, " "));
1773
- usageLines.push("");
1774
- }
1775
- if (argLines.length > 0) {
1776
- usageLines.push(colors.underline(colors.bold("OPTIONS")), "");
1777
- usageLines.push(formatLineColumns(argLines, " "));
1778
- usageLines.push("");
1779
- }
1780
- if (commandsLines.length > 0) {
1781
- usageLines.push(colors.underline(colors.bold("COMMANDS")), "");
1782
- usageLines.push(formatLineColumns(commandsLines, " "));
1783
- usageLines.push(
1784
- "",
1785
- `Use \`${commandName} <command> --help\` for more information about a command.`
1786
- );
1787
- }
1788
- return usageLines.filter((l) => typeof l === "string").join("\n");
1789
- }
1790
-
1791
- async function runMain(cmd, opts = {}) {
1792
- const rawArgs = opts.rawArgs || process.argv.slice(2);
1793
- const showUsage$1 = opts.showUsage || showUsage;
1794
- try {
1795
- if (rawArgs.includes("--help") || rawArgs.includes("-h")) {
1796
- await showUsage$1(...await resolveSubCommand(cmd, rawArgs));
1797
- process.exit(0);
1798
- } else if (rawArgs.length === 1 && rawArgs[0] === "--version") {
1799
- const meta = typeof cmd.meta === "function" ? await cmd.meta() : await cmd.meta;
1800
- if (!meta?.version) {
1801
- throw new CLIError("No version specified", "E_NO_VERSION");
1802
- }
1803
- consola.log(meta.version);
1804
- } else {
1805
- await runCommand(cmd, { rawArgs });
1806
- }
1807
- } catch (error) {
1808
- const isCLIError = error instanceof CLIError;
1809
- if (!isCLIError) {
1810
- consola.error(error, "\n");
1811
- }
1812
- if (isCLIError) {
1813
- await showUsage$1(...await resolveSubCommand(cmd, rawArgs));
1814
- }
1815
- consola.error(error.message);
1816
- process.exit(1);
1817
- }
1818
- }
1819
-
1820
- const ERR_UNSUPPORTED_CONFIG_FORMAT = "Unsupported config format. please use '.js', '.mjs' and '.ts' format";
1821
-
1822
- async function loadConfig(configPath) {
1823
- if (!isSupportedFormat(configPath)) {
1824
- throw new Error(ERR_UNSUPPORTED_CONFIG_FORMAT);
1825
- }
1826
- return import(url.pathToFileURL(configPath).toString()).then(
1827
- (config) => config.default
1828
- );
1829
- }
1830
- function isSupportedFormat(configPath) {
1831
- const ext = nodePath__default.extname(configPath);
1832
- return /\.(js|mjs)$/.test(ext);
1833
- }
1834
-
1835
- async function bundle(configExport) {
1836
- const options = rolldown.arraify(configExport);
1837
- for (const option of options) {
1838
- await bundleInner(option);
1839
- }
1840
- }
1841
- async function bundleInner(options) {
1842
- const dir = options.output?.dir ?? "dist";
1843
- const startTime = node_perf_hooks.performance.now();
1844
- const build = await rolldown.rolldown(options);
1845
- const _output = await build.write(options?.output);
1846
- const entTime = node_perf_hooks.performance.now();
1847
- const outputEntries = collectOutputEntries(_output.output);
1848
- const outputLayoutSizes = collectOutputLayoutAdjustmentSizes(outputEntries);
1849
- printOutputEntries(outputEntries, outputLayoutSizes, dir);
1850
- consola.success(
1851
- `Finished in ${colors.bold((entTime - startTime).toFixed(2))} ms`
1852
- );
1853
- }
1854
- function collectOutputEntries(output) {
1855
- return output.map((chunk) => ({
1856
- type: chunk.type,
1857
- fileName: chunk.fileName,
1858
- size: chunk.type === "chunk" ? chunk.code.length : chunk.source.length
1859
- }));
1860
- }
1861
- function collectOutputLayoutAdjustmentSizes(entries) {
1862
- let longest = 0;
1863
- let biggestSize = 0;
1864
- for (const entry of entries) {
1865
- if (entry.fileName.length > longest) {
1866
- longest = entry.fileName.length;
1867
- }
1868
- if (entry.size > biggestSize) {
1869
- biggestSize = entry.size;
1870
- }
1871
- }
1872
- const sizePad = displaySize(biggestSize).length;
1873
- return {
1874
- longest,
1875
- biggestSize,
1876
- sizePad
1877
- };
1878
- }
1879
- const numberFormatter = new Intl.NumberFormat("en", {
1880
- maximumFractionDigits: 2,
1881
- minimumFractionDigits: 2
1882
- });
1883
- function displaySize(bytes) {
1884
- return `${numberFormatter.format(bytes / 1e3)} kB`;
1885
- }
1886
- const CHUNK_GROUPS = [
1887
- { type: "asset", color: colors.green },
1888
- { type: "chunk", color: colors.cyan }
1889
- ];
1890
- function printOutputEntries(entries, sizeAdjustment, distPath) {
1891
- for (const group of CHUNK_GROUPS) {
1892
- const filtered = entries.filter((e) => e.type === group.type);
1893
- if (!filtered.length) {
1894
- continue;
1895
- }
1896
- for (const entry of filtered.sort((a, z) => a.size - z.size)) {
1897
- let log = colors.dim(withTrailingSlash(distPath));
1898
- log += group.color(entry.fileName.padEnd(sizeAdjustment.longest + 2));
1899
- log += colors.white(entry.type);
1900
- log += colors.dim(
1901
- ` \u2502 size: ${displaySize(entry.size).padStart(sizeAdjustment.sizePad)}`
1902
- );
1903
- consola.info(log);
1904
- }
1905
- }
1906
- }
1907
- function withTrailingSlash(path) {
1908
- if (path[path.length - 1] !== "/") {
1909
- return `${path}/`;
1910
- }
1911
- return path;
1912
- }
1913
-
1914
- const version = "0.10.2";
1915
- const description = "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.";
1916
-
1917
- const DEFAULT_CONFIG_FILENAME = "rolldown.config.js";
1918
- const main = defineCommand({
1919
- meta: {
1920
- name: "rolldown",
1921
- version,
1922
- description
1923
- },
1924
- args: {
1925
- config: {
1926
- type: "string",
1927
- alias: "c",
1928
- description: "Use this config file (if argument is used but value is unspecified, defaults to rolldown.config.js)"
1929
- },
1930
- help: {
1931
- type: "boolean",
1932
- alias: "h",
1933
- description: "Show this help message"
1934
- }
1935
- },
1936
- async run(ctx) {
1937
- if (ctx.args.help) {
1938
- await showUsage(ctx.cmd);
1939
- return;
1940
- }
1941
- const { configPath } = parseArgs(ctx.args);
1942
- const config = await loadConfig(configPath);
1943
- if (!config) {
1944
- consola.error(`No configuration found at ${configPath}`);
1945
- process$1__default.exit(1);
1946
- }
1947
- await bundle(config);
1948
- }
1949
- });
1950
- function parseArgs(args) {
1951
- const { config } = args;
1952
- const cwd = process$1__default.cwd();
1953
- const configPath = config ? nodePath__default.resolve(cwd, config) : nodePath__default.resolve(cwd, DEFAULT_CONFIG_FILENAME);
1954
- return { configPath };
1955
- }
1956
- runMain(main);
1957
-
1958
- exports.colors = colors;
1959
- exports.getDefaultExportFromCjs = getDefaultExportFromCjs;
1960
- exports.isUnicodeSupported = isUnicodeSupported;
1961
- //# sourceMappingURL=cli.cjs.map