proxitor 0.9.0-beta.1 → 0.9.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +88 -7
- package/dist/cli.mjs +10128 -509
- package/dist/cli.mjs.map +1 -1
- package/dist/prompt.mjs +3 -3
- package/dist/prompt.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/add.mjs +0 -136
- package/dist/add.mjs.map +0 -1
- package/dist/browse.mjs +0 -85
- package/dist/browse.mjs.map +0 -1
- package/dist/config.mjs +0 -46
- package/dist/config.mjs.map +0 -1
- package/dist/config2.mjs +0 -73
- package/dist/config2.mjs.map +0 -1
- package/dist/dist.mjs +0 -1335
- package/dist/dist.mjs.map +0 -1
- package/dist/dist2.mjs +0 -6617
- package/dist/dist2.mjs.map +0 -1
- package/dist/edit.mjs +0 -79
- package/dist/edit.mjs.map +0 -1
- package/dist/list.mjs +0 -31
- package/dist/list.mjs.map +0 -1
- package/dist/providers.mjs +0 -250
- package/dist/providers.mjs.map +0 -1
- package/dist/remove.mjs +0 -36
- package/dist/remove.mjs.map +0 -1
- package/dist/validate.mjs +0 -25
- package/dist/validate.mjs.map +0 -1
- package/dist/wizard.mjs +0 -256
- package/dist/wizard.mjs.map +0 -1
package/dist/dist.mjs
DELETED
|
@@ -1,1335 +0,0 @@
|
|
|
1
|
-
import { o as __commonJSMin } from "./cli.mjs";
|
|
2
|
-
import process$1, { stdin, stdout } from "node:process";
|
|
3
|
-
import { ReadStream } from "node:tty";
|
|
4
|
-
import { styleText } from "node:util";
|
|
5
|
-
import "node:fs";
|
|
6
|
-
import "node:path";
|
|
7
|
-
import * as l from "node:readline";
|
|
8
|
-
import f from "node:readline";
|
|
9
|
-
//#region node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/utils.js
|
|
10
|
-
const getCodePointsLength = (() => {
|
|
11
|
-
const SURROGATE_PAIR_RE = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
|
|
12
|
-
return (input) => {
|
|
13
|
-
let surrogatePairsNr = 0;
|
|
14
|
-
SURROGATE_PAIR_RE.lastIndex = 0;
|
|
15
|
-
while (SURROGATE_PAIR_RE.test(input)) surrogatePairsNr += 1;
|
|
16
|
-
return input.length - surrogatePairsNr;
|
|
17
|
-
};
|
|
18
|
-
})();
|
|
19
|
-
const isFullWidth = (x) => {
|
|
20
|
-
return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
|
|
21
|
-
};
|
|
22
|
-
const isWideNotCJKTNotEmoji = (x) => {
|
|
23
|
-
return x === 8987 || x === 9001 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12771 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 19903 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
|
|
24
|
-
};
|
|
25
|
-
//#endregion
|
|
26
|
-
//#region node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/index.js
|
|
27
|
-
const ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y;
|
|
28
|
-
const CONTROL_RE = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
|
|
29
|
-
const CJKT_WIDE_RE = /(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy;
|
|
30
|
-
const TAB_RE = /\t{1,1000}/y;
|
|
31
|
-
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?))*/uy;
|
|
32
|
-
const LATIN_RE = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
|
|
33
|
-
const MODIFIER_RE = /\p{M}+/gu;
|
|
34
|
-
const NO_TRUNCATION$1 = {
|
|
35
|
-
limit: Infinity,
|
|
36
|
-
ellipsis: ""
|
|
37
|
-
};
|
|
38
|
-
const getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {}) => {
|
|
39
|
-
const LIMIT = truncationOptions.limit ?? Infinity;
|
|
40
|
-
const ELLIPSIS = truncationOptions.ellipsis ?? "";
|
|
41
|
-
const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth(ELLIPSIS, NO_TRUNCATION$1, widthOptions).width : 0);
|
|
42
|
-
const ANSI_WIDTH = 0;
|
|
43
|
-
const CONTROL_WIDTH = widthOptions.controlWidth ?? 0;
|
|
44
|
-
const TAB_WIDTH = widthOptions.tabWidth ?? 8;
|
|
45
|
-
const EMOJI_WIDTH = widthOptions.emojiWidth ?? 2;
|
|
46
|
-
const FULL_WIDTH_WIDTH = 2;
|
|
47
|
-
const REGULAR_WIDTH = widthOptions.regularWidth ?? 1;
|
|
48
|
-
const WIDE_WIDTH = widthOptions.wideWidth ?? FULL_WIDTH_WIDTH;
|
|
49
|
-
const PARSE_BLOCKS = [
|
|
50
|
-
[LATIN_RE, REGULAR_WIDTH],
|
|
51
|
-
[ANSI_RE, ANSI_WIDTH],
|
|
52
|
-
[CONTROL_RE, CONTROL_WIDTH],
|
|
53
|
-
[TAB_RE, TAB_WIDTH],
|
|
54
|
-
[EMOJI_RE, EMOJI_WIDTH],
|
|
55
|
-
[CJKT_WIDE_RE, WIDE_WIDTH]
|
|
56
|
-
];
|
|
57
|
-
let indexPrev = 0;
|
|
58
|
-
let index = 0;
|
|
59
|
-
let length = input.length;
|
|
60
|
-
let lengthExtra = 0;
|
|
61
|
-
let truncationEnabled = false;
|
|
62
|
-
let truncationIndex = length;
|
|
63
|
-
let truncationLimit = Math.max(0, LIMIT - ELLIPSIS_WIDTH);
|
|
64
|
-
let unmatchedStart = 0;
|
|
65
|
-
let unmatchedEnd = 0;
|
|
66
|
-
let width = 0;
|
|
67
|
-
let widthExtra = 0;
|
|
68
|
-
outer: while (true) {
|
|
69
|
-
if (unmatchedEnd > unmatchedStart || index >= length && index > indexPrev) {
|
|
70
|
-
const unmatched = input.slice(unmatchedStart, unmatchedEnd) || input.slice(indexPrev, index);
|
|
71
|
-
lengthExtra = 0;
|
|
72
|
-
for (const char of unmatched.replaceAll(MODIFIER_RE, "")) {
|
|
73
|
-
const codePoint = char.codePointAt(0) || 0;
|
|
74
|
-
if (isFullWidth(codePoint)) widthExtra = FULL_WIDTH_WIDTH;
|
|
75
|
-
else if (isWideNotCJKTNotEmoji(codePoint)) widthExtra = WIDE_WIDTH;
|
|
76
|
-
else widthExtra = REGULAR_WIDTH;
|
|
77
|
-
if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, Math.max(unmatchedStart, indexPrev) + lengthExtra);
|
|
78
|
-
if (width + widthExtra > LIMIT) {
|
|
79
|
-
truncationEnabled = true;
|
|
80
|
-
break outer;
|
|
81
|
-
}
|
|
82
|
-
lengthExtra += char.length;
|
|
83
|
-
width += widthExtra;
|
|
84
|
-
}
|
|
85
|
-
unmatchedStart = unmatchedEnd = 0;
|
|
86
|
-
}
|
|
87
|
-
if (index >= length) break outer;
|
|
88
|
-
for (let i = 0, l = PARSE_BLOCKS.length; i < l; i++) {
|
|
89
|
-
const [BLOCK_RE, BLOCK_WIDTH] = PARSE_BLOCKS[i];
|
|
90
|
-
BLOCK_RE.lastIndex = index;
|
|
91
|
-
if (BLOCK_RE.test(input)) {
|
|
92
|
-
lengthExtra = BLOCK_RE === CJKT_WIDE_RE ? getCodePointsLength(input.slice(index, BLOCK_RE.lastIndex)) : BLOCK_RE === EMOJI_RE ? 1 : BLOCK_RE.lastIndex - index;
|
|
93
|
-
widthExtra = lengthExtra * BLOCK_WIDTH;
|
|
94
|
-
if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / BLOCK_WIDTH));
|
|
95
|
-
if (width + widthExtra > LIMIT) {
|
|
96
|
-
truncationEnabled = true;
|
|
97
|
-
break outer;
|
|
98
|
-
}
|
|
99
|
-
width += widthExtra;
|
|
100
|
-
unmatchedStart = indexPrev;
|
|
101
|
-
unmatchedEnd = index;
|
|
102
|
-
index = indexPrev = BLOCK_RE.lastIndex;
|
|
103
|
-
continue outer;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
index += 1;
|
|
107
|
-
}
|
|
108
|
-
return {
|
|
109
|
-
width: truncationEnabled ? truncationLimit : width,
|
|
110
|
-
index: truncationEnabled ? truncationIndex : length,
|
|
111
|
-
truncated: truncationEnabled,
|
|
112
|
-
ellipsed: truncationEnabled && LIMIT >= ELLIPSIS_WIDTH
|
|
113
|
-
};
|
|
114
|
-
};
|
|
115
|
-
//#endregion
|
|
116
|
-
//#region node_modules/.pnpm/fast-string-width@3.0.2/node_modules/fast-string-width/dist/index.js
|
|
117
|
-
const NO_TRUNCATION = {
|
|
118
|
-
limit: Infinity,
|
|
119
|
-
ellipsis: "",
|
|
120
|
-
ellipsisWidth: 0
|
|
121
|
-
};
|
|
122
|
-
const fastStringWidth = (input, options = {}) => {
|
|
123
|
-
return getStringTruncatedWidth(input, NO_TRUNCATION, options).width;
|
|
124
|
-
};
|
|
125
|
-
//#endregion
|
|
126
|
-
//#region node_modules/.pnpm/fast-wrap-ansi@0.2.2/node_modules/fast-wrap-ansi/lib/main.js
|
|
127
|
-
const ESC = "\x1B";
|
|
128
|
-
const CSI = "";
|
|
129
|
-
const END_CODE = 39;
|
|
130
|
-
const ANSI_ESCAPE_BELL = "\x07";
|
|
131
|
-
const ANSI_CSI = "[";
|
|
132
|
-
const ANSI_OSC = "]";
|
|
133
|
-
const ANSI_SGR_TERMINATOR = "m";
|
|
134
|
-
const ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
|
|
135
|
-
const GROUP_REGEX = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`, "y");
|
|
136
|
-
const getClosingCode = (openingCode) => {
|
|
137
|
-
if (openingCode >= 30 && openingCode <= 37) return 39;
|
|
138
|
-
if (openingCode >= 90 && openingCode <= 97) return 39;
|
|
139
|
-
if (openingCode >= 40 && openingCode <= 47) return 49;
|
|
140
|
-
if (openingCode >= 100 && openingCode <= 107) return 49;
|
|
141
|
-
if (openingCode === 1 || openingCode === 2) return 22;
|
|
142
|
-
if (openingCode === 3) return 23;
|
|
143
|
-
if (openingCode === 4) return 24;
|
|
144
|
-
if (openingCode === 7) return 27;
|
|
145
|
-
if (openingCode === 8) return 28;
|
|
146
|
-
if (openingCode === 9) return 29;
|
|
147
|
-
if (openingCode === 0) return 0;
|
|
148
|
-
};
|
|
149
|
-
const wrapAnsiCode = (code) => `${ESC}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
|
|
150
|
-
const wrapAnsiHyperlink = (url) => `${ESC}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;
|
|
151
|
-
const wrapWord = (rows, word, columns) => {
|
|
152
|
-
const characters = word[Symbol.iterator]();
|
|
153
|
-
let isInsideEscape = false;
|
|
154
|
-
let isInsideLinkEscape = false;
|
|
155
|
-
let lastRow = rows.at(-1);
|
|
156
|
-
let visible = lastRow === void 0 ? 0 : fastStringWidth(lastRow);
|
|
157
|
-
let currentCharacter = characters.next();
|
|
158
|
-
let nextCharacter = characters.next();
|
|
159
|
-
let rawCharacterIndex = 0;
|
|
160
|
-
while (!currentCharacter.done) {
|
|
161
|
-
const character = currentCharacter.value;
|
|
162
|
-
const characterLength = fastStringWidth(character);
|
|
163
|
-
if (visible + characterLength <= columns) rows[rows.length - 1] += character;
|
|
164
|
-
else {
|
|
165
|
-
rows.push(character);
|
|
166
|
-
visible = 0;
|
|
167
|
-
}
|
|
168
|
-
if (character === ESC || character === CSI) {
|
|
169
|
-
isInsideEscape = true;
|
|
170
|
-
isInsideLinkEscape = word.startsWith(ANSI_ESCAPE_LINK, rawCharacterIndex + 1);
|
|
171
|
-
}
|
|
172
|
-
if (isInsideEscape) {
|
|
173
|
-
if (isInsideLinkEscape) {
|
|
174
|
-
if (character === ANSI_ESCAPE_BELL) {
|
|
175
|
-
isInsideEscape = false;
|
|
176
|
-
isInsideLinkEscape = false;
|
|
177
|
-
}
|
|
178
|
-
} else if (character === ANSI_SGR_TERMINATOR) isInsideEscape = false;
|
|
179
|
-
} else {
|
|
180
|
-
visible += characterLength;
|
|
181
|
-
if (visible === columns && !nextCharacter.done) {
|
|
182
|
-
rows.push("");
|
|
183
|
-
visible = 0;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
currentCharacter = nextCharacter;
|
|
187
|
-
nextCharacter = characters.next();
|
|
188
|
-
rawCharacterIndex += character.length;
|
|
189
|
-
}
|
|
190
|
-
lastRow = rows.at(-1);
|
|
191
|
-
if (!visible && lastRow !== void 0 && lastRow.length && rows.length > 1) rows[rows.length - 2] += rows.pop();
|
|
192
|
-
};
|
|
193
|
-
const stringVisibleTrimSpacesRight = (string) => {
|
|
194
|
-
const words = string.split(" ");
|
|
195
|
-
let last = words.length;
|
|
196
|
-
while (last) {
|
|
197
|
-
if (fastStringWidth(words[last - 1])) break;
|
|
198
|
-
last--;
|
|
199
|
-
}
|
|
200
|
-
if (last === words.length) return string;
|
|
201
|
-
return words.slice(0, last).join(" ") + words.slice(last).join("");
|
|
202
|
-
};
|
|
203
|
-
const exec = (string, columns, options = {}) => {
|
|
204
|
-
if (options.trim !== false && string.trim() === "") return "";
|
|
205
|
-
let returnValue = "";
|
|
206
|
-
let escapeCode;
|
|
207
|
-
let escapeUrl;
|
|
208
|
-
const words = string.split(" ");
|
|
209
|
-
let rows = [""];
|
|
210
|
-
let rowLength = 0;
|
|
211
|
-
for (let index = 0; index < words.length; index++) {
|
|
212
|
-
const word = words[index];
|
|
213
|
-
if (options.trim !== false) {
|
|
214
|
-
const row = rows.at(-1) ?? "";
|
|
215
|
-
const trimmed = row.trimStart();
|
|
216
|
-
if (row.length !== trimmed.length) {
|
|
217
|
-
rows[rows.length - 1] = trimmed;
|
|
218
|
-
rowLength = fastStringWidth(trimmed);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
if (index !== 0) {
|
|
222
|
-
if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
|
|
223
|
-
rows.push("");
|
|
224
|
-
rowLength = 0;
|
|
225
|
-
}
|
|
226
|
-
if (rowLength || options.trim === false) {
|
|
227
|
-
rows[rows.length - 1] += " ";
|
|
228
|
-
rowLength++;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
const wordLength = fastStringWidth(word);
|
|
232
|
-
if (options.hard && wordLength > columns) {
|
|
233
|
-
const remainingColumns = columns - rowLength;
|
|
234
|
-
const breaksStartingThisLine = 1 + Math.floor((wordLength - remainingColumns - 1) / columns);
|
|
235
|
-
if (Math.floor((wordLength - 1) / columns) < breaksStartingThisLine) rows.push("");
|
|
236
|
-
wrapWord(rows, word, columns);
|
|
237
|
-
rowLength = fastStringWidth(rows.at(-1) ?? "");
|
|
238
|
-
continue;
|
|
239
|
-
}
|
|
240
|
-
if (rowLength + wordLength > columns && rowLength && wordLength) {
|
|
241
|
-
if (options.wordWrap === false && rowLength < columns) {
|
|
242
|
-
wrapWord(rows, word, columns);
|
|
243
|
-
rowLength = fastStringWidth(rows.at(-1) ?? "");
|
|
244
|
-
continue;
|
|
245
|
-
}
|
|
246
|
-
rows.push("");
|
|
247
|
-
rowLength = 0;
|
|
248
|
-
}
|
|
249
|
-
if (rowLength + wordLength > columns && options.wordWrap === false) {
|
|
250
|
-
wrapWord(rows, word, columns);
|
|
251
|
-
rowLength = fastStringWidth(rows.at(-1) ?? "");
|
|
252
|
-
continue;
|
|
253
|
-
}
|
|
254
|
-
rows[rows.length - 1] += word;
|
|
255
|
-
rowLength += wordLength;
|
|
256
|
-
}
|
|
257
|
-
if (options.trim !== false) rows = rows.map((row) => stringVisibleTrimSpacesRight(row));
|
|
258
|
-
const preString = rows.join("\n");
|
|
259
|
-
let inSurrogate = false;
|
|
260
|
-
for (let i = 0; i < preString.length; i++) {
|
|
261
|
-
const character = preString[i];
|
|
262
|
-
returnValue += character;
|
|
263
|
-
if (!inSurrogate) {
|
|
264
|
-
inSurrogate = character >= "\ud800" && character <= "\udbff";
|
|
265
|
-
if (inSurrogate) continue;
|
|
266
|
-
} else inSurrogate = false;
|
|
267
|
-
if (character === ESC || character === CSI) {
|
|
268
|
-
GROUP_REGEX.lastIndex = i + 1;
|
|
269
|
-
const groups = GROUP_REGEX.exec(preString)?.groups;
|
|
270
|
-
if (groups?.code !== void 0) {
|
|
271
|
-
const code = Number.parseFloat(groups.code);
|
|
272
|
-
escapeCode = code === END_CODE ? void 0 : code;
|
|
273
|
-
} else if (groups?.uri !== void 0) escapeUrl = groups.uri.length === 0 ? void 0 : groups.uri;
|
|
274
|
-
}
|
|
275
|
-
if (preString[i + 1] === "\n") {
|
|
276
|
-
if (escapeUrl) returnValue += wrapAnsiHyperlink("");
|
|
277
|
-
const closingCode = escapeCode ? getClosingCode(escapeCode) : void 0;
|
|
278
|
-
if (escapeCode && closingCode) returnValue += wrapAnsiCode(closingCode);
|
|
279
|
-
} else if (character === "\n") {
|
|
280
|
-
if (escapeCode && getClosingCode(escapeCode)) returnValue += wrapAnsiCode(escapeCode);
|
|
281
|
-
if (escapeUrl) returnValue += wrapAnsiHyperlink(escapeUrl);
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
return returnValue;
|
|
285
|
-
};
|
|
286
|
-
const CRLF_OR_LF = /\r?\n/;
|
|
287
|
-
function wrapAnsi(string, columns, options) {
|
|
288
|
-
return String(string).normalize().split(CRLF_OR_LF).map((line) => exec(line, columns, options)).join("\n");
|
|
289
|
-
}
|
|
290
|
-
//#endregion
|
|
291
|
-
//#region node_modules/.pnpm/@clack+core@1.4.1/node_modules/@clack/core/dist/index.mjs
|
|
292
|
-
var import_src = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
293
|
-
const ESC = "\x1B";
|
|
294
|
-
const CSI = `${ESC}[`;
|
|
295
|
-
const beep = "\x07";
|
|
296
|
-
const cursor = {
|
|
297
|
-
to(x, y) {
|
|
298
|
-
if (!y) return `${CSI}${x + 1}G`;
|
|
299
|
-
return `${CSI}${y + 1};${x + 1}H`;
|
|
300
|
-
},
|
|
301
|
-
move(x, y) {
|
|
302
|
-
let ret = "";
|
|
303
|
-
if (x < 0) ret += `${CSI}${-x}D`;
|
|
304
|
-
else if (x > 0) ret += `${CSI}${x}C`;
|
|
305
|
-
if (y < 0) ret += `${CSI}${-y}A`;
|
|
306
|
-
else if (y > 0) ret += `${CSI}${y}B`;
|
|
307
|
-
return ret;
|
|
308
|
-
},
|
|
309
|
-
up: (count = 1) => `${CSI}${count}A`,
|
|
310
|
-
down: (count = 1) => `${CSI}${count}B`,
|
|
311
|
-
forward: (count = 1) => `${CSI}${count}C`,
|
|
312
|
-
backward: (count = 1) => `${CSI}${count}D`,
|
|
313
|
-
nextLine: (count = 1) => `${CSI}E`.repeat(count),
|
|
314
|
-
prevLine: (count = 1) => `${CSI}F`.repeat(count),
|
|
315
|
-
left: `${CSI}G`,
|
|
316
|
-
hide: `${CSI}?25l`,
|
|
317
|
-
show: `${CSI}?25h`,
|
|
318
|
-
save: `${ESC}7`,
|
|
319
|
-
restore: `${ESC}8`
|
|
320
|
-
};
|
|
321
|
-
module.exports = {
|
|
322
|
-
cursor,
|
|
323
|
-
scroll: {
|
|
324
|
-
up: (count = 1) => `${CSI}S`.repeat(count),
|
|
325
|
-
down: (count = 1) => `${CSI}T`.repeat(count)
|
|
326
|
-
},
|
|
327
|
-
erase: {
|
|
328
|
-
screen: `${CSI}2J`,
|
|
329
|
-
up: (count = 1) => `${CSI}1J`.repeat(count),
|
|
330
|
-
down: (count = 1) => `${CSI}J`.repeat(count),
|
|
331
|
-
line: `${CSI}2K`,
|
|
332
|
-
lineEnd: `${CSI}K`,
|
|
333
|
-
lineStart: `${CSI}1K`,
|
|
334
|
-
lines(count) {
|
|
335
|
-
let clear = "";
|
|
336
|
-
for (let i = 0; i < count; i++) clear += this.line + (i < count - 1 ? cursor.up() : "");
|
|
337
|
-
if (count) clear += cursor.left;
|
|
338
|
-
return clear;
|
|
339
|
-
}
|
|
340
|
-
},
|
|
341
|
-
beep
|
|
342
|
-
};
|
|
343
|
-
})))();
|
|
344
|
-
function findCursor(s, o, l) {
|
|
345
|
-
if (!l.some((r) => !r.disabled)) return s;
|
|
346
|
-
const t = s + o, n = Math.max(l.length - 1, 0), e = t < 0 ? n : t > n ? 0 : t;
|
|
347
|
-
return l[e].disabled ? findCursor(e, o < 0 ? -1 : 1, l) : e;
|
|
348
|
-
}
|
|
349
|
-
const settings = {
|
|
350
|
-
actions: new Set([
|
|
351
|
-
"up",
|
|
352
|
-
"down",
|
|
353
|
-
"left",
|
|
354
|
-
"right",
|
|
355
|
-
"space",
|
|
356
|
-
"enter",
|
|
357
|
-
"cancel"
|
|
358
|
-
]),
|
|
359
|
-
aliases: /* @__PURE__ */ new Map([
|
|
360
|
-
["k", "up"],
|
|
361
|
-
["j", "down"],
|
|
362
|
-
["h", "left"],
|
|
363
|
-
["l", "right"],
|
|
364
|
-
["", "cancel"],
|
|
365
|
-
["escape", "cancel"]
|
|
366
|
-
]),
|
|
367
|
-
messages: {
|
|
368
|
-
cancel: "Canceled",
|
|
369
|
-
error: "Something went wrong"
|
|
370
|
-
},
|
|
371
|
-
withGuide: true,
|
|
372
|
-
date: {
|
|
373
|
-
monthNames: [...[
|
|
374
|
-
"January",
|
|
375
|
-
"February",
|
|
376
|
-
"March",
|
|
377
|
-
"April",
|
|
378
|
-
"May",
|
|
379
|
-
"June",
|
|
380
|
-
"July",
|
|
381
|
-
"August",
|
|
382
|
-
"September",
|
|
383
|
-
"October",
|
|
384
|
-
"November",
|
|
385
|
-
"December"
|
|
386
|
-
]],
|
|
387
|
-
messages: {
|
|
388
|
-
required: "Please enter a valid date",
|
|
389
|
-
invalidMonth: "There are only 12 months in a year",
|
|
390
|
-
invalidDay: (n, e) => `There are only ${n} days in ${e}`,
|
|
391
|
-
afterMin: (n) => `Date must be on or after ${n.toISOString().slice(0, 10)}`,
|
|
392
|
-
beforeMax: (n) => `Date must be on or before ${n.toISOString().slice(0, 10)}`
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
};
|
|
396
|
-
function isActionKey(n, e) {
|
|
397
|
-
if (typeof n == "string") return settings.aliases.get(n) === e;
|
|
398
|
-
for (const s of n) if (s !== void 0 && isActionKey(s, e)) return true;
|
|
399
|
-
return false;
|
|
400
|
-
}
|
|
401
|
-
function diffLines(i, s) {
|
|
402
|
-
if (i === s) return;
|
|
403
|
-
const e = i.split(`
|
|
404
|
-
`), t = s.split(`
|
|
405
|
-
`), r = Math.max(e.length, t.length), f = [];
|
|
406
|
-
for (let n = 0; n < r; n++) e[n] !== t[n] && f.push(n);
|
|
407
|
-
return {
|
|
408
|
-
lines: f,
|
|
409
|
-
numLinesBefore: e.length,
|
|
410
|
-
numLinesAfter: t.length,
|
|
411
|
-
numLines: r
|
|
412
|
-
};
|
|
413
|
-
}
|
|
414
|
-
const R = globalThis.process.platform.startsWith("win");
|
|
415
|
-
const CANCEL_SYMBOL = Symbol("clack:cancel");
|
|
416
|
-
function isCancel(e) {
|
|
417
|
-
return e === CANCEL_SYMBOL;
|
|
418
|
-
}
|
|
419
|
-
function setRawMode(e, r) {
|
|
420
|
-
const o = e;
|
|
421
|
-
o.isTTY && o.setRawMode(r);
|
|
422
|
-
}
|
|
423
|
-
function block({ input: e = stdin, output: r = stdout, overwrite: o = true, hideCursor: t = true } = {}) {
|
|
424
|
-
const s = l.createInterface({
|
|
425
|
-
input: e,
|
|
426
|
-
output: r,
|
|
427
|
-
prompt: "",
|
|
428
|
-
tabSize: 1
|
|
429
|
-
});
|
|
430
|
-
l.emitKeypressEvents(e, s), e instanceof ReadStream && e.isTTY && e.setRawMode(true);
|
|
431
|
-
const n = (f, { name: a, sequence: p }) => {
|
|
432
|
-
if (isActionKey([
|
|
433
|
-
String(f),
|
|
434
|
-
a,
|
|
435
|
-
p
|
|
436
|
-
], "cancel")) {
|
|
437
|
-
t && r.write(import_src.cursor.show), process.exit(0);
|
|
438
|
-
return;
|
|
439
|
-
}
|
|
440
|
-
if (!o) return;
|
|
441
|
-
const i = a === "return" ? 0 : -1, m = a === "return" ? -1 : 0;
|
|
442
|
-
l.moveCursor(r, i, m, () => {
|
|
443
|
-
l.clearLine(r, 1, () => {
|
|
444
|
-
e.once("keypress", n);
|
|
445
|
-
});
|
|
446
|
-
});
|
|
447
|
-
};
|
|
448
|
-
return t && r.write(import_src.cursor.hide), e.once("keypress", n), () => {
|
|
449
|
-
e.off("keypress", n), t && r.write(import_src.cursor.show), e instanceof ReadStream && e.isTTY && !R && e.setRawMode(false), s.terminal = false, s.close();
|
|
450
|
-
};
|
|
451
|
-
}
|
|
452
|
-
const getColumns = (e) => "columns" in e && typeof e.columns == "number" ? e.columns : 80, getRows = (e) => "rows" in e && typeof e.rows == "number" ? e.rows : 20;
|
|
453
|
-
function wrapTextWithPrefix(e, r, o, t = o, s = o, n) {
|
|
454
|
-
return wrapAnsi(r, getColumns(e ?? stdout) - o.length, {
|
|
455
|
-
hard: true,
|
|
456
|
-
trim: false
|
|
457
|
-
}).split(`
|
|
458
|
-
`).map((c, i, m) => {
|
|
459
|
-
const d = n ? n(c, i) : c;
|
|
460
|
-
return i === 0 ? `${t}${d}` : i === m.length - 1 ? `${s}${d}` : `${o}${d}`;
|
|
461
|
-
}).join(`
|
|
462
|
-
`);
|
|
463
|
-
}
|
|
464
|
-
function runValidation(e, n) {
|
|
465
|
-
if ("~standard" in e) {
|
|
466
|
-
const a = e["~standard"].validate(n);
|
|
467
|
-
if (a instanceof Promise) throw new TypeError("Schema validation must be synchronous. Update `validate()` and remove any asynchronous logic.");
|
|
468
|
-
return a.issues?.at(0)?.message;
|
|
469
|
-
}
|
|
470
|
-
return e(n);
|
|
471
|
-
}
|
|
472
|
-
var V = class {
|
|
473
|
-
input;
|
|
474
|
-
output;
|
|
475
|
-
_abortSignal;
|
|
476
|
-
rl;
|
|
477
|
-
opts;
|
|
478
|
-
_render;
|
|
479
|
-
_track = false;
|
|
480
|
-
_prevFrame = "";
|
|
481
|
-
_subscribers = /* @__PURE__ */ new Map();
|
|
482
|
-
_cursor = 0;
|
|
483
|
-
state = "initial";
|
|
484
|
-
error = "";
|
|
485
|
-
value;
|
|
486
|
-
userInput = "";
|
|
487
|
-
constructor(t, e = true) {
|
|
488
|
-
const { input: i = stdin, output: n = stdout, render: s, signal: r, ...o } = t;
|
|
489
|
-
this.opts = o, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = s.bind(this), this._track = e, this._abortSignal = r, this.input = i, this.output = n;
|
|
490
|
-
}
|
|
491
|
-
/**
|
|
492
|
-
* Unsubscribe all listeners
|
|
493
|
-
*/
|
|
494
|
-
unsubscribe() {
|
|
495
|
-
this._subscribers.clear();
|
|
496
|
-
}
|
|
497
|
-
/**
|
|
498
|
-
* Set a subscriber with opts
|
|
499
|
-
* @param event - The event name
|
|
500
|
-
*/
|
|
501
|
-
setSubscriber(t, e) {
|
|
502
|
-
const i = this._subscribers.get(t) ?? [];
|
|
503
|
-
i.push(e), this._subscribers.set(t, i);
|
|
504
|
-
}
|
|
505
|
-
/**
|
|
506
|
-
* Subscribe to an event
|
|
507
|
-
* @param event - The event name
|
|
508
|
-
* @param cb - The callback
|
|
509
|
-
*/
|
|
510
|
-
on(t, e) {
|
|
511
|
-
this.setSubscriber(t, { cb: e });
|
|
512
|
-
}
|
|
513
|
-
/**
|
|
514
|
-
* Subscribe to an event once
|
|
515
|
-
* @param event - The event name
|
|
516
|
-
* @param cb - The callback
|
|
517
|
-
*/
|
|
518
|
-
once(t, e) {
|
|
519
|
-
this.setSubscriber(t, {
|
|
520
|
-
cb: e,
|
|
521
|
-
once: true
|
|
522
|
-
});
|
|
523
|
-
}
|
|
524
|
-
/**
|
|
525
|
-
* Emit an event with data
|
|
526
|
-
* @param event - The event name
|
|
527
|
-
* @param data - The data to pass to the callback
|
|
528
|
-
*/
|
|
529
|
-
emit(t, ...e) {
|
|
530
|
-
const i = this._subscribers.get(t) ?? [], n = [];
|
|
531
|
-
for (const s of i) s.cb(...e), s.once && n.push(() => i.splice(i.indexOf(s), 1));
|
|
532
|
-
for (const s of n) s();
|
|
533
|
-
}
|
|
534
|
-
prompt() {
|
|
535
|
-
return new Promise((t) => {
|
|
536
|
-
if (this._abortSignal) {
|
|
537
|
-
if (this._abortSignal.aborted) return this.state = "cancel", this.close(), t(CANCEL_SYMBOL);
|
|
538
|
-
this._abortSignal.addEventListener("abort", () => {
|
|
539
|
-
this.state = "cancel", this.close();
|
|
540
|
-
}, { once: true });
|
|
541
|
-
}
|
|
542
|
-
this.rl = f.createInterface({
|
|
543
|
-
input: this.input,
|
|
544
|
-
tabSize: 2,
|
|
545
|
-
prompt: "",
|
|
546
|
-
escapeCodeTimeout: 50,
|
|
547
|
-
terminal: true
|
|
548
|
-
}), this.rl.prompt(), this.opts.initialUserInput !== void 0 && this._setUserInput(this.opts.initialUserInput, true), this.input.on("keypress", this.onKeypress), setRawMode(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
|
|
549
|
-
this.output.write(import_src.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t(this.value);
|
|
550
|
-
}), this.once("cancel", () => {
|
|
551
|
-
this.output.write(import_src.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t(CANCEL_SYMBOL);
|
|
552
|
-
});
|
|
553
|
-
});
|
|
554
|
-
}
|
|
555
|
-
_isActionKey(t, e) {
|
|
556
|
-
return t === " ";
|
|
557
|
-
}
|
|
558
|
-
_shouldSubmit(t, e) {
|
|
559
|
-
return true;
|
|
560
|
-
}
|
|
561
|
-
_setValue(t) {
|
|
562
|
-
this.value = t, this.emit("value", this.value);
|
|
563
|
-
}
|
|
564
|
-
_setUserInput(t, e) {
|
|
565
|
-
this.userInput = t ?? "", this.emit("userInput", this.userInput), e && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
|
|
566
|
-
}
|
|
567
|
-
_clearUserInput() {
|
|
568
|
-
this.rl?.write(null, {
|
|
569
|
-
ctrl: true,
|
|
570
|
-
name: "u"
|
|
571
|
-
}), this._setUserInput("");
|
|
572
|
-
}
|
|
573
|
-
onKeypress(t, e) {
|
|
574
|
-
if (this._track && e.name !== "return" && (e.name && this._isActionKey(t, e) && this.rl?.write(null, {
|
|
575
|
-
ctrl: true,
|
|
576
|
-
name: "h"
|
|
577
|
-
}), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), e?.name && (!this._track && settings.aliases.has(e.name) && this.emit("cursor", settings.aliases.get(e.name)), settings.actions.has(e.name) && this.emit("cursor", e.name)), t && (t.toLowerCase() === "y" || t.toLowerCase() === "n") && this.emit("confirm", t.toLowerCase() === "y"), this.emit("key", t, e), e?.name === "return" && this._shouldSubmit(t, e)) {
|
|
578
|
-
if (this.opts.validate) {
|
|
579
|
-
const i = runValidation(this.opts.validate, this.value);
|
|
580
|
-
i && (this.error = i instanceof Error ? i.message : i, this.state = "error", this.rl?.write(this.userInput));
|
|
581
|
-
}
|
|
582
|
-
this.state !== "error" && (this.state = "submit");
|
|
583
|
-
}
|
|
584
|
-
isActionKey([
|
|
585
|
-
t,
|
|
586
|
-
e?.name,
|
|
587
|
-
e?.sequence
|
|
588
|
-
], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
|
|
589
|
-
}
|
|
590
|
-
close() {
|
|
591
|
-
this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
|
|
592
|
-
`), setRawMode(this.input, false), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
|
|
593
|
-
}
|
|
594
|
-
restoreCursor() {
|
|
595
|
-
const t = wrapAnsi(this._prevFrame, process.stdout.columns, {
|
|
596
|
-
hard: true,
|
|
597
|
-
trim: false
|
|
598
|
-
}).split(`
|
|
599
|
-
`).length - 1;
|
|
600
|
-
this.output.write(import_src.cursor.move(-999, t * -1));
|
|
601
|
-
}
|
|
602
|
-
render() {
|
|
603
|
-
const t = wrapAnsi(this._render(this) ?? "", process.stdout.columns, {
|
|
604
|
-
hard: true,
|
|
605
|
-
trim: false
|
|
606
|
-
});
|
|
607
|
-
if (t !== this._prevFrame) {
|
|
608
|
-
if (this.state === "initial") this.output.write(import_src.cursor.hide);
|
|
609
|
-
else {
|
|
610
|
-
const e = diffLines(this._prevFrame, t), i = getRows(this.output);
|
|
611
|
-
if (this.restoreCursor(), e) {
|
|
612
|
-
const n = Math.max(0, e.numLinesAfter - i), s = Math.max(0, e.numLinesBefore - i);
|
|
613
|
-
let r = e.lines.find((o) => o >= n);
|
|
614
|
-
if (r === void 0) {
|
|
615
|
-
this._prevFrame = t;
|
|
616
|
-
return;
|
|
617
|
-
}
|
|
618
|
-
if (e.lines.length === 1) {
|
|
619
|
-
this.output.write(import_src.cursor.move(0, r - s)), this.output.write(import_src.erase.lines(1));
|
|
620
|
-
const o = t.split(`
|
|
621
|
-
`);
|
|
622
|
-
this.output.write(o[r]), this._prevFrame = t, this.output.write(import_src.cursor.move(0, o.length - r - 1));
|
|
623
|
-
return;
|
|
624
|
-
} else if (e.lines.length > 1) {
|
|
625
|
-
if (n < s) r = n;
|
|
626
|
-
else {
|
|
627
|
-
const h = r - s;
|
|
628
|
-
h > 0 && this.output.write(import_src.cursor.move(0, h));
|
|
629
|
-
}
|
|
630
|
-
this.output.write(import_src.erase.down());
|
|
631
|
-
const f = t.split(`
|
|
632
|
-
`).slice(r);
|
|
633
|
-
this.output.write(f.join(`
|
|
634
|
-
`)), this._prevFrame = t;
|
|
635
|
-
return;
|
|
636
|
-
}
|
|
637
|
-
}
|
|
638
|
-
this.output.write(import_src.erase.down());
|
|
639
|
-
}
|
|
640
|
-
this.output.write(t), this.state === "initial" && (this.state = "active"), this._prevFrame = t;
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
};
|
|
644
|
-
function p$1(l, e) {
|
|
645
|
-
if (l === void 0 || e.length === 0) return 0;
|
|
646
|
-
const i = e.findIndex((s) => s.value === l);
|
|
647
|
-
return i !== -1 ? i : 0;
|
|
648
|
-
}
|
|
649
|
-
function g(l, e) {
|
|
650
|
-
return (e.label ?? String(e.value)).toLowerCase().includes(l.toLowerCase());
|
|
651
|
-
}
|
|
652
|
-
function m(l, e) {
|
|
653
|
-
if (e) return l ? e : e[0];
|
|
654
|
-
}
|
|
655
|
-
let T$1 = class T extends V {
|
|
656
|
-
filteredOptions;
|
|
657
|
-
multiple;
|
|
658
|
-
isNavigating = false;
|
|
659
|
-
selectedValues = [];
|
|
660
|
-
focusedValue;
|
|
661
|
-
#e = 0;
|
|
662
|
-
#s = "";
|
|
663
|
-
#t;
|
|
664
|
-
#i;
|
|
665
|
-
#n;
|
|
666
|
-
get cursor() {
|
|
667
|
-
return this.#e;
|
|
668
|
-
}
|
|
669
|
-
get userInputWithCursor() {
|
|
670
|
-
if (!this.userInput) return styleText(["inverse", "hidden"], "_");
|
|
671
|
-
if (this._cursor >= this.userInput.length) return `${this.userInput}\u2588`;
|
|
672
|
-
const e = this.userInput.slice(0, this._cursor), [t, ...i] = this.userInput.slice(this._cursor);
|
|
673
|
-
return `${e}${styleText("inverse", t)}${i.join("")}`;
|
|
674
|
-
}
|
|
675
|
-
get options() {
|
|
676
|
-
return typeof this.#i == "function" ? this.#i() : this.#i;
|
|
677
|
-
}
|
|
678
|
-
constructor(e) {
|
|
679
|
-
super(e), this.#i = e.options, this.#n = e.placeholder;
|
|
680
|
-
const t = this.options;
|
|
681
|
-
this.filteredOptions = [...t], this.multiple = e.multiple === true, this.#t = typeof e.options == "function" ? e.filter : e.filter ?? g;
|
|
682
|
-
let i;
|
|
683
|
-
if (e.initialValue && Array.isArray(e.initialValue) ? this.multiple ? i = e.initialValue : i = e.initialValue.slice(0, 1) : !this.multiple && this.options.length > 0 && (i = [this.options[0].value]), i) for (const s of i) {
|
|
684
|
-
const n = t.findIndex((o) => o.value === s);
|
|
685
|
-
n !== -1 && (this.toggleSelected(s), this.#e = n);
|
|
686
|
-
}
|
|
687
|
-
this.focusedValue = this.options[this.#e]?.value, this.on("key", (s, n) => this.#l(s, n)), this.on("userInput", (s) => this.#u(s));
|
|
688
|
-
}
|
|
689
|
-
_isActionKey(e, t) {
|
|
690
|
-
return e === " " || this.multiple && this.isNavigating && t.name === "space" && e !== void 0 && e !== "";
|
|
691
|
-
}
|
|
692
|
-
#l(e, t) {
|
|
693
|
-
const i = t.name === "up", s = t.name === "down", n = t.name === "return", o = this.userInput === "" || this.userInput === " ", u = this.#n, h = this.options, f = u !== void 0 && u !== "" && h.some((r) => !r.disabled && (this.#t ? this.#t(u, r) : true));
|
|
694
|
-
if (t.name === "tab" && o && f) {
|
|
695
|
-
this.userInput === " " && this._clearUserInput(), this._setUserInput(u, true), this.isNavigating = false;
|
|
696
|
-
return;
|
|
697
|
-
}
|
|
698
|
-
i || s ? (this.#e = findCursor(this.#e, i ? -1 : 1, this.filteredOptions), this.focusedValue = this.filteredOptions[this.#e]?.value, this.multiple || (this.selectedValues = [this.focusedValue]), this.isNavigating = true) : n ? this.value = m(this.multiple, this.selectedValues) : this.multiple ? this.focusedValue !== void 0 && (t.name === "tab" || this.isNavigating && t.name === "space") ? this.toggleSelected(this.focusedValue) : this.isNavigating = false : (this.focusedValue && (this.selectedValues = [this.focusedValue]), this.isNavigating = false);
|
|
699
|
-
}
|
|
700
|
-
deselectAll() {
|
|
701
|
-
this.selectedValues = [];
|
|
702
|
-
}
|
|
703
|
-
toggleSelected(e) {
|
|
704
|
-
this.filteredOptions.length !== 0 && (this.multiple ? this.selectedValues.includes(e) ? this.selectedValues = this.selectedValues.filter((t) => t !== e) : this.selectedValues = [...this.selectedValues, e] : this.selectedValues = [e]);
|
|
705
|
-
}
|
|
706
|
-
#u(e) {
|
|
707
|
-
if (e !== this.#s) {
|
|
708
|
-
this.#s = e;
|
|
709
|
-
const t = this.options;
|
|
710
|
-
e && this.#t ? this.filteredOptions = t.filter((n) => this.#t?.(e, n)) : this.filteredOptions = [...t];
|
|
711
|
-
const i = p$1(this.focusedValue, this.filteredOptions);
|
|
712
|
-
this.#e = findCursor(i, 0, this.filteredOptions);
|
|
713
|
-
const s = this.filteredOptions[this.#e];
|
|
714
|
-
s && !s.disabled ? this.focusedValue = s.value : this.focusedValue = void 0, this.multiple || (this.focusedValue !== void 0 ? this.toggleSelected(this.focusedValue) : this.deselectAll());
|
|
715
|
-
}
|
|
716
|
-
}
|
|
717
|
-
};
|
|
718
|
-
var r = class extends V {
|
|
719
|
-
get cursor() {
|
|
720
|
-
return this.value ? 0 : 1;
|
|
721
|
-
}
|
|
722
|
-
get _value() {
|
|
723
|
-
return this.cursor === 0;
|
|
724
|
-
}
|
|
725
|
-
constructor(t) {
|
|
726
|
-
super(t, false), this.value = !!t.initialValue, this.on("userInput", () => {
|
|
727
|
-
this.value = this._value;
|
|
728
|
-
}), this.on("confirm", (i) => {
|
|
729
|
-
this.output.write(import_src.cursor.move(0, -1)), this.value = i, this.state = "submit", this.close();
|
|
730
|
-
}), this.on("cursor", () => {
|
|
731
|
-
this.value = !this.value;
|
|
732
|
-
});
|
|
733
|
-
}
|
|
734
|
-
};
|
|
735
|
-
let a$1 = class a extends V {
|
|
736
|
-
options;
|
|
737
|
-
cursor = 0;
|
|
738
|
-
get _value() {
|
|
739
|
-
return this.options[this.cursor].value;
|
|
740
|
-
}
|
|
741
|
-
get _enabledOptions() {
|
|
742
|
-
return this.options.filter((e) => e.disabled !== true);
|
|
743
|
-
}
|
|
744
|
-
toggleAll() {
|
|
745
|
-
const e = this._enabledOptions, i = this.value !== void 0 && this.value.length === e.length;
|
|
746
|
-
this.value = i ? [] : e.map((t) => t.value);
|
|
747
|
-
}
|
|
748
|
-
toggleInvert() {
|
|
749
|
-
const e = this.value;
|
|
750
|
-
if (!e) return;
|
|
751
|
-
const i = this._enabledOptions.filter((t) => !e.includes(t.value));
|
|
752
|
-
this.value = i.map((t) => t.value);
|
|
753
|
-
}
|
|
754
|
-
toggleValue() {
|
|
755
|
-
this.value === void 0 && (this.value = []);
|
|
756
|
-
const e = this.value.includes(this._value);
|
|
757
|
-
this.value = e ? this.value.filter((i) => i !== this._value) : [...this.value, this._value];
|
|
758
|
-
}
|
|
759
|
-
constructor(e) {
|
|
760
|
-
super(e, false), this.options = e.options, this.value = [...e.initialValues ?? []];
|
|
761
|
-
const i = Math.max(this.options.findIndex(({ value: t }) => t === e.cursorAt), 0);
|
|
762
|
-
this.cursor = this.options[i].disabled ? findCursor(i, 1, this.options) : i, this.on("key", (t, l) => {
|
|
763
|
-
l.name === "a" && this.toggleAll(), l.name === "i" && this.toggleInvert();
|
|
764
|
-
}), this.on("cursor", (t) => {
|
|
765
|
-
switch (t) {
|
|
766
|
-
case "left":
|
|
767
|
-
case "up":
|
|
768
|
-
this.cursor = findCursor(this.cursor, -1, this.options);
|
|
769
|
-
break;
|
|
770
|
-
case "down":
|
|
771
|
-
case "right":
|
|
772
|
-
this.cursor = findCursor(this.cursor, 1, this.options);
|
|
773
|
-
break;
|
|
774
|
-
case "space":
|
|
775
|
-
this.toggleValue();
|
|
776
|
-
break;
|
|
777
|
-
}
|
|
778
|
-
});
|
|
779
|
-
}
|
|
780
|
-
};
|
|
781
|
-
var a = class extends V {
|
|
782
|
-
options;
|
|
783
|
-
cursor = 0;
|
|
784
|
-
get _selectedValue() {
|
|
785
|
-
return this.options[this.cursor];
|
|
786
|
-
}
|
|
787
|
-
changeValue() {
|
|
788
|
-
this.value = this._selectedValue.value;
|
|
789
|
-
}
|
|
790
|
-
constructor(t) {
|
|
791
|
-
super(t, false), this.options = t.options;
|
|
792
|
-
const i = this.options.findIndex(({ value: s }) => s === t.initialValue), e = i === -1 ? 0 : i;
|
|
793
|
-
this.cursor = this.options[e].disabled ? findCursor(e, 1, this.options) : e, this.changeValue(), this.on("cursor", (s) => {
|
|
794
|
-
switch (s) {
|
|
795
|
-
case "left":
|
|
796
|
-
case "up":
|
|
797
|
-
this.cursor = findCursor(this.cursor, -1, this.options);
|
|
798
|
-
break;
|
|
799
|
-
case "down":
|
|
800
|
-
case "right":
|
|
801
|
-
this.cursor = findCursor(this.cursor, 1, this.options);
|
|
802
|
-
break;
|
|
803
|
-
}
|
|
804
|
-
this.changeValue();
|
|
805
|
-
});
|
|
806
|
-
}
|
|
807
|
-
};
|
|
808
|
-
var n = class extends V {
|
|
809
|
-
get userInputWithCursor() {
|
|
810
|
-
if (this.state === "submit") return this.userInput;
|
|
811
|
-
const t = this.userInput;
|
|
812
|
-
if (this.cursor >= t.length) return `${this.userInput}\u2588`;
|
|
813
|
-
const e = t.slice(0, this.cursor), [s, ...r] = t.slice(this.cursor);
|
|
814
|
-
return `${e}${styleText("inverse", s)}${r.join("")}`;
|
|
815
|
-
}
|
|
816
|
-
get cursor() {
|
|
817
|
-
return this._cursor;
|
|
818
|
-
}
|
|
819
|
-
constructor(t) {
|
|
820
|
-
super({
|
|
821
|
-
...t,
|
|
822
|
-
initialUserInput: t.initialUserInput ?? t.initialValue
|
|
823
|
-
}), this.on("userInput", (e) => {
|
|
824
|
-
this._setValue(e);
|
|
825
|
-
}), this.on("finalize", () => {
|
|
826
|
-
this.value || (this.value = t.defaultValue), this.value === void 0 && (this.value = "");
|
|
827
|
-
});
|
|
828
|
-
}
|
|
829
|
-
};
|
|
830
|
-
//#endregion
|
|
831
|
-
//#region node_modules/.pnpm/@clack+prompts@1.5.1/node_modules/@clack/prompts/dist/index.mjs
|
|
832
|
-
function isUnicodeSupported() {
|
|
833
|
-
if (process$1.platform !== "win32") return process$1.env.TERM !== "linux";
|
|
834
|
-
return Boolean(process$1.env.CI) || Boolean(process$1.env.WT_SESSION) || Boolean(process$1.env.TERMINUS_SUBLIME) || process$1.env.ConEmuTask === "{cmd::Cmder}" || process$1.env.TERM_PROGRAM === "Terminus-Sublime" || process$1.env.TERM_PROGRAM === "vscode" || process$1.env.TERM === "xterm-256color" || process$1.env.TERM === "alacritty" || process$1.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
835
|
-
}
|
|
836
|
-
const unicode = isUnicodeSupported(), isCI = () => process.env.CI === "true", unicodeOr = (e, o) => unicode ? e : o, S_STEP_ACTIVE = unicodeOr("◆", "*"), S_STEP_CANCEL = unicodeOr("■", "x"), S_STEP_ERROR = unicodeOr("▲", "x"), S_STEP_SUBMIT = unicodeOr("◇", "o"), S_BAR_START = unicodeOr("┌", "T"), S_BAR = unicodeOr("│", "|"), S_BAR_END = unicodeOr("└", "—"), S_RADIO_ACTIVE = unicodeOr("●", ">"), S_RADIO_INACTIVE = unicodeOr("○", " "), S_CHECKBOX_ACTIVE = unicodeOr("◻", "[•]"), S_CHECKBOX_SELECTED = unicodeOr("◼", "[+]"), S_CHECKBOX_INACTIVE = unicodeOr("◻", "[ ]"), S_BAR_H = unicodeOr("─", "-"), S_CORNER_TOP_RIGHT = unicodeOr("╮", "+"), S_CONNECT_LEFT = unicodeOr("├", "+"), S_CORNER_BOTTOM_RIGHT = unicodeOr("╯", "+"), S_CORNER_BOTTOM_LEFT = unicodeOr("╰", "+"), S_INFO = unicodeOr("●", "•"), S_SUCCESS = unicodeOr("◆", "*"), S_WARN = unicodeOr("▲", "!"), S_ERROR = unicodeOr("■", "x"), symbol = (e) => {
|
|
837
|
-
switch (e) {
|
|
838
|
-
case "initial":
|
|
839
|
-
case "active": return styleText("cyan", S_STEP_ACTIVE);
|
|
840
|
-
case "cancel": return styleText("red", S_STEP_CANCEL);
|
|
841
|
-
case "error": return styleText("yellow", S_STEP_ERROR);
|
|
842
|
-
case "submit": return styleText("green", S_STEP_SUBMIT);
|
|
843
|
-
}
|
|
844
|
-
}, symbolBar = (e) => {
|
|
845
|
-
switch (e) {
|
|
846
|
-
case "initial":
|
|
847
|
-
case "active": return styleText("cyan", S_BAR);
|
|
848
|
-
case "cancel": return styleText("red", S_BAR);
|
|
849
|
-
case "error": return styleText("yellow", S_BAR);
|
|
850
|
-
case "submit": return styleText("green", S_BAR);
|
|
851
|
-
}
|
|
852
|
-
};
|
|
853
|
-
const E$1 = (l, o, g, c, h, O = false) => {
|
|
854
|
-
let r = o, w = 0;
|
|
855
|
-
if (O) for (let i = c - 1; i >= g && (r -= l[i].length, w++, !(r <= h)); i--);
|
|
856
|
-
else for (let i = g; i < c && (r -= l[i].length, w++, !(r <= h)); i++);
|
|
857
|
-
return {
|
|
858
|
-
lineCount: r,
|
|
859
|
-
removals: w
|
|
860
|
-
};
|
|
861
|
-
};
|
|
862
|
-
const limitOptions = ({ cursor: l, options: o, style: g, output: c = process.stdout, maxItems: h = Number.POSITIVE_INFINITY, columnPadding: O = 0, rowPadding: r = 4 }) => {
|
|
863
|
-
const i = getColumns(c) - O, I = getRows(c), C = styleText("dim", "..."), x = Math.max(I - r, 0), m = Math.max(Math.min(h, x), 5);
|
|
864
|
-
let p = 0;
|
|
865
|
-
l >= m - 3 && (p = Math.max(Math.min(l - m + 3, o.length - m), 0));
|
|
866
|
-
let f = m < o.length && p > 0, u = m < o.length && p + m < o.length;
|
|
867
|
-
const W = Math.min(p + m, o.length), e = [];
|
|
868
|
-
let d = 0;
|
|
869
|
-
f && d++, u && d++;
|
|
870
|
-
const v = p + (f ? 1 : 0), P = W - (u ? 1 : 0);
|
|
871
|
-
for (let t = v; t < P; t++) {
|
|
872
|
-
const n = wrapAnsi(g(o[t], t === l), i, {
|
|
873
|
-
hard: true,
|
|
874
|
-
trim: false
|
|
875
|
-
}).split(`
|
|
876
|
-
`);
|
|
877
|
-
e.push(n), d += n.length;
|
|
878
|
-
}
|
|
879
|
-
if (d > x) {
|
|
880
|
-
let t = 0, n = 0, s = d;
|
|
881
|
-
const M = l - v;
|
|
882
|
-
let a = x;
|
|
883
|
-
const T = () => E$1(e, s, 0, M, a), L = () => E$1(e, s, M + 1, e.length, a, true);
|
|
884
|
-
f ? ({lineCount: s, removals: t} = T(), s > a && (u || (a -= 1), {lineCount: s, removals: n} = L())) : (u || (a -= 1), {lineCount: s, removals: n} = L(), s > a && (a -= 1, {lineCount: s, removals: t} = T())), t > 0 && (f = true, e.splice(0, t)), n > 0 && (u = true, e.splice(e.length - n, n));
|
|
885
|
-
}
|
|
886
|
-
const b = [];
|
|
887
|
-
f && b.push(C);
|
|
888
|
-
for (const t of e) for (const n of t) b.push(n);
|
|
889
|
-
return u && b.push(C), b;
|
|
890
|
-
};
|
|
891
|
-
function P(t) {
|
|
892
|
-
return t.label ?? String(t.value ?? "");
|
|
893
|
-
}
|
|
894
|
-
function E(t, c) {
|
|
895
|
-
if (!t) return true;
|
|
896
|
-
const n = (c.label ?? String(c.value ?? "")).toLowerCase(), i = (c.hint ?? "").toLowerCase(), l = String(c.value).toLowerCase(), o = t.toLowerCase();
|
|
897
|
-
return n.includes(o) || i.includes(o) || l.includes(o);
|
|
898
|
-
}
|
|
899
|
-
function N(t, c) {
|
|
900
|
-
const n = [];
|
|
901
|
-
for (const i of c) t.includes(i.value) && n.push(i);
|
|
902
|
-
return n;
|
|
903
|
-
}
|
|
904
|
-
const autocomplete = (t) => new T$1({
|
|
905
|
-
options: t.options,
|
|
906
|
-
initialValue: t.initialValue ? [t.initialValue] : void 0,
|
|
907
|
-
initialUserInput: t.initialUserInput,
|
|
908
|
-
placeholder: t.placeholder,
|
|
909
|
-
filter: t.filter ?? ((n, i) => E(n, i)),
|
|
910
|
-
signal: t.signal,
|
|
911
|
-
input: t.input,
|
|
912
|
-
output: t.output,
|
|
913
|
-
validate: t.validate,
|
|
914
|
-
render() {
|
|
915
|
-
const n = t.withGuide ?? settings.withGuide, i = n ? [`${styleText("gray", S_BAR)}`, `${symbol(this.state)} ${t.message}`] : [`${symbol(this.state)} ${t.message}`], l = this.userInput, o = this.options, m = t.placeholder, p = l === "" && m !== void 0, $ = (r, s) => {
|
|
916
|
-
const a = P(r), u = r.hint && r.value === this.focusedValue ? styleText("dim", ` (${r.hint})`) : "";
|
|
917
|
-
switch (s) {
|
|
918
|
-
case "active": return `${styleText("green", S_RADIO_ACTIVE)} ${a}${u}`;
|
|
919
|
-
case "inactive": return `${styleText("dim", S_RADIO_INACTIVE)} ${styleText("dim", a)}`;
|
|
920
|
-
case "disabled": return `${styleText("gray", S_RADIO_INACTIVE)} ${styleText(["strikethrough", "gray"], a)}`;
|
|
921
|
-
}
|
|
922
|
-
};
|
|
923
|
-
switch (this.state) {
|
|
924
|
-
case "submit": {
|
|
925
|
-
const r = N(this.selectedValues, o), s = r.length > 0 ? ` ${styleText("dim", r.map(P).join(", "))}` : "", a = n ? styleText("gray", S_BAR) : "";
|
|
926
|
-
return `${i.join(`
|
|
927
|
-
`)}
|
|
928
|
-
${a}${s}`;
|
|
929
|
-
}
|
|
930
|
-
case "cancel": {
|
|
931
|
-
const r = l ? ` ${styleText(["strikethrough", "dim"], l)}` : "", s = n ? styleText("gray", S_BAR) : "";
|
|
932
|
-
return `${i.join(`
|
|
933
|
-
`)}
|
|
934
|
-
${s}${r}`;
|
|
935
|
-
}
|
|
936
|
-
default: {
|
|
937
|
-
const r = this.state === "error" ? "yellow" : "cyan", s = n ? `${styleText(r, S_BAR)} ` : "", a = n ? styleText(r, S_BAR_END) : "";
|
|
938
|
-
let u = "";
|
|
939
|
-
if (this.isNavigating || p) {
|
|
940
|
-
const d = p ? m : l;
|
|
941
|
-
u = d !== "" ? ` ${styleText("dim", d)}` : "";
|
|
942
|
-
} else u = ` ${this.userInputWithCursor}`;
|
|
943
|
-
const V = this.filteredOptions.length !== o.length ? styleText("dim", ` (${this.filteredOptions.length} match${this.filteredOptions.length === 1 ? "" : "es"})`) : "", y = this.filteredOptions.length === 0 && l ? [`${s}${styleText("yellow", "No matches found")}`] : [], b = this.state === "error" ? [`${s}${styleText("yellow", this.error)}`] : [];
|
|
944
|
-
n && i.push(`${s.trimEnd()}`), i.push(`${s}${styleText("dim", "Search:")}${u}${V}`, ...y, ...b);
|
|
945
|
-
const g = [`${s}${[
|
|
946
|
-
`${styleText("dim", "↑/↓")} to select`,
|
|
947
|
-
`${styleText("dim", "Enter:")} confirm`,
|
|
948
|
-
`${styleText("dim", "Type:")} to search`
|
|
949
|
-
].join(" • ")}`, a], O = this.filteredOptions.length === 0 ? [] : limitOptions({
|
|
950
|
-
cursor: this.cursor,
|
|
951
|
-
options: this.filteredOptions,
|
|
952
|
-
columnPadding: n ? 3 : 0,
|
|
953
|
-
rowPadding: i.length + g.length,
|
|
954
|
-
style: (d, f) => $(d, d.disabled ? "disabled" : f ? "active" : "inactive"),
|
|
955
|
-
maxItems: t.maxItems,
|
|
956
|
-
output: t.output
|
|
957
|
-
});
|
|
958
|
-
return [
|
|
959
|
-
...i,
|
|
960
|
-
...O.map((d) => `${s}${d}`),
|
|
961
|
-
...g
|
|
962
|
-
].join(`
|
|
963
|
-
`);
|
|
964
|
-
}
|
|
965
|
-
}
|
|
966
|
-
}
|
|
967
|
-
}).prompt();
|
|
968
|
-
const confirm = (i) => {
|
|
969
|
-
const a = i.active ?? "Yes", s = i.inactive ?? "No";
|
|
970
|
-
return new r({
|
|
971
|
-
active: a,
|
|
972
|
-
inactive: s,
|
|
973
|
-
signal: i.signal,
|
|
974
|
-
input: i.input,
|
|
975
|
-
output: i.output,
|
|
976
|
-
initialValue: i.initialValue ?? true,
|
|
977
|
-
render() {
|
|
978
|
-
const e = i.withGuide ?? settings.withGuide, u = `${symbol(this.state)} `, l = e ? `${styleText("gray", S_BAR)} ` : "", f = wrapTextWithPrefix(i.output, i.message, l, u), o = `${e ? `${styleText("gray", S_BAR)}
|
|
979
|
-
` : ""}${f}
|
|
980
|
-
`, c = this.value ? a : s;
|
|
981
|
-
switch (this.state) {
|
|
982
|
-
case "submit": return `${o}${e ? `${styleText("gray", S_BAR)} ` : ""}${styleText("dim", c)}`;
|
|
983
|
-
case "cancel": return `${o}${e ? `${styleText("gray", S_BAR)} ` : ""}${styleText(["strikethrough", "dim"], c)}${e ? `
|
|
984
|
-
${styleText("gray", S_BAR)}` : ""}`;
|
|
985
|
-
default: {
|
|
986
|
-
const r = e ? `${styleText("cyan", S_BAR)} ` : "", g = e ? styleText("cyan", S_BAR_END) : "";
|
|
987
|
-
return `${o}${r}${this.value ? `${styleText("green", S_RADIO_ACTIVE)} ${a}` : `${styleText("dim", S_RADIO_INACTIVE)} ${styleText("dim", a)}`}${i.vertical ? e ? `
|
|
988
|
-
${styleText("cyan", S_BAR)} ` : `
|
|
989
|
-
` : ` ${styleText("dim", "/")} `}${this.value ? `${styleText("dim", S_RADIO_INACTIVE)} ${styleText("dim", s)}` : `${styleText("green", S_RADIO_ACTIVE)} ${s}`}
|
|
990
|
-
${g}
|
|
991
|
-
`;
|
|
992
|
-
}
|
|
993
|
-
}
|
|
994
|
-
}
|
|
995
|
-
}).prompt();
|
|
996
|
-
};
|
|
997
|
-
const log = {
|
|
998
|
-
message: (s = [], { symbol: e = styleText("gray", S_BAR), secondarySymbol: r = styleText("gray", S_BAR), output: m = process.stdout, spacing: l = 1, withGuide: c } = {}) => {
|
|
999
|
-
const t = [], o = c ?? settings.withGuide, f = o ? r : "", O = o ? `${e} ` : "", u = o ? `${r} ` : "";
|
|
1000
|
-
for (let i = 0; i < l; i++) t.push(f);
|
|
1001
|
-
const g = Array.isArray(s) ? s : s.split(`
|
|
1002
|
-
`);
|
|
1003
|
-
if (g.length > 0) {
|
|
1004
|
-
const [i, ...y] = g;
|
|
1005
|
-
i.length > 0 ? t.push(`${O}${i}`) : t.push(o ? e : "");
|
|
1006
|
-
for (const p of y) p.length > 0 ? t.push(`${u}${p}`) : t.push(o ? r : "");
|
|
1007
|
-
}
|
|
1008
|
-
m.write(`${t.join(`
|
|
1009
|
-
`)}
|
|
1010
|
-
`);
|
|
1011
|
-
},
|
|
1012
|
-
info: (s, e) => {
|
|
1013
|
-
log.message(s, {
|
|
1014
|
-
...e,
|
|
1015
|
-
symbol: styleText("blue", S_INFO)
|
|
1016
|
-
});
|
|
1017
|
-
},
|
|
1018
|
-
success: (s, e) => {
|
|
1019
|
-
log.message(s, {
|
|
1020
|
-
...e,
|
|
1021
|
-
symbol: styleText("green", S_SUCCESS)
|
|
1022
|
-
});
|
|
1023
|
-
},
|
|
1024
|
-
step: (s, e) => {
|
|
1025
|
-
log.message(s, {
|
|
1026
|
-
...e,
|
|
1027
|
-
symbol: styleText("green", S_STEP_SUBMIT)
|
|
1028
|
-
});
|
|
1029
|
-
},
|
|
1030
|
-
warn: (s, e) => {
|
|
1031
|
-
log.message(s, {
|
|
1032
|
-
...e,
|
|
1033
|
-
symbol: styleText("yellow", S_WARN)
|
|
1034
|
-
});
|
|
1035
|
-
},
|
|
1036
|
-
/** alias for `log.warn()`. */
|
|
1037
|
-
warning: (s, e) => {
|
|
1038
|
-
log.warn(s, e);
|
|
1039
|
-
},
|
|
1040
|
-
error: (s, e) => {
|
|
1041
|
-
log.message(s, {
|
|
1042
|
-
...e,
|
|
1043
|
-
symbol: styleText("red", S_ERROR)
|
|
1044
|
-
});
|
|
1045
|
-
}
|
|
1046
|
-
}, intro = (o = "", t) => {
|
|
1047
|
-
const i = t?.output ?? process.stdout, e = t?.withGuide ?? settings.withGuide ? `${styleText("gray", S_BAR_START)} ` : "";
|
|
1048
|
-
i.write(`${e}${o}
|
|
1049
|
-
`);
|
|
1050
|
-
}, outro = (o = "", t) => {
|
|
1051
|
-
const i = t?.output ?? process.stdout, e = t?.withGuide ?? settings.withGuide ? `${styleText("gray", S_BAR)}
|
|
1052
|
-
${styleText("gray", S_BAR_END)} ` : "";
|
|
1053
|
-
i.write(`${e}${o}
|
|
1054
|
-
|
|
1055
|
-
`);
|
|
1056
|
-
};
|
|
1057
|
-
const d = (n, a) => n.split(`
|
|
1058
|
-
`).map((m) => a(m)).join(`
|
|
1059
|
-
`);
|
|
1060
|
-
const multiselect = (n) => {
|
|
1061
|
-
const a = (t, o) => {
|
|
1062
|
-
const r = t.label ?? String(t.value);
|
|
1063
|
-
return o === "disabled" ? `${styleText("gray", S_CHECKBOX_INACTIVE)} ${d(r, (l) => styleText(["strikethrough", "gray"], l))}${t.hint ? ` ${styleText("dim", `(${t.hint ?? "disabled"})`)}` : ""}` : o === "active" ? `${styleText("cyan", S_CHECKBOX_ACTIVE)} ${r}${t.hint ? ` ${styleText("dim", `(${t.hint})`)}` : ""}` : o === "selected" ? `${styleText("green", S_CHECKBOX_SELECTED)} ${d(r, (l) => styleText("dim", l))}${t.hint ? ` ${styleText("dim", `(${t.hint})`)}` : ""}` : o === "cancelled" ? `${d(r, (l) => styleText(["strikethrough", "dim"], l))}` : o === "active-selected" ? `${styleText("green", S_CHECKBOX_SELECTED)} ${r}${t.hint ? ` ${styleText("dim", `(${t.hint})`)}` : ""}` : o === "submitted" ? `${d(r, (l) => styleText("dim", l))}` : `${styleText("dim", S_CHECKBOX_INACTIVE)} ${d(r, (l) => styleText("dim", l))}`;
|
|
1064
|
-
}, m = n.required ?? true;
|
|
1065
|
-
return new a$1({
|
|
1066
|
-
options: n.options,
|
|
1067
|
-
signal: n.signal,
|
|
1068
|
-
input: n.input,
|
|
1069
|
-
output: n.output,
|
|
1070
|
-
initialValues: n.initialValues,
|
|
1071
|
-
required: m,
|
|
1072
|
-
cursorAt: n.cursorAt,
|
|
1073
|
-
validate(t) {
|
|
1074
|
-
if (m && (t === void 0 || t.length === 0)) return `Please select at least one option.
|
|
1075
|
-
${styleText("reset", styleText("dim", `Press ${styleText([
|
|
1076
|
-
"gray",
|
|
1077
|
-
"bgWhite",
|
|
1078
|
-
"inverse"
|
|
1079
|
-
], " space ")} to select, ${styleText("gray", styleText("bgWhite", styleText("inverse", " enter ")))} to submit`))}`;
|
|
1080
|
-
},
|
|
1081
|
-
render() {
|
|
1082
|
-
const t = n.withGuide ?? settings.withGuide, o = wrapTextWithPrefix(n.output, n.message, t ? `${symbolBar(this.state)} ` : "", `${symbol(this.state)} `), r = `${t ? `${styleText("gray", S_BAR)}
|
|
1083
|
-
` : ""}${o}
|
|
1084
|
-
`, l = this.value ?? [], g = (i, u) => {
|
|
1085
|
-
if (i.disabled) return a(i, "disabled");
|
|
1086
|
-
const s = l.includes(i.value);
|
|
1087
|
-
return u && s ? a(i, "active-selected") : s ? a(i, "selected") : a(i, u ? "active" : "inactive");
|
|
1088
|
-
};
|
|
1089
|
-
switch (this.state) {
|
|
1090
|
-
case "submit": {
|
|
1091
|
-
const i = this.options.filter(({ value: s }) => l.includes(s)).map((s) => a(s, "submitted")).join(styleText("dim", ", ")) || styleText("dim", "none");
|
|
1092
|
-
return `${r}${wrapTextWithPrefix(n.output, i, t ? `${styleText("gray", S_BAR)} ` : "")}`;
|
|
1093
|
-
}
|
|
1094
|
-
case "cancel": {
|
|
1095
|
-
const i = this.options.filter(({ value: s }) => l.includes(s)).map((s) => a(s, "cancelled")).join(styleText("dim", ", "));
|
|
1096
|
-
if (i.trim() === "") return `${r}${styleText("gray", S_BAR)}`;
|
|
1097
|
-
return `${r}${wrapTextWithPrefix(n.output, i, t ? `${styleText("gray", S_BAR)} ` : "")}${t ? `
|
|
1098
|
-
${styleText("gray", S_BAR)}` : ""}`;
|
|
1099
|
-
}
|
|
1100
|
-
case "error": {
|
|
1101
|
-
const i = t ? `${styleText("yellow", S_BAR)} ` : "", u = this.error.split(`
|
|
1102
|
-
`).map((h, x) => x === 0 ? `${t ? `${styleText("yellow", S_BAR_END)} ` : ""}${styleText("yellow", h)}` : ` ${h}`).join(`
|
|
1103
|
-
`), s = r.split(`
|
|
1104
|
-
`).length, v = u.split(`
|
|
1105
|
-
`).length + 1;
|
|
1106
|
-
return `${r}${i}${limitOptions({
|
|
1107
|
-
output: n.output,
|
|
1108
|
-
options: this.options,
|
|
1109
|
-
cursor: this.cursor,
|
|
1110
|
-
maxItems: n.maxItems,
|
|
1111
|
-
columnPadding: i.length,
|
|
1112
|
-
rowPadding: s + v,
|
|
1113
|
-
style: g
|
|
1114
|
-
}).join(`
|
|
1115
|
-
${i}`)}
|
|
1116
|
-
${u}
|
|
1117
|
-
`;
|
|
1118
|
-
}
|
|
1119
|
-
default: {
|
|
1120
|
-
const i = t ? `${styleText("cyan", S_BAR)} ` : "", u = r.split(`
|
|
1121
|
-
`).length, s = t ? 2 : 1;
|
|
1122
|
-
return `${r}${i}${limitOptions({
|
|
1123
|
-
output: n.output,
|
|
1124
|
-
options: this.options,
|
|
1125
|
-
cursor: this.cursor,
|
|
1126
|
-
maxItems: n.maxItems,
|
|
1127
|
-
columnPadding: i.length,
|
|
1128
|
-
rowPadding: u + s,
|
|
1129
|
-
style: g
|
|
1130
|
-
}).join(`
|
|
1131
|
-
${i}`)}
|
|
1132
|
-
${t ? styleText("cyan", S_BAR_END) : ""}
|
|
1133
|
-
`;
|
|
1134
|
-
}
|
|
1135
|
-
}
|
|
1136
|
-
}
|
|
1137
|
-
}).prompt();
|
|
1138
|
-
};
|
|
1139
|
-
const W$1 = (o) => styleText("dim", o), C = (o, e, s) => {
|
|
1140
|
-
const a = {
|
|
1141
|
-
hard: true,
|
|
1142
|
-
trim: false
|
|
1143
|
-
}, i = wrapAnsi(o, e, a).split(`
|
|
1144
|
-
`), c = i.reduce((n, r) => Math.max(fastStringWidth(r), n), 0);
|
|
1145
|
-
return wrapAnsi(o, e - (i.map(s).reduce((n, r) => Math.max(fastStringWidth(r), n), 0) - c), a);
|
|
1146
|
-
};
|
|
1147
|
-
const note = (o = "", e = "", s) => {
|
|
1148
|
-
const a = s?.output ?? process$1.stdout, i = s?.withGuide ?? settings.withGuide, c = s?.format ?? W$1, g = [
|
|
1149
|
-
"",
|
|
1150
|
-
...C(o, getColumns(a) - 6, c).split(`
|
|
1151
|
-
`).map(c),
|
|
1152
|
-
""
|
|
1153
|
-
], n = fastStringWidth(e), r = Math.max(g.reduce((m, F) => {
|
|
1154
|
-
const O = fastStringWidth(F);
|
|
1155
|
-
return O > m ? O : m;
|
|
1156
|
-
}, 0), n) + 2, h = g.map((m) => `${styleText("gray", S_BAR)} ${m}${" ".repeat(r - fastStringWidth(m))}${styleText("gray", S_BAR)}`).join(`
|
|
1157
|
-
`), T = i ? `${styleText("gray", S_BAR)}
|
|
1158
|
-
` : "", l$1 = i ? S_CONNECT_LEFT : S_CORNER_BOTTOM_LEFT;
|
|
1159
|
-
a.write(`${T}${styleText("green", S_STEP_SUBMIT)} ${styleText("reset", e)} ${styleText("gray", S_BAR_H.repeat(Math.max(r - n - 1, 1)) + S_CORNER_TOP_RIGHT)}
|
|
1160
|
-
${h}
|
|
1161
|
-
${styleText("gray", l$1 + S_BAR_H.repeat(r + 2) + S_CORNER_BOTTOM_RIGHT)}
|
|
1162
|
-
`);
|
|
1163
|
-
};
|
|
1164
|
-
const W = (l) => styleText("magenta", l);
|
|
1165
|
-
const spinner = ({ indicator: l = "dots", onCancel: h, output: n = process.stdout, cancelMessage: G, errorMessage: O, frames: E = unicode ? [
|
|
1166
|
-
"◒",
|
|
1167
|
-
"◐",
|
|
1168
|
-
"◓",
|
|
1169
|
-
"◑"
|
|
1170
|
-
] : [
|
|
1171
|
-
"•",
|
|
1172
|
-
"o",
|
|
1173
|
-
"O",
|
|
1174
|
-
"0"
|
|
1175
|
-
], delay: F = unicode ? 80 : 120, signal: m, ...I } = {}) => {
|
|
1176
|
-
const u = isCI();
|
|
1177
|
-
let M, T, d = false, S = false, s = "", p, w = performance.now();
|
|
1178
|
-
const x = getColumns(n), k = I?.styleFrame ?? W, g = (e) => {
|
|
1179
|
-
const r = e > 1 ? O ?? settings.messages.error : G ?? settings.messages.cancel;
|
|
1180
|
-
S = e === 1, d && (a(r, e), S && typeof h == "function" && h());
|
|
1181
|
-
}, f = () => g(2), i = () => g(1), A = () => {
|
|
1182
|
-
process.on("uncaughtExceptionMonitor", f), process.on("unhandledRejection", f), process.on("SIGINT", i), process.on("SIGTERM", i), process.on("exit", g), m && m.addEventListener("abort", i);
|
|
1183
|
-
}, H = () => {
|
|
1184
|
-
process.removeListener("uncaughtExceptionMonitor", f), process.removeListener("unhandledRejection", f), process.removeListener("SIGINT", i), process.removeListener("SIGTERM", i), process.removeListener("exit", g), m && m.removeEventListener("abort", i);
|
|
1185
|
-
}, y = () => {
|
|
1186
|
-
if (p === void 0) return;
|
|
1187
|
-
u && n.write(`
|
|
1188
|
-
`);
|
|
1189
|
-
const r = wrapAnsi(p, x, {
|
|
1190
|
-
hard: true,
|
|
1191
|
-
trim: false
|
|
1192
|
-
}).split(`
|
|
1193
|
-
`);
|
|
1194
|
-
r.length > 1 && n.write(import_src.cursor.up(r.length - 1)), n.write(import_src.cursor.to(0)), n.write(import_src.erase.down());
|
|
1195
|
-
}, C = (e) => e.replace(/\.+$/, ""), _ = (e) => {
|
|
1196
|
-
const r = (performance.now() - e) / 1e3, t = Math.floor(r / 60), o = Math.floor(r % 60);
|
|
1197
|
-
return t > 0 ? `[${t}m ${o}s]` : `[${o}s]`;
|
|
1198
|
-
}, N = I.withGuide ?? settings.withGuide, P = (e = "") => {
|
|
1199
|
-
d = true, M = block({ output: n }), s = C(e), w = performance.now(), N && n.write(`${styleText("gray", S_BAR)}
|
|
1200
|
-
`);
|
|
1201
|
-
let r = 0, t = 0;
|
|
1202
|
-
A(), T = setInterval(() => {
|
|
1203
|
-
if (u && s === p) return;
|
|
1204
|
-
y(), p = s;
|
|
1205
|
-
const o = k(E[r]);
|
|
1206
|
-
let v;
|
|
1207
|
-
if (u) v = `${o} ${s}...`;
|
|
1208
|
-
else if (l === "timer") v = `${o} ${s} ${_(w)}`;
|
|
1209
|
-
else {
|
|
1210
|
-
const B = ".".repeat(Math.floor(t)).slice(0, 3);
|
|
1211
|
-
v = `${o} ${s}${B}`;
|
|
1212
|
-
}
|
|
1213
|
-
const j = wrapAnsi(v, x, {
|
|
1214
|
-
hard: true,
|
|
1215
|
-
trim: false
|
|
1216
|
-
});
|
|
1217
|
-
n.write(j), r = r + 1 < E.length ? r + 1 : 0, t = t < 4 ? t + .125 : 0;
|
|
1218
|
-
}, F);
|
|
1219
|
-
}, a = (e = "", r = 0, t = false) => {
|
|
1220
|
-
if (!d) return;
|
|
1221
|
-
d = false, clearInterval(T), y();
|
|
1222
|
-
const o = r === 0 ? styleText("green", S_STEP_SUBMIT) : r === 1 ? styleText("red", S_STEP_CANCEL) : styleText("red", S_STEP_ERROR);
|
|
1223
|
-
s = e ?? s, t || (l === "timer" ? n.write(`${o} ${s} ${_(w)}
|
|
1224
|
-
`) : n.write(`${o} ${s}
|
|
1225
|
-
`)), H(), M();
|
|
1226
|
-
};
|
|
1227
|
-
return {
|
|
1228
|
-
start: P,
|
|
1229
|
-
stop: (e = "") => a(e, 0),
|
|
1230
|
-
message: (e = "") => {
|
|
1231
|
-
s = C(e ?? s);
|
|
1232
|
-
},
|
|
1233
|
-
cancel: (e = "") => a(e, 1),
|
|
1234
|
-
error: (e = "") => a(e, 2),
|
|
1235
|
-
clear: () => a("", 0, true),
|
|
1236
|
-
get isCancelled() {
|
|
1237
|
-
return S;
|
|
1238
|
-
}
|
|
1239
|
-
};
|
|
1240
|
-
};
|
|
1241
|
-
const c = (e, a) => e.includes(`
|
|
1242
|
-
`) ? e.split(`
|
|
1243
|
-
`).map((t) => a(t)).join(`
|
|
1244
|
-
`) : a(e);
|
|
1245
|
-
const select = (e) => {
|
|
1246
|
-
const a$2 = (t, d) => {
|
|
1247
|
-
const s = t.label ?? String(t.value);
|
|
1248
|
-
switch (d) {
|
|
1249
|
-
case "disabled": return `${styleText("gray", S_RADIO_INACTIVE)} ${c(s, (n) => styleText("gray", n))}${t.hint ? ` ${styleText("dim", `(${t.hint ?? "disabled"})`)}` : ""}`;
|
|
1250
|
-
case "selected": return `${c(s, (n) => styleText("dim", n))}`;
|
|
1251
|
-
case "active": return `${styleText("green", S_RADIO_ACTIVE)} ${s}${t.hint ? ` ${styleText("dim", `(${t.hint})`)}` : ""}`;
|
|
1252
|
-
case "cancelled": return `${c(s, (n) => styleText(["strikethrough", "dim"], n))}`;
|
|
1253
|
-
default: return `${styleText("dim", S_RADIO_INACTIVE)} ${c(s, (n) => styleText("dim", n))}`;
|
|
1254
|
-
}
|
|
1255
|
-
};
|
|
1256
|
-
return new a({
|
|
1257
|
-
options: e.options,
|
|
1258
|
-
signal: e.signal,
|
|
1259
|
-
input: e.input,
|
|
1260
|
-
output: e.output,
|
|
1261
|
-
initialValue: e.initialValue,
|
|
1262
|
-
render() {
|
|
1263
|
-
const t = e.withGuide ?? settings.withGuide, d = `${symbol(this.state)} `, s = `${symbolBar(this.state)} `, n = wrapTextWithPrefix(e.output, e.message, s, d), u = `${t ? `${styleText("gray", S_BAR)}
|
|
1264
|
-
` : ""}${n}
|
|
1265
|
-
`;
|
|
1266
|
-
switch (this.state) {
|
|
1267
|
-
case "submit": {
|
|
1268
|
-
const r = t ? `${styleText("gray", S_BAR)} ` : "";
|
|
1269
|
-
return `${u}${wrapTextWithPrefix(e.output, a$2(this.options[this.cursor], "selected"), r)}`;
|
|
1270
|
-
}
|
|
1271
|
-
case "cancel": {
|
|
1272
|
-
const r = t ? `${styleText("gray", S_BAR)} ` : "";
|
|
1273
|
-
return `${u}${wrapTextWithPrefix(e.output, a$2(this.options[this.cursor], "cancelled"), r)}${t ? `
|
|
1274
|
-
${styleText("gray", S_BAR)}` : ""}`;
|
|
1275
|
-
}
|
|
1276
|
-
default: {
|
|
1277
|
-
const r = t ? `${styleText("cyan", S_BAR)} ` : "", l = t ? styleText("cyan", S_BAR_END) : "", g = u.split(`
|
|
1278
|
-
`).length, h = t ? 2 : 1;
|
|
1279
|
-
return `${u}${r}${limitOptions({
|
|
1280
|
-
output: e.output,
|
|
1281
|
-
cursor: this.cursor,
|
|
1282
|
-
options: this.options,
|
|
1283
|
-
maxItems: e.maxItems,
|
|
1284
|
-
columnPadding: r.length,
|
|
1285
|
-
rowPadding: g + h,
|
|
1286
|
-
style: (p, b) => a$2(p, p.disabled ? "disabled" : b ? "active" : "inactive")
|
|
1287
|
-
}).join(`
|
|
1288
|
-
${r}`)}
|
|
1289
|
-
${l}
|
|
1290
|
-
`;
|
|
1291
|
-
}
|
|
1292
|
-
}
|
|
1293
|
-
}
|
|
1294
|
-
}).prompt();
|
|
1295
|
-
};
|
|
1296
|
-
`${styleText("gray", S_BAR)}`;
|
|
1297
|
-
const text = (t) => new n({
|
|
1298
|
-
validate: t.validate,
|
|
1299
|
-
placeholder: t.placeholder,
|
|
1300
|
-
defaultValue: t.defaultValue,
|
|
1301
|
-
initialValue: t.initialValue,
|
|
1302
|
-
output: t.output,
|
|
1303
|
-
signal: t.signal,
|
|
1304
|
-
input: t.input,
|
|
1305
|
-
render() {
|
|
1306
|
-
const i = t?.withGuide ?? settings.withGuide, s = `${`${i ? `${styleText("gray", S_BAR)}
|
|
1307
|
-
` : ""}${symbol(this.state)} `}${t.message}
|
|
1308
|
-
`, c = t.placeholder ? styleText("inverse", t.placeholder[0]) + styleText("dim", t.placeholder.slice(1)) : styleText(["inverse", "hidden"], "_"), o = this.userInput ? this.userInputWithCursor : c, a = this.value ?? "";
|
|
1309
|
-
switch (this.state) {
|
|
1310
|
-
case "error": {
|
|
1311
|
-
const n = this.error ? ` ${styleText("yellow", this.error)}` : "", r = i ? `${styleText("yellow", S_BAR)} ` : "", d = i ? styleText("yellow", S_BAR_END) : "";
|
|
1312
|
-
return `${s.trim()}
|
|
1313
|
-
${r}${o}
|
|
1314
|
-
${d}${n}
|
|
1315
|
-
`;
|
|
1316
|
-
}
|
|
1317
|
-
case "submit": {
|
|
1318
|
-
const n = a ? ` ${styleText("dim", a)}` : "";
|
|
1319
|
-
return `${s}${i ? styleText("gray", S_BAR) : ""}${n}`;
|
|
1320
|
-
}
|
|
1321
|
-
case "cancel": {
|
|
1322
|
-
const n = a ? ` ${styleText(["strikethrough", "dim"], a)}` : "", r = i ? styleText("gray", S_BAR) : "";
|
|
1323
|
-
return `${s}${r}${n}${a.trim() ? `
|
|
1324
|
-
${r}` : ""}`;
|
|
1325
|
-
}
|
|
1326
|
-
default: return `${s}${i ? `${styleText("cyan", S_BAR)} ` : ""}${o}
|
|
1327
|
-
${i ? styleText("cyan", S_BAR_END) : ""}
|
|
1328
|
-
`;
|
|
1329
|
-
}
|
|
1330
|
-
}
|
|
1331
|
-
}).prompt();
|
|
1332
|
-
//#endregion
|
|
1333
|
-
export { autocomplete, confirm, intro, isCancel, log, multiselect, note, outro, select, spinner, text };
|
|
1334
|
-
|
|
1335
|
-
//# sourceMappingURL=dist.mjs.map
|