@jannael/glinter 1.2.5 → 1.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +921 -704
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -174,10 +174,10 @@ function errorHandler(error) {
|
|
|
174
174
|
}
|
|
175
175
|
|
|
176
176
|
// node_modules/@clack/core/dist/index.mjs
|
|
177
|
-
import { styleText
|
|
178
|
-
import { stdout
|
|
179
|
-
import * as
|
|
180
|
-
import
|
|
177
|
+
import { styleText } from "util";
|
|
178
|
+
import { stdout, stdin } from "process";
|
|
179
|
+
import * as l from "readline";
|
|
180
|
+
import l__default from "readline";
|
|
181
181
|
|
|
182
182
|
// node_modules/fast-string-truncated-width/dist/utils.js
|
|
183
183
|
var getCodePointsLength = (() => {
|
|
@@ -522,106 +522,162 @@ function wrapAnsi(string, columns, options) {
|
|
|
522
522
|
|
|
523
523
|
// node_modules/@clack/core/dist/index.mjs
|
|
524
524
|
var import_sisteransi = __toESM(require_src(), 1);
|
|
525
|
-
import { ReadStream
|
|
526
|
-
function
|
|
527
|
-
if (!
|
|
528
|
-
return
|
|
529
|
-
const
|
|
530
|
-
return
|
|
531
|
-
}
|
|
532
|
-
function
|
|
533
|
-
const
|
|
525
|
+
import { ReadStream } from "tty";
|
|
526
|
+
function findCursor(s, o, l2) {
|
|
527
|
+
if (!l2.some((r) => !r.disabled))
|
|
528
|
+
return s;
|
|
529
|
+
const t = s + o, n = Math.max(l2.length - 1, 0), e = t < 0 ? n : t > n ? 0 : t;
|
|
530
|
+
return l2[e].disabled ? findCursor(e, o < 0 ? -1 : 1, l2) : e;
|
|
531
|
+
}
|
|
532
|
+
function findTextCursor(s, o, l2, i) {
|
|
533
|
+
const t = i.split(`
|
|
534
534
|
`);
|
|
535
|
-
let n = 0,
|
|
536
|
-
for (const
|
|
537
|
-
if (
|
|
535
|
+
let n = 0, e = s;
|
|
536
|
+
for (const r of t) {
|
|
537
|
+
if (e <= r.length)
|
|
538
538
|
break;
|
|
539
|
-
|
|
540
|
-
}
|
|
541
|
-
for (n = Math.max(0, Math.min(
|
|
542
|
-
n--,
|
|
543
|
-
for (;
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
let
|
|
547
|
-
for (let
|
|
548
|
-
|
|
549
|
-
return
|
|
550
|
-
}
|
|
551
|
-
var
|
|
552
|
-
var
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
539
|
+
e -= r.length + 1, n++;
|
|
540
|
+
}
|
|
541
|
+
for (n = Math.max(0, Math.min(t.length - 1, n + l2)), e = Math.min(e, t[n].length) + o;e < 0 && n > 0; )
|
|
542
|
+
n--, e += t[n].length + 1;
|
|
543
|
+
for (;e > t[n].length && n < t.length - 1; )
|
|
544
|
+
e -= t[n].length + 1, n++;
|
|
545
|
+
e = Math.max(0, Math.min(t[n].length, e));
|
|
546
|
+
let h = 0;
|
|
547
|
+
for (let r = 0;r < n; r++)
|
|
548
|
+
h += t[r].length + 1;
|
|
549
|
+
return h + e;
|
|
550
|
+
}
|
|
551
|
+
var a$2 = ["up", "down", "left", "right", "space", "enter", "cancel"];
|
|
552
|
+
var t = [
|
|
553
|
+
"January",
|
|
554
|
+
"February",
|
|
555
|
+
"March",
|
|
556
|
+
"April",
|
|
557
|
+
"May",
|
|
558
|
+
"June",
|
|
559
|
+
"July",
|
|
560
|
+
"August",
|
|
561
|
+
"September",
|
|
562
|
+
"October",
|
|
563
|
+
"November",
|
|
564
|
+
"December"
|
|
565
|
+
];
|
|
566
|
+
var settings = {
|
|
567
|
+
actions: new Set(a$2),
|
|
568
|
+
aliases: /* @__PURE__ */ new Map([
|
|
569
|
+
["k", "up"],
|
|
570
|
+
["j", "down"],
|
|
571
|
+
["h", "left"],
|
|
572
|
+
["l", "right"],
|
|
573
|
+
["\x03", "cancel"],
|
|
574
|
+
["escape", "cancel"]
|
|
575
|
+
]),
|
|
576
|
+
messages: {
|
|
577
|
+
cancel: "Canceled",
|
|
578
|
+
error: "Something went wrong"
|
|
579
|
+
},
|
|
580
|
+
withGuide: true,
|
|
581
|
+
date: {
|
|
582
|
+
monthNames: [...t],
|
|
583
|
+
messages: {
|
|
584
|
+
required: "Please enter a valid date",
|
|
585
|
+
invalidMonth: "There are only 12 months in a year",
|
|
586
|
+
invalidDay: (n, e) => `There are only ${n} days in ${e}`,
|
|
587
|
+
afterMin: (n) => `Date must be on or after ${n.toISOString().slice(0, 10)}`,
|
|
588
|
+
beforeMax: (n) => `Date must be on or before ${n.toISOString().slice(0, 10)}`
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
};
|
|
592
|
+
function isActionKey(n, e) {
|
|
593
|
+
if (typeof n == "string")
|
|
594
|
+
return settings.aliases.get(n) === e;
|
|
595
|
+
for (const s of n)
|
|
596
|
+
if (s !== undefined && isActionKey(s, e))
|
|
559
597
|
return true;
|
|
560
598
|
return false;
|
|
561
599
|
}
|
|
562
|
-
function
|
|
563
|
-
if (
|
|
600
|
+
function diffLines(i, s) {
|
|
601
|
+
if (i === s)
|
|
564
602
|
return;
|
|
565
|
-
const
|
|
566
|
-
`),
|
|
567
|
-
`),
|
|
568
|
-
for (let
|
|
569
|
-
|
|
570
|
-
return {
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
603
|
+
const e = i.split(`
|
|
604
|
+
`), t2 = s.split(`
|
|
605
|
+
`), r = Math.max(e.length, t2.length), f = [];
|
|
606
|
+
for (let n = 0;n < r; n++)
|
|
607
|
+
e[n] !== t2[n] && f.push(n);
|
|
608
|
+
return {
|
|
609
|
+
lines: f,
|
|
610
|
+
numLinesBefore: e.length,
|
|
611
|
+
numLinesAfter: t2.length,
|
|
612
|
+
numLines: r
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
var R = globalThis.process.platform.startsWith("win");
|
|
616
|
+
var CANCEL_SYMBOL = Symbol("clack:cancel");
|
|
617
|
+
function isCancel(e) {
|
|
618
|
+
return e === CANCEL_SYMBOL;
|
|
619
|
+
}
|
|
620
|
+
function setRawMode(e, r) {
|
|
621
|
+
const o = e;
|
|
622
|
+
o.isTTY && o.setRawMode(r);
|
|
623
|
+
}
|
|
624
|
+
function block({
|
|
625
|
+
input: e = stdin,
|
|
626
|
+
output: r = stdout,
|
|
627
|
+
overwrite: o = true,
|
|
628
|
+
hideCursor: t2 = true
|
|
629
|
+
} = {}) {
|
|
630
|
+
const s = l.createInterface({
|
|
631
|
+
input: e,
|
|
632
|
+
output: r,
|
|
633
|
+
prompt: "",
|
|
634
|
+
tabSize: 1
|
|
635
|
+
});
|
|
636
|
+
l.emitKeypressEvents(e, s), e instanceof ReadStream && e.isTTY && e.setRawMode(true);
|
|
637
|
+
const n = (f, { name: a, sequence: p }) => {
|
|
638
|
+
const c = String(f);
|
|
639
|
+
if (isActionKey([c, a, p], "cancel")) {
|
|
640
|
+
t2 && r.write(import_sisteransi.cursor.show), process.exit(0);
|
|
588
641
|
return;
|
|
589
642
|
}
|
|
590
|
-
if (!
|
|
643
|
+
if (!o)
|
|
591
644
|
return;
|
|
592
|
-
const
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
645
|
+
const i = a === "return" ? 0 : -1, m = a === "return" ? -1 : 0;
|
|
646
|
+
l.moveCursor(r, i, m, () => {
|
|
647
|
+
l.clearLine(r, 1, () => {
|
|
648
|
+
e.once("keypress", n);
|
|
596
649
|
});
|
|
597
650
|
});
|
|
598
651
|
};
|
|
599
|
-
return
|
|
600
|
-
|
|
652
|
+
return t2 && r.write(import_sisteransi.cursor.hide), e.once("keypress", n), () => {
|
|
653
|
+
e.off("keypress", n), t2 && r.write(import_sisteransi.cursor.show), e instanceof ReadStream && e.isTTY && !R && e.setRawMode(false), s.terminal = false, s.close();
|
|
601
654
|
};
|
|
602
655
|
}
|
|
603
|
-
var
|
|
604
|
-
var
|
|
605
|
-
function
|
|
606
|
-
const
|
|
607
|
-
return wrapAnsi(
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
656
|
+
var getColumns = (e) => ("columns" in e) && typeof e.columns == "number" ? e.columns : 80;
|
|
657
|
+
var getRows = (e) => ("rows" in e) && typeof e.rows == "number" ? e.rows : 20;
|
|
658
|
+
function wrapTextWithPrefix(e, r, o, t2 = o, s = o, n) {
|
|
659
|
+
const f = getColumns(e ?? stdout);
|
|
660
|
+
return wrapAnsi(r, f - o.length, {
|
|
661
|
+
hard: true,
|
|
662
|
+
trim: false
|
|
663
|
+
}).split(`
|
|
664
|
+
`).map((c, i, m) => {
|
|
665
|
+
const d = n ? n(c, i) : c;
|
|
666
|
+
return i === 0 ? `${t2}${d}` : i === m.length - 1 ? `${s}${d}` : `${o}${d}`;
|
|
611
667
|
}).join(`
|
|
612
668
|
`);
|
|
613
669
|
}
|
|
614
|
-
function
|
|
615
|
-
if ("~standard" in
|
|
616
|
-
const
|
|
617
|
-
if (
|
|
670
|
+
function runValidation(e, n) {
|
|
671
|
+
if ("~standard" in e) {
|
|
672
|
+
const a = e["~standard"].validate(n);
|
|
673
|
+
if (a instanceof Promise)
|
|
618
674
|
throw new TypeError("Schema validation must be synchronous. Update `validate()` and remove any asynchronous logic.");
|
|
619
|
-
return
|
|
675
|
+
return a.issues?.at(0)?.message;
|
|
620
676
|
}
|
|
621
|
-
return
|
|
677
|
+
return e(n);
|
|
622
678
|
}
|
|
623
679
|
|
|
624
|
-
class
|
|
680
|
+
class V {
|
|
625
681
|
input;
|
|
626
682
|
output;
|
|
627
683
|
_abortSignal;
|
|
@@ -630,270 +686,305 @@ class m {
|
|
|
630
686
|
_render;
|
|
631
687
|
_track = false;
|
|
632
688
|
_prevFrame = "";
|
|
633
|
-
_subscribers = new Map;
|
|
689
|
+
_subscribers = /* @__PURE__ */ new Map;
|
|
634
690
|
_cursor = 0;
|
|
635
691
|
state = "initial";
|
|
636
692
|
error = "";
|
|
637
693
|
value;
|
|
638
694
|
userInput = "";
|
|
639
|
-
constructor(
|
|
640
|
-
const { input:
|
|
641
|
-
this.opts =
|
|
695
|
+
constructor(t2, e = true) {
|
|
696
|
+
const { input: i = stdin, output: n = stdout, render: s, signal: r, ...o } = t2;
|
|
697
|
+
this.opts = o, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = s.bind(this), this._track = e, this._abortSignal = r, this.input = i, this.output = n;
|
|
642
698
|
}
|
|
643
699
|
unsubscribe() {
|
|
644
700
|
this._subscribers.clear();
|
|
645
701
|
}
|
|
646
|
-
setSubscriber(
|
|
647
|
-
const
|
|
648
|
-
|
|
702
|
+
setSubscriber(t2, e) {
|
|
703
|
+
const i = this._subscribers.get(t2) ?? [];
|
|
704
|
+
i.push(e), this._subscribers.set(t2, i);
|
|
649
705
|
}
|
|
650
|
-
on(
|
|
651
|
-
this.setSubscriber(
|
|
706
|
+
on(t2, e) {
|
|
707
|
+
this.setSubscriber(t2, { cb: e });
|
|
652
708
|
}
|
|
653
|
-
once(
|
|
654
|
-
this.setSubscriber(
|
|
709
|
+
once(t2, e) {
|
|
710
|
+
this.setSubscriber(t2, { cb: e, once: true });
|
|
655
711
|
}
|
|
656
|
-
emit(
|
|
657
|
-
const
|
|
658
|
-
for (const
|
|
659
|
-
|
|
660
|
-
for (const
|
|
661
|
-
|
|
712
|
+
emit(t2, ...e) {
|
|
713
|
+
const i = this._subscribers.get(t2) ?? [], n = [];
|
|
714
|
+
for (const s of i)
|
|
715
|
+
s.cb(...e), s.once && n.push(() => i.splice(i.indexOf(s), 1));
|
|
716
|
+
for (const s of n)
|
|
717
|
+
s();
|
|
662
718
|
}
|
|
663
719
|
prompt() {
|
|
664
|
-
return new Promise((
|
|
720
|
+
return new Promise((t2) => {
|
|
665
721
|
if (this._abortSignal) {
|
|
666
722
|
if (this._abortSignal.aborted)
|
|
667
|
-
return this.state = "cancel", this.close(),
|
|
723
|
+
return this.state = "cancel", this.close(), t2(CANCEL_SYMBOL);
|
|
668
724
|
this._abortSignal.addEventListener("abort", () => {
|
|
669
725
|
this.state = "cancel", this.close();
|
|
670
726
|
}, { once: true });
|
|
671
727
|
}
|
|
672
|
-
this.rl =
|
|
673
|
-
|
|
728
|
+
this.rl = l__default.createInterface({
|
|
729
|
+
input: this.input,
|
|
730
|
+
tabSize: 2,
|
|
731
|
+
prompt: "",
|
|
732
|
+
escapeCodeTimeout: 50,
|
|
733
|
+
terminal: true
|
|
734
|
+
}), this.rl.prompt(), this.opts.initialUserInput !== undefined && this._setUserInput(this.opts.initialUserInput, true), this.input.on("keypress", this.onKeypress), setRawMode(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
|
|
735
|
+
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t2(this.value);
|
|
674
736
|
}), this.once("cancel", () => {
|
|
675
|
-
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render),
|
|
737
|
+
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t2(CANCEL_SYMBOL);
|
|
676
738
|
});
|
|
677
739
|
});
|
|
678
740
|
}
|
|
679
|
-
_isActionKey(
|
|
680
|
-
return
|
|
741
|
+
_isActionKey(t2, e) {
|
|
742
|
+
return t2 === "\t";
|
|
681
743
|
}
|
|
682
|
-
_shouldSubmit(
|
|
744
|
+
_shouldSubmit(t2, e) {
|
|
683
745
|
return true;
|
|
684
746
|
}
|
|
685
|
-
_setValue(
|
|
686
|
-
this.value =
|
|
747
|
+
_setValue(t2) {
|
|
748
|
+
this.value = t2, this.emit("value", this.value);
|
|
687
749
|
}
|
|
688
|
-
_setUserInput(
|
|
689
|
-
this.userInput =
|
|
750
|
+
_setUserInput(t2, e) {
|
|
751
|
+
this.userInput = t2 ?? "", this.emit("userInput", this.userInput), e && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
|
|
690
752
|
}
|
|
691
753
|
_clearUserInput() {
|
|
692
754
|
this.rl?.write(null, { ctrl: true, name: "u" }), this._setUserInput("");
|
|
693
755
|
}
|
|
694
|
-
onKeypress(
|
|
695
|
-
if (this._track &&
|
|
756
|
+
onKeypress(t2, e) {
|
|
757
|
+
if (this._track && e.name !== "return" && (e.name && this._isActionKey(t2, e) && this.rl?.write(null, { ctrl: true, name: "h" }), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), e?.name && (!this._track && settings.aliases.has(e.name) && this.emit("cursor", settings.aliases.get(e.name)), settings.actions.has(e.name) && this.emit("cursor", e.name)), t2 && (t2.toLowerCase() === "y" || t2.toLowerCase() === "n") && this.emit("confirm", t2.toLowerCase() === "y"), this.emit("key", t2, e), e?.name === "return" && this._shouldSubmit(t2, e)) {
|
|
696
758
|
if (this.opts.validate) {
|
|
697
|
-
const
|
|
698
|
-
|
|
759
|
+
const i = runValidation(this.opts.validate, this.value);
|
|
760
|
+
i && (this.error = i instanceof Error ? i.message : i, this.state = "error", this.rl?.write(this.userInput));
|
|
699
761
|
}
|
|
700
762
|
this.state !== "error" && (this.state = "submit");
|
|
701
763
|
}
|
|
702
|
-
|
|
764
|
+
isActionKey([t2, e?.name, e?.sequence], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
|
|
703
765
|
}
|
|
704
766
|
close() {
|
|
705
767
|
this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
|
|
706
|
-
`),
|
|
768
|
+
`), setRawMode(this.input, false), this.rl?.close(), this.rl = undefined, this.emit(`${this.state}`, this.value), this.unsubscribe();
|
|
707
769
|
}
|
|
708
770
|
restoreCursor() {
|
|
709
|
-
const
|
|
771
|
+
const t2 = wrapAnsi(this._prevFrame, process.stdout.columns, { hard: true, trim: false }).split(`
|
|
710
772
|
`).length - 1;
|
|
711
|
-
this.output.write(import_sisteransi.cursor.move(-999,
|
|
773
|
+
this.output.write(import_sisteransi.cursor.move(-999, t2 * -1));
|
|
712
774
|
}
|
|
713
775
|
render() {
|
|
714
|
-
const
|
|
715
|
-
|
|
776
|
+
const t2 = wrapAnsi(this._render(this) ?? "", process.stdout.columns, {
|
|
777
|
+
hard: true,
|
|
778
|
+
trim: false
|
|
779
|
+
});
|
|
780
|
+
if (t2 !== this._prevFrame) {
|
|
716
781
|
if (this.state === "initial")
|
|
717
782
|
this.output.write(import_sisteransi.cursor.hide);
|
|
718
783
|
else {
|
|
719
|
-
const
|
|
720
|
-
if (this.restoreCursor(),
|
|
721
|
-
const
|
|
722
|
-
let
|
|
723
|
-
if (
|
|
724
|
-
this._prevFrame =
|
|
784
|
+
const e = diffLines(this._prevFrame, t2), i = getRows(this.output);
|
|
785
|
+
if (this.restoreCursor(), e) {
|
|
786
|
+
const n = Math.max(0, e.numLinesAfter - i), s = Math.max(0, e.numLinesBefore - i);
|
|
787
|
+
let r = e.lines.find((o) => o >= n);
|
|
788
|
+
if (r === undefined) {
|
|
789
|
+
this._prevFrame = t2;
|
|
725
790
|
return;
|
|
726
791
|
}
|
|
727
|
-
if (
|
|
728
|
-
this.output.write(import_sisteransi.cursor.move(0,
|
|
729
|
-
const
|
|
792
|
+
if (e.lines.length === 1) {
|
|
793
|
+
this.output.write(import_sisteransi.cursor.move(0, r - s)), this.output.write(import_sisteransi.erase.lines(1));
|
|
794
|
+
const o = t2.split(`
|
|
730
795
|
`);
|
|
731
|
-
this.output.write(
|
|
796
|
+
this.output.write(o[r]), this._prevFrame = t2, this.output.write(import_sisteransi.cursor.move(0, o.length - r - 1));
|
|
732
797
|
return;
|
|
733
|
-
} else if (
|
|
734
|
-
if (
|
|
735
|
-
|
|
798
|
+
} else if (e.lines.length > 1) {
|
|
799
|
+
if (n < s)
|
|
800
|
+
r = n;
|
|
736
801
|
else {
|
|
737
|
-
const
|
|
738
|
-
|
|
802
|
+
const h = r - s;
|
|
803
|
+
h > 0 && this.output.write(import_sisteransi.cursor.move(0, h));
|
|
739
804
|
}
|
|
740
805
|
this.output.write(import_sisteransi.erase.down());
|
|
741
|
-
const
|
|
742
|
-
`).slice(
|
|
743
|
-
this.output.write(
|
|
744
|
-
`)), this._prevFrame =
|
|
806
|
+
const f = t2.split(`
|
|
807
|
+
`).slice(r);
|
|
808
|
+
this.output.write(f.join(`
|
|
809
|
+
`)), this._prevFrame = t2;
|
|
745
810
|
return;
|
|
746
811
|
}
|
|
747
812
|
}
|
|
748
813
|
this.output.write(import_sisteransi.erase.down());
|
|
749
814
|
}
|
|
750
|
-
this.output.write(
|
|
815
|
+
this.output.write(t2), this.state === "initial" && (this.state = "active"), this._prevFrame = t2;
|
|
751
816
|
}
|
|
752
817
|
}
|
|
753
818
|
}
|
|
754
|
-
function
|
|
755
|
-
if (
|
|
819
|
+
function p$1(l2, e) {
|
|
820
|
+
if (l2 === undefined || e.length === 0)
|
|
756
821
|
return 0;
|
|
757
|
-
const
|
|
758
|
-
return
|
|
822
|
+
const i = e.findIndex((s) => s.value === l2);
|
|
823
|
+
return i !== -1 ? i : 0;
|
|
759
824
|
}
|
|
760
|
-
function
|
|
761
|
-
return (
|
|
825
|
+
function g(l2, e) {
|
|
826
|
+
return (e.label ?? String(e.value)).toLowerCase().includes(l2.toLowerCase());
|
|
762
827
|
}
|
|
763
|
-
function
|
|
764
|
-
if (
|
|
765
|
-
return
|
|
828
|
+
function m(l2, e) {
|
|
829
|
+
if (e)
|
|
830
|
+
return l2 ? e : e[0];
|
|
766
831
|
}
|
|
767
|
-
var
|
|
832
|
+
var T$1 = class T extends V {
|
|
768
833
|
filteredOptions;
|
|
769
834
|
multiple;
|
|
770
835
|
isNavigating = false;
|
|
771
836
|
selectedValues = [];
|
|
772
837
|
focusedValue;
|
|
773
|
-
#
|
|
774
|
-
#
|
|
838
|
+
#e = 0;
|
|
839
|
+
#s = "";
|
|
775
840
|
#t;
|
|
841
|
+
#i;
|
|
776
842
|
#n;
|
|
777
|
-
#u;
|
|
778
843
|
get cursor() {
|
|
779
|
-
return this.#
|
|
844
|
+
return this.#e;
|
|
780
845
|
}
|
|
781
846
|
get userInputWithCursor() {
|
|
782
847
|
if (!this.userInput)
|
|
783
|
-
return
|
|
848
|
+
return styleText(["inverse", "hidden"], "_");
|
|
784
849
|
if (this._cursor >= this.userInput.length)
|
|
785
850
|
return `${this.userInput}\u2588`;
|
|
786
|
-
const
|
|
787
|
-
return `${
|
|
851
|
+
const e = this.userInput.slice(0, this._cursor), [t2, ...i] = this.userInput.slice(this._cursor);
|
|
852
|
+
return `${e}${styleText("inverse", t2)}${i.join("")}`;
|
|
788
853
|
}
|
|
789
854
|
get options() {
|
|
790
|
-
return typeof this.#
|
|
791
|
-
}
|
|
792
|
-
constructor(
|
|
793
|
-
super(
|
|
794
|
-
const
|
|
795
|
-
this.filteredOptions = [...
|
|
796
|
-
let
|
|
797
|
-
if (
|
|
798
|
-
for (const
|
|
799
|
-
const n =
|
|
800
|
-
n !== -1 && (this.toggleSelected(
|
|
855
|
+
return typeof this.#i == "function" ? this.#i() : this.#i;
|
|
856
|
+
}
|
|
857
|
+
constructor(e) {
|
|
858
|
+
super(e), this.#i = e.options, this.#n = e.placeholder;
|
|
859
|
+
const t2 = this.options;
|
|
860
|
+
this.filteredOptions = [...t2], this.multiple = e.multiple === true, this.#t = typeof e.options == "function" ? e.filter : e.filter ?? g;
|
|
861
|
+
let i;
|
|
862
|
+
if (e.initialValue && Array.isArray(e.initialValue) ? this.multiple ? i = e.initialValue : i = e.initialValue.slice(0, 1) : !this.multiple && this.options.length > 0 && (i = [this.options[0].value]), i)
|
|
863
|
+
for (const s of i) {
|
|
864
|
+
const n = t2.findIndex((o) => o.value === s);
|
|
865
|
+
n !== -1 && (this.toggleSelected(s), this.#e = n);
|
|
801
866
|
}
|
|
802
|
-
this.focusedValue = this.options[this.#
|
|
867
|
+
this.focusedValue = this.options[this.#e]?.value, this.on("key", (s, n) => this.#l(s, n)), this.on("userInput", (s) => this.#u(s));
|
|
803
868
|
}
|
|
804
|
-
_isActionKey(
|
|
805
|
-
return
|
|
869
|
+
_isActionKey(e, t2) {
|
|
870
|
+
return e === "\t" || this.multiple && this.isNavigating && t2.name === "space" && e !== undefined && e !== "";
|
|
806
871
|
}
|
|
807
|
-
#e
|
|
808
|
-
const
|
|
809
|
-
if (
|
|
872
|
+
#l(e, t2) {
|
|
873
|
+
const i = t2.name === "up", s = t2.name === "down", n = t2.name === "return", o = this.userInput === "" || this.userInput === "\t", u = this.#n, h = this.options, f = u !== undefined && u !== "" && h.some((r) => !r.disabled && (this.#t ? this.#t(u, r) : true));
|
|
874
|
+
if (t2.name === "tab" && o && f) {
|
|
810
875
|
this.userInput === "\t" && this._clearUserInput(), this._setUserInput(u, true), this.isNavigating = false;
|
|
811
876
|
return;
|
|
812
877
|
}
|
|
813
|
-
|
|
878
|
+
i || s ? (this.#e = findCursor(this.#e, i ? -1 : 1, this.filteredOptions), this.focusedValue = this.filteredOptions[this.#e]?.value, this.multiple || (this.selectedValues = [this.focusedValue]), this.isNavigating = true) : n ? this.value = m(this.multiple, this.selectedValues) : this.multiple ? this.focusedValue !== undefined && (t2.name === "tab" || this.isNavigating && t2.name === "space") ? this.toggleSelected(this.focusedValue) : this.isNavigating = false : (this.focusedValue && (this.selectedValues = [this.focusedValue]), this.isNavigating = false);
|
|
814
879
|
}
|
|
815
880
|
deselectAll() {
|
|
816
881
|
this.selectedValues = [];
|
|
817
882
|
}
|
|
818
|
-
toggleSelected(
|
|
819
|
-
this.filteredOptions.length !== 0 && (this.multiple ? this.selectedValues.includes(
|
|
820
|
-
}
|
|
821
|
-
#
|
|
822
|
-
if (
|
|
823
|
-
this.#
|
|
824
|
-
const
|
|
825
|
-
|
|
826
|
-
const
|
|
827
|
-
this.#
|
|
828
|
-
const
|
|
829
|
-
|
|
883
|
+
toggleSelected(e) {
|
|
884
|
+
this.filteredOptions.length !== 0 && (this.multiple ? this.selectedValues.includes(e) ? this.selectedValues = this.selectedValues.filter((t2) => t2 !== e) : this.selectedValues = [...this.selectedValues, e] : this.selectedValues = [e]);
|
|
885
|
+
}
|
|
886
|
+
#u(e) {
|
|
887
|
+
if (e !== this.#s) {
|
|
888
|
+
this.#s = e;
|
|
889
|
+
const t2 = this.options;
|
|
890
|
+
e && this.#t ? this.filteredOptions = t2.filter((n) => this.#t?.(e, n)) : this.filteredOptions = [...t2];
|
|
891
|
+
const i = p$1(this.focusedValue, this.filteredOptions);
|
|
892
|
+
this.#e = findCursor(i, 0, this.filteredOptions);
|
|
893
|
+
const s = this.filteredOptions[this.#e];
|
|
894
|
+
s && !s.disabled ? this.focusedValue = s.value : this.focusedValue = undefined, this.multiple || (this.focusedValue !== undefined ? this.toggleSelected(this.focusedValue) : this.deselectAll());
|
|
830
895
|
}
|
|
831
896
|
}
|
|
832
897
|
};
|
|
833
898
|
|
|
834
|
-
class
|
|
899
|
+
class r extends V {
|
|
835
900
|
get cursor() {
|
|
836
901
|
return this.value ? 0 : 1;
|
|
837
902
|
}
|
|
838
903
|
get _value() {
|
|
839
904
|
return this.cursor === 0;
|
|
840
905
|
}
|
|
841
|
-
constructor(
|
|
842
|
-
super(
|
|
906
|
+
constructor(t2) {
|
|
907
|
+
super(t2, false), this.value = !!t2.initialValue, this.on("userInput", () => {
|
|
843
908
|
this.value = this._value;
|
|
844
|
-
}), this.on("confirm", (
|
|
845
|
-
this.output.write(import_sisteransi.cursor.move(0, -1)), this.value =
|
|
909
|
+
}), this.on("confirm", (i) => {
|
|
910
|
+
this.output.write(import_sisteransi.cursor.move(0, -1)), this.value = i, this.state = "submit", this.close();
|
|
846
911
|
}), this.on("cursor", () => {
|
|
847
912
|
this.value = !this.value;
|
|
848
913
|
});
|
|
849
914
|
}
|
|
850
915
|
}
|
|
851
|
-
var
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
}
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
}
|
|
865
|
-
|
|
866
|
-
|
|
916
|
+
var _ = {
|
|
917
|
+
Y: { type: "year", len: 4 },
|
|
918
|
+
M: { type: "month", len: 2 },
|
|
919
|
+
D: { type: "day", len: 2 }
|
|
920
|
+
};
|
|
921
|
+
function M(r2) {
|
|
922
|
+
return [...r2].map((t2) => _[t2]);
|
|
923
|
+
}
|
|
924
|
+
function P(r2) {
|
|
925
|
+
const i = new Intl.DateTimeFormat(r2, {
|
|
926
|
+
year: "numeric",
|
|
927
|
+
month: "2-digit",
|
|
928
|
+
day: "2-digit"
|
|
929
|
+
}).formatToParts(new Date(2000, 0, 15)), s = [];
|
|
930
|
+
let n = "/";
|
|
931
|
+
for (const e of i)
|
|
932
|
+
e.type === "literal" ? n = e.value.trim() || e.value : (e.type === "year" || e.type === "month" || e.type === "day") && s.push({ type: e.type, len: e.type === "year" ? 4 : 2 });
|
|
933
|
+
return { segments: s, separator: n };
|
|
934
|
+
}
|
|
935
|
+
function p(r2) {
|
|
936
|
+
return Number.parseInt((r2 || "0").replace(/_/g, "0"), 10) || 0;
|
|
937
|
+
}
|
|
938
|
+
function f(r2) {
|
|
939
|
+
return {
|
|
940
|
+
year: p(r2.year),
|
|
941
|
+
month: p(r2.month),
|
|
942
|
+
day: p(r2.day)
|
|
943
|
+
};
|
|
867
944
|
}
|
|
868
|
-
function
|
|
869
|
-
return new Date(
|
|
945
|
+
function c(r2, t2) {
|
|
946
|
+
return new Date(r2 || 2001, t2 || 1, 0).getDate();
|
|
870
947
|
}
|
|
871
|
-
function
|
|
872
|
-
const { year:
|
|
873
|
-
if (!
|
|
948
|
+
function b(r2) {
|
|
949
|
+
const { year: t2, month: i, day: s } = f(r2);
|
|
950
|
+
if (!t2 || t2 < 0 || t2 > 9999 || !i || i < 1 || i > 12 || !s || s < 1)
|
|
874
951
|
return;
|
|
875
|
-
const
|
|
876
|
-
if (!(
|
|
877
|
-
return { year:
|
|
878
|
-
}
|
|
879
|
-
function
|
|
880
|
-
const
|
|
881
|
-
return
|
|
882
|
-
}
|
|
883
|
-
function
|
|
884
|
-
const
|
|
885
|
-
|
|
952
|
+
const n = new Date(Date.UTC(t2, i - 1, s));
|
|
953
|
+
if (!(n.getUTCFullYear() !== t2 || n.getUTCMonth() !== i - 1 || n.getUTCDate() !== s))
|
|
954
|
+
return { year: t2, month: i, day: s };
|
|
955
|
+
}
|
|
956
|
+
function C(r2) {
|
|
957
|
+
const t2 = b(r2);
|
|
958
|
+
return t2 ? new Date(Date.UTC(t2.year, t2.month - 1, t2.day)) : undefined;
|
|
959
|
+
}
|
|
960
|
+
function T2(r2, t2, i, s) {
|
|
961
|
+
const n = i ? {
|
|
962
|
+
year: i.getUTCFullYear(),
|
|
963
|
+
month: i.getUTCMonth() + 1,
|
|
964
|
+
day: i.getUTCDate()
|
|
965
|
+
} : null, e = s ? {
|
|
966
|
+
year: s.getUTCFullYear(),
|
|
967
|
+
month: s.getUTCMonth() + 1,
|
|
968
|
+
day: s.getUTCDate()
|
|
969
|
+
} : null;
|
|
970
|
+
return r2 === "year" ? { min: n?.year ?? 1, max: e?.year ?? 9999 } : r2 === "month" ? {
|
|
971
|
+
min: n && t2.year === n.year ? n.month : 1,
|
|
972
|
+
max: e && t2.year === e.year ? e.month : 12
|
|
973
|
+
} : {
|
|
974
|
+
min: n && t2.year === n.year && t2.month === n.month ? n.day : 1,
|
|
975
|
+
max: e && t2.year === e.year && t2.month === e.month ? e.day : c(t2.year, t2.month)
|
|
976
|
+
};
|
|
886
977
|
}
|
|
887
978
|
|
|
888
|
-
class
|
|
889
|
-
#
|
|
890
|
-
#
|
|
979
|
+
class U extends V {
|
|
980
|
+
#i;
|
|
981
|
+
#o;
|
|
891
982
|
#t;
|
|
892
|
-
#
|
|
983
|
+
#h;
|
|
893
984
|
#u;
|
|
894
985
|
#e = { segmentIndex: 0, positionInSegment: 0 };
|
|
895
|
-
#
|
|
896
|
-
#
|
|
986
|
+
#n = true;
|
|
987
|
+
#s = null;
|
|
897
988
|
inlineError = "";
|
|
898
989
|
get segmentCursor() {
|
|
899
990
|
return { ...this.#e };
|
|
@@ -902,172 +993,189 @@ class it extends m {
|
|
|
902
993
|
return { ...this.#t };
|
|
903
994
|
}
|
|
904
995
|
get segments() {
|
|
905
|
-
return this.#
|
|
996
|
+
return this.#i;
|
|
906
997
|
}
|
|
907
998
|
get separator() {
|
|
908
|
-
return this.#
|
|
999
|
+
return this.#o;
|
|
909
1000
|
}
|
|
910
1001
|
get formattedValue() {
|
|
911
|
-
return this.#
|
|
912
|
-
}
|
|
913
|
-
#c(t) {
|
|
914
|
-
return this.#s.map((s) => t[s.type]).join(this.#r);
|
|
915
|
-
}
|
|
916
|
-
#a() {
|
|
917
|
-
this._setUserInput(this.#c(this.#t)), this._setValue(E(this.#t) ?? undefined);
|
|
1002
|
+
return this.#l(this.#t);
|
|
918
1003
|
}
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
super({ ...t, initialUserInput: u }, false), this.#s = i, this.#r = e, this.#t = o, this.#n = t.minDate, this.#u = t.maxDate, this.#a(), this.on("cursor", (a) => this.#d(a)), this.on("key", (a, l) => this.#f(a, l)), this.on("finalize", () => this.#g(t));
|
|
1004
|
+
#l(t2) {
|
|
1005
|
+
return this.#i.map((i) => t2[i.type]).join(this.#o);
|
|
922
1006
|
}
|
|
923
|
-
#
|
|
924
|
-
|
|
925
|
-
if (s)
|
|
926
|
-
return this.#e.positionInSegment = Math.max(0, Math.min(this.#e.positionInSegment, s.len - 1)), { segment: s, index: t };
|
|
1007
|
+
#r() {
|
|
1008
|
+
this._setUserInput(this.#l(this.#t)), this._setValue(C(this.#t) ?? undefined);
|
|
927
1009
|
}
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
1010
|
+
constructor(t2) {
|
|
1011
|
+
const i = t2.format ? { segments: M(t2.format), separator: t2.separator ?? "/" } : P(t2.locale), s = t2.separator ?? i.separator, n = t2.format ? M(t2.format) : i.segments, e = t2.initialValue ?? t2.defaultValue, m2 = e ? {
|
|
1012
|
+
year: String(e.getUTCFullYear()).padStart(4, "0"),
|
|
1013
|
+
month: String(e.getUTCMonth() + 1).padStart(2, "0"),
|
|
1014
|
+
day: String(e.getUTCDate()).padStart(2, "0")
|
|
1015
|
+
} : { year: "____", month: "__", day: "__" }, o = n.map((a) => m2[a.type]).join(s);
|
|
1016
|
+
super({ ...t2, initialUserInput: o }, false), this.#i = n, this.#o = s, this.#t = m2, this.#h = t2.minDate, this.#u = t2.maxDate, this.#r(), this.on("cursor", (a) => this.#f(a)), this.on("key", (a, u) => this.#y(a, u)), this.on("finalize", () => this.#p(t2));
|
|
932
1017
|
}
|
|
933
|
-
#
|
|
934
|
-
const
|
|
935
|
-
if (
|
|
1018
|
+
#a() {
|
|
1019
|
+
const t2 = Math.max(0, Math.min(this.#e.segmentIndex, this.#i.length - 1)), i = this.#i[t2];
|
|
1020
|
+
if (i)
|
|
1021
|
+
return this.#e.positionInSegment = Math.max(0, Math.min(this.#e.positionInSegment, i.len - 1)), { segment: i, index: t2 };
|
|
1022
|
+
}
|
|
1023
|
+
#m(t2) {
|
|
1024
|
+
this.inlineError = "", this.#s = null;
|
|
1025
|
+
const i = this.#a();
|
|
1026
|
+
i && (this.#e.segmentIndex = Math.max(0, Math.min(this.#i.length - 1, i.index + t2)), this.#e.positionInSegment = 0, this.#n = true);
|
|
1027
|
+
}
|
|
1028
|
+
#d(t2) {
|
|
1029
|
+
const i = this.#a();
|
|
1030
|
+
if (!i)
|
|
936
1031
|
return;
|
|
937
|
-
const { segment:
|
|
1032
|
+
const { segment: s } = i, n = this.#t[s.type], e = !n || n.replace(/_/g, "") === "", m2 = Number.parseInt((n || "0").replace(/_/g, "0"), 10) || 0, o = T2(s.type, f(this.#t), this.#h, this.#u);
|
|
938
1033
|
let a;
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
1034
|
+
e ? a = t2 === 1 ? o.min : o.max : a = Math.max(Math.min(o.max, m2 + t2), o.min), this.#t = {
|
|
1035
|
+
...this.#t,
|
|
1036
|
+
[s.type]: a.toString().padStart(s.len, "0")
|
|
1037
|
+
}, this.#n = true, this.#s = null, this.#r();
|
|
1038
|
+
}
|
|
1039
|
+
#f(t2) {
|
|
1040
|
+
if (t2)
|
|
1041
|
+
switch (t2) {
|
|
944
1042
|
case "right":
|
|
945
|
-
return this.#
|
|
1043
|
+
return this.#m(1);
|
|
946
1044
|
case "left":
|
|
947
|
-
return this.#
|
|
1045
|
+
return this.#m(-1);
|
|
948
1046
|
case "up":
|
|
949
|
-
return this.#
|
|
1047
|
+
return this.#d(1);
|
|
950
1048
|
case "down":
|
|
951
|
-
return this.#
|
|
1049
|
+
return this.#d(-1);
|
|
952
1050
|
}
|
|
953
1051
|
}
|
|
954
|
-
#
|
|
955
|
-
if (
|
|
1052
|
+
#y(t2, i) {
|
|
1053
|
+
if (i?.name === "backspace" || i?.sequence === "\x7F" || i?.sequence === "\b" || t2 === "\x7F" || t2 === "\b") {
|
|
956
1054
|
this.inlineError = "";
|
|
957
|
-
const
|
|
958
|
-
if (!
|
|
1055
|
+
const n = this.#a();
|
|
1056
|
+
if (!n)
|
|
959
1057
|
return;
|
|
960
|
-
if (!this.#t[
|
|
961
|
-
this.#
|
|
1058
|
+
if (!this.#t[n.segment.type].replace(/_/g, "")) {
|
|
1059
|
+
this.#m(-1);
|
|
962
1060
|
return;
|
|
963
1061
|
}
|
|
964
|
-
this.#t[
|
|
1062
|
+
this.#t[n.segment.type] = "_".repeat(n.segment.len), this.#n = true, this.#e.positionInSegment = 0, this.#r();
|
|
965
1063
|
return;
|
|
966
1064
|
}
|
|
967
|
-
if (
|
|
1065
|
+
if (i?.name === "tab") {
|
|
968
1066
|
this.inlineError = "";
|
|
969
|
-
const
|
|
970
|
-
if (!
|
|
1067
|
+
const n = this.#a();
|
|
1068
|
+
if (!n)
|
|
971
1069
|
return;
|
|
972
|
-
const
|
|
973
|
-
|
|
1070
|
+
const e = i.shift ? -1 : 1, m2 = n.index + e;
|
|
1071
|
+
m2 >= 0 && m2 < this.#i.length && (this.#e.segmentIndex = m2, this.#e.positionInSegment = 0, this.#n = true);
|
|
974
1072
|
return;
|
|
975
1073
|
}
|
|
976
|
-
if (
|
|
977
|
-
const
|
|
978
|
-
if (!
|
|
1074
|
+
if (t2 && /^[0-9]$/.test(t2)) {
|
|
1075
|
+
const n = this.#a();
|
|
1076
|
+
if (!n)
|
|
979
1077
|
return;
|
|
980
|
-
const { segment:
|
|
981
|
-
if (this.#
|
|
982
|
-
const
|
|
983
|
-
if (
|
|
984
|
-
this.inlineError =
|
|
1078
|
+
const { segment: e } = n, m2 = !this.#t[e.type].replace(/_/g, "");
|
|
1079
|
+
if (this.#n && this.#s !== null && !m2) {
|
|
1080
|
+
const h = this.#s + t2, d = { ...this.#t, [e.type]: h }, g2 = this.#g(d, e);
|
|
1081
|
+
if (g2) {
|
|
1082
|
+
this.inlineError = g2, this.#s = null, this.#n = false;
|
|
985
1083
|
return;
|
|
986
1084
|
}
|
|
987
|
-
this.inlineError = "", this.#t[
|
|
1085
|
+
this.inlineError = "", this.#t[e.type] = h, this.#s = null, this.#n = false, this.#r(), n.index < this.#i.length - 1 && (this.#e.segmentIndex = n.index + 1, this.#e.positionInSegment = 0, this.#n = true);
|
|
988
1086
|
return;
|
|
989
1087
|
}
|
|
990
|
-
this.#
|
|
991
|
-
const o = this.#t[
|
|
992
|
-
if (
|
|
1088
|
+
this.#n && !m2 && (this.#t[e.type] = "_".repeat(e.len), this.#e.positionInSegment = 0), this.#n = false, this.#s = null;
|
|
1089
|
+
const o = this.#t[e.type], a = o.indexOf("_"), u = a >= 0 ? a : Math.min(this.#e.positionInSegment, e.len - 1);
|
|
1090
|
+
if (u < 0 || u >= e.len)
|
|
993
1091
|
return;
|
|
994
|
-
let
|
|
995
|
-
if (
|
|
996
|
-
const
|
|
997
|
-
|
|
1092
|
+
let l2 = o.slice(0, u) + t2 + o.slice(u + 1), D = false;
|
|
1093
|
+
if (u === 0 && o === "__" && (e.type === "month" || e.type === "day")) {
|
|
1094
|
+
const h = Number.parseInt(t2, 10);
|
|
1095
|
+
l2 = `0${t2}`, D = h <= (e.type === "month" ? 1 : 2);
|
|
998
1096
|
}
|
|
999
|
-
if (
|
|
1000
|
-
const
|
|
1001
|
-
if (
|
|
1002
|
-
this.inlineError =
|
|
1097
|
+
if (e.type === "year" && (l2 = (o.replace(/_/g, "") + t2).padStart(e.len, "_")), !l2.includes("_")) {
|
|
1098
|
+
const h = { ...this.#t, [e.type]: l2 }, d = this.#g(h, e);
|
|
1099
|
+
if (d) {
|
|
1100
|
+
this.inlineError = d;
|
|
1003
1101
|
return;
|
|
1004
1102
|
}
|
|
1005
1103
|
}
|
|
1006
|
-
this.inlineError = "", this.#t[
|
|
1007
|
-
const y =
|
|
1104
|
+
this.inlineError = "", this.#t[e.type] = l2;
|
|
1105
|
+
const y = l2.includes("_") ? undefined : b(this.#t);
|
|
1008
1106
|
if (y) {
|
|
1009
|
-
const { year:
|
|
1010
|
-
this.#t = {
|
|
1107
|
+
const { year: h, month: d } = y, g2 = c(h, d);
|
|
1108
|
+
this.#t = {
|
|
1109
|
+
year: String(Math.max(0, Math.min(9999, h))).padStart(4, "0"),
|
|
1110
|
+
month: String(Math.max(1, Math.min(12, d))).padStart(2, "0"),
|
|
1111
|
+
day: String(Math.max(1, Math.min(g2, y.day))).padStart(2, "0")
|
|
1112
|
+
};
|
|
1011
1113
|
}
|
|
1012
|
-
this.#
|
|
1013
|
-
const
|
|
1014
|
-
|
|
1114
|
+
this.#r();
|
|
1115
|
+
const S = l2.indexOf("_");
|
|
1116
|
+
D ? (this.#n = true, this.#s = t2) : S >= 0 ? this.#e.positionInSegment = S : a >= 0 && n.index < this.#i.length - 1 ? (this.#e.segmentIndex = n.index + 1, this.#e.positionInSegment = 0, this.#n = true) : this.#e.positionInSegment = Math.min(u + 1, e.len - 1);
|
|
1015
1117
|
}
|
|
1016
1118
|
}
|
|
1017
|
-
#
|
|
1018
|
-
const { month:
|
|
1019
|
-
if (
|
|
1020
|
-
return
|
|
1021
|
-
if (
|
|
1022
|
-
return
|
|
1023
|
-
}
|
|
1024
|
-
#
|
|
1025
|
-
const { year:
|
|
1026
|
-
if (
|
|
1027
|
-
const
|
|
1028
|
-
this.#t = {
|
|
1119
|
+
#g(t2, i) {
|
|
1120
|
+
const { month: s, day: n } = f(t2);
|
|
1121
|
+
if (i.type === "month" && (s < 0 || s > 12))
|
|
1122
|
+
return settings.date.messages.invalidMonth;
|
|
1123
|
+
if (i.type === "day" && (n < 0 || n > 31))
|
|
1124
|
+
return settings.date.messages.invalidDay(31, "any month");
|
|
1125
|
+
}
|
|
1126
|
+
#p(t2) {
|
|
1127
|
+
const { year: i, month: s, day: n } = f(this.#t);
|
|
1128
|
+
if (i && s && n) {
|
|
1129
|
+
const e = c(i, s);
|
|
1130
|
+
this.#t = {
|
|
1131
|
+
...this.#t,
|
|
1132
|
+
day: String(Math.min(n, e)).padStart(2, "0")
|
|
1133
|
+
};
|
|
1029
1134
|
}
|
|
1030
|
-
this.value =
|
|
1135
|
+
this.value = C(this.#t) ?? t2.defaultValue ?? undefined;
|
|
1031
1136
|
}
|
|
1032
1137
|
}
|
|
1033
|
-
var
|
|
1138
|
+
var u$1 = class u extends V {
|
|
1034
1139
|
options;
|
|
1035
1140
|
cursor = 0;
|
|
1036
|
-
#
|
|
1037
|
-
getGroupItems(
|
|
1038
|
-
return this.options.filter((
|
|
1141
|
+
#t;
|
|
1142
|
+
getGroupItems(t2) {
|
|
1143
|
+
return this.options.filter((r2) => r2.group === t2);
|
|
1039
1144
|
}
|
|
1040
|
-
isGroupSelected(
|
|
1041
|
-
const
|
|
1042
|
-
return e === undefined ? false :
|
|
1145
|
+
isGroupSelected(t2) {
|
|
1146
|
+
const r2 = this.getGroupItems(t2), e = this.value;
|
|
1147
|
+
return e === undefined ? false : r2.every((s) => e.includes(s.value));
|
|
1043
1148
|
}
|
|
1044
1149
|
toggleValue() {
|
|
1045
|
-
const
|
|
1046
|
-
if (this.value === undefined && (this.value = []),
|
|
1047
|
-
const
|
|
1048
|
-
this.isGroupSelected(
|
|
1150
|
+
const t2 = this.options[this.cursor];
|
|
1151
|
+
if (this.value === undefined && (this.value = []), t2.group === true) {
|
|
1152
|
+
const r2 = t2.value, e = this.getGroupItems(r2);
|
|
1153
|
+
this.isGroupSelected(r2) ? this.value = this.value.filter((s) => e.findIndex((i) => i.value === s) === -1) : this.value = [...this.value, ...e.map((s) => s.value)], this.value = Array.from(new Set(this.value));
|
|
1049
1154
|
} else {
|
|
1050
|
-
const
|
|
1051
|
-
this.value =
|
|
1155
|
+
const r2 = this.value.includes(t2.value);
|
|
1156
|
+
this.value = r2 ? this.value.filter((e) => e !== t2.value) : [...this.value, t2.value];
|
|
1052
1157
|
}
|
|
1053
1158
|
}
|
|
1054
|
-
constructor(
|
|
1055
|
-
super(
|
|
1056
|
-
const { options:
|
|
1057
|
-
this.#
|
|
1159
|
+
constructor(t2) {
|
|
1160
|
+
super(t2, false);
|
|
1161
|
+
const { options: r2 } = t2;
|
|
1162
|
+
this.#t = t2.selectableGroups !== false, this.options = Object.entries(r2).flatMap(([e, s]) => [
|
|
1163
|
+
{ value: e, group: true, label: e },
|
|
1164
|
+
...s.map((i) => ({ ...i, group: e }))
|
|
1165
|
+
]), this.value = [...t2.initialValues ?? []], this.cursor = Math.max(this.options.findIndex(({ value: e }) => e === t2.cursorAt), this.#t ? 0 : 1), this.on("cursor", (e) => {
|
|
1058
1166
|
switch (e) {
|
|
1059
1167
|
case "left":
|
|
1060
1168
|
case "up": {
|
|
1061
1169
|
this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
|
|
1062
|
-
const
|
|
1063
|
-
!this.#
|
|
1170
|
+
const s = this.options[this.cursor]?.group === true;
|
|
1171
|
+
!this.#t && s && (this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1);
|
|
1064
1172
|
break;
|
|
1065
1173
|
}
|
|
1066
1174
|
case "down":
|
|
1067
1175
|
case "right": {
|
|
1068
1176
|
this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
|
|
1069
|
-
const
|
|
1070
|
-
!this.#
|
|
1177
|
+
const s = this.options[this.cursor]?.group === true;
|
|
1178
|
+
!this.#t && s && (this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1);
|
|
1071
1179
|
break;
|
|
1072
1180
|
}
|
|
1073
1181
|
case "space":
|
|
@@ -1077,126 +1185,126 @@ var rt = class extends m {
|
|
|
1077
1185
|
});
|
|
1078
1186
|
}
|
|
1079
1187
|
};
|
|
1080
|
-
var
|
|
1188
|
+
var o$1 = /* @__PURE__ */ new Set(["up", "down", "left", "right"]);
|
|
1081
1189
|
|
|
1082
|
-
class
|
|
1190
|
+
class h extends V {
|
|
1083
1191
|
#s = false;
|
|
1084
|
-
#
|
|
1192
|
+
#t;
|
|
1085
1193
|
focused = "editor";
|
|
1086
1194
|
get userInputWithCursor() {
|
|
1087
1195
|
if (this.state === "submit")
|
|
1088
1196
|
return this.userInput;
|
|
1089
|
-
const
|
|
1090
|
-
if (this.cursor >=
|
|
1091
|
-
return `${
|
|
1092
|
-
const s =
|
|
1093
|
-
return
|
|
1197
|
+
const t2 = this.userInput;
|
|
1198
|
+
if (this.cursor >= t2.length)
|
|
1199
|
+
return `${t2}\u2588`;
|
|
1200
|
+
const s = t2.slice(0, this.cursor), r2 = t2[this.cursor], e = t2.slice(this.cursor + 1);
|
|
1201
|
+
return r2 === `
|
|
1094
1202
|
` ? `${s}\u2588
|
|
1095
|
-
${
|
|
1203
|
+
${e}` : `${s}${styleText("inverse", r2)}${e}`;
|
|
1096
1204
|
}
|
|
1097
1205
|
get cursor() {
|
|
1098
1206
|
return this._cursor;
|
|
1099
1207
|
}
|
|
1100
|
-
#
|
|
1208
|
+
#r(t2) {
|
|
1101
1209
|
if (this.userInput.length === 0) {
|
|
1102
|
-
this._setUserInput(
|
|
1210
|
+
this._setUserInput(t2);
|
|
1103
1211
|
return;
|
|
1104
1212
|
}
|
|
1105
|
-
this._setUserInput(this.userInput.slice(0, this.cursor) +
|
|
1213
|
+
this._setUserInput(this.userInput.slice(0, this.cursor) + t2 + this.userInput.slice(this.cursor));
|
|
1106
1214
|
}
|
|
1107
|
-
#
|
|
1215
|
+
#i(t2) {
|
|
1108
1216
|
const s = this.value ?? "";
|
|
1109
|
-
switch (
|
|
1217
|
+
switch (t2) {
|
|
1110
1218
|
case "up":
|
|
1111
|
-
this._cursor =
|
|
1219
|
+
this._cursor = findTextCursor(this._cursor, 0, -1, s);
|
|
1112
1220
|
return;
|
|
1113
1221
|
case "down":
|
|
1114
|
-
this._cursor =
|
|
1222
|
+
this._cursor = findTextCursor(this._cursor, 0, 1, s);
|
|
1115
1223
|
return;
|
|
1116
1224
|
case "left":
|
|
1117
|
-
this._cursor =
|
|
1225
|
+
this._cursor = findTextCursor(this._cursor, -1, 0, s);
|
|
1118
1226
|
return;
|
|
1119
1227
|
case "right":
|
|
1120
|
-
this._cursor =
|
|
1228
|
+
this._cursor = findTextCursor(this._cursor, 1, 0, s);
|
|
1121
1229
|
return;
|
|
1122
1230
|
}
|
|
1123
1231
|
}
|
|
1124
|
-
_shouldSubmit(
|
|
1125
|
-
if (this.#
|
|
1126
|
-
return this.focused === "submit" ? true : (this.#
|
|
1232
|
+
_shouldSubmit(t2, s) {
|
|
1233
|
+
if (this.#t)
|
|
1234
|
+
return this.focused === "submit" ? true : (this.#r(`
|
|
1127
1235
|
`), this._cursor++, false);
|
|
1128
|
-
const
|
|
1129
|
-
return this.#s = true,
|
|
1130
|
-
` && (this._setUserInput(this.userInput.slice(0, this.cursor - 1) + this.userInput.slice(this.cursor)), this._cursor--), true) : (this.#
|
|
1236
|
+
const r2 = this.#s;
|
|
1237
|
+
return this.#s = true, r2 ? (this.userInput[this.cursor - 1] === `
|
|
1238
|
+
` && (this._setUserInput(this.userInput.slice(0, this.cursor - 1) + this.userInput.slice(this.cursor)), this._cursor--), true) : (this.#r(`
|
|
1131
1239
|
`), this._cursor++, false);
|
|
1132
1240
|
}
|
|
1133
|
-
constructor(
|
|
1134
|
-
super(
|
|
1135
|
-
if (
|
|
1136
|
-
this.#
|
|
1241
|
+
constructor(t2) {
|
|
1242
|
+
super(t2, false), this.#t = t2.showSubmit ?? false, this.on("key", (s, r2) => {
|
|
1243
|
+
if (r2?.name && o$1.has(r2.name)) {
|
|
1244
|
+
this.#i(r2.name);
|
|
1137
1245
|
return;
|
|
1138
1246
|
}
|
|
1139
|
-
if (s === "\t" && this.#
|
|
1247
|
+
if (s === "\t" && this.#t) {
|
|
1140
1248
|
this.focused = this.focused === "editor" ? "submit" : "editor";
|
|
1141
1249
|
return;
|
|
1142
1250
|
}
|
|
1143
|
-
if (
|
|
1144
|
-
if (this.#s = false,
|
|
1251
|
+
if (r2?.name !== "return") {
|
|
1252
|
+
if (this.#s = false, r2?.name === "backspace" && this.cursor > 0) {
|
|
1145
1253
|
this._setUserInput(this.userInput.slice(0, this.cursor - 1) + this.userInput.slice(this.cursor)), this._cursor--;
|
|
1146
1254
|
return;
|
|
1147
1255
|
}
|
|
1148
|
-
if (
|
|
1256
|
+
if (r2?.name === "delete" && this.cursor < this.userInput.length) {
|
|
1149
1257
|
this._setUserInput(this.userInput.slice(0, this.cursor) + this.userInput.slice(this.cursor + 1));
|
|
1150
1258
|
return;
|
|
1151
1259
|
}
|
|
1152
|
-
s && (this.#
|
|
1260
|
+
s && (this.#t && this.focused === "submit" && (this.focused = "editor"), this.#r(s ?? ""), this._cursor++);
|
|
1153
1261
|
}
|
|
1154
1262
|
}), this.on("userInput", (s) => {
|
|
1155
1263
|
this._setValue(s);
|
|
1156
1264
|
}), this.on("finalize", () => {
|
|
1157
|
-
this.value || (this.value =
|
|
1265
|
+
this.value || (this.value = t2.defaultValue), this.value === undefined && (this.value = "");
|
|
1158
1266
|
});
|
|
1159
1267
|
}
|
|
1160
1268
|
}
|
|
1161
|
-
var
|
|
1269
|
+
var a$1 = class a extends V {
|
|
1162
1270
|
options;
|
|
1163
1271
|
cursor = 0;
|
|
1164
1272
|
get _value() {
|
|
1165
1273
|
return this.options[this.cursor].value;
|
|
1166
1274
|
}
|
|
1167
1275
|
get _enabledOptions() {
|
|
1168
|
-
return this.options.filter((
|
|
1276
|
+
return this.options.filter((e) => e.disabled !== true);
|
|
1169
1277
|
}
|
|
1170
1278
|
toggleAll() {
|
|
1171
|
-
const
|
|
1172
|
-
this.value =
|
|
1279
|
+
const e = this._enabledOptions, i = this.value !== undefined && this.value.length === e.length;
|
|
1280
|
+
this.value = i ? [] : e.map((t2) => t2.value);
|
|
1173
1281
|
}
|
|
1174
1282
|
toggleInvert() {
|
|
1175
|
-
const
|
|
1176
|
-
if (!
|
|
1283
|
+
const e = this.value;
|
|
1284
|
+
if (!e)
|
|
1177
1285
|
return;
|
|
1178
|
-
const
|
|
1179
|
-
this.value =
|
|
1286
|
+
const i = this._enabledOptions.filter((t2) => !e.includes(t2.value));
|
|
1287
|
+
this.value = i.map((t2) => t2.value);
|
|
1180
1288
|
}
|
|
1181
1289
|
toggleValue() {
|
|
1182
1290
|
this.value === undefined && (this.value = []);
|
|
1183
|
-
const
|
|
1184
|
-
this.value =
|
|
1185
|
-
}
|
|
1186
|
-
constructor(
|
|
1187
|
-
super(
|
|
1188
|
-
const
|
|
1189
|
-
this.cursor = this.options[
|
|
1190
|
-
|
|
1191
|
-
}), this.on("cursor", (
|
|
1192
|
-
switch (
|
|
1291
|
+
const e = this.value.includes(this._value);
|
|
1292
|
+
this.value = e ? this.value.filter((i) => i !== this._value) : [...this.value, this._value];
|
|
1293
|
+
}
|
|
1294
|
+
constructor(e) {
|
|
1295
|
+
super(e, false), this.options = e.options, this.value = [...e.initialValues ?? []];
|
|
1296
|
+
const i = Math.max(this.options.findIndex(({ value: t2 }) => t2 === e.cursorAt), 0);
|
|
1297
|
+
this.cursor = this.options[i].disabled ? findCursor(i, 1, this.options) : i, this.on("key", (t2, l2) => {
|
|
1298
|
+
l2.name === "a" && this.toggleAll(), l2.name === "i" && this.toggleInvert();
|
|
1299
|
+
}), this.on("cursor", (t2) => {
|
|
1300
|
+
switch (t2) {
|
|
1193
1301
|
case "left":
|
|
1194
1302
|
case "up":
|
|
1195
|
-
this.cursor =
|
|
1303
|
+
this.cursor = findCursor(this.cursor, -1, this.options);
|
|
1196
1304
|
break;
|
|
1197
1305
|
case "down":
|
|
1198
1306
|
case "right":
|
|
1199
|
-
this.cursor =
|
|
1307
|
+
this.cursor = findCursor(this.cursor, 1, this.options);
|
|
1200
1308
|
break;
|
|
1201
1309
|
case "space":
|
|
1202
1310
|
this.toggleValue();
|
|
@@ -1205,7 +1313,7 @@ var ut = class extends m {
|
|
|
1205
1313
|
});
|
|
1206
1314
|
}
|
|
1207
1315
|
};
|
|
1208
|
-
class
|
|
1316
|
+
class a2 extends V {
|
|
1209
1317
|
options;
|
|
1210
1318
|
cursor = 0;
|
|
1211
1319
|
get _selectedValue() {
|
|
@@ -1214,393 +1322,496 @@ class ht extends m {
|
|
|
1214
1322
|
changeValue() {
|
|
1215
1323
|
this.value = this._selectedValue.value;
|
|
1216
1324
|
}
|
|
1217
|
-
constructor(
|
|
1218
|
-
super(
|
|
1219
|
-
const
|
|
1220
|
-
this.cursor = this.options[e].disabled ?
|
|
1221
|
-
switch (
|
|
1325
|
+
constructor(t2) {
|
|
1326
|
+
super(t2, false), this.options = t2.options;
|
|
1327
|
+
const i = this.options.findIndex(({ value: s }) => s === t2.initialValue), e = i === -1 ? 0 : i;
|
|
1328
|
+
this.cursor = this.options[e].disabled ? findCursor(e, 1, this.options) : e, this.changeValue(), this.on("cursor", (s) => {
|
|
1329
|
+
switch (s) {
|
|
1222
1330
|
case "left":
|
|
1223
1331
|
case "up":
|
|
1224
|
-
this.cursor =
|
|
1332
|
+
this.cursor = findCursor(this.cursor, -1, this.options);
|
|
1225
1333
|
break;
|
|
1226
1334
|
case "down":
|
|
1227
1335
|
case "right":
|
|
1228
|
-
this.cursor =
|
|
1336
|
+
this.cursor = findCursor(this.cursor, 1, this.options);
|
|
1229
1337
|
break;
|
|
1230
1338
|
}
|
|
1231
1339
|
this.changeValue();
|
|
1232
1340
|
});
|
|
1233
1341
|
}
|
|
1234
1342
|
}
|
|
1235
|
-
class
|
|
1343
|
+
class n extends V {
|
|
1236
1344
|
get userInputWithCursor() {
|
|
1237
1345
|
if (this.state === "submit")
|
|
1238
1346
|
return this.userInput;
|
|
1239
|
-
const
|
|
1240
|
-
if (this.cursor >=
|
|
1347
|
+
const t2 = this.userInput;
|
|
1348
|
+
if (this.cursor >= t2.length)
|
|
1241
1349
|
return `${this.userInput}\u2588`;
|
|
1242
|
-
const
|
|
1243
|
-
return `${
|
|
1350
|
+
const e = t2.slice(0, this.cursor), [s, ...r2] = t2.slice(this.cursor);
|
|
1351
|
+
return `${e}${styleText("inverse", s)}${r2.join("")}`;
|
|
1244
1352
|
}
|
|
1245
1353
|
get cursor() {
|
|
1246
1354
|
return this._cursor;
|
|
1247
1355
|
}
|
|
1248
|
-
constructor(
|
|
1249
|
-
super({
|
|
1250
|
-
|
|
1356
|
+
constructor(t2) {
|
|
1357
|
+
super({
|
|
1358
|
+
...t2,
|
|
1359
|
+
initialUserInput: t2.initialUserInput ?? t2.initialValue
|
|
1360
|
+
}), this.on("userInput", (e) => {
|
|
1361
|
+
this._setValue(e);
|
|
1251
1362
|
}), this.on("finalize", () => {
|
|
1252
|
-
this.value || (this.value =
|
|
1363
|
+
this.value || (this.value = t2.defaultValue), this.value === undefined && (this.value = "");
|
|
1253
1364
|
});
|
|
1254
1365
|
}
|
|
1255
1366
|
}
|
|
1256
1367
|
|
|
1257
1368
|
// node_modules/@clack/prompts/dist/index.mjs
|
|
1258
|
-
import { styleText as
|
|
1259
|
-
import
|
|
1369
|
+
import { styleText as styleText2, stripVTControlCharacters } from "util";
|
|
1370
|
+
import process$1 from "process";
|
|
1260
1371
|
var import_sisteransi2 = __toESM(require_src(), 1);
|
|
1261
|
-
function
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
var
|
|
1268
|
-
var
|
|
1269
|
-
var
|
|
1270
|
-
var
|
|
1271
|
-
var
|
|
1272
|
-
var
|
|
1273
|
-
var
|
|
1274
|
-
var
|
|
1275
|
-
var
|
|
1276
|
-
var
|
|
1277
|
-
var
|
|
1278
|
-
var
|
|
1279
|
-
var
|
|
1280
|
-
var
|
|
1281
|
-
var
|
|
1282
|
-
var
|
|
1283
|
-
var
|
|
1284
|
-
var
|
|
1285
|
-
var
|
|
1286
|
-
var
|
|
1287
|
-
var
|
|
1288
|
-
var
|
|
1289
|
-
var
|
|
1290
|
-
var
|
|
1291
|
-
var
|
|
1292
|
-
var
|
|
1293
|
-
|
|
1372
|
+
function isUnicodeSupported() {
|
|
1373
|
+
if (process$1.platform !== "win32") {
|
|
1374
|
+
return process$1.env.TERM !== "linux";
|
|
1375
|
+
}
|
|
1376
|
+
return Boolean(process$1.env.CI) || Boolean(process$1.env.WT_SESSION) || Boolean(process$1.env.TERMINUS_SUBLIME) || process$1.env.ConEmuTask === "{cmd::Cmder}" || process$1.env.TERM_PROGRAM === "Terminus-Sublime" || process$1.env.TERM_PROGRAM === "vscode" || process$1.env.TERM === "xterm-256color" || process$1.env.TERM === "alacritty" || process$1.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
1377
|
+
}
|
|
1378
|
+
var unicode = isUnicodeSupported();
|
|
1379
|
+
var isCI = () => process.env.CI === "true";
|
|
1380
|
+
var unicodeOr = (e, o2) => unicode ? e : o2;
|
|
1381
|
+
var S_STEP_ACTIVE = unicodeOr("\u25C6", "*");
|
|
1382
|
+
var S_STEP_CANCEL = unicodeOr("\u25A0", "x");
|
|
1383
|
+
var S_STEP_ERROR = unicodeOr("\u25B2", "x");
|
|
1384
|
+
var S_STEP_SUBMIT = unicodeOr("\u25C7", "o");
|
|
1385
|
+
var S_BAR_START = unicodeOr("\u250C", "T");
|
|
1386
|
+
var S_BAR = unicodeOr("\u2502", "|");
|
|
1387
|
+
var S_BAR_END = unicodeOr("\u2514", "\u2014");
|
|
1388
|
+
var S_BAR_START_RIGHT = unicodeOr("\u2510", "T");
|
|
1389
|
+
var S_BAR_END_RIGHT = unicodeOr("\u2518", "\u2014");
|
|
1390
|
+
var S_RADIO_ACTIVE = unicodeOr("\u25CF", ">");
|
|
1391
|
+
var S_RADIO_INACTIVE = unicodeOr("\u25CB", " ");
|
|
1392
|
+
var S_CHECKBOX_ACTIVE = unicodeOr("\u25FB", "[\u2022]");
|
|
1393
|
+
var S_CHECKBOX_SELECTED = unicodeOr("\u25FC", "[+]");
|
|
1394
|
+
var S_CHECKBOX_INACTIVE = unicodeOr("\u25FB", "[ ]");
|
|
1395
|
+
var S_PASSWORD_MASK = unicodeOr("\u25AA", "\u2022");
|
|
1396
|
+
var S_BAR_H = unicodeOr("\u2500", "-");
|
|
1397
|
+
var S_CORNER_TOP_RIGHT = unicodeOr("\u256E", "+");
|
|
1398
|
+
var S_CONNECT_LEFT = unicodeOr("\u251C", "+");
|
|
1399
|
+
var S_CORNER_BOTTOM_RIGHT = unicodeOr("\u256F", "+");
|
|
1400
|
+
var S_CORNER_BOTTOM_LEFT = unicodeOr("\u2570", "+");
|
|
1401
|
+
var S_CORNER_TOP_LEFT = unicodeOr("\u256D", "+");
|
|
1402
|
+
var S_INFO = unicodeOr("\u25CF", "\u2022");
|
|
1403
|
+
var S_SUCCESS = unicodeOr("\u25C6", "*");
|
|
1404
|
+
var S_WARN = unicodeOr("\u25B2", "!");
|
|
1405
|
+
var S_ERROR = unicodeOr("\u25A0", "x");
|
|
1406
|
+
var symbol = (e) => {
|
|
1407
|
+
switch (e) {
|
|
1294
1408
|
case "initial":
|
|
1295
1409
|
case "active":
|
|
1296
|
-
return
|
|
1410
|
+
return styleText2("cyan", S_STEP_ACTIVE);
|
|
1297
1411
|
case "cancel":
|
|
1298
|
-
return
|
|
1412
|
+
return styleText2("red", S_STEP_CANCEL);
|
|
1299
1413
|
case "error":
|
|
1300
|
-
return
|
|
1414
|
+
return styleText2("yellow", S_STEP_ERROR);
|
|
1301
1415
|
case "submit":
|
|
1302
|
-
return
|
|
1416
|
+
return styleText2("green", S_STEP_SUBMIT);
|
|
1303
1417
|
}
|
|
1304
1418
|
};
|
|
1305
|
-
var
|
|
1306
|
-
switch (
|
|
1419
|
+
var symbolBar = (e) => {
|
|
1420
|
+
switch (e) {
|
|
1307
1421
|
case "initial":
|
|
1308
1422
|
case "active":
|
|
1309
|
-
return
|
|
1423
|
+
return styleText2("cyan", S_BAR);
|
|
1310
1424
|
case "cancel":
|
|
1311
|
-
return
|
|
1425
|
+
return styleText2("red", S_BAR);
|
|
1312
1426
|
case "error":
|
|
1313
|
-
return
|
|
1427
|
+
return styleText2("yellow", S_BAR);
|
|
1314
1428
|
case "submit":
|
|
1315
|
-
return
|
|
1429
|
+
return styleText2("green", S_BAR);
|
|
1316
1430
|
}
|
|
1317
1431
|
};
|
|
1318
|
-
var
|
|
1319
|
-
let
|
|
1320
|
-
if (
|
|
1321
|
-
for (let
|
|
1432
|
+
var E$1 = (l2, o2, g2, c2, h2, O = false) => {
|
|
1433
|
+
let r2 = o2, w = 0;
|
|
1434
|
+
if (O)
|
|
1435
|
+
for (let i = c2 - 1;i >= g2 && (r2 -= l2[i].length, w++, !(r2 <= h2)); i--)
|
|
1322
1436
|
;
|
|
1323
1437
|
else
|
|
1324
|
-
for (let
|
|
1438
|
+
for (let i = g2;i < c2 && (r2 -= l2[i].length, w++, !(r2 <= h2)); i++)
|
|
1325
1439
|
;
|
|
1326
|
-
return { lineCount:
|
|
1440
|
+
return { lineCount: r2, removals: w };
|
|
1327
1441
|
};
|
|
1328
|
-
var
|
|
1329
|
-
|
|
1442
|
+
var limitOptions = ({
|
|
1443
|
+
cursor: l2,
|
|
1444
|
+
options: o2,
|
|
1445
|
+
style: g2,
|
|
1446
|
+
output: c2 = process.stdout,
|
|
1447
|
+
maxItems: h2 = Number.POSITIVE_INFINITY,
|
|
1448
|
+
columnPadding: O = 0,
|
|
1449
|
+
rowPadding: r2 = 4
|
|
1450
|
+
}) => {
|
|
1451
|
+
const i = getColumns(c2) - O, I = getRows(c2), C2 = styleText2("dim", "..."), x = Math.max(I - r2, 0), m2 = Math.max(Math.min(h2, x), 5);
|
|
1330
1452
|
let p2 = 0;
|
|
1331
|
-
|
|
1332
|
-
let f2 =
|
|
1333
|
-
const
|
|
1334
|
-
let
|
|
1335
|
-
f2 &&
|
|
1336
|
-
const
|
|
1337
|
-
for (let
|
|
1338
|
-
const
|
|
1453
|
+
l2 >= m2 - 3 && (p2 = Math.max(Math.min(l2 - m2 + 3, o2.length - m2), 0));
|
|
1454
|
+
let f2 = m2 < o2.length && p2 > 0, u3 = m2 < o2.length && p2 + m2 < o2.length;
|
|
1455
|
+
const W = Math.min(p2 + m2, o2.length), e = [];
|
|
1456
|
+
let d = 0;
|
|
1457
|
+
f2 && d++, u3 && d++;
|
|
1458
|
+
const v = p2 + (f2 ? 1 : 0), P2 = W - (u3 ? 1 : 0);
|
|
1459
|
+
for (let t2 = v;t2 < P2; t2++) {
|
|
1460
|
+
const n2 = wrapAnsi(g2(o2[t2], t2 === l2), i, {
|
|
1461
|
+
hard: true,
|
|
1462
|
+
trim: false
|
|
1463
|
+
}).split(`
|
|
1339
1464
|
`);
|
|
1340
|
-
|
|
1341
|
-
}
|
|
1342
|
-
if (
|
|
1343
|
-
let
|
|
1344
|
-
const
|
|
1345
|
-
let
|
|
1346
|
-
const
|
|
1347
|
-
f2 ? ({ lineCount:
|
|
1348
|
-
}
|
|
1349
|
-
const
|
|
1350
|
-
f2 &&
|
|
1351
|
-
for (const
|
|
1352
|
-
for (const
|
|
1353
|
-
|
|
1354
|
-
return
|
|
1465
|
+
e.push(n2), d += n2.length;
|
|
1466
|
+
}
|
|
1467
|
+
if (d > x) {
|
|
1468
|
+
let t2 = 0, n2 = 0, s = d;
|
|
1469
|
+
const M2 = l2 - v;
|
|
1470
|
+
let a3 = x;
|
|
1471
|
+
const T3 = () => E$1(e, s, 0, M2, a3), L = () => E$1(e, s, M2 + 1, e.length, a3, true);
|
|
1472
|
+
f2 ? ({ lineCount: s, removals: t2 } = T3(), s > a3 && (u3 || (a3 -= 1), { lineCount: s, removals: n2 } = L())) : (u3 || (a3 -= 1), { lineCount: s, removals: n2 } = L(), s > a3 && (a3 -= 1, { lineCount: s, removals: t2 } = T3())), t2 > 0 && (f2 = true, e.splice(0, t2)), n2 > 0 && (u3 = true, e.splice(e.length - n2, n2));
|
|
1473
|
+
}
|
|
1474
|
+
const b2 = [];
|
|
1475
|
+
f2 && b2.push(C2);
|
|
1476
|
+
for (const t2 of e)
|
|
1477
|
+
for (const n2 of t2)
|
|
1478
|
+
b2.push(n2);
|
|
1479
|
+
return u3 && b2.push(C2), b2;
|
|
1355
1480
|
};
|
|
1356
|
-
var
|
|
1357
|
-
const
|
|
1358
|
-
return new
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
}
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
${
|
|
1481
|
+
var confirm = (i) => {
|
|
1482
|
+
const a3 = i.active ?? "Yes", s = i.inactive ?? "No";
|
|
1483
|
+
return new r({
|
|
1484
|
+
active: a3,
|
|
1485
|
+
inactive: s,
|
|
1486
|
+
signal: i.signal,
|
|
1487
|
+
input: i.input,
|
|
1488
|
+
output: i.output,
|
|
1489
|
+
initialValue: i.initialValue ?? true,
|
|
1490
|
+
render() {
|
|
1491
|
+
const e = i.withGuide ?? settings.withGuide, u3 = `${symbol(this.state)} `, l2 = e ? `${styleText2("gray", S_BAR)} ` : "", f2 = wrapTextWithPrefix(i.output, i.message, l2, u3), o2 = `${e ? `${styleText2("gray", S_BAR)}
|
|
1492
|
+
` : ""}${f2}
|
|
1493
|
+
`, c2 = this.value ? a3 : s;
|
|
1494
|
+
switch (this.state) {
|
|
1495
|
+
case "submit": {
|
|
1496
|
+
const r2 = e ? `${styleText2("gray", S_BAR)} ` : "";
|
|
1497
|
+
return `${o2}${r2}${styleText2("dim", c2)}`;
|
|
1498
|
+
}
|
|
1499
|
+
case "cancel": {
|
|
1500
|
+
const r2 = e ? `${styleText2("gray", S_BAR)} ` : "";
|
|
1501
|
+
return `${o2}${r2}${styleText2(["strikethrough", "dim"], c2)}${e ? `
|
|
1502
|
+
${styleText2("gray", S_BAR)}` : ""}`;
|
|
1503
|
+
}
|
|
1504
|
+
default: {
|
|
1505
|
+
const r2 = e ? `${styleText2("cyan", S_BAR)} ` : "", g2 = e ? styleText2("cyan", S_BAR_END) : "";
|
|
1506
|
+
return `${o2}${r2}${this.value ? `${styleText2("green", S_RADIO_ACTIVE)} ${a3}` : `${styleText2("dim", S_RADIO_INACTIVE)} ${styleText2("dim", a3)}`}${i.vertical ? e ? `
|
|
1507
|
+
${styleText2("cyan", S_BAR)} ` : `
|
|
1508
|
+
` : ` ${styleText2("dim", "/")} `}${this.value ? `${styleText2("dim", S_RADIO_INACTIVE)} ${styleText2("dim", s)}` : `${styleText2("green", S_RADIO_ACTIVE)} ${s}`}
|
|
1509
|
+
${g2}
|
|
1378
1510
|
`;
|
|
1511
|
+
}
|
|
1379
1512
|
}
|
|
1380
1513
|
}
|
|
1381
|
-
}
|
|
1514
|
+
}).prompt();
|
|
1382
1515
|
};
|
|
1383
|
-
var
|
|
1384
|
-
const
|
|
1385
|
-
|
|
1516
|
+
var cancel = (o2 = "", t2) => {
|
|
1517
|
+
const i = t2?.output ?? process.stdout, e = t2?.withGuide ?? settings.withGuide ? `${styleText2("gray", S_BAR_END)} ` : "";
|
|
1518
|
+
i.write(`${e}${styleText2("red", o2)}
|
|
1386
1519
|
|
|
1387
1520
|
`);
|
|
1388
1521
|
};
|
|
1389
|
-
var
|
|
1390
|
-
const
|
|
1391
|
-
|
|
1522
|
+
var intro = (o2 = "", t2) => {
|
|
1523
|
+
const i = t2?.output ?? process.stdout, e = t2?.withGuide ?? settings.withGuide ? `${styleText2("gray", S_BAR_START)} ` : "";
|
|
1524
|
+
i.write(`${e}${o2}
|
|
1392
1525
|
`);
|
|
1393
1526
|
};
|
|
1394
|
-
var
|
|
1395
|
-
const
|
|
1396
|
-
${
|
|
1397
|
-
|
|
1527
|
+
var outro = (o2 = "", t2) => {
|
|
1528
|
+
const i = t2?.output ?? process.stdout, e = t2?.withGuide ?? settings.withGuide ? `${styleText2("gray", S_BAR)}
|
|
1529
|
+
${styleText2("gray", S_BAR_END)} ` : "";
|
|
1530
|
+
i.write(`${e}${o2}
|
|
1398
1531
|
|
|
1399
1532
|
`);
|
|
1400
1533
|
};
|
|
1401
|
-
var
|
|
1402
|
-
`).map((
|
|
1534
|
+
var d = (n2, a3) => n2.split(`
|
|
1535
|
+
`).map((m2) => a3(m2)).join(`
|
|
1403
1536
|
`);
|
|
1404
|
-
var
|
|
1405
|
-
const
|
|
1406
|
-
const
|
|
1407
|
-
return
|
|
1408
|
-
},
|
|
1409
|
-
return new
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
}
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
const
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1537
|
+
var multiselect = (n2) => {
|
|
1538
|
+
const a3 = (t2, o2) => {
|
|
1539
|
+
const r2 = t2.label ?? String(t2.value);
|
|
1540
|
+
return o2 === "disabled" ? `${styleText2("gray", S_CHECKBOX_INACTIVE)} ${d(r2, (l2) => styleText2(["strikethrough", "gray"], l2))}${t2.hint ? ` ${styleText2("dim", `(${t2.hint ?? "disabled"})`)}` : ""}` : o2 === "active" ? `${styleText2("cyan", S_CHECKBOX_ACTIVE)} ${r2}${t2.hint ? ` ${styleText2("dim", `(${t2.hint})`)}` : ""}` : o2 === "selected" ? `${styleText2("green", S_CHECKBOX_SELECTED)} ${d(r2, (l2) => styleText2("dim", l2))}${t2.hint ? ` ${styleText2("dim", `(${t2.hint})`)}` : ""}` : o2 === "cancelled" ? `${d(r2, (l2) => styleText2(["strikethrough", "dim"], l2))}` : o2 === "active-selected" ? `${styleText2("green", S_CHECKBOX_SELECTED)} ${r2}${t2.hint ? ` ${styleText2("dim", `(${t2.hint})`)}` : ""}` : o2 === "submitted" ? `${d(r2, (l2) => styleText2("dim", l2))}` : `${styleText2("dim", S_CHECKBOX_INACTIVE)} ${d(r2, (l2) => styleText2("dim", l2))}`;
|
|
1541
|
+
}, m2 = n2.required ?? true;
|
|
1542
|
+
return new a$1({
|
|
1543
|
+
options: n2.options,
|
|
1544
|
+
signal: n2.signal,
|
|
1545
|
+
input: n2.input,
|
|
1546
|
+
output: n2.output,
|
|
1547
|
+
initialValues: n2.initialValues,
|
|
1548
|
+
required: m2,
|
|
1549
|
+
cursorAt: n2.cursorAt,
|
|
1550
|
+
validate(t2) {
|
|
1551
|
+
if (m2 && (t2 === undefined || t2.length === 0))
|
|
1552
|
+
return `Please select at least one option.
|
|
1553
|
+
${styleText2("reset", styleText2("dim", `Press ${styleText2(["gray", "bgWhite", "inverse"], " space ")} to select, ${styleText2("gray", styleText2("bgWhite", styleText2("inverse", " enter ")))} to submit`))}`;
|
|
1554
|
+
},
|
|
1555
|
+
render() {
|
|
1556
|
+
const t2 = n2.withGuide ?? settings.withGuide, o2 = wrapTextWithPrefix(n2.output, n2.message, t2 ? `${symbolBar(this.state)} ` : "", `${symbol(this.state)} `), r2 = `${t2 ? `${styleText2("gray", S_BAR)}
|
|
1557
|
+
` : ""}${o2}
|
|
1558
|
+
`, l2 = this.value ?? [], g2 = (i, u3) => {
|
|
1559
|
+
if (i.disabled)
|
|
1560
|
+
return a3(i, "disabled");
|
|
1561
|
+
const s = l2.includes(i.value);
|
|
1562
|
+
return u3 && s ? a3(i, "active-selected") : s ? a3(i, "selected") : a3(i, u3 ? "active" : "inactive");
|
|
1563
|
+
};
|
|
1564
|
+
switch (this.state) {
|
|
1565
|
+
case "submit": {
|
|
1566
|
+
const i = this.options.filter(({ value: s }) => l2.includes(s)).map((s) => a3(s, "submitted")).join(styleText2("dim", ", ")) || styleText2("dim", "none"), u3 = wrapTextWithPrefix(n2.output, i, t2 ? `${styleText2("gray", S_BAR)} ` : "");
|
|
1567
|
+
return `${r2}${u3}`;
|
|
1568
|
+
}
|
|
1569
|
+
case "cancel": {
|
|
1570
|
+
const i = this.options.filter(({ value: s }) => l2.includes(s)).map((s) => a3(s, "cancelled")).join(styleText2("dim", ", "));
|
|
1571
|
+
if (i.trim() === "")
|
|
1572
|
+
return `${r2}${styleText2("gray", S_BAR)}`;
|
|
1573
|
+
const u3 = wrapTextWithPrefix(n2.output, i, t2 ? `${styleText2("gray", S_BAR)} ` : "");
|
|
1574
|
+
return `${r2}${u3}${t2 ? `
|
|
1575
|
+
${styleText2("gray", S_BAR)}` : ""}`;
|
|
1576
|
+
}
|
|
1577
|
+
case "error": {
|
|
1578
|
+
const i = t2 ? `${styleText2("yellow", S_BAR)} ` : "", u3 = this.error.split(`
|
|
1579
|
+
`).map((h2, x) => x === 0 ? `${t2 ? `${styleText2("yellow", S_BAR_END)} ` : ""}${styleText2("yellow", h2)}` : ` ${h2}`).join(`
|
|
1580
|
+
`), s = r2.split(`
|
|
1581
|
+
`).length, v = u3.split(`
|
|
1440
1582
|
`).length + 1;
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1583
|
+
return `${r2}${i}${limitOptions({
|
|
1584
|
+
output: n2.output,
|
|
1585
|
+
options: this.options,
|
|
1586
|
+
cursor: this.cursor,
|
|
1587
|
+
maxItems: n2.maxItems,
|
|
1588
|
+
columnPadding: i.length,
|
|
1589
|
+
rowPadding: s + v,
|
|
1590
|
+
style: g2
|
|
1591
|
+
}).join(`
|
|
1592
|
+
${i}`)}
|
|
1593
|
+
${u3}
|
|
1444
1594
|
`;
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
`).length,
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1595
|
+
}
|
|
1596
|
+
default: {
|
|
1597
|
+
const i = t2 ? `${styleText2("cyan", S_BAR)} ` : "", u3 = r2.split(`
|
|
1598
|
+
`).length, s = t2 ? 2 : 1;
|
|
1599
|
+
return `${r2}${i}${limitOptions({
|
|
1600
|
+
output: n2.output,
|
|
1601
|
+
options: this.options,
|
|
1602
|
+
cursor: this.cursor,
|
|
1603
|
+
maxItems: n2.maxItems,
|
|
1604
|
+
columnPadding: i.length,
|
|
1605
|
+
rowPadding: u3 + s,
|
|
1606
|
+
style: g2
|
|
1607
|
+
}).join(`
|
|
1608
|
+
${i}`)}
|
|
1609
|
+
${t2 ? styleText2("cyan", S_BAR_END) : ""}
|
|
1452
1610
|
`;
|
|
1611
|
+
}
|
|
1453
1612
|
}
|
|
1454
1613
|
}
|
|
1455
|
-
}
|
|
1614
|
+
}).prompt();
|
|
1456
1615
|
};
|
|
1457
|
-
var
|
|
1458
|
-
var
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1616
|
+
var W = (l2) => styleText2("magenta", l2);
|
|
1617
|
+
var spinner = ({
|
|
1618
|
+
indicator: l2 = "dots",
|
|
1619
|
+
onCancel: h2,
|
|
1620
|
+
output: n2 = process.stdout,
|
|
1621
|
+
cancelMessage: G,
|
|
1622
|
+
errorMessage: O,
|
|
1623
|
+
frames: E = unicode ? ["\u25D2", "\u25D0", "\u25D3", "\u25D1"] : ["\u2022", "o", "O", "0"],
|
|
1624
|
+
delay: F = unicode ? 80 : 120,
|
|
1625
|
+
signal: m2,
|
|
1626
|
+
...I
|
|
1627
|
+
} = {}) => {
|
|
1628
|
+
const u3 = isCI();
|
|
1629
|
+
let M2, T3, d2 = false, S = false, s = "", p2, w = performance.now();
|
|
1630
|
+
const x = getColumns(n2), k = I?.styleFrame ?? W, g2 = (e) => {
|
|
1631
|
+
const r2 = e > 1 ? O ?? settings.messages.error : G ?? settings.messages.cancel;
|
|
1632
|
+
S = e === 1, d2 && (a3(r2, e), S && typeof h2 == "function" && h2());
|
|
1633
|
+
}, f2 = () => g2(2), i = () => g2(1), A = () => {
|
|
1634
|
+
process.on("uncaughtExceptionMonitor", f2), process.on("unhandledRejection", f2), process.on("SIGINT", i), process.on("SIGTERM", i), process.on("exit", g2), m2 && m2.addEventListener("abort", i);
|
|
1635
|
+
}, H = () => {
|
|
1636
|
+
process.removeListener("uncaughtExceptionMonitor", f2), process.removeListener("unhandledRejection", f2), process.removeListener("SIGINT", i), process.removeListener("SIGTERM", i), process.removeListener("exit", g2), m2 && m2.removeEventListener("abort", i);
|
|
1637
|
+
}, y = () => {
|
|
1638
|
+
if (p2 === undefined)
|
|
1470
1639
|
return;
|
|
1471
|
-
|
|
1640
|
+
u3 && n2.write(`
|
|
1472
1641
|
`);
|
|
1473
|
-
const
|
|
1642
|
+
const r2 = wrapAnsi(p2, x, {
|
|
1643
|
+
hard: true,
|
|
1644
|
+
trim: false
|
|
1645
|
+
}).split(`
|
|
1474
1646
|
`);
|
|
1475
|
-
|
|
1476
|
-
},
|
|
1477
|
-
const
|
|
1478
|
-
return
|
|
1479
|
-
},
|
|
1480
|
-
|
|
1647
|
+
r2.length > 1 && n2.write(import_sisteransi2.cursor.up(r2.length - 1)), n2.write(import_sisteransi2.cursor.to(0)), n2.write(import_sisteransi2.erase.down());
|
|
1648
|
+
}, C2 = (e) => e.replace(/\.+$/, ""), _2 = (e) => {
|
|
1649
|
+
const r2 = (performance.now() - e) / 1000, t2 = Math.floor(r2 / 60), o2 = Math.floor(r2 % 60);
|
|
1650
|
+
return t2 > 0 ? `[${t2}m ${o2}s]` : `[${o2}s]`;
|
|
1651
|
+
}, N = I.withGuide ?? settings.withGuide, P2 = (e = "") => {
|
|
1652
|
+
d2 = true, M2 = block({ output: n2 }), s = C2(e), w = performance.now(), N && n2.write(`${styleText2("gray", S_BAR)}
|
|
1481
1653
|
`);
|
|
1482
|
-
let
|
|
1483
|
-
|
|
1484
|
-
if (
|
|
1654
|
+
let r2 = 0, t2 = 0;
|
|
1655
|
+
A(), T3 = setInterval(() => {
|
|
1656
|
+
if (u3 && s === p2)
|
|
1485
1657
|
return;
|
|
1486
|
-
|
|
1487
|
-
const
|
|
1488
|
-
let
|
|
1489
|
-
if (
|
|
1490
|
-
|
|
1491
|
-
else if (
|
|
1492
|
-
|
|
1658
|
+
y(), p2 = s;
|
|
1659
|
+
const o2 = k(E[r2]);
|
|
1660
|
+
let v;
|
|
1661
|
+
if (u3)
|
|
1662
|
+
v = `${o2} ${s}...`;
|
|
1663
|
+
else if (l2 === "timer")
|
|
1664
|
+
v = `${o2} ${s} ${_2(w)}`;
|
|
1493
1665
|
else {
|
|
1494
|
-
const
|
|
1495
|
-
|
|
1666
|
+
const B = ".".repeat(Math.floor(t2)).slice(0, 3);
|
|
1667
|
+
v = `${o2} ${s}${B}`;
|
|
1496
1668
|
}
|
|
1497
|
-
const
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1669
|
+
const j = wrapAnsi(v, x, {
|
|
1670
|
+
hard: true,
|
|
1671
|
+
trim: false
|
|
1672
|
+
});
|
|
1673
|
+
n2.write(j), r2 = r2 + 1 < E.length ? r2 + 1 : 0, t2 = t2 < 4 ? t2 + 0.125 : 0;
|
|
1674
|
+
}, F);
|
|
1675
|
+
}, a3 = (e = "", r2 = 0, t2 = false) => {
|
|
1676
|
+
if (!d2)
|
|
1502
1677
|
return;
|
|
1503
|
-
|
|
1504
|
-
const
|
|
1505
|
-
|
|
1506
|
-
`) :
|
|
1507
|
-
`)),
|
|
1678
|
+
d2 = false, clearInterval(T3), y();
|
|
1679
|
+
const o2 = r2 === 0 ? styleText2("green", S_STEP_SUBMIT) : r2 === 1 ? styleText2("red", S_STEP_CANCEL) : styleText2("red", S_STEP_ERROR);
|
|
1680
|
+
s = e ?? s, t2 || (l2 === "timer" ? n2.write(`${o2} ${s} ${_2(w)}
|
|
1681
|
+
`) : n2.write(`${o2} ${s}
|
|
1682
|
+
`)), H(), M2();
|
|
1508
1683
|
};
|
|
1509
|
-
return {
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1684
|
+
return {
|
|
1685
|
+
start: P2,
|
|
1686
|
+
stop: (e = "") => a3(e, 0),
|
|
1687
|
+
message: (e = "") => {
|
|
1688
|
+
s = C2(e ?? s);
|
|
1689
|
+
},
|
|
1690
|
+
cancel: (e = "") => a3(e, 1),
|
|
1691
|
+
error: (e = "") => a3(e, 2),
|
|
1692
|
+
clear: () => a3("", 0, true),
|
|
1693
|
+
get isCancelled() {
|
|
1694
|
+
return S;
|
|
1695
|
+
}
|
|
1696
|
+
};
|
|
1697
|
+
};
|
|
1698
|
+
var u3 = {
|
|
1699
|
+
light: unicodeOr("\u2500", "-"),
|
|
1700
|
+
heavy: unicodeOr("\u2501", "="),
|
|
1701
|
+
block: unicodeOr("\u2588", "#")
|
|
1514
1702
|
};
|
|
1515
|
-
var
|
|
1516
|
-
|
|
1517
|
-
`)
|
|
1518
|
-
`)
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
switch (r) {
|
|
1703
|
+
var c2 = (e, a3) => e.includes(`
|
|
1704
|
+
`) ? e.split(`
|
|
1705
|
+
`).map((t2) => a3(t2)).join(`
|
|
1706
|
+
`) : a3(e);
|
|
1707
|
+
var select = (e) => {
|
|
1708
|
+
const a3 = (t2, d2) => {
|
|
1709
|
+
const s = t2.label ?? String(t2.value);
|
|
1710
|
+
switch (d2) {
|
|
1524
1711
|
case "disabled":
|
|
1525
|
-
return `${
|
|
1712
|
+
return `${styleText2("gray", S_RADIO_INACTIVE)} ${c2(s, (n2) => styleText2("gray", n2))}${t2.hint ? ` ${styleText2("dim", `(${t2.hint ?? "disabled"})`)}` : ""}`;
|
|
1526
1713
|
case "selected":
|
|
1527
|
-
return `${
|
|
1714
|
+
return `${c2(s, (n2) => styleText2("dim", n2))}`;
|
|
1528
1715
|
case "active":
|
|
1529
|
-
return `${
|
|
1716
|
+
return `${styleText2("green", S_RADIO_ACTIVE)} ${s}${t2.hint ? ` ${styleText2("dim", `(${t2.hint})`)}` : ""}`;
|
|
1530
1717
|
case "cancelled":
|
|
1531
|
-
return `${
|
|
1718
|
+
return `${c2(s, (n2) => styleText2(["strikethrough", "dim"], n2))}`;
|
|
1532
1719
|
default:
|
|
1533
|
-
return `${
|
|
1720
|
+
return `${styleText2("dim", S_RADIO_INACTIVE)} ${c2(s, (n2) => styleText2("dim", n2))}`;
|
|
1534
1721
|
}
|
|
1535
1722
|
};
|
|
1536
|
-
return new
|
|
1537
|
-
|
|
1538
|
-
|
|
1723
|
+
return new a2({
|
|
1724
|
+
options: e.options,
|
|
1725
|
+
signal: e.signal,
|
|
1726
|
+
input: e.input,
|
|
1727
|
+
output: e.output,
|
|
1728
|
+
initialValue: e.initialValue,
|
|
1729
|
+
render() {
|
|
1730
|
+
const t2 = e.withGuide ?? settings.withGuide, d2 = `${symbol(this.state)} `, s = `${symbolBar(this.state)} `, n2 = wrapTextWithPrefix(e.output, e.message, s, d2), u4 = `${t2 ? `${styleText2("gray", S_BAR)}
|
|
1731
|
+
` : ""}${n2}
|
|
1539
1732
|
`;
|
|
1733
|
+
switch (this.state) {
|
|
1734
|
+
case "submit": {
|
|
1735
|
+
const r2 = t2 ? `${styleText2("gray", S_BAR)} ` : "", l2 = wrapTextWithPrefix(e.output, a3(this.options[this.cursor], "selected"), r2);
|
|
1736
|
+
return `${u4}${l2}`;
|
|
1737
|
+
}
|
|
1738
|
+
case "cancel": {
|
|
1739
|
+
const r2 = t2 ? `${styleText2("gray", S_BAR)} ` : "", l2 = wrapTextWithPrefix(e.output, a3(this.options[this.cursor], "cancelled"), r2);
|
|
1740
|
+
return `${u4}${l2}${t2 ? `
|
|
1741
|
+
${styleText2("gray", S_BAR)}` : ""}`;
|
|
1742
|
+
}
|
|
1743
|
+
default: {
|
|
1744
|
+
const r2 = t2 ? `${styleText2("cyan", S_BAR)} ` : "", l2 = t2 ? styleText2("cyan", S_BAR_END) : "", g2 = u4.split(`
|
|
1745
|
+
`).length, h2 = t2 ? 2 : 1;
|
|
1746
|
+
return `${u4}${r2}${limitOptions({
|
|
1747
|
+
output: e.output,
|
|
1748
|
+
cursor: this.cursor,
|
|
1749
|
+
options: this.options,
|
|
1750
|
+
maxItems: e.maxItems,
|
|
1751
|
+
columnPadding: r2.length,
|
|
1752
|
+
rowPadding: g2 + h2,
|
|
1753
|
+
style: (p2, b2) => a3(p2, p2.disabled ? "disabled" : b2 ? "active" : "inactive")
|
|
1754
|
+
}).join(`
|
|
1755
|
+
${r2}`)}
|
|
1756
|
+
${l2}
|
|
1757
|
+
`;
|
|
1758
|
+
}
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1761
|
+
}).prompt();
|
|
1762
|
+
};
|
|
1763
|
+
var i = `${styleText2("gray", S_BAR)} `;
|
|
1764
|
+
var text = (t2) => new n({
|
|
1765
|
+
validate: t2.validate,
|
|
1766
|
+
placeholder: t2.placeholder,
|
|
1767
|
+
defaultValue: t2.defaultValue,
|
|
1768
|
+
initialValue: t2.initialValue,
|
|
1769
|
+
output: t2.output,
|
|
1770
|
+
signal: t2.signal,
|
|
1771
|
+
input: t2.input,
|
|
1772
|
+
render() {
|
|
1773
|
+
const i2 = t2?.withGuide ?? settings.withGuide, s = `${`${i2 ? `${styleText2("gray", S_BAR)}
|
|
1774
|
+
` : ""}${symbol(this.state)} `}${t2.message}
|
|
1775
|
+
`, c3 = t2.placeholder ? styleText2("inverse", t2.placeholder[0]) + styleText2("dim", t2.placeholder.slice(1)) : styleText2(["inverse", "hidden"], "_"), o2 = this.userInput ? this.userInputWithCursor : c3, a3 = this.value ?? "";
|
|
1540
1776
|
switch (this.state) {
|
|
1777
|
+
case "error": {
|
|
1778
|
+
const n2 = this.error ? ` ${styleText2("yellow", this.error)}` : "", r2 = i2 ? `${styleText2("yellow", S_BAR)} ` : "", d2 = i2 ? styleText2("yellow", S_BAR_END) : "";
|
|
1779
|
+
return `${s.trim()}
|
|
1780
|
+
${r2}${o2}
|
|
1781
|
+
${d2}${n2}
|
|
1782
|
+
`;
|
|
1783
|
+
}
|
|
1541
1784
|
case "submit": {
|
|
1542
|
-
const
|
|
1543
|
-
return `${
|
|
1785
|
+
const n2 = a3 ? ` ${styleText2("dim", a3)}` : "", r2 = i2 ? styleText2("gray", S_BAR) : "";
|
|
1786
|
+
return `${s}${r2}${n2}`;
|
|
1544
1787
|
}
|
|
1545
1788
|
case "cancel": {
|
|
1546
|
-
const
|
|
1547
|
-
return `${
|
|
1548
|
-
${
|
|
1789
|
+
const n2 = a3 ? ` ${styleText2(["strikethrough", "dim"], a3)}` : "", r2 = i2 ? styleText2("gray", S_BAR) : "";
|
|
1790
|
+
return `${s}${r2}${n2}${a3.trim() ? `
|
|
1791
|
+
${r2}` : ""}`;
|
|
1549
1792
|
}
|
|
1550
1793
|
default: {
|
|
1551
|
-
const
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
${c}`)}
|
|
1555
|
-
${o}
|
|
1794
|
+
const n2 = i2 ? `${styleText2("cyan", S_BAR)} ` : "", r2 = i2 ? styleText2("cyan", S_BAR_END) : "";
|
|
1795
|
+
return `${s}${n2}${o2}
|
|
1796
|
+
${r2}
|
|
1556
1797
|
`;
|
|
1557
1798
|
}
|
|
1558
1799
|
}
|
|
1559
|
-
} }).prompt();
|
|
1560
|
-
};
|
|
1561
|
-
var Bt = `${e("gray", $2)} `;
|
|
1562
|
-
var Re = (t) => new ct({ validate: t.validate, placeholder: t.placeholder, defaultValue: t.defaultValue, initialValue: t.initialValue, output: t.output, signal: t.signal, input: t.input, render() {
|
|
1563
|
-
const i = t?.withGuide ?? h.withGuide, s = `${`${i ? `${e("gray", $2)}
|
|
1564
|
-
` : ""}${P2(this.state)} `}${t.message}
|
|
1565
|
-
`, r = t.placeholder ? e("inverse", t.placeholder[0]) + e("dim", t.placeholder.slice(1)) : e(["inverse", "hidden"], "_"), u = this.userInput ? this.userInputWithCursor : r, n = this.value ?? "";
|
|
1566
|
-
switch (this.state) {
|
|
1567
|
-
case "error": {
|
|
1568
|
-
const a = this.error ? ` ${e("yellow", this.error)}` : "", c = i ? `${e("yellow", $2)} ` : "", o = i ? e("yellow", x2) : "";
|
|
1569
|
-
return `${s.trim()}
|
|
1570
|
-
${c}${u}
|
|
1571
|
-
${o}${a}
|
|
1572
|
-
`;
|
|
1573
|
-
}
|
|
1574
|
-
case "submit": {
|
|
1575
|
-
const a = n ? ` ${e("dim", n)}` : "", c = i ? e("gray", $2) : "";
|
|
1576
|
-
return `${s}${c}${a}`;
|
|
1577
|
-
}
|
|
1578
|
-
case "cancel": {
|
|
1579
|
-
const a = n ? ` ${e(["strikethrough", "dim"], n)}` : "", c = i ? e("gray", $2) : "";
|
|
1580
|
-
return `${s}${c}${a}${n.trim() ? `
|
|
1581
|
-
${c}` : ""}`;
|
|
1582
|
-
}
|
|
1583
|
-
default: {
|
|
1584
|
-
const a = i ? `${e("cyan", $2)} ` : "", c = i ? e("cyan", x2) : "";
|
|
1585
|
-
return `${s}${a}${u}
|
|
1586
|
-
${c}
|
|
1587
|
-
`;
|
|
1588
|
-
}
|
|
1589
1800
|
}
|
|
1590
|
-
}
|
|
1801
|
+
}).prompt();
|
|
1591
1802
|
|
|
1592
1803
|
// apps/cli/utils/multiselect.ts
|
|
1593
1804
|
async function MultiSelect({
|
|
1594
1805
|
message,
|
|
1595
1806
|
options
|
|
1596
1807
|
}) {
|
|
1597
|
-
const selected = await
|
|
1808
|
+
const selected = await multiselect({
|
|
1598
1809
|
message,
|
|
1599
1810
|
options,
|
|
1600
1811
|
required: true
|
|
1601
1812
|
});
|
|
1602
|
-
if (
|
|
1603
|
-
|
|
1813
|
+
if (isCancel(selected)) {
|
|
1814
|
+
cancel("Operation cancelled.");
|
|
1604
1815
|
process.exit(0);
|
|
1605
1816
|
}
|
|
1606
1817
|
return selected;
|
|
@@ -1621,7 +1832,7 @@ class AddCommand {
|
|
|
1621
1832
|
console.log(`${CHECK({ text: "All changes are either staged or sensitive (like .env)." })}`);
|
|
1622
1833
|
return;
|
|
1623
1834
|
}
|
|
1624
|
-
const options = changes.map((
|
|
1835
|
+
const options = changes.map((c3) => ({ value: c3.value, label: c3.label }));
|
|
1625
1836
|
const selectedChanges = await MultiSelect({
|
|
1626
1837
|
message: `Select the changes you want to commit.
|
|
1627
1838
|
` + BLUE({ text: "[space] to select" }) + `
|
|
@@ -1633,7 +1844,7 @@ class AddCommand {
|
|
|
1633
1844
|
});
|
|
1634
1845
|
let selected = selectedChanges.map((file) => file.trim());
|
|
1635
1846
|
if (selected.includes("all")) {
|
|
1636
|
-
selected = changes.map((
|
|
1847
|
+
selected = changes.map((c3) => c3.value);
|
|
1637
1848
|
}
|
|
1638
1849
|
if (selected.length > 0) {
|
|
1639
1850
|
await this.stageChangesUseCase.execute(selected);
|
|
@@ -1698,8 +1909,8 @@ class Change {
|
|
|
1698
1909
|
}
|
|
1699
1910
|
static fromPorcelain(entries) {
|
|
1700
1911
|
const changes = [];
|
|
1701
|
-
for (let
|
|
1702
|
-
const entry = entries[
|
|
1912
|
+
for (let i2 = 0;i2 < entries.length; i2++) {
|
|
1913
|
+
const entry = entries[i2];
|
|
1703
1914
|
if (!entry)
|
|
1704
1915
|
continue;
|
|
1705
1916
|
const status = entry.slice(0, 2);
|
|
@@ -1710,7 +1921,7 @@ class Change {
|
|
|
1710
1921
|
let displayPath = file;
|
|
1711
1922
|
const value = file;
|
|
1712
1923
|
if (status.startsWith("R") || status.startsWith("C")) {
|
|
1713
|
-
const source = entries[++
|
|
1924
|
+
const source = entries[++i2];
|
|
1714
1925
|
displayPath = `${source} -> ${file}`;
|
|
1715
1926
|
}
|
|
1716
1927
|
changes.push(new Change({ value, status, displayPath }));
|
|
@@ -1760,11 +1971,11 @@ class StageChangesUseCase {
|
|
|
1760
1971
|
}
|
|
1761
1972
|
|
|
1762
1973
|
// apps/cli/modules/add/infra/bun-git.repository.ts
|
|
1763
|
-
var {
|
|
1974
|
+
var {$ } = globalThis.Bun;
|
|
1764
1975
|
class BunGitRepository {
|
|
1765
1976
|
async getEntries() {
|
|
1766
1977
|
try {
|
|
1767
|
-
const output = await
|
|
1978
|
+
const output = await $`git status --porcelain -z`.quiet().text();
|
|
1768
1979
|
if (!output.trim()) {
|
|
1769
1980
|
return [];
|
|
1770
1981
|
}
|
|
@@ -1901,7 +2112,7 @@ async function Input({
|
|
|
1901
2112
|
message,
|
|
1902
2113
|
placeholder
|
|
1903
2114
|
}) {
|
|
1904
|
-
const value = await
|
|
2115
|
+
const value = await text({
|
|
1905
2116
|
message,
|
|
1906
2117
|
placeholder,
|
|
1907
2118
|
validate(input) {
|
|
@@ -1910,8 +2121,8 @@ async function Input({
|
|
|
1910
2121
|
}
|
|
1911
2122
|
}
|
|
1912
2123
|
});
|
|
1913
|
-
if (
|
|
1914
|
-
|
|
2124
|
+
if (isCancel(value)) {
|
|
2125
|
+
cancel("Operation cancelled.");
|
|
1915
2126
|
process.exit(0);
|
|
1916
2127
|
}
|
|
1917
2128
|
return value.trim();
|
|
@@ -1922,12 +2133,12 @@ async function Select({
|
|
|
1922
2133
|
message,
|
|
1923
2134
|
options
|
|
1924
2135
|
}) {
|
|
1925
|
-
const selected = await
|
|
2136
|
+
const selected = await select({
|
|
1926
2137
|
message,
|
|
1927
2138
|
options
|
|
1928
2139
|
});
|
|
1929
|
-
if (
|
|
1930
|
-
|
|
2140
|
+
if (isCancel(selected)) {
|
|
2141
|
+
cancel("Operation cancelled.");
|
|
1931
2142
|
process.exit(0);
|
|
1932
2143
|
}
|
|
1933
2144
|
return selected;
|
|
@@ -2004,12 +2215,12 @@ async function Confirm({
|
|
|
2004
2215
|
cancelMessage,
|
|
2005
2216
|
exitOnCancel = true
|
|
2006
2217
|
}) {
|
|
2007
|
-
const confirmed = await
|
|
2218
|
+
const confirmed = await confirm({
|
|
2008
2219
|
message
|
|
2009
2220
|
});
|
|
2010
|
-
if (
|
|
2221
|
+
if (isCancel(confirmed)) {
|
|
2011
2222
|
if (exitOnCancel) {
|
|
2012
|
-
|
|
2223
|
+
cancel(cancelMessage ?? "Operation cancelled.");
|
|
2013
2224
|
process.exit(0);
|
|
2014
2225
|
}
|
|
2015
2226
|
return null;
|
|
@@ -2019,17 +2230,17 @@ async function Confirm({
|
|
|
2019
2230
|
|
|
2020
2231
|
// apps/cli/utils/intro.ts
|
|
2021
2232
|
function Intro(message) {
|
|
2022
|
-
|
|
2233
|
+
intro(message);
|
|
2023
2234
|
}
|
|
2024
2235
|
|
|
2025
2236
|
// apps/cli/utils/outro.ts
|
|
2026
2237
|
function Outro(message) {
|
|
2027
|
-
|
|
2238
|
+
outro(message);
|
|
2028
2239
|
}
|
|
2029
2240
|
|
|
2030
2241
|
// apps/cli/utils/spinner.ts
|
|
2031
2242
|
function Spinner() {
|
|
2032
|
-
return
|
|
2243
|
+
return spinner();
|
|
2033
2244
|
}
|
|
2034
2245
|
|
|
2035
2246
|
// apps/cli/modules/setup/app/setup-command.ts
|
|
@@ -2050,11 +2261,11 @@ class SetupCommand {
|
|
|
2050
2261
|
Outro("Setup cancelled.");
|
|
2051
2262
|
return;
|
|
2052
2263
|
}
|
|
2053
|
-
const
|
|
2054
|
-
|
|
2264
|
+
const spinner2 = Spinner();
|
|
2265
|
+
spinner2.start("Writing aliases...");
|
|
2055
2266
|
const { total } = await this.setupAliasesUseCase.execute();
|
|
2056
2267
|
console.log("");
|
|
2057
|
-
|
|
2268
|
+
spinner2.stop(`${CHECK({ text: `${total} aliases configured successfully.` })}`);
|
|
2058
2269
|
Outro(`${GREEN({ text: "GLINTER" })}, if you like the project, give a star on github: https://github.com/jannael/glinter`);
|
|
2059
2270
|
console.log("");
|
|
2060
2271
|
console.log(MAGENTA({ text: "To use the aliases, please restart your terminal." }));
|
|
@@ -2072,7 +2283,10 @@ import path from "path";
|
|
|
2072
2283
|
class BunAliasUnix {
|
|
2073
2284
|
async setAlias(name, value) {
|
|
2074
2285
|
const profilePath = this.getUnixProfilePath();
|
|
2075
|
-
|
|
2286
|
+
const dir = path.dirname(profilePath);
|
|
2287
|
+
if (!fs.existsSync(dir)) {
|
|
2288
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
2289
|
+
}
|
|
2076
2290
|
const current = fs.existsSync(profilePath) ? fs.readFileSync(profilePath, "utf8") : "";
|
|
2077
2291
|
const updated = this.upsertUnixProfileAlias(current, name, value);
|
|
2078
2292
|
fs.writeFileSync(profilePath, updated);
|
|
@@ -2118,7 +2332,10 @@ import path2 from "path";
|
|
|
2118
2332
|
class BunAliasWindows {
|
|
2119
2333
|
async setAlias(name, value) {
|
|
2120
2334
|
const psProfilePath = this.getWindowsProfilePath();
|
|
2121
|
-
|
|
2335
|
+
const dir = path2.dirname(psProfilePath);
|
|
2336
|
+
if (!fs2.existsSync(dir)) {
|
|
2337
|
+
fs2.mkdirSync(dir, { recursive: true });
|
|
2338
|
+
}
|
|
2122
2339
|
const current = fs2.existsSync(psProfilePath) ? fs2.readFileSync(psProfilePath, "utf8") : "";
|
|
2123
2340
|
const updated = this.upsertWindowsProfileFunction(current, name, value);
|
|
2124
2341
|
fs2.writeFileSync(psProfilePath, updated);
|
|
@@ -2213,8 +2430,8 @@ class Branch {
|
|
|
2213
2430
|
}
|
|
2214
2431
|
static fromGitBranch(entries) {
|
|
2215
2432
|
const branches = [];
|
|
2216
|
-
for (let
|
|
2217
|
-
const entry = entries[
|
|
2433
|
+
for (let i2 = 0;i2 < entries?.length; i2++) {
|
|
2434
|
+
const entry = entries[i2];
|
|
2218
2435
|
if (!entry)
|
|
2219
2436
|
continue;
|
|
2220
2437
|
const current = entry.includes("*");
|
|
@@ -2299,11 +2516,11 @@ class SwitchCommand {
|
|
|
2299
2516
|
}
|
|
2300
2517
|
|
|
2301
2518
|
// apps/cli/modules/switch/infra/bun-switch-repository.ts
|
|
2302
|
-
var {$: $
|
|
2519
|
+
var {$: $2 } = globalThis.Bun;
|
|
2303
2520
|
class BunSwitchRepository {
|
|
2304
2521
|
async getBranches() {
|
|
2305
2522
|
try {
|
|
2306
|
-
const output = await $
|
|
2523
|
+
const output = await $2`git branch -a`.quiet().text();
|
|
2307
2524
|
if (!output.trim()) {
|
|
2308
2525
|
return [];
|
|
2309
2526
|
}
|