create-rstack 1.9.0 → 1.9.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/dist/index.d.ts +54 -0
- package/dist/index.js +1117 -719
- package/package.json +7 -7
- package/template-biome/package.json +1 -1
- package/template-eslint/react-ts/package.json +1 -1
- package/template-eslint/svelte-js/package.json +1 -1
- package/template-eslint/svelte-ts/package.json +2 -2
- package/template-eslint/vanilla-ts/package.json +1 -1
- package/template-eslint/vue-ts/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4,15 +4,14 @@ import node_path, { delimiter, dirname, normalize as external_node_path_normaliz
|
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
5
|
import node_util, { styleText } from "node:util";
|
|
6
6
|
import node_process, { cwd as external_node_process_cwd, stdin, stdout } from "node:process";
|
|
7
|
-
import
|
|
7
|
+
import node_readline from "node:readline";
|
|
8
|
+
import node_tty from "node:tty";
|
|
8
9
|
import node_os from "node:os";
|
|
9
10
|
import { createRequire } from "node:module";
|
|
10
11
|
import { spawn } from "node:child_process";
|
|
11
12
|
import { PassThrough } from "node:stream";
|
|
12
|
-
import node_readline from "node:readline";
|
|
13
13
|
import { createRequire as __rspack_createRequire } from "node:module";
|
|
14
14
|
const __rspack_createRequire_require = __rspack_createRequire(import.meta.url);
|
|
15
|
-
import * as __rspack_external_node_readline_91c31510 from "node:readline";
|
|
16
15
|
var __webpack_modules__ = {};
|
|
17
16
|
var __webpack_module_cache__ = {};
|
|
18
17
|
function __webpack_require__(moduleId) {
|
|
@@ -534,165 +533,321 @@ __webpack_require__.add({
|
|
|
534
533
|
module.exports = __rspack_createRequire_require("node:fs/promises");
|
|
535
534
|
}
|
|
536
535
|
});
|
|
537
|
-
const
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
}
|
|
543
|
-
const
|
|
536
|
+
const isAmbiguous = (x)=>0xA1 === x || 0xA4 === x || 0xA7 === x || 0xA8 === x || 0xAA === x || 0xAD === x || 0xAE === x || x >= 0xB0 && x <= 0xB4 || x >= 0xB6 && x <= 0xBA || x >= 0xBC && x <= 0xBF || 0xC6 === x || 0xD0 === x || 0xD7 === x || 0xD8 === x || x >= 0xDE && x <= 0xE1 || 0xE6 === x || x >= 0xE8 && x <= 0xEA || 0xEC === x || 0xED === x || 0xF0 === x || 0xF2 === x || 0xF3 === x || x >= 0xF7 && x <= 0xFA || 0xFC === x || 0xFE === x || 0x101 === x || 0x111 === x || 0x113 === x || 0x11B === x || 0x126 === x || 0x127 === x || 0x12B === x || x >= 0x131 && x <= 0x133 || 0x138 === x || x >= 0x13F && x <= 0x142 || 0x144 === x || x >= 0x148 && x <= 0x14B || 0x14D === x || 0x152 === x || 0x153 === x || 0x166 === x || 0x167 === x || 0x16B === x || 0x1CE === x || 0x1D0 === x || 0x1D2 === x || 0x1D4 === x || 0x1D6 === x || 0x1D8 === x || 0x1DA === x || 0x1DC === x || 0x251 === x || 0x261 === x || 0x2C4 === x || 0x2C7 === x || x >= 0x2C9 && x <= 0x2CB || 0x2CD === x || 0x2D0 === x || x >= 0x2D8 && x <= 0x2DB || 0x2DD === x || 0x2DF === x || x >= 0x300 && x <= 0x36F || x >= 0x391 && x <= 0x3A1 || x >= 0x3A3 && x <= 0x3A9 || x >= 0x3B1 && x <= 0x3C1 || x >= 0x3C3 && x <= 0x3C9 || 0x401 === x || x >= 0x410 && x <= 0x44F || 0x451 === x || 0x2010 === x || x >= 0x2013 && x <= 0x2016 || 0x2018 === x || 0x2019 === x || 0x201C === x || 0x201D === x || x >= 0x2020 && x <= 0x2022 || x >= 0x2024 && x <= 0x2027 || 0x2030 === x || 0x2032 === x || 0x2033 === x || 0x2035 === x || 0x203B === x || 0x203E === x || 0x2074 === x || 0x207F === x || x >= 0x2081 && x <= 0x2084 || 0x20AC === x || 0x2103 === x || 0x2105 === x || 0x2109 === x || 0x2113 === x || 0x2116 === x || 0x2121 === x || 0x2122 === x || 0x2126 === x || 0x212B === x || 0x2153 === x || 0x2154 === x || x >= 0x215B && x <= 0x215E || x >= 0x2160 && x <= 0x216B || x >= 0x2170 && x <= 0x2179 || 0x2189 === x || x >= 0x2190 && x <= 0x2199 || 0x21B8 === x || 0x21B9 === x || 0x21D2 === x || 0x21D4 === x || 0x21E7 === x || 0x2200 === x || 0x2202 === x || 0x2203 === x || 0x2207 === x || 0x2208 === x || 0x220B === x || 0x220F === x || 0x2211 === x || 0x2215 === x || 0x221A === x || x >= 0x221D && x <= 0x2220 || 0x2223 === x || 0x2225 === x || x >= 0x2227 && x <= 0x222C || 0x222E === x || x >= 0x2234 && x <= 0x2237 || 0x223C === x || 0x223D === x || 0x2248 === x || 0x224C === x || 0x2252 === x || 0x2260 === x || 0x2261 === x || x >= 0x2264 && x <= 0x2267 || 0x226A === x || 0x226B === x || 0x226E === x || 0x226F === x || 0x2282 === x || 0x2283 === x || 0x2286 === x || 0x2287 === x || 0x2295 === x || 0x2299 === x || 0x22A5 === x || 0x22BF === x || 0x2312 === x || x >= 0x2460 && x <= 0x24E9 || x >= 0x24EB && x <= 0x254B || x >= 0x2550 && x <= 0x2573 || x >= 0x2580 && x <= 0x258F || x >= 0x2592 && x <= 0x2595 || 0x25A0 === x || 0x25A1 === x || x >= 0x25A3 && x <= 0x25A9 || 0x25B2 === x || 0x25B3 === x || 0x25B6 === x || 0x25B7 === x || 0x25BC === x || 0x25BD === x || 0x25C0 === x || 0x25C1 === x || x >= 0x25C6 && x <= 0x25C8 || 0x25CB === x || x >= 0x25CE && x <= 0x25D1 || x >= 0x25E2 && x <= 0x25E5 || 0x25EF === x || 0x2605 === x || 0x2606 === x || 0x2609 === x || 0x260E === x || 0x260F === x || 0x261C === x || 0x261E === x || 0x2640 === x || 0x2642 === x || 0x2660 === x || 0x2661 === x || x >= 0x2663 && x <= 0x2665 || x >= 0x2667 && x <= 0x266A || 0x266C === x || 0x266D === x || 0x266F === x || 0x269E === x || 0x269F === x || 0x26BF === x || x >= 0x26C6 && x <= 0x26CD || x >= 0x26CF && x <= 0x26D3 || x >= 0x26D5 && x <= 0x26E1 || 0x26E3 === x || 0x26E8 === x || 0x26E9 === x || x >= 0x26EB && x <= 0x26F1 || 0x26F4 === x || x >= 0x26F6 && x <= 0x26F9 || 0x26FB === x || 0x26FC === x || 0x26FE === x || 0x26FF === x || 0x273D === x || x >= 0x2776 && x <= 0x277F || x >= 0x2B56 && x <= 0x2B59 || x >= 0x3248 && x <= 0x324F || x >= 0xE000 && x <= 0xF8FF || x >= 0xFE00 && x <= 0xFE0F || 0xFFFD === x || x >= 0x1F100 && x <= 0x1F10A || x >= 0x1F110 && x <= 0x1F12D || x >= 0x1F130 && x <= 0x1F169 || x >= 0x1F170 && x <= 0x1F18D || 0x1F18F === x || 0x1F190 === x || x >= 0x1F19B && x <= 0x1F1AC || x >= 0xE0100 && x <= 0xE01EF || x >= 0xF0000 && x <= 0xFFFFD || x >= 0x100000 && x <= 0x10FFFD;
|
|
537
|
+
const isFullWidth = (x)=>0x3000 === x || x >= 0xFF01 && x <= 0xFF60 || x >= 0xFFE0 && x <= 0xFFE6;
|
|
538
|
+
const isWide = (x)=>x >= 0x1100 && x <= 0x115F || 0x231A === x || 0x231B === x || 0x2329 === x || 0x232A === x || x >= 0x23E9 && x <= 0x23EC || 0x23F0 === x || 0x23F3 === x || 0x25FD === x || 0x25FE === x || 0x2614 === x || 0x2615 === x || x >= 0x2648 && x <= 0x2653 || 0x267F === x || 0x2693 === x || 0x26A1 === x || 0x26AA === x || 0x26AB === x || 0x26BD === x || 0x26BE === x || 0x26C4 === x || 0x26C5 === x || 0x26CE === x || 0x26D4 === x || 0x26EA === x || 0x26F2 === x || 0x26F3 === x || 0x26F5 === x || 0x26FA === x || 0x26FD === x || 0x2705 === x || 0x270A === x || 0x270B === x || 0x2728 === x || 0x274C === x || 0x274E === x || x >= 0x2753 && x <= 0x2755 || 0x2757 === x || x >= 0x2795 && x <= 0x2797 || 0x27B0 === x || 0x27BF === x || 0x2B1B === x || 0x2B1C === x || 0x2B50 === x || 0x2B55 === x || x >= 0x2E80 && x <= 0x2E99 || x >= 0x2E9B && x <= 0x2EF3 || x >= 0x2F00 && x <= 0x2FD5 || x >= 0x2FF0 && x <= 0x2FFF || x >= 0x3001 && x <= 0x303E || x >= 0x3041 && x <= 0x3096 || x >= 0x3099 && x <= 0x30FF || x >= 0x3105 && x <= 0x312F || x >= 0x3131 && x <= 0x318E || x >= 0x3190 && x <= 0x31E3 || x >= 0x31EF && x <= 0x321E || x >= 0x3220 && x <= 0x3247 || x >= 0x3250 && x <= 0x4DBF || x >= 0x4E00 && x <= 0xA48C || x >= 0xA490 && x <= 0xA4C6 || x >= 0xA960 && x <= 0xA97C || x >= 0xAC00 && x <= 0xD7A3 || x >= 0xF900 && x <= 0xFAFF || x >= 0xFE10 && x <= 0xFE19 || x >= 0xFE30 && x <= 0xFE52 || x >= 0xFE54 && x <= 0xFE66 || x >= 0xFE68 && x <= 0xFE6B || x >= 0x16FE0 && x <= 0x16FE4 || 0x16FF0 === x || 0x16FF1 === x || x >= 0x17000 && x <= 0x187F7 || x >= 0x18800 && x <= 0x18CD5 || x >= 0x18D00 && x <= 0x18D08 || x >= 0x1AFF0 && x <= 0x1AFF3 || x >= 0x1AFF5 && x <= 0x1AFFB || 0x1AFFD === x || 0x1AFFE === x || x >= 0x1B000 && x <= 0x1B122 || 0x1B132 === x || x >= 0x1B150 && x <= 0x1B152 || 0x1B155 === x || x >= 0x1B164 && x <= 0x1B167 || x >= 0x1B170 && x <= 0x1B2FB || 0x1F004 === x || 0x1F0CF === x || 0x1F18E === x || x >= 0x1F191 && x <= 0x1F19A || x >= 0x1F200 && x <= 0x1F202 || x >= 0x1F210 && x <= 0x1F23B || x >= 0x1F240 && x <= 0x1F248 || 0x1F250 === x || 0x1F251 === x || x >= 0x1F260 && x <= 0x1F265 || x >= 0x1F300 && x <= 0x1F320 || x >= 0x1F32D && x <= 0x1F335 || x >= 0x1F337 && x <= 0x1F37C || x >= 0x1F37E && x <= 0x1F393 || x >= 0x1F3A0 && x <= 0x1F3CA || x >= 0x1F3CF && x <= 0x1F3D3 || x >= 0x1F3E0 && x <= 0x1F3F0 || 0x1F3F4 === x || x >= 0x1F3F8 && x <= 0x1F43E || 0x1F440 === x || x >= 0x1F442 && x <= 0x1F4FC || x >= 0x1F4FF && x <= 0x1F53D || x >= 0x1F54B && x <= 0x1F54E || x >= 0x1F550 && x <= 0x1F567 || 0x1F57A === x || 0x1F595 === x || 0x1F596 === x || 0x1F5A4 === x || x >= 0x1F5FB && x <= 0x1F64F || x >= 0x1F680 && x <= 0x1F6C5 || 0x1F6CC === x || x >= 0x1F6D0 && x <= 0x1F6D2 || x >= 0x1F6D5 && x <= 0x1F6D7 || x >= 0x1F6DC && x <= 0x1F6DF || 0x1F6EB === x || 0x1F6EC === x || x >= 0x1F6F4 && x <= 0x1F6FC || x >= 0x1F7E0 && x <= 0x1F7EB || 0x1F7F0 === x || x >= 0x1F90C && x <= 0x1F93A || x >= 0x1F93C && x <= 0x1F945 || x >= 0x1F947 && x <= 0x1F9FF || x >= 0x1FA70 && x <= 0x1FA7C || x >= 0x1FA80 && x <= 0x1FA88 || x >= 0x1FA90 && x <= 0x1FABD || x >= 0x1FABF && x <= 0x1FAC5 || x >= 0x1FACE && x <= 0x1FADB || x >= 0x1FAE0 && x <= 0x1FAE8 || x >= 0x1FAF0 && x <= 0x1FAF8 || x >= 0x20000 && x <= 0x2FFFD || x >= 0x30000 && x <= 0x3FFFD;
|
|
539
|
+
const ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y;
|
|
540
|
+
const CONTROL_RE = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
|
|
541
|
+
const TAB_RE = /\t{1,1000}/y;
|
|
542
|
+
const EMOJI_RE = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu;
|
|
543
|
+
const LATIN_RE = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
|
|
544
|
+
const MODIFIER_RE = /\p{M}+/gu;
|
|
545
|
+
const NO_TRUNCATION = {
|
|
544
546
|
limit: 1 / 0,
|
|
545
|
-
ellipsis:
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
547
|
+
ellipsis: ''
|
|
548
|
+
};
|
|
549
|
+
const getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {})=>{
|
|
550
|
+
const LIMIT = truncationOptions.limit ?? 1 / 0;
|
|
551
|
+
const ELLIPSIS = truncationOptions.ellipsis ?? '';
|
|
552
|
+
const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth(ELLIPSIS, NO_TRUNCATION, widthOptions).width : 0);
|
|
553
|
+
const ANSI_WIDTH = widthOptions.ansiWidth ?? 0;
|
|
554
|
+
const CONTROL_WIDTH = widthOptions.controlWidth ?? 0;
|
|
555
|
+
const TAB_WIDTH = widthOptions.tabWidth ?? 8;
|
|
556
|
+
const AMBIGUOUS_WIDTH = widthOptions.ambiguousWidth ?? 1;
|
|
557
|
+
const EMOJI_WIDTH = widthOptions.emojiWidth ?? 2;
|
|
558
|
+
const FULL_WIDTH_WIDTH = widthOptions.fullWidthWidth ?? 2;
|
|
559
|
+
const REGULAR_WIDTH = widthOptions.regularWidth ?? 1;
|
|
560
|
+
const WIDE_WIDTH = widthOptions.wideWidth ?? 2;
|
|
561
|
+
let indexPrev = 0;
|
|
562
|
+
let index = 0;
|
|
563
|
+
let length = input.length;
|
|
564
|
+
let lengthExtra = 0;
|
|
565
|
+
let truncationEnabled = false;
|
|
566
|
+
let truncationIndex = length;
|
|
567
|
+
let truncationLimit = Math.max(0, LIMIT - ELLIPSIS_WIDTH);
|
|
568
|
+
let unmatchedStart = 0;
|
|
569
|
+
let unmatchedEnd = 0;
|
|
570
|
+
let width = 0;
|
|
571
|
+
let widthExtra = 0;
|
|
572
|
+
outer: while(true){
|
|
573
|
+
if (unmatchedEnd > unmatchedStart || index >= length && index > indexPrev) {
|
|
574
|
+
const unmatched = input.slice(unmatchedStart, unmatchedEnd) || input.slice(indexPrev, index);
|
|
575
|
+
lengthExtra = 0;
|
|
576
|
+
for (const char of unmatched.replaceAll(MODIFIER_RE, '')){
|
|
577
|
+
const codePoint = char.codePointAt(0) || 0;
|
|
578
|
+
widthExtra = isFullWidth(codePoint) ? FULL_WIDTH_WIDTH : isWide(codePoint) ? WIDE_WIDTH : AMBIGUOUS_WIDTH !== REGULAR_WIDTH && isAmbiguous(codePoint) ? AMBIGUOUS_WIDTH : REGULAR_WIDTH;
|
|
579
|
+
if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, Math.max(unmatchedStart, indexPrev) + lengthExtra);
|
|
580
|
+
if (width + widthExtra > LIMIT) {
|
|
581
|
+
truncationEnabled = true;
|
|
582
|
+
break outer;
|
|
558
583
|
}
|
|
559
|
-
|
|
584
|
+
lengthExtra += char.length;
|
|
585
|
+
width += widthExtra;
|
|
560
586
|
}
|
|
561
|
-
|
|
562
|
-
}
|
|
563
|
-
if (
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
587
|
+
unmatchedStart = unmatchedEnd = 0;
|
|
588
|
+
}
|
|
589
|
+
if (index >= length) break;
|
|
590
|
+
LATIN_RE.lastIndex = index;
|
|
591
|
+
if (LATIN_RE.test(input)) {
|
|
592
|
+
lengthExtra = LATIN_RE.lastIndex - index;
|
|
593
|
+
widthExtra = lengthExtra * REGULAR_WIDTH;
|
|
594
|
+
if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / REGULAR_WIDTH));
|
|
595
|
+
if (width + widthExtra > LIMIT) {
|
|
596
|
+
truncationEnabled = true;
|
|
567
597
|
break;
|
|
568
598
|
}
|
|
569
|
-
|
|
599
|
+
width += widthExtra;
|
|
600
|
+
unmatchedStart = indexPrev;
|
|
601
|
+
unmatchedEnd = index;
|
|
602
|
+
index = indexPrev = LATIN_RE.lastIndex;
|
|
570
603
|
continue;
|
|
571
604
|
}
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
605
|
+
ANSI_RE.lastIndex = index;
|
|
606
|
+
if (ANSI_RE.test(input)) {
|
|
607
|
+
if (width + ANSI_WIDTH > truncationLimit) truncationIndex = Math.min(truncationIndex, index);
|
|
608
|
+
if (width + ANSI_WIDTH > LIMIT) {
|
|
609
|
+
truncationEnabled = true;
|
|
575
610
|
break;
|
|
576
611
|
}
|
|
577
|
-
|
|
612
|
+
width += ANSI_WIDTH;
|
|
613
|
+
unmatchedStart = indexPrev;
|
|
614
|
+
unmatchedEnd = index;
|
|
615
|
+
index = indexPrev = ANSI_RE.lastIndex;
|
|
578
616
|
continue;
|
|
579
617
|
}
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
618
|
+
CONTROL_RE.lastIndex = index;
|
|
619
|
+
if (CONTROL_RE.test(input)) {
|
|
620
|
+
lengthExtra = CONTROL_RE.lastIndex - index;
|
|
621
|
+
widthExtra = lengthExtra * CONTROL_WIDTH;
|
|
622
|
+
if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / CONTROL_WIDTH));
|
|
623
|
+
if (width + widthExtra > LIMIT) {
|
|
624
|
+
truncationEnabled = true;
|
|
583
625
|
break;
|
|
584
626
|
}
|
|
585
|
-
|
|
627
|
+
width += widthExtra;
|
|
628
|
+
unmatchedStart = indexPrev;
|
|
629
|
+
unmatchedEnd = index;
|
|
630
|
+
index = indexPrev = CONTROL_RE.lastIndex;
|
|
586
631
|
continue;
|
|
587
632
|
}
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
633
|
+
TAB_RE.lastIndex = index;
|
|
634
|
+
if (TAB_RE.test(input)) {
|
|
635
|
+
lengthExtra = TAB_RE.lastIndex - index;
|
|
636
|
+
widthExtra = lengthExtra * TAB_WIDTH;
|
|
637
|
+
if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / TAB_WIDTH));
|
|
638
|
+
if (width + widthExtra > LIMIT) {
|
|
639
|
+
truncationEnabled = true;
|
|
591
640
|
break;
|
|
592
641
|
}
|
|
593
|
-
|
|
642
|
+
width += widthExtra;
|
|
643
|
+
unmatchedStart = indexPrev;
|
|
644
|
+
unmatchedEnd = index;
|
|
645
|
+
index = indexPrev = TAB_RE.lastIndex;
|
|
594
646
|
continue;
|
|
595
647
|
}
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
648
|
+
EMOJI_RE.lastIndex = index;
|
|
649
|
+
if (EMOJI_RE.test(input)) {
|
|
650
|
+
if (width + EMOJI_WIDTH > truncationLimit) truncationIndex = Math.min(truncationIndex, index);
|
|
651
|
+
if (width + EMOJI_WIDTH > LIMIT) {
|
|
652
|
+
truncationEnabled = true;
|
|
599
653
|
break;
|
|
600
654
|
}
|
|
601
|
-
|
|
655
|
+
width += EMOJI_WIDTH;
|
|
656
|
+
unmatchedStart = indexPrev;
|
|
657
|
+
unmatchedEnd = index;
|
|
658
|
+
index = indexPrev = EMOJI_RE.lastIndex;
|
|
602
659
|
continue;
|
|
603
660
|
}
|
|
604
|
-
|
|
661
|
+
index += 1;
|
|
605
662
|
}
|
|
606
663
|
return {
|
|
607
|
-
width:
|
|
608
|
-
index:
|
|
609
|
-
truncated:
|
|
610
|
-
ellipsed:
|
|
664
|
+
width: truncationEnabled ? truncationLimit : width,
|
|
665
|
+
index: truncationEnabled ? truncationIndex : length,
|
|
666
|
+
truncated: truncationEnabled,
|
|
667
|
+
ellipsed: truncationEnabled && LIMIT >= ELLIPSIS_WIDTH
|
|
611
668
|
};
|
|
612
|
-
}
|
|
669
|
+
};
|
|
670
|
+
const dist = getStringTruncatedWidth;
|
|
671
|
+
const dist_NO_TRUNCATION = {
|
|
613
672
|
limit: 1 / 0,
|
|
614
|
-
ellipsis:
|
|
673
|
+
ellipsis: '',
|
|
615
674
|
ellipsisWidth: 0
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
675
|
+
};
|
|
676
|
+
const fastStringWidth = (input, options = {})=>dist(input, dist_NO_TRUNCATION, options).width;
|
|
677
|
+
const fast_string_width_dist = fastStringWidth;
|
|
678
|
+
const ESC = '\x1B';
|
|
679
|
+
const CSI = '\x9B';
|
|
680
|
+
const END_CODE = 39;
|
|
681
|
+
const ANSI_ESCAPE_BELL = '\u0007';
|
|
682
|
+
const ANSI_CSI = '[';
|
|
683
|
+
const ANSI_OSC = ']';
|
|
684
|
+
const ANSI_SGR_TERMINATOR = 'm';
|
|
685
|
+
const ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
|
|
686
|
+
const GROUP_REGEX = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`, 'y');
|
|
687
|
+
const getClosingCode = (openingCode)=>{
|
|
688
|
+
if (openingCode >= 30 && openingCode <= 37) return 39;
|
|
689
|
+
if (openingCode >= 90 && openingCode <= 97) return 39;
|
|
690
|
+
if (openingCode >= 40 && openingCode <= 47) return 49;
|
|
691
|
+
if (openingCode >= 100 && openingCode <= 107) return 49;
|
|
692
|
+
if (1 === openingCode || 2 === openingCode) return 22;
|
|
693
|
+
if (3 === openingCode) return 23;
|
|
694
|
+
if (4 === openingCode) return 24;
|
|
695
|
+
if (7 === openingCode) return 27;
|
|
696
|
+
if (8 === openingCode) return 28;
|
|
697
|
+
if (9 === openingCode) return 29;
|
|
698
|
+
if (0 === openingCode) return 0;
|
|
699
|
+
};
|
|
700
|
+
const wrapAnsiCode = (code)=>`${ESC}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
|
|
701
|
+
const wrapAnsiHyperlink = (url)=>`${ESC}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;
|
|
702
|
+
const wrapWord = (rows, word, columns)=>{
|
|
703
|
+
const characters = word[Symbol.iterator]();
|
|
704
|
+
let isInsideEscape = false;
|
|
705
|
+
let isInsideLinkEscape = false;
|
|
706
|
+
let lastRow = rows.at(-1);
|
|
707
|
+
let visible = void 0 === lastRow ? 0 : fast_string_width_dist(lastRow);
|
|
708
|
+
let currentCharacter = characters.next();
|
|
709
|
+
let nextCharacter = characters.next();
|
|
710
|
+
let rawCharacterIndex = 0;
|
|
711
|
+
while(!currentCharacter.done){
|
|
712
|
+
const character = currentCharacter.value;
|
|
713
|
+
const characterLength = fast_string_width_dist(character);
|
|
714
|
+
if (visible + characterLength <= columns) rows[rows.length - 1] += character;
|
|
715
|
+
else {
|
|
716
|
+
rows.push(character);
|
|
717
|
+
visible = 0;
|
|
718
|
+
}
|
|
719
|
+
if (character === ESC || character === CSI) {
|
|
720
|
+
isInsideEscape = true;
|
|
721
|
+
isInsideLinkEscape = word.startsWith(ANSI_ESCAPE_LINK, rawCharacterIndex + 1);
|
|
722
|
+
}
|
|
723
|
+
if (isInsideEscape) {
|
|
724
|
+
if (isInsideLinkEscape) {
|
|
725
|
+
if (character === ANSI_ESCAPE_BELL) {
|
|
726
|
+
isInsideEscape = false;
|
|
727
|
+
isInsideLinkEscape = false;
|
|
728
|
+
}
|
|
729
|
+
} else if (character === ANSI_SGR_TERMINATOR) isInsideEscape = false;
|
|
730
|
+
} else {
|
|
731
|
+
visible += characterLength;
|
|
732
|
+
if (visible === columns && !nextCharacter.done) {
|
|
733
|
+
rows.push('');
|
|
734
|
+
visible = 0;
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
currentCharacter = nextCharacter;
|
|
738
|
+
nextCharacter = characters.next();
|
|
739
|
+
rawCharacterIndex += character.length;
|
|
740
|
+
}
|
|
741
|
+
lastRow = rows.at(-1);
|
|
742
|
+
if (!visible && void 0 !== lastRow && lastRow.length && rows.length > 1) rows[rows.length - 2] += rows.pop();
|
|
743
|
+
};
|
|
744
|
+
const stringVisibleTrimSpacesRight = (string)=>{
|
|
745
|
+
const words = string.split(' ');
|
|
746
|
+
let last = words.length;
|
|
747
|
+
while(last){
|
|
748
|
+
if (fast_string_width_dist(words[last - 1])) break;
|
|
749
|
+
last--;
|
|
750
|
+
}
|
|
751
|
+
if (last === words.length) return string;
|
|
752
|
+
return words.slice(0, last).join(' ') + words.slice(last).join('');
|
|
753
|
+
};
|
|
754
|
+
const exec = (string, columns, options = {})=>{
|
|
755
|
+
if (false !== options.trim && '' === string.trim()) return '';
|
|
756
|
+
let returnValue = '';
|
|
757
|
+
let escapeCode;
|
|
758
|
+
let escapeUrl;
|
|
759
|
+
const words = string.split(' ');
|
|
760
|
+
let rows = [
|
|
761
|
+
''
|
|
645
762
|
];
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
if (
|
|
650
|
-
const
|
|
651
|
-
|
|
763
|
+
let rowLength = 0;
|
|
764
|
+
for(let index = 0; index < words.length; index++){
|
|
765
|
+
const word = words[index];
|
|
766
|
+
if (false !== options.trim) {
|
|
767
|
+
const row = rows.at(-1) ?? '';
|
|
768
|
+
const trimmed = row.trimStart();
|
|
769
|
+
if (row.length !== trimmed.length) {
|
|
770
|
+
rows[rows.length - 1] = trimmed;
|
|
771
|
+
rowLength = fast_string_width_dist(trimmed);
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
if (0 !== index) {
|
|
775
|
+
if (rowLength >= columns && (false === options.wordWrap || false === options.trim)) {
|
|
776
|
+
rows.push('');
|
|
777
|
+
rowLength = 0;
|
|
778
|
+
}
|
|
779
|
+
if (rowLength || false === options.trim) {
|
|
780
|
+
rows[rows.length - 1] += ' ';
|
|
781
|
+
rowLength++;
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
const wordLength = fast_string_width_dist(word);
|
|
785
|
+
if (options.hard && wordLength > columns) {
|
|
786
|
+
const remainingColumns = columns - rowLength;
|
|
787
|
+
const breaksStartingThisLine = 1 + Math.floor((wordLength - remainingColumns - 1) / columns);
|
|
788
|
+
const breaksStartingNextLine = Math.floor((wordLength - 1) / columns);
|
|
789
|
+
if (breaksStartingNextLine < breaksStartingThisLine) rows.push('');
|
|
790
|
+
wrapWord(rows, word, columns);
|
|
791
|
+
rowLength = fast_string_width_dist(rows.at(-1) ?? '');
|
|
652
792
|
continue;
|
|
653
793
|
}
|
|
654
|
-
if (
|
|
655
|
-
if (
|
|
656
|
-
|
|
794
|
+
if (rowLength + wordLength > columns && rowLength && wordLength) {
|
|
795
|
+
if (false === options.wordWrap && rowLength < columns) {
|
|
796
|
+
wrapWord(rows, word, columns);
|
|
797
|
+
rowLength = fast_string_width_dist(rows.at(-1) ?? '');
|
|
657
798
|
continue;
|
|
658
799
|
}
|
|
659
|
-
|
|
800
|
+
rows.push('');
|
|
801
|
+
rowLength = 0;
|
|
660
802
|
}
|
|
661
|
-
if (
|
|
662
|
-
|
|
803
|
+
if (rowLength + wordLength > columns && false === options.wordWrap) {
|
|
804
|
+
wrapWord(rows, word, columns);
|
|
805
|
+
rowLength = fast_string_width_dist(rows.at(-1) ?? '');
|
|
663
806
|
continue;
|
|
664
807
|
}
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
let
|
|
671
|
-
for(;
|
|
672
|
-
const
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
if (
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
808
|
+
rows[rows.length - 1] += word;
|
|
809
|
+
rowLength += wordLength;
|
|
810
|
+
}
|
|
811
|
+
if (false !== options.trim) rows = rows.map((row)=>stringVisibleTrimSpacesRight(row));
|
|
812
|
+
const preString = rows.join('\n');
|
|
813
|
+
let inSurrogate = false;
|
|
814
|
+
for(let i = 0; i < preString.length; i++){
|
|
815
|
+
const character = preString[i];
|
|
816
|
+
returnValue += character;
|
|
817
|
+
if (!inSurrogate) {
|
|
818
|
+
inSurrogate = character >= '\ud800' && character <= '\udbff';
|
|
819
|
+
if (character === ESC || character === CSI) {
|
|
820
|
+
GROUP_REGEX.lastIndex = i + 1;
|
|
821
|
+
const groupsResult = GROUP_REGEX.exec(preString);
|
|
822
|
+
const groups = groupsResult?.groups;
|
|
823
|
+
if (groups?.code !== void 0) {
|
|
824
|
+
const code = Number.parseFloat(groups.code);
|
|
825
|
+
escapeCode = code === END_CODE ? void 0 : code;
|
|
826
|
+
} else if (groups?.uri !== void 0) escapeUrl = 0 === groups.uri.length ? void 0 : groups.uri;
|
|
827
|
+
}
|
|
828
|
+
if ('\n' === preString[i + 1]) {
|
|
829
|
+
if (escapeUrl) returnValue += wrapAnsiHyperlink('');
|
|
830
|
+
const closingCode = escapeCode ? getClosingCode(escapeCode) : void 0;
|
|
831
|
+
if (escapeCode && closingCode) returnValue += wrapAnsiCode(closingCode);
|
|
832
|
+
} else if ('\n' === character) {
|
|
833
|
+
if (escapeCode && getClosingCode(escapeCode)) returnValue += wrapAnsiCode(escapeCode);
|
|
834
|
+
if (escapeUrl) returnValue += wrapAnsiHyperlink(escapeUrl);
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
return returnValue;
|
|
687
839
|
};
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
`).split(`
|
|
692
|
-
`).map((i)=>Et(i, e, s)).join(`
|
|
693
|
-
`);
|
|
840
|
+
const CRLF_OR_LF = /\r?\n/;
|
|
841
|
+
function wrapAnsi(string, columns, options) {
|
|
842
|
+
return String(string).normalize().split(CRLF_OR_LF).map((line)=>exec(line, columns, options)).join('\n');
|
|
694
843
|
}
|
|
695
|
-
const
|
|
844
|
+
const src = __webpack_require__("./node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js");
|
|
845
|
+
function dist_d(r, t, e) {
|
|
846
|
+
if (!e.some((o)=>!o.disabled)) return r;
|
|
847
|
+
const s = r + t, i = Math.max(e.length - 1, 0), n = s < 0 ? i : s > i ? 0 : s;
|
|
848
|
+
return e[n].disabled ? dist_d(n, t < 0 ? -1 : 1, e) : n;
|
|
849
|
+
}
|
|
850
|
+
const E = [
|
|
696
851
|
"up",
|
|
697
852
|
"down",
|
|
698
853
|
"left",
|
|
@@ -700,8 +855,21 @@ const At = [
|
|
|
700
855
|
"space",
|
|
701
856
|
"enter",
|
|
702
857
|
"cancel"
|
|
703
|
-
],
|
|
704
|
-
|
|
858
|
+
], dist_G = [
|
|
859
|
+
"January",
|
|
860
|
+
"February",
|
|
861
|
+
"March",
|
|
862
|
+
"April",
|
|
863
|
+
"May",
|
|
864
|
+
"June",
|
|
865
|
+
"July",
|
|
866
|
+
"August",
|
|
867
|
+
"September",
|
|
868
|
+
"October",
|
|
869
|
+
"November",
|
|
870
|
+
"December"
|
|
871
|
+
], dist_u = {
|
|
872
|
+
actions: new Set(E),
|
|
705
873
|
aliases: new Map([
|
|
706
874
|
[
|
|
707
875
|
"k",
|
|
@@ -732,75 +900,58 @@ const At = [
|
|
|
732
900
|
cancel: "Canceled",
|
|
733
901
|
error: "Something went wrong"
|
|
734
902
|
},
|
|
735
|
-
withGuide: !0
|
|
903
|
+
withGuide: !0,
|
|
904
|
+
date: {
|
|
905
|
+
monthNames: [
|
|
906
|
+
...dist_G
|
|
907
|
+
],
|
|
908
|
+
messages: {
|
|
909
|
+
required: "Please enter a valid date",
|
|
910
|
+
invalidMonth: "There are only 12 months in a year",
|
|
911
|
+
invalidDay: (r, t)=>`There are only ${r} days in ${t}`,
|
|
912
|
+
afterMin: (r)=>`Date must be on or after ${r.toISOString().slice(0, 10)}`,
|
|
913
|
+
beforeMax: (r)=>`Date must be on or before ${r.toISOString().slice(0, 10)}`
|
|
914
|
+
}
|
|
915
|
+
}
|
|
736
916
|
};
|
|
737
|
-
function
|
|
738
|
-
if ("string" == typeof
|
|
739
|
-
for (const
|
|
917
|
+
function V(r, t) {
|
|
918
|
+
if ("string" == typeof r) return dist_u.aliases.get(r) === t;
|
|
919
|
+
for (const e of r)if (void 0 !== e && V(e, t)) return !0;
|
|
740
920
|
return !1;
|
|
741
921
|
}
|
|
742
|
-
function
|
|
743
|
-
if (
|
|
744
|
-
const
|
|
745
|
-
`),
|
|
746
|
-
`),
|
|
747
|
-
for(let
|
|
922
|
+
function dist_j(r, t) {
|
|
923
|
+
if (r === t) return;
|
|
924
|
+
const e = r.split(`
|
|
925
|
+
`), s = t.split(`
|
|
926
|
+
`), i = Math.max(e.length, s.length), n = [];
|
|
927
|
+
for(let o = 0; o < i; o++)e[o] !== s[o] && n.push(o);
|
|
748
928
|
return {
|
|
749
929
|
lines: n,
|
|
750
|
-
numLinesBefore:
|
|
751
|
-
numLinesAfter:
|
|
752
|
-
numLines:
|
|
930
|
+
numLinesBefore: e.length,
|
|
931
|
+
numLinesAfter: s.length,
|
|
932
|
+
numLines: i
|
|
753
933
|
};
|
|
754
934
|
}
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
935
|
+
globalThis.process.platform.startsWith("win");
|
|
936
|
+
const dist_C = Symbol("clack:cancel");
|
|
937
|
+
function dist_q(r) {
|
|
938
|
+
return r === dist_C;
|
|
758
939
|
}
|
|
759
|
-
function
|
|
760
|
-
const
|
|
761
|
-
|
|
940
|
+
function w(r, t) {
|
|
941
|
+
const e = r;
|
|
942
|
+
e.isTTY && e.setRawMode(t);
|
|
762
943
|
}
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
prompt: "",
|
|
768
|
-
tabSize: 1
|
|
769
|
-
});
|
|
770
|
-
__rspack_external_node_readline_91c31510.emitKeypressEvents(t, r), t instanceof ReadStream && t.isTTY && t.setRawMode(!0);
|
|
771
|
-
const n = (u, { name: a, sequence: l })=>{
|
|
772
|
-
const E = String(u);
|
|
773
|
-
if (H([
|
|
774
|
-
E,
|
|
775
|
-
a,
|
|
776
|
-
l
|
|
777
|
-
], "cancel")) {
|
|
778
|
-
i && e.write(src.cursor.show), process.exit(0);
|
|
779
|
-
return;
|
|
780
|
-
}
|
|
781
|
-
if (!s) return;
|
|
782
|
-
const g = "return" === a ? 0 : -1, m = "return" === a ? -1 : 0;
|
|
783
|
-
__rspack_external_node_readline_91c31510.moveCursor(e, g, m, ()=>{
|
|
784
|
-
__rspack_external_node_readline_91c31510.clearLine(e, 1, ()=>{
|
|
785
|
-
t.once("keypress", n);
|
|
786
|
-
});
|
|
787
|
-
});
|
|
788
|
-
};
|
|
789
|
-
return i && e.write(src.cursor.hide), t.once("keypress", n), ()=>{
|
|
790
|
-
t.off("keypress", n), i && e.write(src.cursor.show), t instanceof ReadStream && t.isTTY && !bt && t.setRawMode(!1), r.terminal = !1, r.close();
|
|
791
|
-
};
|
|
792
|
-
}
|
|
793
|
-
const dist_rt = (t)=>"columns" in t && "number" == typeof t.columns ? t.columns : 80, nt = (t)=>"rows" in t && "number" == typeof t.rows ? t.rows : 20;
|
|
794
|
-
function Bt(t, e, s, i = s) {
|
|
795
|
-
const r = dist_rt(t ?? stdout);
|
|
796
|
-
return K(e, r - s.length, {
|
|
944
|
+
const O = (r)=>"columns" in r && "number" == typeof r.columns ? r.columns : 80, dist_A = (r)=>"rows" in r && "number" == typeof r.rows ? r.rows : 20;
|
|
945
|
+
function dist_R(r, t, e, s = e) {
|
|
946
|
+
const i = O(r ?? stdout);
|
|
947
|
+
return wrapAnsi(t, i - e.length, {
|
|
797
948
|
hard: !0,
|
|
798
949
|
trim: !1
|
|
799
950
|
}).split(`
|
|
800
|
-
`).map((n,
|
|
951
|
+
`).map((n, o)=>`${0 === o ? s : e}${n}`).join(`
|
|
801
952
|
`);
|
|
802
953
|
}
|
|
803
|
-
class
|
|
954
|
+
let dist_p = class {
|
|
804
955
|
input;
|
|
805
956
|
output;
|
|
806
957
|
_abortSignal;
|
|
@@ -815,64 +966,64 @@ class dist_B {
|
|
|
815
966
|
error = "";
|
|
816
967
|
value;
|
|
817
968
|
userInput = "";
|
|
818
|
-
constructor(
|
|
819
|
-
const { input:
|
|
820
|
-
this.opts = a, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = n.bind(this), this._track =
|
|
969
|
+
constructor(t, e = !0){
|
|
970
|
+
const { input: s = stdin, output: i = stdout, render: n, signal: o, ...a } = t;
|
|
971
|
+
this.opts = a, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = n.bind(this), this._track = e, this._abortSignal = o, this.input = s, this.output = i;
|
|
821
972
|
}
|
|
822
973
|
unsubscribe() {
|
|
823
974
|
this._subscribers.clear();
|
|
824
975
|
}
|
|
825
|
-
setSubscriber(
|
|
826
|
-
const
|
|
827
|
-
|
|
976
|
+
setSubscriber(t, e) {
|
|
977
|
+
const s = this._subscribers.get(t) ?? [];
|
|
978
|
+
s.push(e), this._subscribers.set(t, s);
|
|
828
979
|
}
|
|
829
|
-
on(
|
|
830
|
-
this.setSubscriber(
|
|
831
|
-
cb:
|
|
980
|
+
on(t, e) {
|
|
981
|
+
this.setSubscriber(t, {
|
|
982
|
+
cb: e
|
|
832
983
|
});
|
|
833
984
|
}
|
|
834
|
-
once(
|
|
835
|
-
this.setSubscriber(
|
|
836
|
-
cb:
|
|
985
|
+
once(t, e) {
|
|
986
|
+
this.setSubscriber(t, {
|
|
987
|
+
cb: e,
|
|
837
988
|
once: !0
|
|
838
989
|
});
|
|
839
990
|
}
|
|
840
|
-
emit(
|
|
841
|
-
const
|
|
842
|
-
for (const n of
|
|
843
|
-
for (const n of
|
|
991
|
+
emit(t, ...e) {
|
|
992
|
+
const s = this._subscribers.get(t) ?? [], i = [];
|
|
993
|
+
for (const n of s)n.cb(...e), n.once && i.push(()=>s.splice(s.indexOf(n), 1));
|
|
994
|
+
for (const n of i)n();
|
|
844
995
|
}
|
|
845
996
|
prompt() {
|
|
846
|
-
return new Promise((
|
|
997
|
+
return new Promise((t)=>{
|
|
847
998
|
if (this._abortSignal) {
|
|
848
|
-
if (this._abortSignal.aborted) return this.state = "cancel", this.close(),
|
|
999
|
+
if (this._abortSignal.aborted) return this.state = "cancel", this.close(), t(dist_C);
|
|
849
1000
|
this._abortSignal.addEventListener("abort", ()=>{
|
|
850
1001
|
this.state = "cancel", this.close();
|
|
851
1002
|
}, {
|
|
852
1003
|
once: !0
|
|
853
1004
|
});
|
|
854
1005
|
}
|
|
855
|
-
this.rl =
|
|
1006
|
+
this.rl = node_readline.createInterface({
|
|
856
1007
|
input: this.input,
|
|
857
1008
|
tabSize: 2,
|
|
858
1009
|
prompt: "",
|
|
859
1010
|
escapeCodeTimeout: 50,
|
|
860
1011
|
terminal: !0
|
|
861
|
-
}), this.rl.prompt(), void 0 !== this.opts.initialUserInput && this._setUserInput(this.opts.initialUserInput, !0), this.input.on("keypress", this.onKeypress),
|
|
862
|
-
this.output.write(src.cursor.show), this.output.off("resize", this.render),
|
|
1012
|
+
}), this.rl.prompt(), void 0 !== this.opts.initialUserInput && this._setUserInput(this.opts.initialUserInput, !0), this.input.on("keypress", this.onKeypress), w(this.input, !0), this.output.on("resize", this.render), this.render(), this.once("submit", ()=>{
|
|
1013
|
+
this.output.write(src.cursor.show), this.output.off("resize", this.render), w(this.input, !1), t(this.value);
|
|
863
1014
|
}), this.once("cancel", ()=>{
|
|
864
|
-
this.output.write(src.cursor.show), this.output.off("resize", this.render),
|
|
1015
|
+
this.output.write(src.cursor.show), this.output.off("resize", this.render), w(this.input, !1), t(dist_C);
|
|
865
1016
|
});
|
|
866
1017
|
});
|
|
867
1018
|
}
|
|
868
|
-
_isActionKey(
|
|
869
|
-
return " " ===
|
|
1019
|
+
_isActionKey(t, e) {
|
|
1020
|
+
return " " === t;
|
|
870
1021
|
}
|
|
871
|
-
_setValue(
|
|
872
|
-
this.value =
|
|
1022
|
+
_setValue(t) {
|
|
1023
|
+
this.value = t, this.emit("value", this.value);
|
|
873
1024
|
}
|
|
874
|
-
_setUserInput(
|
|
875
|
-
this.userInput =
|
|
1025
|
+
_setUserInput(t, e) {
|
|
1026
|
+
this.userInput = t ?? "", this.emit("userInput", this.userInput), e && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
|
|
876
1027
|
}
|
|
877
1028
|
_clearUserInput() {
|
|
878
1029
|
this.rl?.write(null, {
|
|
@@ -880,121 +1031,280 @@ class dist_B {
|
|
|
880
1031
|
name: "u"
|
|
881
1032
|
}), this._setUserInput("");
|
|
882
1033
|
}
|
|
883
|
-
onKeypress(
|
|
884
|
-
if (this._track && "return" !==
|
|
1034
|
+
onKeypress(t, e) {
|
|
1035
|
+
if (this._track && "return" !== e.name && (e.name && this._isActionKey(t, e) && this.rl?.write(null, {
|
|
885
1036
|
ctrl: !0,
|
|
886
1037
|
name: "h"
|
|
887
|
-
}), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), "error" === this.state && (this.state = "active"),
|
|
1038
|
+
}), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), "error" === this.state && (this.state = "active"), e?.name && (!this._track && dist_u.aliases.has(e.name) && this.emit("cursor", dist_u.aliases.get(e.name)), dist_u.actions.has(e.name) && this.emit("cursor", e.name)), t && ("y" === t.toLowerCase() || "n" === t.toLowerCase()) && this.emit("confirm", "y" === t.toLowerCase()), this.emit("key", t?.toLowerCase(), e), e?.name === "return") {
|
|
888
1039
|
if (this.opts.validate) {
|
|
889
|
-
const
|
|
890
|
-
|
|
1040
|
+
const s = this.opts.validate(this.value);
|
|
1041
|
+
s && (this.error = s instanceof Error ? s.message : s, this.state = "error", this.rl?.write(this.userInput));
|
|
891
1042
|
}
|
|
892
1043
|
"error" !== this.state && (this.state = "submit");
|
|
893
1044
|
}
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
1045
|
+
V([
|
|
1046
|
+
t,
|
|
1047
|
+
e?.name,
|
|
1048
|
+
e?.sequence
|
|
898
1049
|
], "cancel") && (this.state = "cancel"), ("submit" === this.state || "cancel" === this.state) && this.emit("finalize"), this.render(), ("submit" === this.state || "cancel" === this.state) && this.close();
|
|
899
1050
|
}
|
|
900
1051
|
close() {
|
|
901
1052
|
this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
|
|
902
|
-
`),
|
|
1053
|
+
`), w(this.input, !1), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
|
|
903
1054
|
}
|
|
904
1055
|
restoreCursor() {
|
|
905
|
-
const
|
|
1056
|
+
const t = wrapAnsi(this._prevFrame, process.stdout.columns, {
|
|
906
1057
|
hard: !0,
|
|
907
1058
|
trim: !1
|
|
908
1059
|
}).split(`
|
|
909
1060
|
`).length - 1;
|
|
910
|
-
this.output.write(src.cursor.move(-999, -1 *
|
|
1061
|
+
this.output.write(src.cursor.move(-999, -1 * t));
|
|
911
1062
|
}
|
|
912
1063
|
render() {
|
|
913
|
-
const
|
|
1064
|
+
const t = wrapAnsi(this._render(this) ?? "", process.stdout.columns, {
|
|
914
1065
|
hard: !0,
|
|
915
1066
|
trim: !1
|
|
916
1067
|
});
|
|
917
|
-
if (
|
|
1068
|
+
if (t !== this._prevFrame) {
|
|
918
1069
|
if ("initial" === this.state) this.output.write(src.cursor.hide);
|
|
919
1070
|
else {
|
|
920
|
-
const
|
|
921
|
-
if (this.restoreCursor(),
|
|
922
|
-
const
|
|
923
|
-
let
|
|
924
|
-
if (void 0 ===
|
|
925
|
-
this._prevFrame =
|
|
1071
|
+
const e = dist_j(this._prevFrame, t), s = dist_A(this.output);
|
|
1072
|
+
if (this.restoreCursor(), e) {
|
|
1073
|
+
const i = Math.max(0, e.numLinesAfter - s), n = Math.max(0, e.numLinesBefore - s);
|
|
1074
|
+
let o = e.lines.find((a)=>a >= i);
|
|
1075
|
+
if (void 0 === o) {
|
|
1076
|
+
this._prevFrame = t;
|
|
926
1077
|
return;
|
|
927
1078
|
}
|
|
928
|
-
if (1 ===
|
|
929
|
-
this.output.write(src.cursor.move(0,
|
|
930
|
-
const a =
|
|
1079
|
+
if (1 === e.lines.length) {
|
|
1080
|
+
this.output.write(src.cursor.move(0, o - n)), this.output.write(src.erase.lines(1));
|
|
1081
|
+
const a = t.split(`
|
|
931
1082
|
`);
|
|
932
|
-
this.output.write(a[
|
|
1083
|
+
this.output.write(a[o]), this._prevFrame = t, this.output.write(src.cursor.move(0, a.length - o - 1));
|
|
933
1084
|
return;
|
|
934
1085
|
}
|
|
935
|
-
if (
|
|
936
|
-
if (
|
|
1086
|
+
if (e.lines.length > 1) {
|
|
1087
|
+
if (i < n) o = i;
|
|
937
1088
|
else {
|
|
938
|
-
const
|
|
939
|
-
|
|
1089
|
+
const h = o - n;
|
|
1090
|
+
h > 0 && this.output.write(src.cursor.move(0, h));
|
|
940
1091
|
}
|
|
941
1092
|
this.output.write(src.erase.down());
|
|
942
|
-
const a =
|
|
943
|
-
`).slice(
|
|
1093
|
+
const a = t.split(`
|
|
1094
|
+
`).slice(o);
|
|
944
1095
|
this.output.write(a.join(`
|
|
945
|
-
`)), this._prevFrame =
|
|
1096
|
+
`)), this._prevFrame = t;
|
|
946
1097
|
return;
|
|
947
1098
|
}
|
|
948
1099
|
}
|
|
949
1100
|
this.output.write(src.erase.down());
|
|
950
1101
|
}
|
|
951
|
-
this.output.write(
|
|
1102
|
+
this.output.write(t), "initial" === this.state && (this.state = "active"), this._prevFrame = t;
|
|
952
1103
|
}
|
|
953
1104
|
}
|
|
1105
|
+
};
|
|
1106
|
+
function dist_W(r, t) {
|
|
1107
|
+
if (void 0 === r || 0 === t.length) return 0;
|
|
1108
|
+
const e = t.findIndex((s)=>s.value === r);
|
|
1109
|
+
return -1 !== e ? e : 0;
|
|
1110
|
+
}
|
|
1111
|
+
function dist_B(r, t) {
|
|
1112
|
+
return (t.label ?? String(t.value)).toLowerCase().includes(r.toLowerCase());
|
|
1113
|
+
}
|
|
1114
|
+
function J(r, t) {
|
|
1115
|
+
if (t) return r ? t : t[0];
|
|
954
1116
|
}
|
|
955
|
-
let
|
|
1117
|
+
let H = class extends dist_p {
|
|
1118
|
+
filteredOptions;
|
|
1119
|
+
multiple;
|
|
1120
|
+
isNavigating = !1;
|
|
1121
|
+
selectedValues = [];
|
|
1122
|
+
focusedValue;
|
|
1123
|
+
#e = 0;
|
|
1124
|
+
#o = "";
|
|
1125
|
+
#t;
|
|
1126
|
+
#n;
|
|
1127
|
+
#a;
|
|
1128
|
+
get cursor() {
|
|
1129
|
+
return this.#e;
|
|
1130
|
+
}
|
|
1131
|
+
get userInputWithCursor() {
|
|
1132
|
+
if (!this.userInput) return styleText([
|
|
1133
|
+
"inverse",
|
|
1134
|
+
"hidden"
|
|
1135
|
+
], "_");
|
|
1136
|
+
if (this._cursor >= this.userInput.length) return `${this.userInput}\u2588`;
|
|
1137
|
+
const t = this.userInput.slice(0, this._cursor), [e, ...s] = this.userInput.slice(this._cursor);
|
|
1138
|
+
return `${t}${styleText("inverse", e)}${s.join("")}`;
|
|
1139
|
+
}
|
|
1140
|
+
get options() {
|
|
1141
|
+
return "function" == typeof this.#n ? this.#n() : this.#n;
|
|
1142
|
+
}
|
|
1143
|
+
constructor(t){
|
|
1144
|
+
super(t), this.#n = t.options, this.#a = t.placeholder;
|
|
1145
|
+
const e = this.options;
|
|
1146
|
+
this.filteredOptions = [
|
|
1147
|
+
...e
|
|
1148
|
+
], this.multiple = !0 === t.multiple, this.#t = "function" == typeof t.options ? t.filter : t.filter ?? dist_B;
|
|
1149
|
+
let s;
|
|
1150
|
+
if (t.initialValue && Array.isArray(t.initialValue) ? this.multiple ? s = t.initialValue : s = t.initialValue.slice(0, 1) : !this.multiple && this.options.length > 0 && (s = [
|
|
1151
|
+
this.options[0].value
|
|
1152
|
+
]), s) for (const i of s){
|
|
1153
|
+
const n = e.findIndex((o)=>o.value === i);
|
|
1154
|
+
-1 !== n && (this.toggleSelected(i), this.#e = n);
|
|
1155
|
+
}
|
|
1156
|
+
this.focusedValue = this.options[this.#e]?.value, this.on("key", (i, n)=>this.#s(i, n)), this.on("userInput", (i)=>this.#i(i));
|
|
1157
|
+
}
|
|
1158
|
+
_isActionKey(t, e) {
|
|
1159
|
+
return " " === t || this.multiple && this.isNavigating && "space" === e.name && void 0 !== t && "" !== t;
|
|
1160
|
+
}
|
|
1161
|
+
#s(t, e) {
|
|
1162
|
+
const s = "up" === e.name, i = "down" === e.name, n = "return" === e.name, o = "" === this.userInput || " " === this.userInput, a = this.#a, h = this.options, l = void 0 !== a && "" !== a && h.some((f)=>!f.disabled && (this.#t ? this.#t(a, f) : !0));
|
|
1163
|
+
if ("tab" === e.name && o && l) {
|
|
1164
|
+
" " === this.userInput && this._clearUserInput(), this._setUserInput(a, !0), this.isNavigating = !1;
|
|
1165
|
+
return;
|
|
1166
|
+
}
|
|
1167
|
+
s || i ? (this.#e = dist_d(this.#e, s ? -1 : 1, this.filteredOptions), this.focusedValue = this.filteredOptions[this.#e]?.value, this.multiple || (this.selectedValues = [
|
|
1168
|
+
this.focusedValue
|
|
1169
|
+
]), this.isNavigating = !0) : n ? this.value = J(this.multiple, this.selectedValues) : this.multiple ? void 0 !== this.focusedValue && ("tab" === e.name || this.isNavigating && "space" === e.name) ? this.toggleSelected(this.focusedValue) : this.isNavigating = !1 : (this.focusedValue && (this.selectedValues = [
|
|
1170
|
+
this.focusedValue
|
|
1171
|
+
]), this.isNavigating = !1);
|
|
1172
|
+
}
|
|
1173
|
+
deselectAll() {
|
|
1174
|
+
this.selectedValues = [];
|
|
1175
|
+
}
|
|
1176
|
+
toggleSelected(t) {
|
|
1177
|
+
0 !== this.filteredOptions.length && (this.multiple ? this.selectedValues.includes(t) ? this.selectedValues = this.selectedValues.filter((e)=>e !== t) : this.selectedValues = [
|
|
1178
|
+
...this.selectedValues,
|
|
1179
|
+
t
|
|
1180
|
+
] : this.selectedValues = [
|
|
1181
|
+
t
|
|
1182
|
+
]);
|
|
1183
|
+
}
|
|
1184
|
+
#i(t) {
|
|
1185
|
+
if (t !== this.#o) {
|
|
1186
|
+
this.#o = t;
|
|
1187
|
+
const e = this.options;
|
|
1188
|
+
t && this.#t ? this.filteredOptions = e.filter((n)=>this.#t?.(t, n)) : this.filteredOptions = [
|
|
1189
|
+
...e
|
|
1190
|
+
];
|
|
1191
|
+
const s = dist_W(this.focusedValue, this.filteredOptions);
|
|
1192
|
+
this.#e = dist_d(s, 0, this.filteredOptions);
|
|
1193
|
+
const i = this.filteredOptions[this.#e];
|
|
1194
|
+
i && !i.disabled ? this.focusedValue = i.value : this.focusedValue = void 0, this.multiple || (void 0 !== this.focusedValue ? this.toggleSelected(this.focusedValue) : this.deselectAll());
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
};
|
|
1198
|
+
class st extends dist_p {
|
|
1199
|
+
options;
|
|
1200
|
+
cursor = 0;
|
|
1201
|
+
#e;
|
|
1202
|
+
getGroupItems(t) {
|
|
1203
|
+
return this.options.filter((e)=>e.group === t);
|
|
1204
|
+
}
|
|
1205
|
+
isGroupSelected(t) {
|
|
1206
|
+
const e = this.getGroupItems(t), s = this.value;
|
|
1207
|
+
return void 0 === s ? !1 : e.every((i)=>s.includes(i.value));
|
|
1208
|
+
}
|
|
1209
|
+
toggleValue() {
|
|
1210
|
+
const t = this.options[this.cursor];
|
|
1211
|
+
if (void 0 === this.value && (this.value = []), !0 === t.group) {
|
|
1212
|
+
const e = t.value, s = this.getGroupItems(e);
|
|
1213
|
+
this.isGroupSelected(e) ? this.value = this.value.filter((i)=>-1 === s.findIndex((n)=>n.value === i)) : this.value = [
|
|
1214
|
+
...this.value,
|
|
1215
|
+
...s.map((i)=>i.value)
|
|
1216
|
+
], this.value = Array.from(new Set(this.value));
|
|
1217
|
+
} else {
|
|
1218
|
+
const e = this.value.includes(t.value);
|
|
1219
|
+
this.value = e ? this.value.filter((s)=>s !== t.value) : [
|
|
1220
|
+
...this.value,
|
|
1221
|
+
t.value
|
|
1222
|
+
];
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
constructor(t){
|
|
1226
|
+
super(t, !1);
|
|
1227
|
+
const { options: e } = t;
|
|
1228
|
+
this.#e = !1 !== t.selectableGroups, this.options = Object.entries(e).flatMap(([s, i])=>[
|
|
1229
|
+
{
|
|
1230
|
+
value: s,
|
|
1231
|
+
group: !0,
|
|
1232
|
+
label: s
|
|
1233
|
+
},
|
|
1234
|
+
...i.map((n)=>({
|
|
1235
|
+
...n,
|
|
1236
|
+
group: s
|
|
1237
|
+
}))
|
|
1238
|
+
]), this.value = [
|
|
1239
|
+
...t.initialValues ?? []
|
|
1240
|
+
], this.cursor = Math.max(this.options.findIndex(({ value: s })=>s === t.cursorAt), this.#e ? 0 : 1), this.on("cursor", (s)=>{
|
|
1241
|
+
switch(s){
|
|
1242
|
+
case "left":
|
|
1243
|
+
case "up":
|
|
1244
|
+
{
|
|
1245
|
+
this.cursor = 0 === this.cursor ? this.options.length - 1 : this.cursor - 1;
|
|
1246
|
+
const i = this.options[this.cursor]?.group === !0;
|
|
1247
|
+
!this.#e && i && (this.cursor = 0 === this.cursor ? this.options.length - 1 : this.cursor - 1);
|
|
1248
|
+
break;
|
|
1249
|
+
}
|
|
1250
|
+
case "down":
|
|
1251
|
+
case "right":
|
|
1252
|
+
{
|
|
1253
|
+
this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
|
|
1254
|
+
const i = this.options[this.cursor]?.group === !0;
|
|
1255
|
+
!this.#e && i && (this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1);
|
|
1256
|
+
break;
|
|
1257
|
+
}
|
|
1258
|
+
case "space":
|
|
1259
|
+
this.toggleValue();
|
|
1260
|
+
break;
|
|
1261
|
+
}
|
|
1262
|
+
});
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
let it = class extends dist_p {
|
|
956
1266
|
options;
|
|
957
1267
|
cursor = 0;
|
|
958
1268
|
get _value() {
|
|
959
1269
|
return this.options[this.cursor].value;
|
|
960
1270
|
}
|
|
961
1271
|
get _enabledOptions() {
|
|
962
|
-
return this.options.filter((
|
|
1272
|
+
return this.options.filter((t)=>!0 !== t.disabled);
|
|
963
1273
|
}
|
|
964
1274
|
toggleAll() {
|
|
965
|
-
const
|
|
966
|
-
this.value =
|
|
1275
|
+
const t = this._enabledOptions, e = void 0 !== this.value && this.value.length === t.length;
|
|
1276
|
+
this.value = e ? [] : t.map((s)=>s.value);
|
|
967
1277
|
}
|
|
968
1278
|
toggleInvert() {
|
|
969
|
-
const
|
|
970
|
-
if (!
|
|
971
|
-
const
|
|
972
|
-
this.value =
|
|
1279
|
+
const t = this.value;
|
|
1280
|
+
if (!t) return;
|
|
1281
|
+
const e = this._enabledOptions.filter((s)=>!t.includes(s.value));
|
|
1282
|
+
this.value = e.map((s)=>s.value);
|
|
973
1283
|
}
|
|
974
1284
|
toggleValue() {
|
|
975
1285
|
void 0 === this.value && (this.value = []);
|
|
976
|
-
const
|
|
977
|
-
this.value =
|
|
1286
|
+
const t = this.value.includes(this._value);
|
|
1287
|
+
this.value = t ? this.value.filter((e)=>e !== this._value) : [
|
|
978
1288
|
...this.value,
|
|
979
1289
|
this._value
|
|
980
1290
|
];
|
|
981
1291
|
}
|
|
982
|
-
constructor(
|
|
983
|
-
super(
|
|
984
|
-
...
|
|
1292
|
+
constructor(t){
|
|
1293
|
+
super(t, !1), this.options = t.options, this.value = [
|
|
1294
|
+
...t.initialValues ?? []
|
|
985
1295
|
];
|
|
986
|
-
const
|
|
987
|
-
this.cursor = this.options[
|
|
988
|
-
"a" ===
|
|
989
|
-
}), this.on("cursor", (
|
|
990
|
-
switch(
|
|
1296
|
+
const e = Math.max(this.options.findIndex(({ value: s })=>s === t.cursorAt), 0);
|
|
1297
|
+
this.cursor = this.options[e].disabled ? dist_d(e, 1, this.options) : e, this.on("key", (s)=>{
|
|
1298
|
+
"a" === s && this.toggleAll(), "i" === s && this.toggleInvert();
|
|
1299
|
+
}), this.on("cursor", (s)=>{
|
|
1300
|
+
switch(s){
|
|
991
1301
|
case "left":
|
|
992
1302
|
case "up":
|
|
993
|
-
this.cursor =
|
|
1303
|
+
this.cursor = dist_d(this.cursor, -1, this.options);
|
|
994
1304
|
break;
|
|
995
1305
|
case "down":
|
|
996
1306
|
case "right":
|
|
997
|
-
this.cursor =
|
|
1307
|
+
this.cursor = dist_d(this.cursor, 1, this.options);
|
|
998
1308
|
break;
|
|
999
1309
|
case "space":
|
|
1000
1310
|
this.toggleValue();
|
|
@@ -1003,7 +1313,7 @@ let Lt = class extends dist_B {
|
|
|
1003
1313
|
});
|
|
1004
1314
|
}
|
|
1005
1315
|
};
|
|
1006
|
-
class
|
|
1316
|
+
class nt extends dist_p {
|
|
1007
1317
|
options;
|
|
1008
1318
|
cursor = 0;
|
|
1009
1319
|
get _selectedValue() {
|
|
@@ -1012,335 +1322,379 @@ class Tt extends dist_B {
|
|
|
1012
1322
|
changeValue() {
|
|
1013
1323
|
this.value = this._selectedValue.value;
|
|
1014
1324
|
}
|
|
1015
|
-
constructor(
|
|
1016
|
-
super(
|
|
1017
|
-
const
|
|
1018
|
-
this.cursor = this.options[
|
|
1019
|
-
switch(
|
|
1325
|
+
constructor(t){
|
|
1326
|
+
super(t, !1), this.options = t.options;
|
|
1327
|
+
const e = this.options.findIndex(({ value: i })=>i === t.initialValue), s = -1 === e ? 0 : e;
|
|
1328
|
+
this.cursor = this.options[s].disabled ? dist_d(s, 1, this.options) : s, this.changeValue(), this.on("cursor", (i)=>{
|
|
1329
|
+
switch(i){
|
|
1020
1330
|
case "left":
|
|
1021
1331
|
case "up":
|
|
1022
|
-
this.cursor =
|
|
1332
|
+
this.cursor = dist_d(this.cursor, -1, this.options);
|
|
1023
1333
|
break;
|
|
1024
1334
|
case "down":
|
|
1025
1335
|
case "right":
|
|
1026
|
-
this.cursor =
|
|
1336
|
+
this.cursor = dist_d(this.cursor, 1, this.options);
|
|
1027
1337
|
break;
|
|
1028
1338
|
}
|
|
1029
1339
|
this.changeValue();
|
|
1030
1340
|
});
|
|
1031
1341
|
}
|
|
1032
1342
|
}
|
|
1033
|
-
class
|
|
1343
|
+
class at extends dist_p {
|
|
1034
1344
|
get userInputWithCursor() {
|
|
1035
1345
|
if ("submit" === this.state) return this.userInput;
|
|
1036
|
-
const
|
|
1037
|
-
if (this.cursor >=
|
|
1038
|
-
const
|
|
1039
|
-
return `${
|
|
1346
|
+
const t = this.userInput;
|
|
1347
|
+
if (this.cursor >= t.length) return `${this.userInput}\u2588`;
|
|
1348
|
+
const e = t.slice(0, this.cursor), [s, ...i] = t.slice(this.cursor);
|
|
1349
|
+
return `${e}${styleText("inverse", s)}${i.join("")}`;
|
|
1040
1350
|
}
|
|
1041
1351
|
get cursor() {
|
|
1042
1352
|
return this._cursor;
|
|
1043
1353
|
}
|
|
1044
|
-
constructor(
|
|
1354
|
+
constructor(t){
|
|
1045
1355
|
super({
|
|
1046
|
-
...
|
|
1047
|
-
initialUserInput:
|
|
1048
|
-
}), this.on("userInput", (
|
|
1049
|
-
this._setValue(
|
|
1356
|
+
...t,
|
|
1357
|
+
initialUserInput: t.initialUserInput ?? t.initialValue
|
|
1358
|
+
}), this.on("userInput", (e)=>{
|
|
1359
|
+
this._setValue(e);
|
|
1050
1360
|
}), this.on("finalize", ()=>{
|
|
1051
|
-
this.value || (this.value =
|
|
1361
|
+
this.value || (this.value = t.defaultValue), void 0 === this.value && (this.value = "");
|
|
1052
1362
|
});
|
|
1053
1363
|
}
|
|
1054
1364
|
}
|
|
1055
|
-
function
|
|
1365
|
+
function Ze() {
|
|
1056
1366
|
return "win32" !== node_process.platform ? "linux" !== node_process.env.TERM : !!node_process.env.CI || !!node_process.env.WT_SESSION || !!node_process.env.TERMINUS_SUBLIME || "{cmd::Cmder}" === node_process.env.ConEmuTask || "Terminus-Sublime" === node_process.env.TERM_PROGRAM || "vscode" === node_process.env.TERM_PROGRAM || "xterm-256color" === node_process.env.TERM || "alacritty" === node_process.env.TERM || "JetBrains-JediTerm" === node_process.env.TERMINAL_EMULATOR;
|
|
1057
1367
|
}
|
|
1058
|
-
const ee =
|
|
1368
|
+
const ee = Ze(), ae = ()=>"true" === process.env.CI, Te = (e)=>!0 === e.isTTY, dist_w = (e, i)=>ee ? e : i, _e = dist_w("\u25C6", "*"), oe = dist_w("\u25A0", "x"), ue = dist_w("\u25B2", "x"), dist_F = dist_w("\u25C7", "o"), prompts_dist_d = (dist_w("\u250C", "T"), dist_w("\u2502", "|")), dist_E = dist_w("\u2514", "\u2014"), dist_z = (dist_w("\u2510", "T"), dist_w("\u2518", "\u2014"), dist_w("\u25CF", ">")), dist_H = dist_w("\u25CB", " "), te = dist_w("\u25FB", "[\u2022]"), dist_U = dist_w("\u25FC", "[+]"), dist_J = dist_w("\u25FB", "[ ]"), se = (dist_w("\u25AA", "\u2022"), dist_w("\u2500", "-")), ce = dist_w("\u256E", "+"), Ge = dist_w("\u251C", "+"), $e = dist_w("\u256F", "+"), de = dist_w("\u2570", "+"), he = (dist_w("\u256D", "+"), dist_w("\u25CF", "\u2022")), pe = dist_w("\u25C6", "*"), me = dist_w("\u25B2", "!"), ge = dist_w("\u25A0", "x"), dist_V = (e)=>{
|
|
1059
1369
|
switch(e){
|
|
1060
1370
|
case "initial":
|
|
1061
1371
|
case "active":
|
|
1062
|
-
return styleText("cyan",
|
|
1372
|
+
return styleText("cyan", _e);
|
|
1063
1373
|
case "cancel":
|
|
1064
|
-
return styleText("red",
|
|
1374
|
+
return styleText("red", oe);
|
|
1065
1375
|
case "error":
|
|
1066
|
-
return styleText("yellow",
|
|
1376
|
+
return styleText("yellow", ue);
|
|
1067
1377
|
case "submit":
|
|
1068
|
-
return styleText("green",
|
|
1378
|
+
return styleText("green", dist_F);
|
|
1069
1379
|
}
|
|
1070
|
-
},
|
|
1380
|
+
}, ye = (e)=>{
|
|
1071
1381
|
switch(e){
|
|
1072
1382
|
case "initial":
|
|
1073
1383
|
case "active":
|
|
1074
|
-
return styleText("cyan",
|
|
1384
|
+
return styleText("cyan", prompts_dist_d);
|
|
1075
1385
|
case "cancel":
|
|
1076
|
-
return styleText("red",
|
|
1386
|
+
return styleText("red", prompts_dist_d);
|
|
1077
1387
|
case "error":
|
|
1078
|
-
return styleText("yellow",
|
|
1388
|
+
return styleText("yellow", prompts_dist_d);
|
|
1079
1389
|
case "submit":
|
|
1080
|
-
return styleText("green",
|
|
1081
|
-
}
|
|
1082
|
-
}, dist_mt = (e)=>161 === e || 164 === e || 167 === e || 168 === e || 170 === e || 173 === e || 174 === e || e >= 176 && e <= 180 || e >= 182 && e <= 186 || e >= 188 && e <= 191 || 198 === e || 208 === e || 215 === e || 216 === e || e >= 222 && e <= 225 || 230 === e || e >= 232 && e <= 234 || 236 === e || 237 === e || 240 === e || 242 === e || 243 === e || e >= 247 && e <= 250 || 252 === e || 254 === e || 257 === e || 273 === e || 275 === e || 283 === e || 294 === e || 295 === e || 299 === e || e >= 305 && e <= 307 || 312 === e || e >= 319 && e <= 322 || 324 === e || e >= 328 && e <= 331 || 333 === e || 338 === e || 339 === e || 358 === e || 359 === e || 363 === e || 462 === e || 464 === e || 466 === e || 468 === e || 470 === e || 472 === e || 474 === e || 476 === e || 593 === e || 609 === e || 708 === e || 711 === e || e >= 713 && e <= 715 || 717 === e || 720 === e || e >= 728 && e <= 731 || 733 === e || 735 === e || e >= 768 && e <= 879 || e >= 913 && e <= 929 || e >= 931 && e <= 937 || e >= 945 && e <= 961 || e >= 963 && e <= 969 || 1025 === e || e >= 1040 && e <= 1103 || 1105 === e || 8208 === e || e >= 8211 && e <= 8214 || 8216 === e || 8217 === e || 8220 === e || 8221 === e || e >= 8224 && e <= 8226 || e >= 8228 && e <= 8231 || 8240 === e || 8242 === e || 8243 === e || 8245 === e || 8251 === e || 8254 === e || 8308 === e || 8319 === e || e >= 8321 && e <= 8324 || 8364 === e || 8451 === e || 8453 === e || 8457 === e || 8467 === e || 8470 === e || 8481 === e || 8482 === e || 8486 === e || 8491 === e || 8531 === e || 8532 === e || e >= 8539 && e <= 8542 || e >= 8544 && e <= 8555 || e >= 8560 && e <= 8569 || 8585 === e || e >= 8592 && e <= 8601 || 8632 === e || 8633 === e || 8658 === e || 8660 === e || 8679 === e || 8704 === e || 8706 === e || 8707 === e || 8711 === e || 8712 === e || 8715 === e || 8719 === e || 8721 === e || 8725 === e || 8730 === e || e >= 8733 && e <= 8736 || 8739 === e || 8741 === e || e >= 8743 && e <= 8748 || 8750 === e || e >= 8756 && e <= 8759 || 8764 === e || 8765 === e || 8776 === e || 8780 === e || 8786 === e || 8800 === e || 8801 === e || e >= 8804 && e <= 8807 || 8810 === e || 8811 === e || 8814 === e || 8815 === e || 8834 === e || 8835 === e || 8838 === e || 8839 === e || 8853 === e || 8857 === e || 8869 === e || 8895 === e || 8978 === e || e >= 9312 && e <= 9449 || e >= 9451 && e <= 9547 || e >= 9552 && e <= 9587 || e >= 9600 && e <= 9615 || e >= 9618 && e <= 9621 || 9632 === e || 9633 === e || e >= 9635 && e <= 9641 || 9650 === e || 9651 === e || 9654 === e || 9655 === e || 9660 === e || 9661 === e || 9664 === e || 9665 === e || e >= 9670 && e <= 9672 || 9675 === e || e >= 9678 && e <= 9681 || e >= 9698 && e <= 9701 || 9711 === e || 9733 === e || 9734 === e || 9737 === e || 9742 === e || 9743 === e || 9756 === e || 9758 === e || 9792 === e || 9794 === e || 9824 === e || 9825 === e || e >= 9827 && e <= 9829 || e >= 9831 && e <= 9834 || 9836 === e || 9837 === e || 9839 === e || 9886 === e || 9887 === e || 9919 === e || e >= 9926 && e <= 9933 || e >= 9935 && e <= 9939 || e >= 9941 && e <= 9953 || 9955 === e || 9960 === e || 9961 === e || e >= 9963 && e <= 9969 || 9972 === e || e >= 9974 && e <= 9977 || 9979 === e || 9980 === e || 9982 === e || 9983 === e || 10045 === e || e >= 10102 && e <= 10111 || e >= 11094 && e <= 11097 || e >= 12872 && e <= 12879 || e >= 57344 && e <= 63743 || e >= 65024 && e <= 65039 || 65533 === e || e >= 127232 && e <= 127242 || e >= 127248 && e <= 127277 || e >= 127280 && e <= 127337 || e >= 127344 && e <= 127373 || 127375 === e || 127376 === e || e >= 127387 && e <= 127404 || e >= 917760 && e <= 917999 || e >= 983040 && e <= 1048573 || e >= 1048576 && e <= 1114109, dist_gt = (e)=>12288 === e || e >= 65281 && e <= 65376 || e >= 65504 && e <= 65510, dist_ft = (e)=>e >= 4352 && e <= 4447 || 8986 === e || 8987 === e || 9001 === e || 9002 === e || e >= 9193 && e <= 9196 || 9200 === e || 9203 === e || 9725 === e || 9726 === e || 9748 === e || 9749 === e || e >= 9800 && e <= 9811 || 9855 === e || 9875 === e || 9889 === e || 9898 === e || 9899 === e || 9917 === e || 9918 === e || 9924 === e || 9925 === e || 9934 === e || 9940 === e || 9962 === e || 9970 === e || 9971 === e || 9973 === e || 9978 === e || 9981 === e || 9989 === e || 9994 === e || 9995 === e || 10024 === e || 10060 === e || 10062 === e || e >= 10067 && e <= 10069 || 10071 === e || e >= 10133 && e <= 10135 || 10160 === e || 10175 === e || 11035 === e || 11036 === e || 11088 === e || 11093 === e || e >= 11904 && e <= 11929 || e >= 11931 && e <= 12019 || e >= 12032 && e <= 12245 || e >= 12272 && e <= 12287 || e >= 12289 && e <= 12350 || e >= 12353 && e <= 12438 || e >= 12441 && e <= 12543 || e >= 12549 && e <= 12591 || e >= 12593 && e <= 12686 || e >= 12688 && e <= 12771 || e >= 12783 && e <= 12830 || e >= 12832 && e <= 12871 || e >= 12880 && e <= 19903 || e >= 19968 && e <= 42124 || e >= 42128 && e <= 42182 || e >= 43360 && e <= 43388 || e >= 44032 && e <= 55203 || e >= 63744 && e <= 64255 || e >= 65040 && e <= 65049 || e >= 65072 && e <= 65106 || e >= 65108 && e <= 65126 || e >= 65128 && e <= 65131 || e >= 94176 && e <= 94180 || 94192 === e || 94193 === e || e >= 94208 && e <= 100343 || e >= 100352 && e <= 101589 || e >= 101632 && e <= 101640 || e >= 110576 && e <= 110579 || e >= 110581 && e <= 110587 || 110589 === e || 110590 === e || e >= 110592 && e <= 110882 || 110898 === e || e >= 110928 && e <= 110930 || 110933 === e || e >= 110948 && e <= 110951 || e >= 110960 && e <= 111355 || 126980 === e || 127183 === e || 127374 === e || e >= 127377 && e <= 127386 || e >= 127488 && e <= 127490 || e >= 127504 && e <= 127547 || e >= 127552 && e <= 127560 || 127568 === e || 127569 === e || e >= 127584 && e <= 127589 || e >= 127744 && e <= 127776 || e >= 127789 && e <= 127797 || e >= 127799 && e <= 127868 || e >= 127870 && e <= 127891 || e >= 127904 && e <= 127946 || e >= 127951 && e <= 127955 || e >= 127968 && e <= 127984 || 127988 === e || e >= 127992 && e <= 128062 || 128064 === e || e >= 128066 && e <= 128252 || e >= 128255 && e <= 128317 || e >= 128331 && e <= 128334 || e >= 128336 && e <= 128359 || 128378 === e || 128405 === e || 128406 === e || 128420 === e || e >= 128507 && e <= 128591 || e >= 128640 && e <= 128709 || 128716 === e || e >= 128720 && e <= 128722 || e >= 128725 && e <= 128727 || e >= 128732 && e <= 128735 || 128747 === e || 128748 === e || e >= 128756 && e <= 128764 || e >= 128992 && e <= 129003 || 129008 === e || e >= 129292 && e <= 129338 || e >= 129340 && e <= 129349 || e >= 129351 && e <= 129535 || e >= 129648 && e <= 129660 || e >= 129664 && e <= 129672 || e >= 129680 && e <= 129725 || e >= 129727 && e <= 129733 || e >= 129742 && e <= 129755 || e >= 129760 && e <= 129768 || e >= 129776 && e <= 129784 || e >= 131072 && e <= 196605 || e >= 196608 && e <= 262141, we = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y, re = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y, ie = /\t{1,1000}/y, Ae = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu, ne = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y, dist_Ft = /\p{M}+/gu, dist_yt = {
|
|
1083
|
-
limit: 1 / 0,
|
|
1084
|
-
ellipsis: ""
|
|
1085
|
-
}, Le = (e, r = {}, s = {})=>{
|
|
1086
|
-
const i = r.limit ?? 1 / 0, a = r.ellipsis ?? "", o = r?.ellipsisWidth ?? (a ? Le(a, dist_yt, s).width : 0), u = s.ansiWidth ?? 0, l = s.controlWidth ?? 0, n = s.tabWidth ?? 8, c = s.ambiguousWidth ?? 1, p = s.emojiWidth ?? 2, f = s.fullWidthWidth ?? 2, g = s.regularWidth ?? 1, E = s.wideWidth ?? 2;
|
|
1087
|
-
let $ = 0, m = 0, d = e.length, F = 0, y = !1, v = d, C = Math.max(0, i - o), A = 0, b = 0, w = 0, S = 0;
|
|
1088
|
-
e: for(;;){
|
|
1089
|
-
if (b > A || m >= d && m > $) {
|
|
1090
|
-
const T = e.slice(A, b) || e.slice($, m);
|
|
1091
|
-
F = 0;
|
|
1092
|
-
for (const M of T.replaceAll(dist_Ft, "")){
|
|
1093
|
-
const O = M.codePointAt(0) || 0;
|
|
1094
|
-
if (dist_gt(O) ? S = f : dist_ft(O) ? S = E : c !== g && dist_mt(O) ? S = c : S = g, w + S > C && (v = Math.min(v, Math.max(A, $) + F)), w + S > i) {
|
|
1095
|
-
y = !0;
|
|
1096
|
-
break e;
|
|
1097
|
-
}
|
|
1098
|
-
F += M.length, w += S;
|
|
1099
|
-
}
|
|
1100
|
-
A = b = 0;
|
|
1101
|
-
}
|
|
1102
|
-
if (m >= d) break;
|
|
1103
|
-
if (ne.lastIndex = m, ne.test(e)) {
|
|
1104
|
-
if (F = ne.lastIndex - m, S = F * g, w + S > C && (v = Math.min(v, m + Math.floor((C - w) / g))), w + S > i) {
|
|
1105
|
-
y = !0;
|
|
1106
|
-
break;
|
|
1107
|
-
}
|
|
1108
|
-
w += S, A = $, b = m, m = $ = ne.lastIndex;
|
|
1109
|
-
continue;
|
|
1110
|
-
}
|
|
1111
|
-
if (we.lastIndex = m, we.test(e)) {
|
|
1112
|
-
if (w + u > C && (v = Math.min(v, m)), w + u > i) {
|
|
1113
|
-
y = !0;
|
|
1114
|
-
break;
|
|
1115
|
-
}
|
|
1116
|
-
w += u, A = $, b = m, m = $ = we.lastIndex;
|
|
1117
|
-
continue;
|
|
1118
|
-
}
|
|
1119
|
-
if (re.lastIndex = m, re.test(e)) {
|
|
1120
|
-
if (F = re.lastIndex - m, S = F * l, w + S > C && (v = Math.min(v, m + Math.floor((C - w) / l))), w + S > i) {
|
|
1121
|
-
y = !0;
|
|
1122
|
-
break;
|
|
1123
|
-
}
|
|
1124
|
-
w += S, A = $, b = m, m = $ = re.lastIndex;
|
|
1125
|
-
continue;
|
|
1126
|
-
}
|
|
1127
|
-
if (ie.lastIndex = m, ie.test(e)) {
|
|
1128
|
-
if (F = ie.lastIndex - m, S = F * n, w + S > C && (v = Math.min(v, m + Math.floor((C - w) / n))), w + S > i) {
|
|
1129
|
-
y = !0;
|
|
1130
|
-
break;
|
|
1131
|
-
}
|
|
1132
|
-
w += S, A = $, b = m, m = $ = ie.lastIndex;
|
|
1133
|
-
continue;
|
|
1134
|
-
}
|
|
1135
|
-
if (Ae.lastIndex = m, Ae.test(e)) {
|
|
1136
|
-
if (w + p > C && (v = Math.min(v, m)), w + p > i) {
|
|
1137
|
-
y = !0;
|
|
1138
|
-
break;
|
|
1139
|
-
}
|
|
1140
|
-
w += p, A = $, b = m, m = $ = Ae.lastIndex;
|
|
1141
|
-
continue;
|
|
1142
|
-
}
|
|
1143
|
-
m += 1;
|
|
1390
|
+
return styleText("green", prompts_dist_d);
|
|
1144
1391
|
}
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
};
|
|
1151
|
-
}, dist_Et = {
|
|
1152
|
-
limit: 1 / 0,
|
|
1153
|
-
ellipsis: "",
|
|
1154
|
-
ellipsisWidth: 0
|
|
1155
|
-
}, D = (e, r = {})=>Le(e, dist_Et, r).width, ae = "\x1B", je = "\x9B", dist_vt = 39, Ce = "\x07", ke = "[", dist_wt = "]", Ve = "m", Se = `${dist_wt}8;;`, He = new RegExp(`(?:\\${ke}(?<code>\\d+)m|\\${Se}(?<uri>.*)${Ce})`, "y"), dist_At = (e)=>{
|
|
1156
|
-
if (e >= 30 && e <= 37 || e >= 90 && e <= 97) return 39;
|
|
1157
|
-
if (e >= 40 && e <= 47 || e >= 100 && e <= 107) return 49;
|
|
1158
|
-
if (1 === e || 2 === e) return 22;
|
|
1159
|
-
if (3 === e) return 23;
|
|
1160
|
-
if (4 === e) return 24;
|
|
1161
|
-
if (7 === e) return 27;
|
|
1162
|
-
if (8 === e) return 28;
|
|
1163
|
-
if (9 === e) return 29;
|
|
1164
|
-
if (0 === e) return 0;
|
|
1165
|
-
}, Ue = (e)=>`${ae}${ke}${e}${Ve}`, Ke = (e)=>`${ae}${Se}${e}${Ce}`, dist_Ct = (e)=>e.map((r)=>D(r)), Ie = (e, r, s)=>{
|
|
1166
|
-
const i = r[Symbol.iterator]();
|
|
1167
|
-
let a = !1, o = !1, u = e.at(-1), l = void 0 === u ? 0 : D(u), n = i.next(), c = i.next(), p = 0;
|
|
1168
|
-
for(; !n.done;){
|
|
1169
|
-
const f = n.value, g = D(f);
|
|
1170
|
-
l + g <= s ? e[e.length - 1] += f : (e.push(f), l = 0), (f === ae || f === je) && (a = !0, o = r.startsWith(Se, p + 1)), a ? o ? f === Ce && (a = !1, o = !1) : f === Ve && (a = !1) : (l += g, l !== s || c.done || (e.push(""), l = 0)), n = c, c = i.next(), p += f.length;
|
|
1171
|
-
}
|
|
1172
|
-
u = e.at(-1), !l && void 0 !== u && u.length > 0 && e.length > 1 && (e[e.length - 2] += e.pop());
|
|
1173
|
-
}, dist_St = (e)=>{
|
|
1174
|
-
const r = e.split(" ");
|
|
1175
|
-
let s = r.length;
|
|
1176
|
-
for(; s > 0 && !(D(r[s - 1]) > 0);)s--;
|
|
1177
|
-
return s === r.length ? e : r.slice(0, s).join(" ") + r.slice(s).join("");
|
|
1178
|
-
}, dist_It = (e, r, s = {})=>{
|
|
1179
|
-
if (!1 !== s.trim && "" === e.trim()) return "";
|
|
1180
|
-
let i = "", a, o;
|
|
1181
|
-
const u = e.split(" "), l = dist_Ct(u);
|
|
1182
|
-
let n = [
|
|
1183
|
-
""
|
|
1184
|
-
];
|
|
1185
|
-
for (const [$, m] of u.entries()){
|
|
1186
|
-
!1 !== s.trim && (n[n.length - 1] = (n.at(-1) ?? "").trimStart());
|
|
1187
|
-
let d = D(n.at(-1) ?? "");
|
|
1188
|
-
if (0 !== $ && (d >= r && (!1 === s.wordWrap || !1 === s.trim) && (n.push(""), d = 0), (d > 0 || !1 === s.trim) && (n[n.length - 1] += " ", d++)), s.hard && l[$] > r) {
|
|
1189
|
-
const F = r - d, y = 1 + Math.floor((l[$] - F - 1) / r);
|
|
1190
|
-
Math.floor((l[$] - 1) / r) < y && n.push(""), Ie(n, m, r);
|
|
1191
|
-
continue;
|
|
1192
|
-
}
|
|
1193
|
-
if (d + l[$] > r && d > 0 && l[$] > 0) {
|
|
1194
|
-
if (!1 === s.wordWrap && d < r) {
|
|
1195
|
-
Ie(n, m, r);
|
|
1196
|
-
continue;
|
|
1197
|
-
}
|
|
1198
|
-
n.push("");
|
|
1199
|
-
}
|
|
1200
|
-
if (d + l[$] > r && !1 === s.wordWrap) {
|
|
1201
|
-
Ie(n, m, r);
|
|
1202
|
-
continue;
|
|
1203
|
-
}
|
|
1204
|
-
n[n.length - 1] += m;
|
|
1205
|
-
}
|
|
1206
|
-
!1 !== s.trim && (n = n.map(($)=>dist_St($)));
|
|
1207
|
-
const c = n.join(`
|
|
1208
|
-
`), p = c[Symbol.iterator]();
|
|
1209
|
-
let f = p.next(), g = p.next(), E = 0;
|
|
1210
|
-
for(; !f.done;){
|
|
1211
|
-
const $ = f.value, m = g.value;
|
|
1212
|
-
if (i += $, $ === ae || $ === je) {
|
|
1213
|
-
He.lastIndex = E + 1;
|
|
1214
|
-
const y = He.exec(c)?.groups;
|
|
1215
|
-
if (y?.code !== void 0) {
|
|
1216
|
-
const v = Number.parseFloat(y.code);
|
|
1217
|
-
a = v === dist_vt ? void 0 : v;
|
|
1218
|
-
} else y?.uri !== void 0 && (o = 0 === y.uri.length ? void 0 : y.uri);
|
|
1219
|
-
}
|
|
1220
|
-
const d = a ? dist_At(a) : void 0;
|
|
1221
|
-
m === `
|
|
1222
|
-
` ? (o && (i += Ke("")), a && d && (i += Ue(d))) : $ === `
|
|
1223
|
-
` && (a && d && (i += Ue(a)), o && (i += Ke(o))), E += $.length, f = g, g = p.next();
|
|
1224
|
-
}
|
|
1225
|
-
return i;
|
|
1226
|
-
};
|
|
1227
|
-
function J(e, r, s) {
|
|
1228
|
-
return String(e).normalize().replaceAll(`\r
|
|
1229
|
-
`, `
|
|
1230
|
-
`).split(`
|
|
1231
|
-
`).map((i)=>dist_It(i, r, s)).join(`
|
|
1232
|
-
`);
|
|
1233
|
-
}
|
|
1234
|
-
const dist_bt = (e, r, s, i, a)=>{
|
|
1235
|
-
let o = r, u = 0;
|
|
1236
|
-
for(let l = s; l < i; l++){
|
|
1237
|
-
const n = e[l];
|
|
1238
|
-
if (o -= n.length, u++, o <= a) break;
|
|
1392
|
+
}, dist_et = (e, i, s, r, u)=>{
|
|
1393
|
+
let n = i, o = 0;
|
|
1394
|
+
for(let c = s; c < r; c++){
|
|
1395
|
+
const a = e[c];
|
|
1396
|
+
if (n -= a.length, o++, n <= u) break;
|
|
1239
1397
|
}
|
|
1240
1398
|
return {
|
|
1241
|
-
lineCount:
|
|
1242
|
-
removals:
|
|
1399
|
+
lineCount: n,
|
|
1400
|
+
removals: o
|
|
1243
1401
|
};
|
|
1244
|
-
},
|
|
1245
|
-
const
|
|
1246
|
-
let
|
|
1247
|
-
e >=
|
|
1248
|
-
let
|
|
1249
|
-
const
|
|
1250
|
-
let
|
|
1251
|
-
|
|
1252
|
-
const
|
|
1253
|
-
for(let
|
|
1254
|
-
const
|
|
1402
|
+
}, dist_Y = ({ cursor: e, options: i, style: s, output: r = process.stdout, maxItems: u = 1 / 0, columnPadding: n = 0, rowPadding: o = 4 })=>{
|
|
1403
|
+
const c = O(r) - n, a = dist_A(r), l = styleText("dim", "..."), $ = Math.max(a - o, 0), y = Math.max(Math.min(u, $), 5);
|
|
1404
|
+
let p = 0;
|
|
1405
|
+
e >= y - 3 && (p = Math.max(Math.min(e - y + 3, i.length - y), 0));
|
|
1406
|
+
let m = y < i.length && p > 0, g = y < i.length && p + y < i.length;
|
|
1407
|
+
const S = Math.min(p + y, i.length), h = [];
|
|
1408
|
+
let f = 0;
|
|
1409
|
+
m && f++, g && f++;
|
|
1410
|
+
const v = p + (m ? 1 : 0), T = S - (g ? 1 : 0);
|
|
1411
|
+
for(let b = v; b < T; b++){
|
|
1412
|
+
const x = wrapAnsi(s(i[b], b === e), c, {
|
|
1255
1413
|
hard: !0,
|
|
1256
1414
|
trim: !1
|
|
1257
1415
|
}).split(`
|
|
1258
1416
|
`);
|
|
1259
|
-
|
|
1417
|
+
h.push(x), f += x.length;
|
|
1260
1418
|
}
|
|
1261
|
-
if (
|
|
1262
|
-
let
|
|
1263
|
-
const
|
|
1264
|
-
|
|
1419
|
+
if (f > $) {
|
|
1420
|
+
let b = 0, x = 0, G = f;
|
|
1421
|
+
const M = e - v, R = (j, D)=>dist_et(h, G, j, D, $);
|
|
1422
|
+
m ? ({ lineCount: G, removals: b } = R(0, M), G > $ && ({ lineCount: G, removals: x } = R(M + 1, h.length))) : ({ lineCount: G, removals: x } = R(M + 1, h.length), G > $ && ({ lineCount: G, removals: b } = R(0, M))), b > 0 && (m = !0, h.splice(0, b)), x > 0 && (g = !0, h.splice(h.length - x, x));
|
|
1265
1423
|
}
|
|
1266
1424
|
const C = [];
|
|
1267
|
-
|
|
1268
|
-
for (const
|
|
1269
|
-
return
|
|
1425
|
+
m && C.push(l);
|
|
1426
|
+
for (const b of h)for (const x of b)C.push(x);
|
|
1427
|
+
return g && C.push(l), C;
|
|
1270
1428
|
};
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1429
|
+
function Me(e) {
|
|
1430
|
+
return e.label ?? String(e.value ?? "");
|
|
1431
|
+
}
|
|
1432
|
+
function Re(e, i) {
|
|
1433
|
+
if (!e) return !0;
|
|
1434
|
+
const s = (i.label ?? String(i.value ?? "")).toLowerCase(), r = (i.hint ?? "").toLowerCase(), u = String(i.value).toLowerCase(), n = e.toLowerCase();
|
|
1435
|
+
return s.includes(n) || r.includes(n) || u.includes(n);
|
|
1436
|
+
}
|
|
1437
|
+
function dist_tt(e, i) {
|
|
1438
|
+
const s = [];
|
|
1439
|
+
for (const r of i)e.includes(r.value) && s.push(r);
|
|
1440
|
+
return s;
|
|
1441
|
+
}
|
|
1442
|
+
const Ae = (e)=>new H({
|
|
1443
|
+
options: e.options,
|
|
1444
|
+
initialValue: e.initialValue ? [
|
|
1445
|
+
e.initialValue
|
|
1446
|
+
] : void 0,
|
|
1447
|
+
initialUserInput: e.initialUserInput,
|
|
1448
|
+
placeholder: e.placeholder,
|
|
1449
|
+
filter: e.filter ?? ((i, s)=>Re(i, s)),
|
|
1450
|
+
signal: e.signal,
|
|
1451
|
+
input: e.input,
|
|
1452
|
+
output: e.output,
|
|
1453
|
+
validate: e.validate,
|
|
1454
|
+
render () {
|
|
1455
|
+
const i = e.withGuide ?? dist_u.withGuide, s = i ? [
|
|
1456
|
+
`${styleText("gray", prompts_dist_d)}`,
|
|
1457
|
+
`${dist_V(this.state)} ${e.message}`
|
|
1458
|
+
] : [
|
|
1459
|
+
`${dist_V(this.state)} ${e.message}`
|
|
1460
|
+
], r = this.userInput, u = this.options, n = e.placeholder, o = "" === r && void 0 !== n, c = (a, l)=>{
|
|
1461
|
+
const $ = Me(a), y = a.hint && a.value === this.focusedValue ? styleText("dim", ` (${a.hint})`) : "";
|
|
1462
|
+
switch(l){
|
|
1463
|
+
case "active":
|
|
1464
|
+
return `${styleText("green", dist_z)} ${$}${y}`;
|
|
1465
|
+
case "inactive":
|
|
1466
|
+
return `${styleText("dim", dist_H)} ${styleText("dim", $)}`;
|
|
1467
|
+
case "disabled":
|
|
1468
|
+
return `${styleText("gray", dist_H)} ${styleText([
|
|
1469
|
+
"strikethrough",
|
|
1470
|
+
"gray"
|
|
1471
|
+
], $)}`;
|
|
1472
|
+
}
|
|
1473
|
+
};
|
|
1474
|
+
switch(this.state){
|
|
1475
|
+
case "submit":
|
|
1476
|
+
{
|
|
1477
|
+
const a = dist_tt(this.selectedValues, u), l = a.length > 0 ? ` ${styleText("dim", a.map(Me).join(", "))}` : "", $ = i ? styleText("gray", prompts_dist_d) : "";
|
|
1478
|
+
return `${s.join(`
|
|
1479
|
+
`)}
|
|
1480
|
+
${$}${l}`;
|
|
1481
|
+
}
|
|
1482
|
+
case "cancel":
|
|
1483
|
+
{
|
|
1484
|
+
const a = r ? ` ${styleText([
|
|
1485
|
+
"strikethrough",
|
|
1486
|
+
"dim"
|
|
1487
|
+
], r)}` : "", l = i ? styleText("gray", prompts_dist_d) : "";
|
|
1488
|
+
return `${s.join(`
|
|
1489
|
+
`)}
|
|
1490
|
+
${l}${a}`;
|
|
1491
|
+
}
|
|
1492
|
+
default:
|
|
1493
|
+
{
|
|
1494
|
+
const a = "error" === this.state ? "yellow" : "cyan", l = i ? `${styleText(a, prompts_dist_d)} ` : "", $ = i ? styleText(a, dist_E) : "";
|
|
1495
|
+
let y = "";
|
|
1496
|
+
if (this.isNavigating || o) {
|
|
1497
|
+
const v = o ? n : r;
|
|
1498
|
+
y = "" !== v ? ` ${styleText("dim", v)}` : "";
|
|
1499
|
+
} else y = ` ${this.userInputWithCursor}`;
|
|
1500
|
+
const p = this.filteredOptions.length !== u.length ? styleText("dim", ` (${this.filteredOptions.length} match${1 === this.filteredOptions.length ? "" : "es"})`) : "", m = 0 === this.filteredOptions.length && r ? [
|
|
1501
|
+
`${l}${styleText("yellow", "No matches found")}`
|
|
1502
|
+
] : [], g = "error" === this.state ? [
|
|
1503
|
+
`${l}${styleText("yellow", this.error)}`
|
|
1504
|
+
] : [];
|
|
1505
|
+
i && s.push(`${l.trimEnd()}`), s.push(`${l}${styleText("dim", "Search:")}${y}${p}`, ...m, ...g);
|
|
1506
|
+
const S = [
|
|
1507
|
+
`${styleText("dim", "\u2191/\u2193")} to select`,
|
|
1508
|
+
`${styleText("dim", "Enter:")} confirm`,
|
|
1509
|
+
`${styleText("dim", "Type:")} to search`
|
|
1510
|
+
], h = [
|
|
1511
|
+
`${l}${S.join(" \u2022 ")}`,
|
|
1512
|
+
$
|
|
1513
|
+
], f = 0 === this.filteredOptions.length ? [] : dist_Y({
|
|
1514
|
+
cursor: this.cursor,
|
|
1515
|
+
options: this.filteredOptions,
|
|
1516
|
+
columnPadding: i ? 3 : 0,
|
|
1517
|
+
rowPadding: s.length + h.length,
|
|
1518
|
+
style: (v, T)=>c(v, v.disabled ? "disabled" : T ? "active" : "inactive"),
|
|
1519
|
+
maxItems: e.maxItems,
|
|
1520
|
+
output: e.output
|
|
1521
|
+
});
|
|
1522
|
+
return [
|
|
1523
|
+
...s,
|
|
1524
|
+
...f.map((v)=>`${l}${v}`),
|
|
1525
|
+
...h
|
|
1526
|
+
].join(`
|
|
1276
1527
|
`);
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
g.length > 0 ? u.push(`${c}${g}`) : u.push(l ? r : "");
|
|
1280
|
-
for (const $ of E)$.length > 0 ? u.push(`${p}${$}`) : u.push(l ? s : "");
|
|
1528
|
+
}
|
|
1529
|
+
}
|
|
1281
1530
|
}
|
|
1282
|
-
|
|
1531
|
+
}).prompt();
|
|
1532
|
+
const ht = (e)=>{
|
|
1533
|
+
const { selectableGroups: i = !0, groupSpacing: s = 0 } = e, r = (n, o, c = [])=>{
|
|
1534
|
+
const a = n.label ?? String(n.value), l = "string" == typeof n.group, $ = l && (c[c.indexOf(n) + 1] ?? {
|
|
1535
|
+
group: !0
|
|
1536
|
+
}), y = l && $ && !0 === $.group, p = l ? i ? `${y ? dist_E : prompts_dist_d} ` : " " : "";
|
|
1537
|
+
let m = "";
|
|
1538
|
+
if (s > 0 && !l) {
|
|
1539
|
+
const S = `
|
|
1540
|
+
${styleText("cyan", prompts_dist_d)}`;
|
|
1541
|
+
m = `${S.repeat(s - 1)}${S} `;
|
|
1542
|
+
}
|
|
1543
|
+
if ("active" === o) return `${m}${styleText("dim", p)}${styleText("cyan", te)} ${a}${n.hint ? ` ${styleText("dim", `(${n.hint})`)}` : ""}`;
|
|
1544
|
+
if ("group-active" === o) return `${m}${p}${styleText("cyan", te)} ${styleText("dim", a)}`;
|
|
1545
|
+
if ("group-active-selected" === o) return `${m}${p}${styleText("green", dist_U)} ${styleText("dim", a)}`;
|
|
1546
|
+
if ("selected" === o) {
|
|
1547
|
+
const S = l || i ? styleText("green", dist_U) : "";
|
|
1548
|
+
return `${m}${styleText("dim", p)}${S} ${styleText("dim", a)}${n.hint ? ` ${styleText("dim", `(${n.hint})`)}` : ""}`;
|
|
1549
|
+
}
|
|
1550
|
+
if ("cancelled" === o) return `${styleText([
|
|
1551
|
+
"strikethrough",
|
|
1552
|
+
"dim"
|
|
1553
|
+
], a)}`;
|
|
1554
|
+
if ("active-selected" === o) return `${m}${styleText("dim", p)}${styleText("green", dist_U)} ${a}${n.hint ? ` ${styleText("dim", `(${n.hint})`)}` : ""}`;
|
|
1555
|
+
if ("submitted" === o) return `${styleText("dim", a)}`;
|
|
1556
|
+
const g = l || i ? styleText("dim", dist_J) : "";
|
|
1557
|
+
return `${m}${styleText("dim", p)}${g} ${styleText("dim", a)}`;
|
|
1558
|
+
}, u = e.required ?? !0;
|
|
1559
|
+
return new st({
|
|
1560
|
+
options: e.options,
|
|
1561
|
+
signal: e.signal,
|
|
1562
|
+
input: e.input,
|
|
1563
|
+
output: e.output,
|
|
1564
|
+
initialValues: e.initialValues,
|
|
1565
|
+
required: u,
|
|
1566
|
+
cursorAt: e.cursorAt,
|
|
1567
|
+
selectableGroups: i,
|
|
1568
|
+
validate (n) {
|
|
1569
|
+
if (u && (void 0 === n || 0 === n.length)) return `Please select at least one option.
|
|
1570
|
+
${styleText("reset", styleText("dim", `Press ${styleText([
|
|
1571
|
+
"gray",
|
|
1572
|
+
"bgWhite",
|
|
1573
|
+
"inverse"
|
|
1574
|
+
], " space ")} to select, ${styleText("gray", styleText([
|
|
1575
|
+
"bgWhite",
|
|
1576
|
+
"inverse"
|
|
1577
|
+
], " enter "))} to submit`))}`;
|
|
1578
|
+
},
|
|
1579
|
+
render () {
|
|
1580
|
+
const n = e.withGuide ?? dist_u.withGuide, o = `${n ? `${styleText("gray", prompts_dist_d)}
|
|
1581
|
+
` : ""}${dist_V(this.state)} ${e.message}
|
|
1582
|
+
`, c = this.value ?? [];
|
|
1583
|
+
switch(this.state){
|
|
1584
|
+
case "submit":
|
|
1585
|
+
{
|
|
1586
|
+
const a = this.options.filter(({ value: $ })=>c.includes($)).map(($)=>r($, "submitted")), l = 0 === a.length ? "" : ` ${a.join(styleText("dim", ", "))}`;
|
|
1587
|
+
return `${o}${n ? styleText("gray", prompts_dist_d) : ""}${l}`;
|
|
1588
|
+
}
|
|
1589
|
+
case "cancel":
|
|
1590
|
+
{
|
|
1591
|
+
const a = this.options.filter(({ value: l })=>c.includes(l)).map((l)=>r(l, "cancelled")).join(styleText("dim", ", "));
|
|
1592
|
+
return `${o}${n ? `${styleText("gray", prompts_dist_d)} ` : ""}${a.trim() ? `${a}${n ? `
|
|
1593
|
+
${styleText("gray", prompts_dist_d)}` : ""}` : ""}`;
|
|
1594
|
+
}
|
|
1595
|
+
case "error":
|
|
1596
|
+
{
|
|
1597
|
+
const a = this.error.split(`
|
|
1598
|
+
`).map((l, $)=>0 === $ ? `${n ? `${styleText("yellow", dist_E)} ` : ""}${styleText("yellow", l)}` : ` ${l}`).join(`
|
|
1599
|
+
`);
|
|
1600
|
+
return `${o}${n ? `${styleText("yellow", prompts_dist_d)} ` : ""}${this.options.map((l, $, y)=>{
|
|
1601
|
+
const p = c.includes(l.value) || !0 === l.group && this.isGroupSelected(`${l.value}`), m = $ === this.cursor;
|
|
1602
|
+
return m || "string" != typeof l.group || this.options[this.cursor].value !== l.group ? m && p ? r(l, "active-selected", y) : p ? r(l, "selected", y) : r(l, m ? "active" : "inactive", y) : r(l, p ? "group-active-selected" : "group-active", y);
|
|
1603
|
+
}).join(`
|
|
1604
|
+
${n ? `${styleText("yellow", prompts_dist_d)} ` : ""}`)}
|
|
1605
|
+
${a}
|
|
1606
|
+
`;
|
|
1607
|
+
}
|
|
1608
|
+
default:
|
|
1609
|
+
{
|
|
1610
|
+
const a = this.options.map(($, y, p)=>{
|
|
1611
|
+
const m = c.includes($.value) || !0 === $.group && this.isGroupSelected(`${$.value}`), g = y === this.cursor, S = !g && "string" == typeof $.group && this.options[this.cursor].value === $.group;
|
|
1612
|
+
let h = "";
|
|
1613
|
+
return S ? h = r($, m ? "group-active-selected" : "group-active", p) : g && m ? h = r($, "active-selected", p) : m ? h = r($, "selected", p) : h = r($, g ? "active" : "inactive", p), `${0 !== y && !h.startsWith(`
|
|
1614
|
+
`) ? " " : ""}${h}`;
|
|
1615
|
+
}).join(`
|
|
1616
|
+
${n ? styleText("cyan", prompts_dist_d) : ""}`), l = a.startsWith(`
|
|
1617
|
+
`) ? "" : " ";
|
|
1618
|
+
return `${o}${n ? styleText("cyan", prompts_dist_d) : ""}${l}${a}
|
|
1619
|
+
${n ? styleText("cyan", dist_E) : ""}
|
|
1620
|
+
`;
|
|
1621
|
+
}
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
}).prompt();
|
|
1625
|
+
}, dist_O = {
|
|
1626
|
+
message: (e = [], { symbol: i = styleText("gray", prompts_dist_d), secondarySymbol: s = styleText("gray", prompts_dist_d), output: r = process.stdout, spacing: u = 1, withGuide: n } = {})=>{
|
|
1627
|
+
const o = [], c = n ?? dist_u.withGuide, a = c ? s : "", l = c ? `${i} ` : "", $ = c ? `${s} ` : "";
|
|
1628
|
+
for(let p = 0; p < u; p++)o.push(a);
|
|
1629
|
+
const y = Array.isArray(e) ? e : e.split(`
|
|
1630
|
+
`);
|
|
1631
|
+
if (y.length > 0) {
|
|
1632
|
+
const [p, ...m] = y;
|
|
1633
|
+
p.length > 0 ? o.push(`${l}${p}`) : o.push(c ? i : "");
|
|
1634
|
+
for (const g of m)g.length > 0 ? o.push(`${$}${g}`) : o.push(c ? s : "");
|
|
1635
|
+
}
|
|
1636
|
+
r.write(`${o.join(`
|
|
1283
1637
|
`)}
|
|
1284
1638
|
`);
|
|
1285
1639
|
},
|
|
1286
|
-
info: (e,
|
|
1287
|
-
|
|
1288
|
-
...
|
|
1289
|
-
symbol: styleText("blue",
|
|
1640
|
+
info: (e, i)=>{
|
|
1641
|
+
dist_O.message(e, {
|
|
1642
|
+
...i,
|
|
1643
|
+
symbol: styleText("blue", he)
|
|
1290
1644
|
});
|
|
1291
1645
|
},
|
|
1292
|
-
success: (e,
|
|
1293
|
-
|
|
1294
|
-
...
|
|
1295
|
-
symbol: styleText("green",
|
|
1646
|
+
success: (e, i)=>{
|
|
1647
|
+
dist_O.message(e, {
|
|
1648
|
+
...i,
|
|
1649
|
+
symbol: styleText("green", pe)
|
|
1296
1650
|
});
|
|
1297
1651
|
},
|
|
1298
|
-
step: (e,
|
|
1299
|
-
|
|
1300
|
-
...
|
|
1301
|
-
symbol: styleText("green",
|
|
1652
|
+
step: (e, i)=>{
|
|
1653
|
+
dist_O.message(e, {
|
|
1654
|
+
...i,
|
|
1655
|
+
symbol: styleText("green", dist_F)
|
|
1302
1656
|
});
|
|
1303
1657
|
},
|
|
1304
|
-
warn: (e,
|
|
1305
|
-
|
|
1306
|
-
...
|
|
1307
|
-
symbol: styleText("yellow",
|
|
1658
|
+
warn: (e, i)=>{
|
|
1659
|
+
dist_O.message(e, {
|
|
1660
|
+
...i,
|
|
1661
|
+
symbol: styleText("yellow", me)
|
|
1308
1662
|
});
|
|
1309
1663
|
},
|
|
1310
|
-
warning: (e,
|
|
1311
|
-
|
|
1664
|
+
warning: (e, i)=>{
|
|
1665
|
+
dist_O.warn(e, i);
|
|
1312
1666
|
},
|
|
1313
|
-
error: (e,
|
|
1314
|
-
|
|
1315
|
-
...
|
|
1316
|
-
symbol: styleText("red",
|
|
1667
|
+
error: (e, i)=>{
|
|
1668
|
+
dist_O.message(e, {
|
|
1669
|
+
...i,
|
|
1670
|
+
symbol: styleText("red", ge)
|
|
1317
1671
|
});
|
|
1318
1672
|
}
|
|
1319
|
-
},
|
|
1320
|
-
const s =
|
|
1321
|
-
s.write(`${
|
|
1673
|
+
}, pt = (e = "", i)=>{
|
|
1674
|
+
const s = i?.output ?? process.stdout, r = i?.withGuide ?? dist_u.withGuide ? `${styleText("gray", dist_E)} ` : "";
|
|
1675
|
+
s.write(`${r}${styleText("red", e)}
|
|
1322
1676
|
|
|
1323
1677
|
`);
|
|
1324
|
-
},
|
|
1325
|
-
const s =
|
|
1326
|
-
${styleText("gray",
|
|
1327
|
-
s.write(`${
|
|
1678
|
+
}, gt = (e = "", i)=>{
|
|
1679
|
+
const s = i?.output ?? process.stdout, r = i?.withGuide ?? dist_u.withGuide ? `${styleText("gray", prompts_dist_d)}
|
|
1680
|
+
${styleText("gray", dist_E)} ` : "";
|
|
1681
|
+
s.write(`${r}${e}
|
|
1328
1682
|
|
|
1329
1683
|
`);
|
|
1330
|
-
}, dist_Q = (e,
|
|
1331
|
-
`).map((s)=>
|
|
1332
|
-
`),
|
|
1333
|
-
const
|
|
1334
|
-
const
|
|
1335
|
-
return "disabled" ===
|
|
1684
|
+
}, dist_Q = (e, i)=>e.split(`
|
|
1685
|
+
`).map((s)=>i(s)).join(`
|
|
1686
|
+
`), yt = (e)=>{
|
|
1687
|
+
const i = (r, u)=>{
|
|
1688
|
+
const n = r.label ?? String(r.value);
|
|
1689
|
+
return "disabled" === u ? `${styleText("gray", dist_J)} ${dist_Q(n, (o)=>styleText([
|
|
1336
1690
|
"strikethrough",
|
|
1337
1691
|
"gray"
|
|
1338
|
-
],
|
|
1692
|
+
], o))}${r.hint ? ` ${styleText("dim", `(${r.hint ?? "disabled"})`)}` : ""}` : "active" === u ? `${styleText("cyan", te)} ${n}${r.hint ? ` ${styleText("dim", `(${r.hint})`)}` : ""}` : "selected" === u ? `${styleText("green", dist_U)} ${dist_Q(n, (o)=>styleText("dim", o))}${r.hint ? ` ${styleText("dim", `(${r.hint})`)}` : ""}` : "cancelled" === u ? `${dist_Q(n, (o)=>styleText([
|
|
1339
1693
|
"strikethrough",
|
|
1340
1694
|
"dim"
|
|
1341
|
-
],
|
|
1695
|
+
], o))}` : "active-selected" === u ? `${styleText("green", dist_U)} ${n}${r.hint ? ` ${styleText("dim", `(${r.hint})`)}` : ""}` : "submitted" === u ? `${dist_Q(n, (o)=>styleText("dim", o))}` : `${styleText("dim", dist_J)} ${dist_Q(n, (o)=>styleText("dim", o))}`;
|
|
1342
1696
|
}, s = e.required ?? !0;
|
|
1343
|
-
return new
|
|
1697
|
+
return new it({
|
|
1344
1698
|
options: e.options,
|
|
1345
1699
|
signal: e.signal,
|
|
1346
1700
|
input: e.input,
|
|
@@ -1348,8 +1702,8 @@ ${styleText("gray", dist_x)} ` : "";
|
|
|
1348
1702
|
initialValues: e.initialValues,
|
|
1349
1703
|
required: s,
|
|
1350
1704
|
cursorAt: e.cursorAt,
|
|
1351
|
-
validate (
|
|
1352
|
-
if (s && (void 0 ===
|
|
1705
|
+
validate (r) {
|
|
1706
|
+
if (s && (void 0 === r || 0 === r.length)) return `Please select at least one option.
|
|
1353
1707
|
${styleText("reset", styleText("dim", `Press ${styleText([
|
|
1354
1708
|
"gray",
|
|
1355
1709
|
"bgWhite",
|
|
@@ -1357,234 +1711,278 @@ ${styleText("reset", styleText("dim", `Press ${styleText([
|
|
|
1357
1711
|
], " space ")} to select, ${styleText("gray", styleText("bgWhite", styleText("inverse", " enter ")))} to submit`))}`;
|
|
1358
1712
|
},
|
|
1359
1713
|
render () {
|
|
1360
|
-
const
|
|
1361
|
-
${
|
|
1362
|
-
`, o = this.value ?? [],
|
|
1363
|
-
if (
|
|
1364
|
-
const
|
|
1365
|
-
return
|
|
1714
|
+
const r = e.withGuide ?? dist_u.withGuide, u = dist_R(e.output, e.message, r ? `${ye(this.state)} ` : "", `${dist_V(this.state)} `), n = `${r ? `${styleText("gray", prompts_dist_d)}
|
|
1715
|
+
` : ""}${u}
|
|
1716
|
+
`, o = this.value ?? [], c = (a, l)=>{
|
|
1717
|
+
if (a.disabled) return i(a, "disabled");
|
|
1718
|
+
const $ = o.includes(a.value);
|
|
1719
|
+
return l && $ ? i(a, "active-selected") : $ ? i(a, "selected") : i(a, l ? "active" : "inactive");
|
|
1366
1720
|
};
|
|
1367
1721
|
switch(this.state){
|
|
1368
1722
|
case "submit":
|
|
1369
1723
|
{
|
|
1370
|
-
const
|
|
1371
|
-
return `${
|
|
1724
|
+
const a = this.options.filter(({ value: $ })=>o.includes($)).map(($)=>i($, "submitted")).join(styleText("dim", ", ")) || styleText("dim", "none"), l = dist_R(e.output, a, r ? `${styleText("gray", prompts_dist_d)} ` : "");
|
|
1725
|
+
return `${n}${l}`;
|
|
1372
1726
|
}
|
|
1373
1727
|
case "cancel":
|
|
1374
1728
|
{
|
|
1375
|
-
const
|
|
1376
|
-
if ("" ===
|
|
1377
|
-
const
|
|
1378
|
-
return `${
|
|
1379
|
-
${styleText("gray",
|
|
1729
|
+
const a = this.options.filter(({ value: $ })=>o.includes($)).map(($)=>i($, "cancelled")).join(styleText("dim", ", "));
|
|
1730
|
+
if ("" === a.trim()) return `${n}${styleText("gray", prompts_dist_d)}`;
|
|
1731
|
+
const l = dist_R(e.output, a, r ? `${styleText("gray", prompts_dist_d)} ` : "");
|
|
1732
|
+
return `${n}${l}${r ? `
|
|
1733
|
+
${styleText("gray", prompts_dist_d)}` : ""}`;
|
|
1380
1734
|
}
|
|
1381
1735
|
case "error":
|
|
1382
1736
|
{
|
|
1383
|
-
const
|
|
1384
|
-
`).map((
|
|
1385
|
-
`),
|
|
1386
|
-
`).length,
|
|
1737
|
+
const a = r ? `${styleText("yellow", prompts_dist_d)} ` : "", l = this.error.split(`
|
|
1738
|
+
`).map((p, m)=>0 === m ? `${r ? `${styleText("yellow", dist_E)} ` : ""}${styleText("yellow", p)}` : ` ${p}`).join(`
|
|
1739
|
+
`), $ = n.split(`
|
|
1740
|
+
`).length, y = l.split(`
|
|
1387
1741
|
`).length + 1;
|
|
1388
|
-
return `${
|
|
1742
|
+
return `${n}${a}${dist_Y({
|
|
1389
1743
|
output: e.output,
|
|
1390
1744
|
options: this.options,
|
|
1391
1745
|
cursor: this.cursor,
|
|
1392
1746
|
maxItems: e.maxItems,
|
|
1393
|
-
columnPadding:
|
|
1394
|
-
rowPadding:
|
|
1395
|
-
style:
|
|
1747
|
+
columnPadding: a.length,
|
|
1748
|
+
rowPadding: $ + y,
|
|
1749
|
+
style: c
|
|
1396
1750
|
}).join(`
|
|
1397
|
-
${
|
|
1398
|
-
${
|
|
1751
|
+
${a}`)}
|
|
1752
|
+
${l}
|
|
1399
1753
|
`;
|
|
1400
1754
|
}
|
|
1401
1755
|
default:
|
|
1402
1756
|
{
|
|
1403
|
-
const
|
|
1404
|
-
`).length;
|
|
1405
|
-
return `${
|
|
1757
|
+
const a = r ? `${styleText("cyan", prompts_dist_d)} ` : "", l = n.split(`
|
|
1758
|
+
`).length, $ = r ? 2 : 1;
|
|
1759
|
+
return `${n}${a}${dist_Y({
|
|
1406
1760
|
output: e.output,
|
|
1407
1761
|
options: this.options,
|
|
1408
1762
|
cursor: this.cursor,
|
|
1409
1763
|
maxItems: e.maxItems,
|
|
1410
|
-
columnPadding:
|
|
1411
|
-
rowPadding:
|
|
1412
|
-
style:
|
|
1764
|
+
columnPadding: a.length,
|
|
1765
|
+
rowPadding: l + $,
|
|
1766
|
+
style: c
|
|
1413
1767
|
}).join(`
|
|
1414
|
-
${
|
|
1415
|
-
${styleText("cyan",
|
|
1768
|
+
${a}`)}
|
|
1769
|
+
${r ? styleText("cyan", dist_E) : ""}
|
|
1416
1770
|
`;
|
|
1417
1771
|
}
|
|
1418
1772
|
}
|
|
1419
1773
|
}
|
|
1420
1774
|
}).prompt();
|
|
1421
|
-
},
|
|
1422
|
-
const
|
|
1775
|
+
}, ft = (e)=>styleText("dim", e), vt = (e, i, s)=>{
|
|
1776
|
+
const r = {
|
|
1423
1777
|
hard: !0,
|
|
1424
1778
|
trim: !1
|
|
1425
|
-
},
|
|
1426
|
-
`),
|
|
1427
|
-
return
|
|
1428
|
-
},
|
|
1429
|
-
const
|
|
1779
|
+
}, u = wrapAnsi(e, i, r).split(`
|
|
1780
|
+
`), n = u.reduce((a, l)=>Math.max(fast_string_width_dist(l), a), 0), o = u.map(s).reduce((a, l)=>Math.max(fast_string_width_dist(l), a), 0), c = i - (o - n);
|
|
1781
|
+
return wrapAnsi(e, c, r);
|
|
1782
|
+
}, wt = (e = "", i = "", s)=>{
|
|
1783
|
+
const r = s?.output ?? node_process.stdout, u = s?.withGuide ?? dist_u.withGuide, n = s?.format ?? ft, o = [
|
|
1430
1784
|
"",
|
|
1431
|
-
...
|
|
1432
|
-
`).map(
|
|
1785
|
+
...vt(e, O(r) - 6, n).split(`
|
|
1786
|
+
`).map(n),
|
|
1433
1787
|
""
|
|
1434
|
-
],
|
|
1435
|
-
const
|
|
1436
|
-
return
|
|
1437
|
-
}, 0),
|
|
1438
|
-
`),
|
|
1439
|
-
` : "",
|
|
1440
|
-
|
|
1441
|
-
${
|
|
1442
|
-
${styleText("gray",
|
|
1443
|
-
`);
|
|
1444
|
-
}, Kt = (e)=>styleText("magenta", e), be = ({ indicator: e = "dots", onCancel: r, output: s = process.stdout, cancelMessage: i, errorMessage: a, frames: o = ee ? [
|
|
1445
|
-
"\u25D2",
|
|
1446
|
-
"\u25D0",
|
|
1447
|
-
"\u25D3",
|
|
1448
|
-
"\u25D1"
|
|
1449
|
-
] : [
|
|
1450
|
-
"\u2022",
|
|
1451
|
-
"o",
|
|
1452
|
-
"O",
|
|
1453
|
-
"0"
|
|
1454
|
-
], delay: u = ee ? 80 : 120, signal: l, ...n } = {})=>{
|
|
1455
|
-
const c = ce();
|
|
1456
|
-
let p, f, g = !1, E = !1, $ = "", m, d = performance.now();
|
|
1457
|
-
const F = dist_rt(s), y = n?.styleFrame ?? Kt, v = (B)=>{
|
|
1458
|
-
const P = B > 1 ? a ?? dist_.messages.error : i ?? dist_.messages.cancel;
|
|
1459
|
-
E = 1 === B, g && (k(P, B), E && "function" == typeof r && r());
|
|
1460
|
-
}, C = ()=>v(2), A = ()=>v(1), b = ()=>{
|
|
1461
|
-
process.on("uncaughtExceptionMonitor", C), process.on("unhandledRejection", C), process.on("SIGINT", A), process.on("SIGTERM", A), process.on("exit", v), l && l.addEventListener("abort", A);
|
|
1462
|
-
}, w = ()=>{
|
|
1463
|
-
process.removeListener("uncaughtExceptionMonitor", C), process.removeListener("unhandledRejection", C), process.removeListener("SIGINT", A), process.removeListener("SIGTERM", A), process.removeListener("exit", v), l && l.removeEventListener("abort", A);
|
|
1464
|
-
}, S = ()=>{
|
|
1465
|
-
if (void 0 === m) return;
|
|
1466
|
-
c && s.write(`
|
|
1467
|
-
`);
|
|
1468
|
-
const B = J(m, F, {
|
|
1469
|
-
hard: !0,
|
|
1470
|
-
trim: !1
|
|
1471
|
-
}).split(`
|
|
1472
|
-
`);
|
|
1473
|
-
B.length > 1 && s.write(src.cursor.up(B.length - 1)), s.write(src.cursor.to(0)), s.write(src.erase.down());
|
|
1474
|
-
}, T = (B)=>B.replace(/\.+$/, ""), M = (B)=>{
|
|
1475
|
-
const P = (performance.now() - B) / 1e3, G = Math.floor(P / 60), L = Math.floor(P % 60);
|
|
1476
|
-
return G > 0 ? `[${G}m ${L}s]` : `[${L}s]`;
|
|
1477
|
-
}, O = n.withGuide ?? dist_.withGuide, le = (B = "")=>{
|
|
1478
|
-
g = !0, p = xt({
|
|
1479
|
-
output: s
|
|
1480
|
-
}), $ = T(B), d = performance.now(), O && s.write(`${styleText("gray", dist_h)}
|
|
1788
|
+
], c = fast_string_width_dist(i), a = Math.max(o.reduce((p, m)=>{
|
|
1789
|
+
const g = fast_string_width_dist(m);
|
|
1790
|
+
return g > p ? g : p;
|
|
1791
|
+
}, 0), c) + 2, l = o.map((p)=>`${styleText("gray", prompts_dist_d)} ${p}${" ".repeat(a - fast_string_width_dist(p))}${styleText("gray", prompts_dist_d)}`).join(`
|
|
1792
|
+
`), $ = u ? `${styleText("gray", prompts_dist_d)}
|
|
1793
|
+
` : "", y = u ? Ge : de;
|
|
1794
|
+
r.write(`${$}${styleText("green", dist_F)} ${styleText("reset", i)} ${styleText("gray", se.repeat(Math.max(a - c - 1, 1)) + ce)}
|
|
1795
|
+
${l}
|
|
1796
|
+
${styleText("gray", y + se.repeat(a + 2) + $e)}
|
|
1481
1797
|
`);
|
|
1482
|
-
let P = 0, G = 0;
|
|
1483
|
-
b(), f = setInterval(()=>{
|
|
1484
|
-
if (c && $ === m) return;
|
|
1485
|
-
S(), m = $;
|
|
1486
|
-
const L = y(o[P]);
|
|
1487
|
-
let Z;
|
|
1488
|
-
if (c) Z = `${L} ${$}...`;
|
|
1489
|
-
else if ("timer" === e) Z = `${L} ${$} ${M(d)}`;
|
|
1490
|
-
else {
|
|
1491
|
-
const et = ".".repeat(Math.floor(G)).slice(0, 3);
|
|
1492
|
-
Z = `${L} ${$}${et}`;
|
|
1493
|
-
}
|
|
1494
|
-
const Ze = J(Z, F, {
|
|
1495
|
-
hard: !0,
|
|
1496
|
-
trim: !1
|
|
1497
|
-
});
|
|
1498
|
-
s.write(Ze), P = P + 1 < o.length ? P + 1 : 0, G = G < 4 ? G + .125 : 0;
|
|
1499
|
-
}, u);
|
|
1500
|
-
}, k = (B = "", P = 0, G = !1)=>{
|
|
1501
|
-
if (!g) return;
|
|
1502
|
-
g = !1, clearInterval(f), S();
|
|
1503
|
-
const L = 0 === P ? styleText("green", dist_V) : 1 === P ? styleText("red", $e) : styleText("red", de);
|
|
1504
|
-
$ = B ?? $, G || ("timer" === e ? s.write(`${L} ${$} ${M(d)}
|
|
1505
|
-
`) : s.write(`${L} ${$}
|
|
1506
|
-
`)), w(), p();
|
|
1507
|
-
};
|
|
1508
|
-
return {
|
|
1509
|
-
start: le,
|
|
1510
|
-
stop: (B = "")=>k(B, 0),
|
|
1511
|
-
message: (B = "")=>{
|
|
1512
|
-
$ = T(B ?? $);
|
|
1513
|
-
},
|
|
1514
|
-
cancel: (B = "")=>k(B, 1),
|
|
1515
|
-
error: (B = "")=>k(B, 2),
|
|
1516
|
-
clear: ()=>k("", 0, !0),
|
|
1517
|
-
get isCancelled () {
|
|
1518
|
-
return E;
|
|
1519
|
-
}
|
|
1520
|
-
};
|
|
1521
1798
|
};
|
|
1522
|
-
|
|
1523
|
-
const
|
|
1799
|
+
dist_w("\u2500", "-"), dist_w("\u2501", "="), dist_w("\u2588", "#");
|
|
1800
|
+
const re = (e, i)=>e.includes(`
|
|
1524
1801
|
`) ? e.split(`
|
|
1525
|
-
`).map((s)=>
|
|
1526
|
-
`) :
|
|
1527
|
-
const
|
|
1528
|
-
const
|
|
1529
|
-
switch(
|
|
1802
|
+
`).map((s)=>i(s)).join(`
|
|
1803
|
+
`) : i(e), _t = (e)=>{
|
|
1804
|
+
const i = (s, r)=>{
|
|
1805
|
+
const u = s.label ?? String(s.value);
|
|
1806
|
+
switch(r){
|
|
1530
1807
|
case "disabled":
|
|
1531
|
-
return `${styleText("gray", dist_H)} ${
|
|
1808
|
+
return `${styleText("gray", dist_H)} ${re(u, (n)=>styleText("gray", n))}${s.hint ? ` ${styleText("dim", `(${s.hint ?? "disabled"})`)}` : ""}`;
|
|
1532
1809
|
case "selected":
|
|
1533
|
-
return `${
|
|
1810
|
+
return `${re(u, (n)=>styleText("dim", n))}`;
|
|
1534
1811
|
case "active":
|
|
1535
|
-
return `${styleText("green", dist_z)} ${
|
|
1812
|
+
return `${styleText("green", dist_z)} ${u}${s.hint ? ` ${styleText("dim", `(${s.hint})`)}` : ""}`;
|
|
1536
1813
|
case "cancelled":
|
|
1537
|
-
return `${
|
|
1814
|
+
return `${re(u, (n)=>styleText([
|
|
1538
1815
|
"strikethrough",
|
|
1539
1816
|
"dim"
|
|
1540
|
-
],
|
|
1817
|
+
], n))}`;
|
|
1541
1818
|
default:
|
|
1542
|
-
return `${styleText("dim", dist_H)} ${
|
|
1819
|
+
return `${styleText("dim", dist_H)} ${re(u, (n)=>styleText("dim", n))}`;
|
|
1543
1820
|
}
|
|
1544
1821
|
};
|
|
1545
|
-
return new
|
|
1822
|
+
return new nt({
|
|
1546
1823
|
options: e.options,
|
|
1547
1824
|
signal: e.signal,
|
|
1548
1825
|
input: e.input,
|
|
1549
1826
|
output: e.output,
|
|
1550
1827
|
initialValue: e.initialValue,
|
|
1551
1828
|
render () {
|
|
1552
|
-
const s = e.withGuide ??
|
|
1553
|
-
` : ""}${
|
|
1829
|
+
const s = e.withGuide ?? dist_u.withGuide, r = `${dist_V(this.state)} `, u = `${ye(this.state)} `, n = dist_R(e.output, e.message, u, r), o = `${s ? `${styleText("gray", prompts_dist_d)}
|
|
1830
|
+
` : ""}${n}
|
|
1554
1831
|
`;
|
|
1555
1832
|
switch(this.state){
|
|
1556
1833
|
case "submit":
|
|
1557
1834
|
{
|
|
1558
|
-
const
|
|
1559
|
-
return `${
|
|
1835
|
+
const c = s ? `${styleText("gray", prompts_dist_d)} ` : "", a = dist_R(e.output, i(this.options[this.cursor], "selected"), c);
|
|
1836
|
+
return `${o}${a}`;
|
|
1560
1837
|
}
|
|
1561
1838
|
case "cancel":
|
|
1562
1839
|
{
|
|
1563
|
-
const
|
|
1564
|
-
return `${
|
|
1565
|
-
${styleText("gray",
|
|
1840
|
+
const c = s ? `${styleText("gray", prompts_dist_d)} ` : "", a = dist_R(e.output, i(this.options[this.cursor], "cancelled"), c);
|
|
1841
|
+
return `${o}${a}${s ? `
|
|
1842
|
+
${styleText("gray", prompts_dist_d)}` : ""}`;
|
|
1566
1843
|
}
|
|
1567
1844
|
default:
|
|
1568
1845
|
{
|
|
1569
|
-
const
|
|
1570
|
-
`).length,
|
|
1571
|
-
return `${
|
|
1846
|
+
const c = s ? `${styleText("cyan", prompts_dist_d)} ` : "", a = s ? styleText("cyan", dist_E) : "", l = o.split(`
|
|
1847
|
+
`).length, $ = s ? 2 : 1;
|
|
1848
|
+
return `${o}${c}${dist_Y({
|
|
1572
1849
|
output: e.output,
|
|
1573
1850
|
cursor: this.cursor,
|
|
1574
1851
|
options: this.options,
|
|
1575
1852
|
maxItems: e.maxItems,
|
|
1576
|
-
columnPadding:
|
|
1577
|
-
rowPadding:
|
|
1578
|
-
style: (
|
|
1853
|
+
columnPadding: c.length,
|
|
1854
|
+
rowPadding: l + $,
|
|
1855
|
+
style: (y, p)=>i(y, y.disabled ? "disabled" : p ? "active" : "inactive")
|
|
1579
1856
|
}).join(`
|
|
1580
|
-
${
|
|
1581
|
-
${
|
|
1857
|
+
${c}`)}
|
|
1858
|
+
${a}
|
|
1582
1859
|
`;
|
|
1583
1860
|
}
|
|
1584
1861
|
}
|
|
1585
1862
|
}
|
|
1586
1863
|
}).prompt();
|
|
1587
|
-
},
|
|
1864
|
+
}, xt = (styleText("gray", prompts_dist_d), (e)=>e.replace(/\x1b\[(?:\d+;)*\d*[ABCDEFGHfJKSTsu]|\x1b\[(s|u)/g, "")), Gt = (e)=>{
|
|
1865
|
+
const i = e.output ?? process.stdout, s = O(i), r = styleText("gray", prompts_dist_d), u = e.spacing ?? 1, n = 3, o = !0 === e.retainLog, c = !ae() && Te(i);
|
|
1866
|
+
i.write(`${r}
|
|
1867
|
+
`), i.write(`${styleText("green", dist_F)} ${e.title}
|
|
1868
|
+
`);
|
|
1869
|
+
for(let h = 0; h < u; h++)i.write(`${r}
|
|
1870
|
+
`);
|
|
1871
|
+
const a = [
|
|
1872
|
+
{
|
|
1873
|
+
value: "",
|
|
1874
|
+
full: ""
|
|
1875
|
+
}
|
|
1876
|
+
];
|
|
1877
|
+
let l = !1;
|
|
1878
|
+
const $ = (h)=>{
|
|
1879
|
+
if (0 === a.length) return;
|
|
1880
|
+
let f = 0;
|
|
1881
|
+
h && (f += u + 2);
|
|
1882
|
+
for (const v of a){
|
|
1883
|
+
const { value: T, result: C } = v;
|
|
1884
|
+
let b = C?.message ?? T;
|
|
1885
|
+
if (0 === b.length) continue;
|
|
1886
|
+
void 0 === C && void 0 !== v.header && "" !== v.header && (b += `
|
|
1887
|
+
${v.header}`);
|
|
1888
|
+
const x = b.split(`
|
|
1889
|
+
`).reduce((G, M)=>"" === M ? G + 1 : G + Math.ceil((M.length + n) / s), 0);
|
|
1890
|
+
f += x;
|
|
1891
|
+
}
|
|
1892
|
+
f > 0 && (f += 1, i.write(src.erase.lines(f)));
|
|
1893
|
+
}, y = (h, f, v)=>{
|
|
1894
|
+
const T = v ? `${h.full}
|
|
1895
|
+
${h.value}` : h.value;
|
|
1896
|
+
void 0 !== h.header && "" !== h.header && dist_O.message(h.header.split(`
|
|
1897
|
+
`).map((C)=>styleText("bold", C)), {
|
|
1898
|
+
output: i,
|
|
1899
|
+
secondarySymbol: r,
|
|
1900
|
+
symbol: r,
|
|
1901
|
+
spacing: 0
|
|
1902
|
+
}), dist_O.message(T.split(`
|
|
1903
|
+
`).map((C)=>styleText("dim", C)), {
|
|
1904
|
+
output: i,
|
|
1905
|
+
secondarySymbol: r,
|
|
1906
|
+
symbol: r,
|
|
1907
|
+
spacing: f ?? u
|
|
1908
|
+
});
|
|
1909
|
+
}, p = ()=>{
|
|
1910
|
+
for (const h of a){
|
|
1911
|
+
const { header: f, value: v, full: T } = h;
|
|
1912
|
+
(void 0 === f || 0 === f.length) && 0 === v.length || y(h, void 0, !0 === o && T.length > 0);
|
|
1913
|
+
}
|
|
1914
|
+
}, m = (h, f, v)=>{
|
|
1915
|
+
if ($(!1), v?.raw === !0 && l || "" === h.value || (h.value += `
|
|
1916
|
+
`), h.value += xt(f), l = v?.raw === !0, void 0 !== e.limit) {
|
|
1917
|
+
const T = h.value.split(`
|
|
1918
|
+
`), C = T.length - e.limit;
|
|
1919
|
+
if (C > 0) {
|
|
1920
|
+
const b = T.splice(0, C);
|
|
1921
|
+
o && (h.full += ("" === h.full ? "" : `
|
|
1922
|
+
`) + b.join(`
|
|
1923
|
+
`));
|
|
1924
|
+
}
|
|
1925
|
+
h.value = T.join(`
|
|
1926
|
+
`);
|
|
1927
|
+
}
|
|
1928
|
+
c && g();
|
|
1929
|
+
}, g = ()=>{
|
|
1930
|
+
for (const h of a)h.result ? "error" === h.result.status ? dist_O.error(h.result.message, {
|
|
1931
|
+
output: i,
|
|
1932
|
+
secondarySymbol: r,
|
|
1933
|
+
spacing: 0
|
|
1934
|
+
}) : dist_O.success(h.result.message, {
|
|
1935
|
+
output: i,
|
|
1936
|
+
secondarySymbol: r,
|
|
1937
|
+
spacing: 0
|
|
1938
|
+
}) : "" !== h.value && y(h, 0);
|
|
1939
|
+
}, S = (h, f)=>{
|
|
1940
|
+
$(!1), h.result = f, c && g();
|
|
1941
|
+
};
|
|
1942
|
+
return {
|
|
1943
|
+
message (h, f) {
|
|
1944
|
+
m(a[0], h, f);
|
|
1945
|
+
},
|
|
1946
|
+
group (h) {
|
|
1947
|
+
const f = {
|
|
1948
|
+
header: h,
|
|
1949
|
+
value: "",
|
|
1950
|
+
full: ""
|
|
1951
|
+
};
|
|
1952
|
+
return a.push(f), {
|
|
1953
|
+
message (v, T) {
|
|
1954
|
+
m(f, v, T);
|
|
1955
|
+
},
|
|
1956
|
+
error (v) {
|
|
1957
|
+
S(f, {
|
|
1958
|
+
status: "error",
|
|
1959
|
+
message: v
|
|
1960
|
+
});
|
|
1961
|
+
},
|
|
1962
|
+
success (v) {
|
|
1963
|
+
S(f, {
|
|
1964
|
+
status: "success",
|
|
1965
|
+
message: v
|
|
1966
|
+
});
|
|
1967
|
+
}
|
|
1968
|
+
};
|
|
1969
|
+
},
|
|
1970
|
+
error (h, f) {
|
|
1971
|
+
$(!0), dist_O.error(h, {
|
|
1972
|
+
output: i,
|
|
1973
|
+
secondarySymbol: r,
|
|
1974
|
+
spacing: 1
|
|
1975
|
+
}), f?.showLog !== !1 && p(), a.splice(1, a.length - 1), a[0].value = "", a[0].full = "";
|
|
1976
|
+
},
|
|
1977
|
+
success (h, f) {
|
|
1978
|
+
$(!0), dist_O.success(h, {
|
|
1979
|
+
output: i,
|
|
1980
|
+
secondarySymbol: r,
|
|
1981
|
+
spacing: 1
|
|
1982
|
+
}), f?.showLog === !0 && p(), a.splice(1, a.length - 1), a[0].value = "", a[0].full = "";
|
|
1983
|
+
}
|
|
1984
|
+
};
|
|
1985
|
+
}, Ot = (e)=>new at({
|
|
1588
1986
|
validate: e.validate,
|
|
1589
1987
|
placeholder: e.placeholder,
|
|
1590
1988
|
defaultValue: e.defaultValue,
|
|
@@ -1593,45 +1991,45 @@ ${n}
|
|
|
1593
1991
|
signal: e.signal,
|
|
1594
1992
|
input: e.input,
|
|
1595
1993
|
render () {
|
|
1596
|
-
const
|
|
1597
|
-
` : ""}${
|
|
1598
|
-
`,
|
|
1994
|
+
const i = e?.withGuide ?? dist_u.withGuide, s = `${i ? `${styleText("gray", prompts_dist_d)}
|
|
1995
|
+
` : ""}${dist_V(this.state)} ${e.message}
|
|
1996
|
+
`, r = e.placeholder ? styleText("inverse", e.placeholder[0]) + styleText("dim", e.placeholder.slice(1)) : styleText([
|
|
1599
1997
|
"inverse",
|
|
1600
1998
|
"hidden"
|
|
1601
|
-
], "_"),
|
|
1999
|
+
], "_"), u = this.userInput ? this.userInputWithCursor : r, n = this.value ?? "";
|
|
1602
2000
|
switch(this.state){
|
|
1603
2001
|
case "error":
|
|
1604
2002
|
{
|
|
1605
|
-
const
|
|
2003
|
+
const o = this.error ? ` ${styleText("yellow", this.error)}` : "", c = i ? `${styleText("yellow", prompts_dist_d)} ` : "", a = i ? styleText("yellow", dist_E) : "";
|
|
1606
2004
|
return `${s.trim()}
|
|
1607
|
-
${
|
|
1608
|
-
${
|
|
2005
|
+
${c}${u}
|
|
2006
|
+
${a}${o}
|
|
1609
2007
|
`;
|
|
1610
2008
|
}
|
|
1611
2009
|
case "submit":
|
|
1612
2010
|
{
|
|
1613
|
-
const
|
|
1614
|
-
return `${s}${
|
|
2011
|
+
const o = n ? ` ${styleText("dim", n)}` : "", c = i ? styleText("gray", prompts_dist_d) : "";
|
|
2012
|
+
return `${s}${c}${o}`;
|
|
1615
2013
|
}
|
|
1616
2014
|
case "cancel":
|
|
1617
2015
|
{
|
|
1618
|
-
const
|
|
2016
|
+
const o = n ? ` ${styleText([
|
|
1619
2017
|
"strikethrough",
|
|
1620
2018
|
"dim"
|
|
1621
|
-
],
|
|
1622
|
-
return `${s}${
|
|
1623
|
-
${
|
|
2019
|
+
], n)}` : "", c = i ? styleText("gray", prompts_dist_d) : "";
|
|
2020
|
+
return `${s}${c}${o}${n.trim() ? `
|
|
2021
|
+
${c}` : ""}`;
|
|
1624
2022
|
}
|
|
1625
2023
|
default:
|
|
1626
2024
|
{
|
|
1627
|
-
const
|
|
1628
|
-
return `${s}${
|
|
1629
|
-
${
|
|
2025
|
+
const o = i ? `${styleText("cyan", prompts_dist_d)} ` : "", c = i ? styleText("cyan", dist_E) : "";
|
|
2026
|
+
return `${s}${o}${u}
|
|
2027
|
+
${c}
|
|
1630
2028
|
`;
|
|
1631
2029
|
}
|
|
1632
2030
|
}
|
|
1633
2031
|
}
|
|
1634
|
-
}).prompt()
|
|
2032
|
+
}).prompt();
|
|
1635
2033
|
function checkNodeVersion() {
|
|
1636
2034
|
const { versions } = process;
|
|
1637
2035
|
if ("styleText" in node_util || !versions.node || versions.bun || versions.deno) return;
|
|
@@ -2368,10 +2766,10 @@ const main_M = {
|
|
|
2368
2766
|
timeout: void 0,
|
|
2369
2767
|
persist: false
|
|
2370
2768
|
};
|
|
2371
|
-
const
|
|
2769
|
+
const main_N = {
|
|
2372
2770
|
windowsHide: true
|
|
2373
2771
|
};
|
|
2374
|
-
function
|
|
2772
|
+
function P(e, t) {
|
|
2375
2773
|
return {
|
|
2376
2774
|
command: external_node_path_normalize(e),
|
|
2377
2775
|
args: t ?? []
|
|
@@ -2486,7 +2884,7 @@ var main_L = class {
|
|
|
2486
2884
|
const e = external_node_process_cwd();
|
|
2487
2885
|
const n = this._options;
|
|
2488
2886
|
const r = {
|
|
2489
|
-
...
|
|
2887
|
+
...main_N,
|
|
2490
2888
|
...n.nodeOptions
|
|
2491
2889
|
};
|
|
2492
2890
|
const i = [];
|
|
@@ -2496,7 +2894,7 @@ var main_L = class {
|
|
|
2496
2894
|
if (true === n.persist) r.detached = true;
|
|
2497
2895
|
if (i.length > 0) r.signal = main_F(i);
|
|
2498
2896
|
r.env = main_h(e, r.env);
|
|
2499
|
-
const { command: a, args: s } =
|
|
2897
|
+
const { command: a, args: s } = P(this._command, this._args);
|
|
2500
2898
|
const c = (0, main_A._parse)(a, s, r);
|
|
2501
2899
|
const l = spawn(c.command, c.args, c.options);
|
|
2502
2900
|
if (l.stderr) this._streamErr = l.stderr;
|
|
@@ -2533,7 +2931,7 @@ const main_R = (e, t, n)=>{
|
|
|
2533
2931
|
return r;
|
|
2534
2932
|
};
|
|
2535
2933
|
const main_z = main_R;
|
|
2536
|
-
const
|
|
2934
|
+
const dist_0 = __webpack_require__("./node_modules/.pnpm/@vercel+detect-agent@1.2.1/node_modules/@vercel/detect-agent/dist/index.js");
|
|
2537
2935
|
const cjs = __webpack_require__("./node_modules/.pnpm/deepmerge@4.3.1/node_modules/deepmerge/dist/cjs.js");
|
|
2538
2936
|
var cjs_default = /*#__PURE__*/ __webpack_require__.n(cjs);
|
|
2539
2937
|
const minimist = __webpack_require__("./node_modules/.pnpm/minimist@1.2.8/node_modules/minimist/index.js");
|
|
@@ -2541,11 +2939,11 @@ var minimist_default = /*#__PURE__*/ __webpack_require__.n(minimist);
|
|
|
2541
2939
|
const src_filename = fileURLToPath(import.meta.url);
|
|
2542
2940
|
const src_dirname = dirname(src_filename);
|
|
2543
2941
|
function cancelAndExit() {
|
|
2544
|
-
|
|
2942
|
+
pt('Operation cancelled.');
|
|
2545
2943
|
process.exit(0);
|
|
2546
2944
|
}
|
|
2547
2945
|
function checkCancel(value) {
|
|
2548
|
-
if (
|
|
2946
|
+
if (dist_q(value)) cancelAndExit();
|
|
2549
2947
|
return value;
|
|
2550
2948
|
}
|
|
2551
2949
|
function formatProjectName(input) {
|
|
@@ -2654,7 +3052,7 @@ async function getTools({ tools, dir, template }, extraTools, templateName) {
|
|
|
2654
3052
|
options.unshift(...filteredExtraTools.filter((tool)=>'pre' === tool.order).map(normalize));
|
|
2655
3053
|
options.push(...filteredExtraTools.filter((tool)=>'pre' !== tool.order).map(normalize));
|
|
2656
3054
|
}
|
|
2657
|
-
return checkCancel(await
|
|
3055
|
+
return checkCancel(await yt({
|
|
2658
3056
|
message: 'Select additional tools (Use <space> to select, <enter> to continue)',
|
|
2659
3057
|
options,
|
|
2660
3058
|
required: false
|
|
@@ -2674,7 +3072,7 @@ function orderExtraSkills(extraSkills) {
|
|
|
2674
3072
|
...extraSkills.filter((extraSkill)=>'post' === extraSkill.order)
|
|
2675
3073
|
];
|
|
2676
3074
|
}
|
|
2677
|
-
async function getSkills({ skill, dir, template }, extraSkills, templateName, promptMultiselect =
|
|
3075
|
+
async function getSkills({ skill, dir, template }, extraSkills, templateName, promptMultiselect = yt) {
|
|
2678
3076
|
const parsedSkills = parseSkillsOption(skill);
|
|
2679
3077
|
const filteredExtraSkills = filterExtraSkills(extraSkills, templateName);
|
|
2680
3078
|
if (null !== parsedSkills) return parsedSkills.filter((value)=>filteredExtraSkills?.some((extraSkill)=>extraSkill.value === value));
|
|
@@ -2749,28 +3147,28 @@ async function runSkillCommand(skill, cwd) {
|
|
|
2749
3147
|
skill.skill ?? skill.value
|
|
2750
3148
|
];
|
|
2751
3149
|
const command = `npx ${args.join(' ')}`;
|
|
2752
|
-
|
|
2753
|
-
const
|
|
2754
|
-
|
|
2755
|
-
|
|
3150
|
+
dist_O.info(`Running skill install command: ${color.dim(command)}`);
|
|
3151
|
+
const installationTaskLog = Gt({
|
|
3152
|
+
title: `Installing skill ${skill.value}`
|
|
3153
|
+
});
|
|
3154
|
+
const proc = main_R('npx', args, {
|
|
2756
3155
|
nodeOptions: {
|
|
2757
3156
|
cwd,
|
|
2758
3157
|
stdio: 'pipe'
|
|
2759
3158
|
}
|
|
2760
3159
|
});
|
|
3160
|
+
for await (const line of proc)installationTaskLog.message(line);
|
|
3161
|
+
const result = await proc;
|
|
2761
3162
|
if (0 !== result.exitCode) {
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
result.stdout
|
|
2766
|
-
].filter(Boolean).join('\n').trim();
|
|
2767
|
-
throw new Error(`Failed to install skill "${skill.value}" from "${skill.source}" using command: ${command}${details ? `\n${details}` : ''}`);
|
|
3163
|
+
const message = `Failed to install skill "${skill.value}" from "${skill.source}" using command: ${command}`;
|
|
3164
|
+
installationTaskLog.error(message);
|
|
3165
|
+
throw new Error(message);
|
|
2768
3166
|
}
|
|
2769
|
-
|
|
3167
|
+
installationTaskLog.success(`Installed skill ${skill.value}`);
|
|
2770
3168
|
}
|
|
2771
3169
|
async function create({ name, root, templates, skipFiles, getTemplateName, mapESLintTemplate, version, noteInformation, extraTools, extraSkills, argv: processArgv = process.argv }) {
|
|
2772
3170
|
src_logger.greet(`\n◆ Create ${upperFirst(name)} Project`);
|
|
2773
|
-
const { isAgent } = await (0,
|
|
3171
|
+
const { isAgent } = await (0, dist_0.determineAgent)();
|
|
2774
3172
|
if (isAgent) {
|
|
2775
3173
|
console.log('');
|
|
2776
3174
|
src_logger.info(`To create a project non-interactively, run: npx -y create-${name} <DIR> --template <TEMPLATE>`);
|
|
@@ -2784,7 +3182,7 @@ async function create({ name, root, templates, skipFiles, getTemplateName, mapES
|
|
|
2784
3182
|
packageManager
|
|
2785
3183
|
};
|
|
2786
3184
|
if (!version) version = (await readPackageJson(root)).version;
|
|
2787
|
-
const projectName = argv.dir ?? checkCancel(await
|
|
3185
|
+
const projectName = argv.dir ?? checkCancel(await Ot({
|
|
2788
3186
|
message: 'Project name or path',
|
|
2789
3187
|
placeholder: `${name.toLowerCase()}-project`,
|
|
2790
3188
|
defaultValue: `${name.toLowerCase()}-project`,
|
|
@@ -2797,7 +3195,7 @@ async function create({ name, root, templates, skipFiles, getTemplateName, mapES
|
|
|
2797
3195
|
const packageName = argv.packageName || formatted.packageName;
|
|
2798
3196
|
const distFolder = node_path.isAbsolute(targetDir) ? targetDir : node_path.join(cwd, targetDir);
|
|
2799
3197
|
if (!argv.override && node_fs.existsSync(distFolder) && !isEmptyDir(distFolder)) {
|
|
2800
|
-
const option = checkCancel(await
|
|
3198
|
+
const option = checkCancel(await _t({
|
|
2801
3199
|
message: `"${targetDir}" is not empty, please choose:`,
|
|
2802
3200
|
options: [
|
|
2803
3201
|
{
|
|
@@ -2815,7 +3213,7 @@ async function create({ name, root, templates, skipFiles, getTemplateName, mapES
|
|
|
2815
3213
|
const templateName = await getTemplateName(argv);
|
|
2816
3214
|
const tools = await getTools(argv, extraTools, templateName);
|
|
2817
3215
|
const filteredExtraSkills = filterExtraSkills(extraSkills, templateName);
|
|
2818
|
-
const skills = await getSkills(argv, filteredExtraSkills, templateName,
|
|
3216
|
+
const skills = await getSkills(argv, filteredExtraSkills, templateName, yt);
|
|
2819
3217
|
const srcFolder = node_path.join(root, `template-${templateName}`);
|
|
2820
3218
|
const commonFolder = node_path.join(root, 'template-common');
|
|
2821
3219
|
if (!node_fs.existsSync(srcFolder)) throw new Error(`Invalid input: template "${templateName}" not found.`);
|
|
@@ -2898,8 +3296,8 @@ async function create({ name, root, templates, skipFiles, getTemplateName, mapES
|
|
|
2898
3296
|
`3. ${color.cyan(`${packageManager} install`)}`,
|
|
2899
3297
|
`4. ${color.cyan(`${packageManager} run dev`)}`
|
|
2900
3298
|
];
|
|
2901
|
-
if (nextSteps.length)
|
|
2902
|
-
|
|
3299
|
+
if (nextSteps.length) wt(nextSteps.map((step)=>color.reset(step)).join('\n'), 'Next steps');
|
|
3300
|
+
gt('All set, happy coding!');
|
|
2903
3301
|
}
|
|
2904
3302
|
function sortObjectKeys(obj) {
|
|
2905
3303
|
const sortedKeys = Object.keys(obj).sort();
|
|
@@ -3062,4 +3460,4 @@ function collectAgentsFiles(agentsMdSearchDirs) {
|
|
|
3062
3460
|
}
|
|
3063
3461
|
return agentsFiles;
|
|
3064
3462
|
}
|
|
3065
|
-
export { BUILTIN_TOOLS,
|
|
3463
|
+
export { Ae as autocomplete, BUILTIN_TOOLS, Ot as text, _t as select, checkCancel, collectAgentsFiles, copyFolder, create, ht as groupMultiselect, mergeAgentsFiles, mergePackageJson, yt as multiselect };
|