termkit 2.2.0 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +104 -12
- package/dist/index.js +95 -54
- package/dist/index.mjs +95 -54
- package/dist/models/Bar.d.ts +4 -2
- package/dist/models/Bar.d.ts.map +1 -1
- package/dist/models/Spinner.d.ts +8 -4
- package/dist/models/Spinner.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -521,17 +521,40 @@ console.log('CPU ' + Chart.Sparkline(samples, { style: (s) => Color.green(s) })
|
|
|
521
521
|
|
|
522
522
|
Options: `min`, `max`, `style`.
|
|
523
523
|
|
|
524
|
-
### Bar
|
|
524
|
+
### Bar
|
|
525
525
|
|
|
526
|
-
|
|
526
|
+
Animated progress bar. Pass text as the first argument and options second:
|
|
527
527
|
|
|
528
528
|
```ts
|
|
529
529
|
import { Bar } from 'termkit'
|
|
530
530
|
|
|
531
|
+
const bar = new Bar('Processing…', { progress: 0 })
|
|
532
|
+
bar.start()
|
|
533
|
+
```
|
|
534
|
+
|
|
535
|
+
Update the inline label while running:
|
|
536
|
+
|
|
537
|
+
```ts
|
|
538
|
+
bar.update('Uploading assets…')
|
|
539
|
+
```
|
|
540
|
+
|
|
541
|
+
Write a persistent log line while the bar keeps running. The default glyph is a faint `·`; pass any string — plain or pre-colored — as the second argument to override it:
|
|
542
|
+
|
|
543
|
+
```ts
|
|
544
|
+
bar.log('Processed batch 3')
|
|
545
|
+
bar.log('Skipped 4 files', '→')
|
|
546
|
+
bar.log('Error on item 12', Color.hex('#ef4444')('✖'))
|
|
547
|
+
bar.log('No glyph line', '')
|
|
548
|
+
```
|
|
549
|
+
|
|
550
|
+
#### ETA and rate tracking
|
|
551
|
+
|
|
552
|
+
Attach progress tracking with `.track()` and `.tick()`:
|
|
553
|
+
|
|
554
|
+
```ts
|
|
531
555
|
const total = 500
|
|
532
|
-
const bar = new Bar({ progress: 0 })
|
|
556
|
+
const bar = new Bar('Processing…', { progress: 0 })
|
|
533
557
|
bar.track(total, { showRate: true, showEta: true, unit: 'files' })
|
|
534
|
-
bar.message('Processing…')
|
|
535
558
|
bar.start()
|
|
536
559
|
|
|
537
560
|
for await (const item of items) {
|
|
@@ -539,7 +562,6 @@ for await (const item of items) {
|
|
|
539
562
|
bar.tick()
|
|
540
563
|
}
|
|
541
564
|
|
|
542
|
-
bar.stop()
|
|
543
565
|
bar.succeed(`Done — ${total} files processed`)
|
|
544
566
|
```
|
|
545
567
|
|
|
@@ -552,7 +574,23 @@ bar.rate // units per second (number)
|
|
|
552
574
|
bar.eta // estimated seconds remaining (number)
|
|
553
575
|
```
|
|
554
576
|
|
|
555
|
-
Options on `track(total, opts?)`: `unit` (label appended to rate), `showRate` (default `true`), `showEta` (default `true`). Both can also be set via constructor: `new Bar({ showRate: true, showEta: true, rateUnit: 'MB' })`.
|
|
577
|
+
Options on `track(total, opts?)`: `unit` (label appended to rate), `showRate` (default `true`), `showEta` (default `true`). Both can also be set via constructor options: `new Bar('Uploading…', { showRate: true, showEta: true, rateUnit: 'MB' })`.
|
|
578
|
+
|
|
579
|
+
#### Bar.current
|
|
580
|
+
|
|
581
|
+
`Bar.current` follows the same pattern as `Spinner.current` — set on `.start()`, cleared on any terminal method. Use it to reach the active bar from deep in processing loops or error handlers:
|
|
582
|
+
|
|
583
|
+
```ts
|
|
584
|
+
const bar = new Bar('Processing…', { progress: 0 })
|
|
585
|
+
bar.track(total)
|
|
586
|
+
bar.start()
|
|
587
|
+
|
|
588
|
+
// from a utility function
|
|
589
|
+
Bar.current?.update('Flushing cache…')
|
|
590
|
+
|
|
591
|
+
// in a catch block
|
|
592
|
+
Bar.current?.fail(`Failed: ${err.message}`)
|
|
593
|
+
```
|
|
556
594
|
|
|
557
595
|
### MultiBar
|
|
558
596
|
|
|
@@ -581,7 +619,7 @@ deploy.succeed('Deployed')
|
|
|
581
619
|
multi.stop()
|
|
582
620
|
```
|
|
583
621
|
|
|
584
|
-
Each `add()` call accepts the same options as `Bar` and returns a `Bar` instance — `.
|
|
622
|
+
Each `add()` call accepts the same options as `Bar` and returns a `Bar` instance — `.update()`, `.tick()`, `.track()`, `.progress`, and the completion methods all work the same way. Bars must be added before `.start()`.
|
|
585
623
|
|
|
586
624
|
Options: `interval`.
|
|
587
625
|
|
|
@@ -592,7 +630,7 @@ Animated spinner for indeterminate work. Shares the same completion API as `Bar`
|
|
|
592
630
|
```ts
|
|
593
631
|
import { Spinner } from 'termkit'
|
|
594
632
|
|
|
595
|
-
const spinner = new Spinner(
|
|
633
|
+
const spinner = new Spinner('Loading…')
|
|
596
634
|
spinner.start()
|
|
597
635
|
|
|
598
636
|
await doWork()
|
|
@@ -600,21 +638,75 @@ await doWork()
|
|
|
600
638
|
spinner.succeed('Done')
|
|
601
639
|
```
|
|
602
640
|
|
|
603
|
-
|
|
641
|
+
Pass options as the second argument:
|
|
604
642
|
|
|
605
643
|
```ts
|
|
606
|
-
spinner
|
|
644
|
+
const spinner = new Spinner('Thinking…', { frames: Spinner.FRAMES.dots, interval: 60 })
|
|
645
|
+
```
|
|
646
|
+
|
|
647
|
+
Update the inline label while running:
|
|
648
|
+
|
|
649
|
+
```ts
|
|
650
|
+
spinner.update('Still working…')
|
|
651
|
+
```
|
|
652
|
+
|
|
653
|
+
Use `prefix` and `suffix` to bookend the text independently of the spinner frame, which always stays at the far left. Spaces between the parts are automatic:
|
|
654
|
+
|
|
655
|
+
```ts
|
|
656
|
+
// renders: ⠋ 0 files copied
|
|
657
|
+
const spinner = new Spinner('files copied')
|
|
658
|
+
spinner.start()
|
|
659
|
+
spinner.prefix(String(count)) // ⠋ 42 files copied
|
|
660
|
+
spinner.suffix('(estimating…)') // ⠋ 42 files copied (estimating…)
|
|
661
|
+
```
|
|
662
|
+
|
|
663
|
+
All three — `update()`, `prefix()`, and `suffix()` — are chainable and can be called while the spinner is running.
|
|
664
|
+
|
|
665
|
+
Write a persistent log line while the spinner keeps running. The default glyph is a faint `·`; pass any string — plain or pre-colored — as the second argument to override it:
|
|
666
|
+
|
|
667
|
+
```ts
|
|
668
|
+
spinner.log('Fetched 42 items')
|
|
669
|
+
spinner.log('Fetched 42 items', '→')
|
|
670
|
+
spinner.log('Fetched 42 items', Color.hex('#00ff00')('✔'))
|
|
671
|
+
spinner.log('Fetched 42 items', '') // no glyph
|
|
672
|
+
```
|
|
673
|
+
|
|
674
|
+
The completion methods accept a custom glyph color via `successColor`, `failColor`, `warnColor`, and `infoColor` — the glyph is colored, the message text is left unstyled:
|
|
675
|
+
|
|
676
|
+
```ts
|
|
677
|
+
const spinner = new Spinner('Deploying…', { successColor: '#a855f7', failColor: '#ef4444' })
|
|
678
|
+
spinner.succeed('Build complete') // purple ✔
|
|
679
|
+
spinner.fail('Connection refused') // red ✖
|
|
680
|
+
```
|
|
681
|
+
|
|
682
|
+
#### Spinner.current
|
|
683
|
+
|
|
684
|
+
`Spinner.current` is automatically set to whichever spinner called `.start()` most recently, and cleared when it terminates. Use it to reach the active spinner from helpers, error handlers, or signal listeners without passing the instance around:
|
|
685
|
+
|
|
686
|
+
```ts
|
|
687
|
+
// top-level handler
|
|
688
|
+
const spinner = new Spinner('Deploying…')
|
|
689
|
+
spinner.start()
|
|
690
|
+
|
|
691
|
+
// anywhere else in your app
|
|
692
|
+
Spinner.current?.update('Uploading assets…')
|
|
693
|
+
|
|
694
|
+
// in a catch block
|
|
695
|
+
Spinner.current?.fail(`Deploy failed: ${err.message}`)
|
|
696
|
+
|
|
697
|
+
// in a SIGTERM handler — ?. is intentional: a spinner may not be running
|
|
698
|
+
process.on('SIGTERM', () => Spinner.current?.stop('Interrupted'))
|
|
607
699
|
```
|
|
608
700
|
|
|
609
701
|
Built-in frame sets are available on `Spinner.FRAMES`:
|
|
610
702
|
|
|
611
703
|
```ts
|
|
612
|
-
new Spinner({ frames: Spinner.FRAMES.dots
|
|
704
|
+
new Spinner('Thinking…', { frames: Spinner.FRAMES.dots }).start()
|
|
613
705
|
```
|
|
614
706
|
|
|
615
707
|
Frame sets: `braille`, `dots`, `line`, `arrow`, `bounce`.
|
|
616
708
|
|
|
617
|
-
Options: `frames`, `
|
|
709
|
+
Options: `frames`, `prefix`, `suffix`, `reverse`, `interval`, `colors`, `bgColors`, `colorCycle`, `shimmer`, `successColor`, `failColor`, `warnColor`, `infoColor`, `glyphs`.
|
|
618
710
|
|
|
619
711
|
### Scrollbox
|
|
620
712
|
|
package/dist/index.js
CHANGED
|
@@ -1041,8 +1041,8 @@ var Command = class {
|
|
|
1041
1041
|
};
|
|
1042
1042
|
|
|
1043
1043
|
// src/models/Bar.ts
|
|
1044
|
-
var
|
|
1045
|
-
constructor(options
|
|
1044
|
+
var _Bar = class _Bar {
|
|
1045
|
+
constructor(text, options) {
|
|
1046
1046
|
// used by MultiBar — not intended for direct external use
|
|
1047
1047
|
this._isManaged = false;
|
|
1048
1048
|
this._managedFinalLine = null;
|
|
@@ -1060,37 +1060,38 @@ var Bar = class {
|
|
|
1060
1060
|
this._tickCount = 0;
|
|
1061
1061
|
this._startTime = null;
|
|
1062
1062
|
this._etaSuffix = "";
|
|
1063
|
+
const opts = typeof text === "string" ? { ...options, text } : text ?? {};
|
|
1063
1064
|
this.running = false;
|
|
1064
1065
|
this.forwardMotion = true;
|
|
1065
|
-
this._autoLength =
|
|
1066
|
-
this.length =
|
|
1067
|
-
this.prefixString =
|
|
1068
|
-
this.suffixString =
|
|
1069
|
-
this.character =
|
|
1070
|
-
this.beforeEmpty =
|
|
1071
|
-
this.afterEmpty =
|
|
1066
|
+
this._autoLength = opts.length === void 0;
|
|
1067
|
+
this.length = opts.length ?? process.stdout.columns ?? 80;
|
|
1068
|
+
this.prefixString = opts.prefix ?? "[";
|
|
1069
|
+
this.suffixString = opts.suffix ?? "]";
|
|
1070
|
+
this.character = opts.character ?? "\u2500\u2500";
|
|
1071
|
+
this.beforeEmpty = opts.before ?? " ";
|
|
1072
|
+
this.afterEmpty = opts.after ?? " ";
|
|
1072
1073
|
this.position = 1;
|
|
1073
|
-
this.interval =
|
|
1074
|
-
this.mode =
|
|
1075
|
-
this.progress =
|
|
1076
|
-
this.colorFill =
|
|
1077
|
-
this.colorCycle =
|
|
1078
|
-
this.shimmer =
|
|
1079
|
-
this.text =
|
|
1080
|
-
this.reverse =
|
|
1081
|
-
this.onBounce =
|
|
1082
|
-
this.onLoop =
|
|
1083
|
-
this.onComplete =
|
|
1084
|
-
this.colors =
|
|
1085
|
-
this.bgColors =
|
|
1086
|
-
this._successColor =
|
|
1087
|
-
this._failColor =
|
|
1088
|
-
this._warnColor =
|
|
1089
|
-
this._infoColor =
|
|
1090
|
-
this._glyphs =
|
|
1091
|
-
this._showRate =
|
|
1092
|
-
this._showEta =
|
|
1093
|
-
this._rateUnit =
|
|
1074
|
+
this.interval = opts.interval ?? 35;
|
|
1075
|
+
this.mode = opts.mode ?? "bounce";
|
|
1076
|
+
this.progress = opts.progress;
|
|
1077
|
+
this.colorFill = opts.colorFill ?? false;
|
|
1078
|
+
this.colorCycle = opts.colorCycle ?? 0.5;
|
|
1079
|
+
this.shimmer = opts.shimmer ?? 0;
|
|
1080
|
+
this.text = opts.text ?? "";
|
|
1081
|
+
this.reverse = opts.reverse ?? false;
|
|
1082
|
+
this.onBounce = opts.onBounce;
|
|
1083
|
+
this.onLoop = opts.onLoop;
|
|
1084
|
+
this.onComplete = opts.onComplete;
|
|
1085
|
+
this.colors = opts.colors ?? ["#c026d3", "#e879f9"];
|
|
1086
|
+
this.bgColors = opts.bgColors ?? [];
|
|
1087
|
+
this._successColor = opts.successColor ?? GREEN;
|
|
1088
|
+
this._failColor = opts.failColor ?? RED;
|
|
1089
|
+
this._warnColor = opts.warnColor ?? YELLOW;
|
|
1090
|
+
this._infoColor = opts.infoColor ?? BLUE;
|
|
1091
|
+
this._glyphs = opts.glyphs ?? true;
|
|
1092
|
+
this._showRate = opts.showRate ?? false;
|
|
1093
|
+
this._showEta = opts.showEta ?? false;
|
|
1094
|
+
this._rateUnit = opts.rateUnit ?? "";
|
|
1094
1095
|
}
|
|
1095
1096
|
get colors() {
|
|
1096
1097
|
return this._colors;
|
|
@@ -1139,6 +1140,7 @@ var Bar = class {
|
|
|
1139
1140
|
if (this._isManaged) return;
|
|
1140
1141
|
if (!process.stdout.isTTY) return;
|
|
1141
1142
|
this.running = true;
|
|
1143
|
+
_Bar.current = this;
|
|
1142
1144
|
process.stdout.write(HIDE_CURSOR);
|
|
1143
1145
|
this._cleanupDeregister = registerCleanup(() => {
|
|
1144
1146
|
this.running = false;
|
|
@@ -1164,6 +1166,7 @@ var Bar = class {
|
|
|
1164
1166
|
this._managedFinalLine = message ?? "";
|
|
1165
1167
|
return this;
|
|
1166
1168
|
}
|
|
1169
|
+
if (_Bar.current === this) _Bar.current = null;
|
|
1167
1170
|
this._cleanupDeregister?.();
|
|
1168
1171
|
this._cleanupDeregister = null;
|
|
1169
1172
|
if (process.stdout.isTTY) {
|
|
@@ -1178,10 +1181,18 @@ var Bar = class {
|
|
|
1178
1181
|
`);
|
|
1179
1182
|
return this;
|
|
1180
1183
|
}
|
|
1181
|
-
|
|
1184
|
+
update(string) {
|
|
1182
1185
|
this.text = string;
|
|
1183
1186
|
return this;
|
|
1184
1187
|
}
|
|
1188
|
+
log(message, glyph = `${FAINT}\xB7${RESET}`) {
|
|
1189
|
+
if (process.stdout.isTTY) {
|
|
1190
|
+
this.clear();
|
|
1191
|
+
}
|
|
1192
|
+
process.stdout.write(`${glyph ? `${glyph} ` : ""}${message}
|
|
1193
|
+
`);
|
|
1194
|
+
return this;
|
|
1195
|
+
}
|
|
1185
1196
|
track(total, options) {
|
|
1186
1197
|
this._total = total;
|
|
1187
1198
|
this._tickCount = 0;
|
|
@@ -1228,6 +1239,7 @@ var Bar = class {
|
|
|
1228
1239
|
}
|
|
1229
1240
|
succeed(string) {
|
|
1230
1241
|
this.running = false;
|
|
1242
|
+
if (_Bar.current === this) _Bar.current = null;
|
|
1231
1243
|
if (this._isManaged) {
|
|
1232
1244
|
const glyph = this._glyphs ? colorText(this._successColor, "\u2714") + " " : "";
|
|
1233
1245
|
this._managedFinalLine = `${glyph}${string ?? ""}`;
|
|
@@ -1251,6 +1263,7 @@ var Bar = class {
|
|
|
1251
1263
|
}
|
|
1252
1264
|
fail(string) {
|
|
1253
1265
|
this.running = false;
|
|
1266
|
+
if (_Bar.current === this) _Bar.current = null;
|
|
1254
1267
|
if (this._isManaged) {
|
|
1255
1268
|
const glyph = this._glyphs ? colorText(this._failColor, "\u2716") + " " : "";
|
|
1256
1269
|
this._managedFinalLine = `${glyph}${string ?? ""}`;
|
|
@@ -1274,6 +1287,7 @@ var Bar = class {
|
|
|
1274
1287
|
}
|
|
1275
1288
|
warn(string) {
|
|
1276
1289
|
this.running = false;
|
|
1290
|
+
if (_Bar.current === this) _Bar.current = null;
|
|
1277
1291
|
if (this._isManaged) {
|
|
1278
1292
|
const glyph = this._glyphs ? colorText(this._warnColor, "\u26A0") + " " : "";
|
|
1279
1293
|
this._managedFinalLine = `${glyph}${string ?? ""}`;
|
|
@@ -1297,6 +1311,7 @@ var Bar = class {
|
|
|
1297
1311
|
}
|
|
1298
1312
|
info(string) {
|
|
1299
1313
|
this.running = false;
|
|
1314
|
+
if (_Bar.current === this) _Bar.current = null;
|
|
1300
1315
|
if (this._isManaged) {
|
|
1301
1316
|
const glyph = this._glyphs ? colorText(this._infoColor, "\u2139") + " " : "";
|
|
1302
1317
|
this._managedFinalLine = `${glyph}${string ?? ""}`;
|
|
@@ -1464,7 +1479,8 @@ var Bar = class {
|
|
|
1464
1479
|
}, this.interval);
|
|
1465
1480
|
}
|
|
1466
1481
|
};
|
|
1467
|
-
|
|
1482
|
+
_Bar.current = null;
|
|
1483
|
+
_Bar.COLORS = {
|
|
1468
1484
|
blueRed: ["#0000ff", "#ff0000"],
|
|
1469
1485
|
redBlue: ["#ff0000", "#0000ff"],
|
|
1470
1486
|
rainbow: ["#ff0000", "#ff7f00", "#ffff00", "#00ff00", "#0000ff", "#8b00ff"],
|
|
@@ -1472,6 +1488,7 @@ Bar.COLORS = {
|
|
|
1472
1488
|
cool: ["#00ffff", "#0000ff", "#8b00ff"],
|
|
1473
1489
|
sunset: ["#8b00ff", "#ff0000", "#ff7f00"]
|
|
1474
1490
|
};
|
|
1491
|
+
var Bar = _Bar;
|
|
1475
1492
|
|
|
1476
1493
|
// src/models/Chart.ts
|
|
1477
1494
|
var Chart_exports = {};
|
|
@@ -1995,7 +2012,7 @@ var MultiBar = class {
|
|
|
1995
2012
|
this._interval = options.interval ?? 35;
|
|
1996
2013
|
}
|
|
1997
2014
|
// Add a bar to the group. Must be called before start().
|
|
1998
|
-
// Returns the Bar instance — use .
|
|
2015
|
+
// Returns the Bar instance — use .update(), .progress, .tick(), .succeed(), etc.
|
|
1999
2016
|
add(options = {}) {
|
|
2000
2017
|
const bar = new Bar(options);
|
|
2001
2018
|
bar._isManaged = true;
|
|
@@ -2463,7 +2480,7 @@ async function scrollbox(lines, options) {
|
|
|
2463
2480
|
|
|
2464
2481
|
// src/models/Spinner.ts
|
|
2465
2482
|
var _Spinner = class _Spinner {
|
|
2466
|
-
constructor(options
|
|
2483
|
+
constructor(text, options) {
|
|
2467
2484
|
this._colors = [];
|
|
2468
2485
|
this._parsedColors = [];
|
|
2469
2486
|
this._bgColors = [];
|
|
@@ -2472,24 +2489,25 @@ var _Spinner = class _Spinner {
|
|
|
2472
2489
|
this._shimmerPhase = 0;
|
|
2473
2490
|
this._lastLineLength = 0;
|
|
2474
2491
|
this._cleanupDeregister = null;
|
|
2492
|
+
const opts = typeof text === "string" ? { ...options, text } : text ?? {};
|
|
2475
2493
|
this.running = false;
|
|
2476
2494
|
this.frameIndex = 0;
|
|
2477
|
-
this.frames =
|
|
2478
|
-
this.
|
|
2479
|
-
this.
|
|
2480
|
-
this.text =
|
|
2481
|
-
this.reverse =
|
|
2482
|
-
this.interval =
|
|
2483
|
-
this.colorCycle =
|
|
2484
|
-
this.shimmer =
|
|
2485
|
-
this.onSpin =
|
|
2486
|
-
this.colors =
|
|
2487
|
-
this.bgColors =
|
|
2488
|
-
this._successColor =
|
|
2489
|
-
this._failColor =
|
|
2490
|
-
this._warnColor =
|
|
2491
|
-
this._infoColor =
|
|
2492
|
-
this._glyphs =
|
|
2495
|
+
this.frames = opts.frames ?? (config.glyphs ? _Spinner.FRAMES.braille : _Spinner.FRAMES.line);
|
|
2496
|
+
this._prefix = opts.prefix ?? "";
|
|
2497
|
+
this._suffix = opts.suffix ?? "";
|
|
2498
|
+
this.text = opts.text ?? "";
|
|
2499
|
+
this.reverse = opts.reverse ?? false;
|
|
2500
|
+
this.interval = opts.interval ?? 80;
|
|
2501
|
+
this.colorCycle = opts.colorCycle ?? 1;
|
|
2502
|
+
this.shimmer = opts.shimmer ?? 0;
|
|
2503
|
+
this.onSpin = opts.onSpin;
|
|
2504
|
+
this.colors = opts.colors ?? ["#c026d3", "#e879f9"];
|
|
2505
|
+
this.bgColors = opts.bgColors ?? [];
|
|
2506
|
+
this._successColor = opts.successColor ?? GREEN;
|
|
2507
|
+
this._failColor = opts.failColor ?? RED;
|
|
2508
|
+
this._warnColor = opts.warnColor ?? YELLOW;
|
|
2509
|
+
this._infoColor = opts.infoColor ?? BLUE;
|
|
2510
|
+
this._glyphs = opts.glyphs ?? config.glyphs;
|
|
2493
2511
|
}
|
|
2494
2512
|
get colors() {
|
|
2495
2513
|
return this._colors;
|
|
@@ -2508,6 +2526,7 @@ var _Spinner = class _Spinner {
|
|
|
2508
2526
|
start() {
|
|
2509
2527
|
if (!process.stdout.isTTY) return;
|
|
2510
2528
|
this.running = true;
|
|
2529
|
+
_Spinner.current = this;
|
|
2511
2530
|
process.stdout.write(HIDE_CURSOR);
|
|
2512
2531
|
this._cleanupDeregister = registerCleanup(() => {
|
|
2513
2532
|
this.running = false;
|
|
@@ -2518,6 +2537,7 @@ var _Spinner = class _Spinner {
|
|
|
2518
2537
|
}
|
|
2519
2538
|
stop(message) {
|
|
2520
2539
|
this.running = false;
|
|
2540
|
+
if (_Spinner.current === this) _Spinner.current = null;
|
|
2521
2541
|
this._cleanupDeregister?.();
|
|
2522
2542
|
this._cleanupDeregister = null;
|
|
2523
2543
|
if (process.stdout.isTTY) {
|
|
@@ -2528,12 +2548,21 @@ var _Spinner = class _Spinner {
|
|
|
2528
2548
|
`);
|
|
2529
2549
|
return this;
|
|
2530
2550
|
}
|
|
2531
|
-
|
|
2551
|
+
update(string) {
|
|
2532
2552
|
this.text = string;
|
|
2533
2553
|
return this;
|
|
2534
2554
|
}
|
|
2555
|
+
prefix(string) {
|
|
2556
|
+
this._prefix = string;
|
|
2557
|
+
return this;
|
|
2558
|
+
}
|
|
2559
|
+
suffix(string) {
|
|
2560
|
+
this._suffix = string;
|
|
2561
|
+
return this;
|
|
2562
|
+
}
|
|
2535
2563
|
succeed(string) {
|
|
2536
2564
|
this.running = false;
|
|
2565
|
+
if (_Spinner.current === this) _Spinner.current = null;
|
|
2537
2566
|
this._cleanupDeregister?.();
|
|
2538
2567
|
this._cleanupDeregister = null;
|
|
2539
2568
|
if (process.stdout.isTTY) {
|
|
@@ -2549,6 +2578,7 @@ var _Spinner = class _Spinner {
|
|
|
2549
2578
|
}
|
|
2550
2579
|
fail(string) {
|
|
2551
2580
|
this.running = false;
|
|
2581
|
+
if (_Spinner.current === this) _Spinner.current = null;
|
|
2552
2582
|
this._cleanupDeregister?.();
|
|
2553
2583
|
this._cleanupDeregister = null;
|
|
2554
2584
|
if (process.stdout.isTTY) {
|
|
@@ -2564,6 +2594,7 @@ var _Spinner = class _Spinner {
|
|
|
2564
2594
|
}
|
|
2565
2595
|
warn(string) {
|
|
2566
2596
|
this.running = false;
|
|
2597
|
+
if (_Spinner.current === this) _Spinner.current = null;
|
|
2567
2598
|
this._cleanupDeregister?.();
|
|
2568
2599
|
this._cleanupDeregister = null;
|
|
2569
2600
|
if (process.stdout.isTTY) {
|
|
@@ -2579,6 +2610,7 @@ var _Spinner = class _Spinner {
|
|
|
2579
2610
|
}
|
|
2580
2611
|
info(string) {
|
|
2581
2612
|
this.running = false;
|
|
2613
|
+
if (_Spinner.current === this) _Spinner.current = null;
|
|
2582
2614
|
this._cleanupDeregister?.();
|
|
2583
2615
|
this._cleanupDeregister = null;
|
|
2584
2616
|
if (process.stdout.isTTY) {
|
|
@@ -2592,6 +2624,14 @@ var _Spinner = class _Spinner {
|
|
|
2592
2624
|
}
|
|
2593
2625
|
return this;
|
|
2594
2626
|
}
|
|
2627
|
+
log(message, glyph = `${FAINT}\xB7${RESET}`) {
|
|
2628
|
+
if (process.stdout.isTTY) {
|
|
2629
|
+
this.clear();
|
|
2630
|
+
}
|
|
2631
|
+
process.stdout.write(`${glyph ? `${glyph} ` : ""}${message}
|
|
2632
|
+
`);
|
|
2633
|
+
return this;
|
|
2634
|
+
}
|
|
2595
2635
|
clear() {
|
|
2596
2636
|
process.stdout.clearLine?.(0);
|
|
2597
2637
|
this._lastLineLength = 0;
|
|
@@ -2606,9 +2646,9 @@ var _Spinner = class _Spinner {
|
|
|
2606
2646
|
}
|
|
2607
2647
|
run() {
|
|
2608
2648
|
const frame = this.coloredFrame();
|
|
2609
|
-
const
|
|
2610
|
-
const content = this.reverse ?
|
|
2611
|
-
const raw =
|
|
2649
|
+
const label = [this._prefix, this.text, this._suffix].filter(Boolean).join(" ");
|
|
2650
|
+
const content = this.reverse ? label ? `${label} ${frame}` : frame : label ? `${frame} ${label}` : frame;
|
|
2651
|
+
const raw = content;
|
|
2612
2652
|
const displayLen = stringLength(raw);
|
|
2613
2653
|
const padding = " ".repeat(Math.max(0, this._lastLineLength - displayLen));
|
|
2614
2654
|
this._lastLineLength = displayLen;
|
|
@@ -2626,6 +2666,7 @@ var _Spinner = class _Spinner {
|
|
|
2626
2666
|
}, this.interval);
|
|
2627
2667
|
}
|
|
2628
2668
|
};
|
|
2669
|
+
_Spinner.current = null;
|
|
2629
2670
|
_Spinner.FRAMES = {
|
|
2630
2671
|
braille: ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"],
|
|
2631
2672
|
dots: ["\u28FE", "\u28FD", "\u28FB", "\u28BF", "\u287F", "\u28DF", "\u28EF", "\u28F7"],
|
package/dist/index.mjs
CHANGED
|
@@ -981,8 +981,8 @@ var Command = class {
|
|
|
981
981
|
};
|
|
982
982
|
|
|
983
983
|
// src/models/Bar.ts
|
|
984
|
-
var
|
|
985
|
-
constructor(options
|
|
984
|
+
var _Bar = class _Bar {
|
|
985
|
+
constructor(text, options) {
|
|
986
986
|
// used by MultiBar — not intended for direct external use
|
|
987
987
|
this._isManaged = false;
|
|
988
988
|
this._managedFinalLine = null;
|
|
@@ -1000,37 +1000,38 @@ var Bar = class {
|
|
|
1000
1000
|
this._tickCount = 0;
|
|
1001
1001
|
this._startTime = null;
|
|
1002
1002
|
this._etaSuffix = "";
|
|
1003
|
+
const opts = typeof text === "string" ? { ...options, text } : text ?? {};
|
|
1003
1004
|
this.running = false;
|
|
1004
1005
|
this.forwardMotion = true;
|
|
1005
|
-
this._autoLength =
|
|
1006
|
-
this.length =
|
|
1007
|
-
this.prefixString =
|
|
1008
|
-
this.suffixString =
|
|
1009
|
-
this.character =
|
|
1010
|
-
this.beforeEmpty =
|
|
1011
|
-
this.afterEmpty =
|
|
1006
|
+
this._autoLength = opts.length === void 0;
|
|
1007
|
+
this.length = opts.length ?? process.stdout.columns ?? 80;
|
|
1008
|
+
this.prefixString = opts.prefix ?? "[";
|
|
1009
|
+
this.suffixString = opts.suffix ?? "]";
|
|
1010
|
+
this.character = opts.character ?? "\u2500\u2500";
|
|
1011
|
+
this.beforeEmpty = opts.before ?? " ";
|
|
1012
|
+
this.afterEmpty = opts.after ?? " ";
|
|
1012
1013
|
this.position = 1;
|
|
1013
|
-
this.interval =
|
|
1014
|
-
this.mode =
|
|
1015
|
-
this.progress =
|
|
1016
|
-
this.colorFill =
|
|
1017
|
-
this.colorCycle =
|
|
1018
|
-
this.shimmer =
|
|
1019
|
-
this.text =
|
|
1020
|
-
this.reverse =
|
|
1021
|
-
this.onBounce =
|
|
1022
|
-
this.onLoop =
|
|
1023
|
-
this.onComplete =
|
|
1024
|
-
this.colors =
|
|
1025
|
-
this.bgColors =
|
|
1026
|
-
this._successColor =
|
|
1027
|
-
this._failColor =
|
|
1028
|
-
this._warnColor =
|
|
1029
|
-
this._infoColor =
|
|
1030
|
-
this._glyphs =
|
|
1031
|
-
this._showRate =
|
|
1032
|
-
this._showEta =
|
|
1033
|
-
this._rateUnit =
|
|
1014
|
+
this.interval = opts.interval ?? 35;
|
|
1015
|
+
this.mode = opts.mode ?? "bounce";
|
|
1016
|
+
this.progress = opts.progress;
|
|
1017
|
+
this.colorFill = opts.colorFill ?? false;
|
|
1018
|
+
this.colorCycle = opts.colorCycle ?? 0.5;
|
|
1019
|
+
this.shimmer = opts.shimmer ?? 0;
|
|
1020
|
+
this.text = opts.text ?? "";
|
|
1021
|
+
this.reverse = opts.reverse ?? false;
|
|
1022
|
+
this.onBounce = opts.onBounce;
|
|
1023
|
+
this.onLoop = opts.onLoop;
|
|
1024
|
+
this.onComplete = opts.onComplete;
|
|
1025
|
+
this.colors = opts.colors ?? ["#c026d3", "#e879f9"];
|
|
1026
|
+
this.bgColors = opts.bgColors ?? [];
|
|
1027
|
+
this._successColor = opts.successColor ?? GREEN;
|
|
1028
|
+
this._failColor = opts.failColor ?? RED;
|
|
1029
|
+
this._warnColor = opts.warnColor ?? YELLOW;
|
|
1030
|
+
this._infoColor = opts.infoColor ?? BLUE;
|
|
1031
|
+
this._glyphs = opts.glyphs ?? true;
|
|
1032
|
+
this._showRate = opts.showRate ?? false;
|
|
1033
|
+
this._showEta = opts.showEta ?? false;
|
|
1034
|
+
this._rateUnit = opts.rateUnit ?? "";
|
|
1034
1035
|
}
|
|
1035
1036
|
get colors() {
|
|
1036
1037
|
return this._colors;
|
|
@@ -1079,6 +1080,7 @@ var Bar = class {
|
|
|
1079
1080
|
if (this._isManaged) return;
|
|
1080
1081
|
if (!process.stdout.isTTY) return;
|
|
1081
1082
|
this.running = true;
|
|
1083
|
+
_Bar.current = this;
|
|
1082
1084
|
process.stdout.write(HIDE_CURSOR);
|
|
1083
1085
|
this._cleanupDeregister = registerCleanup(() => {
|
|
1084
1086
|
this.running = false;
|
|
@@ -1104,6 +1106,7 @@ var Bar = class {
|
|
|
1104
1106
|
this._managedFinalLine = message ?? "";
|
|
1105
1107
|
return this;
|
|
1106
1108
|
}
|
|
1109
|
+
if (_Bar.current === this) _Bar.current = null;
|
|
1107
1110
|
this._cleanupDeregister?.();
|
|
1108
1111
|
this._cleanupDeregister = null;
|
|
1109
1112
|
if (process.stdout.isTTY) {
|
|
@@ -1118,10 +1121,18 @@ var Bar = class {
|
|
|
1118
1121
|
`);
|
|
1119
1122
|
return this;
|
|
1120
1123
|
}
|
|
1121
|
-
|
|
1124
|
+
update(string) {
|
|
1122
1125
|
this.text = string;
|
|
1123
1126
|
return this;
|
|
1124
1127
|
}
|
|
1128
|
+
log(message, glyph = `${FAINT}\xB7${RESET}`) {
|
|
1129
|
+
if (process.stdout.isTTY) {
|
|
1130
|
+
this.clear();
|
|
1131
|
+
}
|
|
1132
|
+
process.stdout.write(`${glyph ? `${glyph} ` : ""}${message}
|
|
1133
|
+
`);
|
|
1134
|
+
return this;
|
|
1135
|
+
}
|
|
1125
1136
|
track(total, options) {
|
|
1126
1137
|
this._total = total;
|
|
1127
1138
|
this._tickCount = 0;
|
|
@@ -1168,6 +1179,7 @@ var Bar = class {
|
|
|
1168
1179
|
}
|
|
1169
1180
|
succeed(string) {
|
|
1170
1181
|
this.running = false;
|
|
1182
|
+
if (_Bar.current === this) _Bar.current = null;
|
|
1171
1183
|
if (this._isManaged) {
|
|
1172
1184
|
const glyph = this._glyphs ? colorText(this._successColor, "\u2714") + " " : "";
|
|
1173
1185
|
this._managedFinalLine = `${glyph}${string ?? ""}`;
|
|
@@ -1191,6 +1203,7 @@ var Bar = class {
|
|
|
1191
1203
|
}
|
|
1192
1204
|
fail(string) {
|
|
1193
1205
|
this.running = false;
|
|
1206
|
+
if (_Bar.current === this) _Bar.current = null;
|
|
1194
1207
|
if (this._isManaged) {
|
|
1195
1208
|
const glyph = this._glyphs ? colorText(this._failColor, "\u2716") + " " : "";
|
|
1196
1209
|
this._managedFinalLine = `${glyph}${string ?? ""}`;
|
|
@@ -1214,6 +1227,7 @@ var Bar = class {
|
|
|
1214
1227
|
}
|
|
1215
1228
|
warn(string) {
|
|
1216
1229
|
this.running = false;
|
|
1230
|
+
if (_Bar.current === this) _Bar.current = null;
|
|
1217
1231
|
if (this._isManaged) {
|
|
1218
1232
|
const glyph = this._glyphs ? colorText(this._warnColor, "\u26A0") + " " : "";
|
|
1219
1233
|
this._managedFinalLine = `${glyph}${string ?? ""}`;
|
|
@@ -1237,6 +1251,7 @@ var Bar = class {
|
|
|
1237
1251
|
}
|
|
1238
1252
|
info(string) {
|
|
1239
1253
|
this.running = false;
|
|
1254
|
+
if (_Bar.current === this) _Bar.current = null;
|
|
1240
1255
|
if (this._isManaged) {
|
|
1241
1256
|
const glyph = this._glyphs ? colorText(this._infoColor, "\u2139") + " " : "";
|
|
1242
1257
|
this._managedFinalLine = `${glyph}${string ?? ""}`;
|
|
@@ -1404,7 +1419,8 @@ var Bar = class {
|
|
|
1404
1419
|
}, this.interval);
|
|
1405
1420
|
}
|
|
1406
1421
|
};
|
|
1407
|
-
|
|
1422
|
+
_Bar.current = null;
|
|
1423
|
+
_Bar.COLORS = {
|
|
1408
1424
|
blueRed: ["#0000ff", "#ff0000"],
|
|
1409
1425
|
redBlue: ["#ff0000", "#0000ff"],
|
|
1410
1426
|
rainbow: ["#ff0000", "#ff7f00", "#ffff00", "#00ff00", "#0000ff", "#8b00ff"],
|
|
@@ -1412,6 +1428,7 @@ Bar.COLORS = {
|
|
|
1412
1428
|
cool: ["#00ffff", "#0000ff", "#8b00ff"],
|
|
1413
1429
|
sunset: ["#8b00ff", "#ff0000", "#ff7f00"]
|
|
1414
1430
|
};
|
|
1431
|
+
var Bar = _Bar;
|
|
1415
1432
|
|
|
1416
1433
|
// src/models/Chart.ts
|
|
1417
1434
|
var Chart_exports = {};
|
|
@@ -1935,7 +1952,7 @@ var MultiBar = class {
|
|
|
1935
1952
|
this._interval = options.interval ?? 35;
|
|
1936
1953
|
}
|
|
1937
1954
|
// Add a bar to the group. Must be called before start().
|
|
1938
|
-
// Returns the Bar instance — use .
|
|
1955
|
+
// Returns the Bar instance — use .update(), .progress, .tick(), .succeed(), etc.
|
|
1939
1956
|
add(options = {}) {
|
|
1940
1957
|
const bar = new Bar(options);
|
|
1941
1958
|
bar._isManaged = true;
|
|
@@ -2403,7 +2420,7 @@ async function scrollbox(lines, options) {
|
|
|
2403
2420
|
|
|
2404
2421
|
// src/models/Spinner.ts
|
|
2405
2422
|
var _Spinner = class _Spinner {
|
|
2406
|
-
constructor(options
|
|
2423
|
+
constructor(text, options) {
|
|
2407
2424
|
this._colors = [];
|
|
2408
2425
|
this._parsedColors = [];
|
|
2409
2426
|
this._bgColors = [];
|
|
@@ -2412,24 +2429,25 @@ var _Spinner = class _Spinner {
|
|
|
2412
2429
|
this._shimmerPhase = 0;
|
|
2413
2430
|
this._lastLineLength = 0;
|
|
2414
2431
|
this._cleanupDeregister = null;
|
|
2432
|
+
const opts = typeof text === "string" ? { ...options, text } : text ?? {};
|
|
2415
2433
|
this.running = false;
|
|
2416
2434
|
this.frameIndex = 0;
|
|
2417
|
-
this.frames =
|
|
2418
|
-
this.
|
|
2419
|
-
this.
|
|
2420
|
-
this.text =
|
|
2421
|
-
this.reverse =
|
|
2422
|
-
this.interval =
|
|
2423
|
-
this.colorCycle =
|
|
2424
|
-
this.shimmer =
|
|
2425
|
-
this.onSpin =
|
|
2426
|
-
this.colors =
|
|
2427
|
-
this.bgColors =
|
|
2428
|
-
this._successColor =
|
|
2429
|
-
this._failColor =
|
|
2430
|
-
this._warnColor =
|
|
2431
|
-
this._infoColor =
|
|
2432
|
-
this._glyphs =
|
|
2435
|
+
this.frames = opts.frames ?? (config.glyphs ? _Spinner.FRAMES.braille : _Spinner.FRAMES.line);
|
|
2436
|
+
this._prefix = opts.prefix ?? "";
|
|
2437
|
+
this._suffix = opts.suffix ?? "";
|
|
2438
|
+
this.text = opts.text ?? "";
|
|
2439
|
+
this.reverse = opts.reverse ?? false;
|
|
2440
|
+
this.interval = opts.interval ?? 80;
|
|
2441
|
+
this.colorCycle = opts.colorCycle ?? 1;
|
|
2442
|
+
this.shimmer = opts.shimmer ?? 0;
|
|
2443
|
+
this.onSpin = opts.onSpin;
|
|
2444
|
+
this.colors = opts.colors ?? ["#c026d3", "#e879f9"];
|
|
2445
|
+
this.bgColors = opts.bgColors ?? [];
|
|
2446
|
+
this._successColor = opts.successColor ?? GREEN;
|
|
2447
|
+
this._failColor = opts.failColor ?? RED;
|
|
2448
|
+
this._warnColor = opts.warnColor ?? YELLOW;
|
|
2449
|
+
this._infoColor = opts.infoColor ?? BLUE;
|
|
2450
|
+
this._glyphs = opts.glyphs ?? config.glyphs;
|
|
2433
2451
|
}
|
|
2434
2452
|
get colors() {
|
|
2435
2453
|
return this._colors;
|
|
@@ -2448,6 +2466,7 @@ var _Spinner = class _Spinner {
|
|
|
2448
2466
|
start() {
|
|
2449
2467
|
if (!process.stdout.isTTY) return;
|
|
2450
2468
|
this.running = true;
|
|
2469
|
+
_Spinner.current = this;
|
|
2451
2470
|
process.stdout.write(HIDE_CURSOR);
|
|
2452
2471
|
this._cleanupDeregister = registerCleanup(() => {
|
|
2453
2472
|
this.running = false;
|
|
@@ -2458,6 +2477,7 @@ var _Spinner = class _Spinner {
|
|
|
2458
2477
|
}
|
|
2459
2478
|
stop(message) {
|
|
2460
2479
|
this.running = false;
|
|
2480
|
+
if (_Spinner.current === this) _Spinner.current = null;
|
|
2461
2481
|
this._cleanupDeregister?.();
|
|
2462
2482
|
this._cleanupDeregister = null;
|
|
2463
2483
|
if (process.stdout.isTTY) {
|
|
@@ -2468,12 +2488,21 @@ var _Spinner = class _Spinner {
|
|
|
2468
2488
|
`);
|
|
2469
2489
|
return this;
|
|
2470
2490
|
}
|
|
2471
|
-
|
|
2491
|
+
update(string) {
|
|
2472
2492
|
this.text = string;
|
|
2473
2493
|
return this;
|
|
2474
2494
|
}
|
|
2495
|
+
prefix(string) {
|
|
2496
|
+
this._prefix = string;
|
|
2497
|
+
return this;
|
|
2498
|
+
}
|
|
2499
|
+
suffix(string) {
|
|
2500
|
+
this._suffix = string;
|
|
2501
|
+
return this;
|
|
2502
|
+
}
|
|
2475
2503
|
succeed(string) {
|
|
2476
2504
|
this.running = false;
|
|
2505
|
+
if (_Spinner.current === this) _Spinner.current = null;
|
|
2477
2506
|
this._cleanupDeregister?.();
|
|
2478
2507
|
this._cleanupDeregister = null;
|
|
2479
2508
|
if (process.stdout.isTTY) {
|
|
@@ -2489,6 +2518,7 @@ var _Spinner = class _Spinner {
|
|
|
2489
2518
|
}
|
|
2490
2519
|
fail(string) {
|
|
2491
2520
|
this.running = false;
|
|
2521
|
+
if (_Spinner.current === this) _Spinner.current = null;
|
|
2492
2522
|
this._cleanupDeregister?.();
|
|
2493
2523
|
this._cleanupDeregister = null;
|
|
2494
2524
|
if (process.stdout.isTTY) {
|
|
@@ -2504,6 +2534,7 @@ var _Spinner = class _Spinner {
|
|
|
2504
2534
|
}
|
|
2505
2535
|
warn(string) {
|
|
2506
2536
|
this.running = false;
|
|
2537
|
+
if (_Spinner.current === this) _Spinner.current = null;
|
|
2507
2538
|
this._cleanupDeregister?.();
|
|
2508
2539
|
this._cleanupDeregister = null;
|
|
2509
2540
|
if (process.stdout.isTTY) {
|
|
@@ -2519,6 +2550,7 @@ var _Spinner = class _Spinner {
|
|
|
2519
2550
|
}
|
|
2520
2551
|
info(string) {
|
|
2521
2552
|
this.running = false;
|
|
2553
|
+
if (_Spinner.current === this) _Spinner.current = null;
|
|
2522
2554
|
this._cleanupDeregister?.();
|
|
2523
2555
|
this._cleanupDeregister = null;
|
|
2524
2556
|
if (process.stdout.isTTY) {
|
|
@@ -2532,6 +2564,14 @@ var _Spinner = class _Spinner {
|
|
|
2532
2564
|
}
|
|
2533
2565
|
return this;
|
|
2534
2566
|
}
|
|
2567
|
+
log(message, glyph = `${FAINT}\xB7${RESET}`) {
|
|
2568
|
+
if (process.stdout.isTTY) {
|
|
2569
|
+
this.clear();
|
|
2570
|
+
}
|
|
2571
|
+
process.stdout.write(`${glyph ? `${glyph} ` : ""}${message}
|
|
2572
|
+
`);
|
|
2573
|
+
return this;
|
|
2574
|
+
}
|
|
2535
2575
|
clear() {
|
|
2536
2576
|
process.stdout.clearLine?.(0);
|
|
2537
2577
|
this._lastLineLength = 0;
|
|
@@ -2546,9 +2586,9 @@ var _Spinner = class _Spinner {
|
|
|
2546
2586
|
}
|
|
2547
2587
|
run() {
|
|
2548
2588
|
const frame = this.coloredFrame();
|
|
2549
|
-
const
|
|
2550
|
-
const content = this.reverse ?
|
|
2551
|
-
const raw =
|
|
2589
|
+
const label = [this._prefix, this.text, this._suffix].filter(Boolean).join(" ");
|
|
2590
|
+
const content = this.reverse ? label ? `${label} ${frame}` : frame : label ? `${frame} ${label}` : frame;
|
|
2591
|
+
const raw = content;
|
|
2552
2592
|
const displayLen = stringLength(raw);
|
|
2553
2593
|
const padding = " ".repeat(Math.max(0, this._lastLineLength - displayLen));
|
|
2554
2594
|
this._lastLineLength = displayLen;
|
|
@@ -2566,6 +2606,7 @@ var _Spinner = class _Spinner {
|
|
|
2566
2606
|
}, this.interval);
|
|
2567
2607
|
}
|
|
2568
2608
|
};
|
|
2609
|
+
_Spinner.current = null;
|
|
2569
2610
|
_Spinner.FRAMES = {
|
|
2570
2611
|
braille: ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"],
|
|
2571
2612
|
dots: ["\u28FE", "\u28FD", "\u28FB", "\u28BF", "\u287F", "\u28DF", "\u28EF", "\u28F7"],
|
package/dist/models/Bar.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ export interface BarOptions {
|
|
|
30
30
|
rateUnit?: string;
|
|
31
31
|
}
|
|
32
32
|
export declare class Bar {
|
|
33
|
+
static current: Bar | null;
|
|
33
34
|
static readonly COLORS: {
|
|
34
35
|
blueRed: string[];
|
|
35
36
|
redBlue: string[];
|
|
@@ -83,7 +84,7 @@ export declare class Bar {
|
|
|
83
84
|
private _showEta;
|
|
84
85
|
private _rateUnit;
|
|
85
86
|
private _etaSuffix;
|
|
86
|
-
constructor(options?: BarOptions);
|
|
87
|
+
constructor(text?: string | BarOptions, options?: BarOptions);
|
|
87
88
|
get colors(): string[];
|
|
88
89
|
set colors(value: string[]);
|
|
89
90
|
get bgColors(): string[];
|
|
@@ -95,7 +96,8 @@ export declare class Bar {
|
|
|
95
96
|
set empty(string: string);
|
|
96
97
|
start(): void;
|
|
97
98
|
stop(message?: string): this;
|
|
98
|
-
|
|
99
|
+
update(string: string): this;
|
|
100
|
+
log(message: string, glyph?: string): this;
|
|
99
101
|
track(total: number, options?: {
|
|
100
102
|
unit?: string;
|
|
101
103
|
showRate?: boolean;
|
package/dist/models/Bar.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Bar.d.ts","sourceRoot":"","sources":["../../src/models/Bar.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"Bar.d.ts","sourceRoot":"","sources":["../../src/models/Bar.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAA8K,MAAM,eAAe,CAAA;AAGrN,MAAM,MAAM,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,cAAc,CAAA;AAExD,MAAM,WAAW,UAAU;IACzB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO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IAAI,IAAI;IAUpB,OAAO,CAAC,KAAK;IAIb,OAAO,CAAC,UAAU;IAKlB,OAAO,CAAC,WAAW;IAOnB,OAAO,CAAC,SAAS;IAMjB,OAAO,CAAC,aAAa;IAMrB,OAAO,CAAC,gBAAgB;IA0BxB,OAAO,CAAC,kBAAkB;IAqB1B,OAAO,CAAC,oBAAoB;IAsC5B,OAAO,CAAC,SAAS;IAkBjB,OAAO,CAAC,GAAG;CAOZ;AAGD,OAAO,EAAE,SAAS,EAAE,CAAA"}
|
package/dist/models/Spinner.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export interface SpinnerOptions {
|
|
|
17
17
|
glyphs?: boolean;
|
|
18
18
|
}
|
|
19
19
|
export declare class Spinner {
|
|
20
|
+
static current: Spinner | null;
|
|
20
21
|
static readonly FRAMES: {
|
|
21
22
|
braille: string[];
|
|
22
23
|
dots: string[];
|
|
@@ -31,10 +32,10 @@ export declare class Spinner {
|
|
|
31
32
|
text: string;
|
|
32
33
|
reverse: boolean;
|
|
33
34
|
onSpin: (() => void) | undefined;
|
|
35
|
+
private _prefix;
|
|
36
|
+
private _suffix;
|
|
34
37
|
private running;
|
|
35
38
|
private frameIndex;
|
|
36
|
-
private prefixString;
|
|
37
|
-
private suffixString;
|
|
38
39
|
private _colors;
|
|
39
40
|
private _parsedColors;
|
|
40
41
|
private _bgColors;
|
|
@@ -48,18 +49,21 @@ export declare class Spinner {
|
|
|
48
49
|
private _infoColor;
|
|
49
50
|
private _glyphs;
|
|
50
51
|
private _cleanupDeregister;
|
|
51
|
-
constructor(options?: SpinnerOptions);
|
|
52
|
+
constructor(text?: string | SpinnerOptions, options?: SpinnerOptions);
|
|
52
53
|
get colors(): string[];
|
|
53
54
|
set colors(value: string[]);
|
|
54
55
|
get bgColors(): string[];
|
|
55
56
|
set bgColors(value: string[]);
|
|
56
57
|
start(): void;
|
|
57
58
|
stop(message?: string): this;
|
|
58
|
-
|
|
59
|
+
update(string: string): this;
|
|
60
|
+
prefix(string: string): this;
|
|
61
|
+
suffix(string: string): this;
|
|
59
62
|
succeed(string?: string): this;
|
|
60
63
|
fail(string?: string): this;
|
|
61
64
|
warn(string?: string): this;
|
|
62
65
|
info(string?: string): this;
|
|
66
|
+
log(message: string, glyph?: string): this;
|
|
63
67
|
private clear;
|
|
64
68
|
private coloredFrame;
|
|
65
69
|
private run;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Spinner.d.ts","sourceRoot":"","sources":["../../src/models/Spinner.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IACjB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAA;IACnB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB;AAED,qBAAa,OAAO;IAClB,MAAM,CAAC,QAAQ,CAAC,MAAM;;;;;;MAMrB;IAED,MAAM,EAAE,MAAM,EAAE,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,OAAO,CAAA;IAChB,MAAM,EAAE,CA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