@topcli/prompts 1.6.0 → 1.8.0

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.
@@ -1,333 +0,0 @@
1
- // Import Node.js Dependencies
2
- import { EOL } from "node:os";
3
-
4
- // Import Third-party Dependencies
5
- import kleur from "kleur";
6
- import wcwidth from "@topcli/wcwidth";
7
-
8
- // Import Internal Dependencies
9
- import { AbstractPrompt } from "./abstract.js";
10
- import { stripAnsi } from "../utils.js";
11
- import { SYMBOLS } from "../constants.js";
12
-
13
- // CONSTANTS
14
- const kRequiredChoiceProperties = ["label", "value"];
15
-
16
- export class MultiselectPrompt extends AbstractPrompt {
17
- #boundExitEvent = () => void 0;
18
- #boundKeyPressEvent = () => void 0;
19
- #validators;
20
-
21
- activeIndex = 0;
22
- selectedIndexes = [];
23
- questionMessage;
24
- autocompleteValue = "";
25
-
26
- get choices() {
27
- return this.options.choices;
28
- }
29
-
30
- get filteredChoices() {
31
- return this.options.autocomplete && this.autocompleteValue.length > 0 ? this.choices.filter((choice) => {
32
- if (typeof choice === "string") {
33
- if (this.autocompleteValue.includes(" ")) {
34
- return this.autocompleteValue.split(" ").every((word) => choice.includes(word)) ||
35
- choice.includes(this.autocompleteValue);
36
- }
37
-
38
- return choice.includes(this.autocompleteValue);
39
- }
40
-
41
- if (this.autocompleteValue.includes(" ")) {
42
- return this.autocompleteValue.split(" ").every((word) => choice.label.includes(word)) ||
43
- choice.label.includes(this.autocompleteValue);
44
- }
45
-
46
- return choice.label.includes(this.autocompleteValue);
47
- }) : this.choices;
48
- }
49
-
50
- get longestChoice() {
51
- return Math.max(...this.filteredChoices.map((choice) => {
52
- if (typeof choice === "string") {
53
- return choice.length;
54
- }
55
-
56
- return choice.label.length;
57
- }));
58
- }
59
-
60
- constructor(message, options) {
61
- const {
62
- stdin = process.stdin,
63
- stdout = process.stdout,
64
- choices,
65
- preSelectedChoices,
66
- validators = []
67
- } = options ?? {};
68
-
69
- super(message, stdin, stdout);
70
-
71
- if (!options) {
72
- this.destroy();
73
- throw new TypeError("Missing required options");
74
- }
75
-
76
- this.options = options;
77
-
78
- if (!choices?.length) {
79
- this.destroy();
80
- throw new TypeError("Missing required param: choices");
81
- }
82
-
83
- this.#validators = validators;
84
-
85
- for (const choice of choices) {
86
- if (typeof choice === "string") {
87
- continue;
88
- }
89
-
90
- for (const prop of kRequiredChoiceProperties) {
91
- if (!choice[prop]) {
92
- this.destroy();
93
- throw new TypeError(`Missing ${prop} for choice ${JSON.stringify(choice)}`);
94
- }
95
- }
96
- }
97
-
98
- if (!preSelectedChoices) {
99
- return;
100
- }
101
-
102
- for (const choice of preSelectedChoices) {
103
- const choiceIndex = this.filteredChoices.findIndex((item) => {
104
- if (typeof item === "string") {
105
- return item === choice;
106
- }
107
-
108
- return item.value === choice;
109
- });
110
-
111
- if (choiceIndex === -1) {
112
- throw new Error(`Invalid pre-selected choice: ${choice.value ?? choice}`);
113
- }
114
-
115
- this.selectedIndexes.push(choiceIndex);
116
- }
117
- }
118
-
119
- #getFormattedChoice(choiceIndex) {
120
- const choice = this.filteredChoices[choiceIndex];
121
-
122
- if (typeof choice === "string") {
123
- return { value: choice, label: choice };
124
- }
125
-
126
- return choice;
127
- }
128
-
129
- #getVisibleChoices() {
130
- const maxVisible = this.options.maxVisible || 8;
131
- let startIndex = Math.min(this.filteredChoices.length - maxVisible, this.activeIndex - Math.floor(maxVisible / 2));
132
- if (startIndex < 0) {
133
- startIndex = 0;
134
- }
135
-
136
- const endIndex = Math.min(startIndex + maxVisible, this.filteredChoices.length);
137
-
138
- return { startIndex, endIndex };
139
- }
140
-
141
- #showChoices() {
142
- const { startIndex, endIndex } = this.#getVisibleChoices();
143
- this.lastRender = { startIndex, endIndex };
144
-
145
- if (this.options.autocomplete) {
146
- this.write(`${SYMBOLS.Pointer} ${this.autocompleteValue}${EOL}`);
147
- }
148
- for (let choiceIndex = startIndex; choiceIndex < endIndex; choiceIndex++) {
149
- const choice = this.#getFormattedChoice(choiceIndex);
150
- const isChoiceActive = choiceIndex === this.activeIndex;
151
- const isChoiceSelected = this.selectedIndexes.includes(choiceIndex);
152
- const showPreviousChoicesArrow = startIndex > 0 && choiceIndex === startIndex;
153
- const showNextChoicesArrow = endIndex < this.filteredChoices.length && choiceIndex === endIndex - 1;
154
-
155
- let prefixArrow = " ";
156
- if (showPreviousChoicesArrow) {
157
- prefixArrow = SYMBOLS.Previous + " ";
158
- }
159
- else if (showNextChoicesArrow) {
160
- prefixArrow = SYMBOLS.Next + " ";
161
- }
162
-
163
- const prefix = `${prefixArrow}${isChoiceSelected ? SYMBOLS.Active : SYMBOLS.Inactive}`;
164
- const formattedLabel = choice.label.padEnd(
165
- this.longestChoice < 10 ? this.longestChoice : 0
166
- );
167
- const formattedDescription = choice.description ? ` - ${choice.description}` : "";
168
- const color = isChoiceActive ? kleur.white().bold : kleur.gray;
169
- const str = `${prefix} ${color(`${formattedLabel}${formattedDescription}`)}${EOL}`;
170
-
171
- this.write(str);
172
- }
173
- }
174
-
175
- #showAnsweredQuestion(choices, isAgentAnswer = false) {
176
- const prefixSymbol = this.selectedIndexes.length === 0 && !isAgentAnswer ? SYMBOLS.Cross : SYMBOLS.Tick;
177
- const prefix = `${prefixSymbol} ${kleur.bold(this.message)} ${SYMBOLS.Pointer}`;
178
- const formattedChoice = kleur.yellow(choices);
179
-
180
- this.write(`${prefix}${choices ? ` ${formattedChoice}` : ""}${EOL}`);
181
- }
182
-
183
- #onProcessExit() {
184
- this.stdin.off("keypress", this.#boundKeyPressEvent);
185
- this.stdout.moveCursor(-this.stdout.columns, 0);
186
- this.stdout.clearScreenDown();
187
- this.write(SYMBOLS.ShowCursor);
188
- }
189
-
190
- #onKeypress(...args) {
191
- const [resolve, render, _, key] = args;
192
- if (key.name === "up") {
193
- this.activeIndex = this.activeIndex === 0 ? this.filteredChoices.length - 1 : this.activeIndex - 1;
194
- render();
195
- }
196
- else if (key.name === "down") {
197
- this.activeIndex = this.activeIndex === this.filteredChoices.length - 1 ? 0 : this.activeIndex + 1;
198
- render();
199
- }
200
- else if (key.ctrl && key.name === "a") {
201
- // eslint-disable-next-line max-len
202
- this.selectedIndexes = this.selectedIndexes.length === this.filteredChoices.length ? [] : this.filteredChoices.map((_, index) => index);
203
- render();
204
- }
205
- else if (key.name === "right") {
206
- this.selectedIndexes.push(this.activeIndex);
207
- render();
208
- }
209
- else if (key.name === "left") {
210
- this.selectedIndexes = this.selectedIndexes.filter((index) => index !== this.activeIndex);
211
- render();
212
- }
213
- else if (key.name === "return") {
214
- const labels = this.selectedIndexes.map((index) => this.filteredChoices[index].label ?? this.filteredChoices[index]);
215
- const values = this.selectedIndexes.map((index) => this.filteredChoices[index].value ?? this.filteredChoices[index]);
216
-
217
- for (const validator of this.#validators) {
218
- if (!validator.validate(values)) {
219
- const error = validator.error(values);
220
- render({ error });
221
-
222
- return;
223
- }
224
- }
225
-
226
- render({ clearRender: true });
227
-
228
- this.#showAnsweredQuestion(labels.join(", "));
229
-
230
- this.write(SYMBOLS.ShowCursor);
231
- this.destroy();
232
-
233
- this.#onProcessExit();
234
- process.off("exit", this.#boundExitEvent);
235
-
236
- resolve(values);
237
- }
238
- else {
239
- if (!key.ctrl && this.options.autocomplete) {
240
- // reset selected choices when user type
241
- this.selectedIndexes = [];
242
- this.activeIndex = 0;
243
- if (key.name === "backspace" && this.autocompleteValue.length > 0) {
244
- this.autocompleteValue = this.autocompleteValue.slice(0, -1);
245
- }
246
- else if (key.name !== "backspace") {
247
- this.autocompleteValue += key.sequence;
248
- }
249
- }
250
- render();
251
- }
252
- }
253
-
254
- async multiselect() {
255
- if (this.agent.nextAnswers.length > 0) {
256
- const answer = this.agent.nextAnswers.shift();
257
- this.#showAnsweredQuestion(answer, true);
258
- this.destroy();
259
-
260
- return answer;
261
- }
262
-
263
- this.write(SYMBOLS.HideCursor);
264
- this.#showQuestion();
265
-
266
- const render = (options = {}) => {
267
- const {
268
- initialRender = false,
269
- clearRender = false,
270
- error = null
271
- } = options;
272
-
273
- if (!initialRender) {
274
- let linesToClear = this.lastRender.endIndex - this.lastRender.startIndex;
275
- while (linesToClear > 0) {
276
- this.clearLastLine();
277
- linesToClear--;
278
- }
279
- if (this.options.autocomplete) {
280
- let linesToClear = Math.ceil(
281
- wcwidth(`${SYMBOLS.Pointer} ${this.autocompleteValue}`) / this.stdout.columns
282
- );
283
- while (linesToClear > 0) {
284
- this.clearLastLine();
285
- linesToClear--;
286
- }
287
- }
288
- }
289
-
290
- if (clearRender) {
291
- const questionLineCount = Math.ceil(
292
- wcwidth(stripAnsi(this.questionMessage)) / this.stdout.columns
293
- );
294
- this.stdout.moveCursor(-this.stdout.columns, -(1 + questionLineCount));
295
- this.stdout.clearScreenDown();
296
-
297
- return;
298
- }
299
-
300
- if (error) {
301
- const linesToClear = Math.ceil(wcwidth(this.questionMessage) / this.stdout.columns) + 1;
302
- this.stdout.moveCursor(0, -linesToClear);
303
- this.stdout.clearScreenDown();
304
- this.#showQuestion(error);
305
- }
306
-
307
- this.#showChoices();
308
- };
309
-
310
- render({ initialRender: true });
311
-
312
- return new Promise((resolve) => {
313
- this.#boundKeyPressEvent = this.#onKeypress.bind(this, resolve, render);
314
- this.stdin.on("keypress", this.#boundKeyPressEvent);
315
-
316
- this.#boundExitEvent = this.#onProcessExit.bind(this);
317
- process.once("exit", this.#boundExitEvent);
318
- });
319
- }
320
-
321
- #showQuestion(error = null) {
322
- let hint = kleur.gray(
323
- // eslint-disable-next-line max-len
324
- `(Press ${kleur.bold("<Ctrl+A>")} to toggle all, ${kleur.bold("<Ctrl+Space>")} to select, ${kleur.bold("<Left/Right>")} to toggle, ${kleur.bold("<Return>")} to submit)`
325
- );
326
- if (error) {
327
- hint += ` ${kleur.red().bold(`[${error}]`)}`;
328
- }
329
- this.questionMessage = `${SYMBOLS.QuestionMark} ${kleur.bold(this.message)} ${hint}`;
330
-
331
- this.write(`${this.questionMessage}${EOL}`);
332
- }
333
- }
@@ -1,115 +0,0 @@
1
- // Import Node.js Dependencies
2
- import { EOL } from "node:os";
3
-
4
- // Import Third-party Dependencies
5
- import kleur from "kleur";
6
- import wcwidth from "@topcli/wcwidth";
7
-
8
- // Import Internal Dependencies
9
- import { AbstractPrompt } from "./abstract.js";
10
- import { stripAnsi } from "../utils.js";
11
- import { SYMBOLS } from "../constants.js";
12
-
13
- export class QuestionPrompt extends AbstractPrompt {
14
- #validators;
15
- #secure;
16
-
17
- constructor(message, options = {}) {
18
- const {
19
- stdin = process.stdin,
20
- stdout = process.stdout,
21
- defaultValue,
22
- validators = [],
23
- secure = false
24
- } = options;
25
-
26
- super(message, stdin, stdout);
27
-
28
- if (defaultValue && typeof defaultValue !== "string") {
29
- throw new TypeError("defaultValue must be a string");
30
- }
31
-
32
- this.defaultValue = defaultValue;
33
- this.tip = this.defaultValue ? ` (${this.defaultValue})` : "";
34
- this.#validators = validators;
35
- this.#secure = Boolean(secure);
36
- this.questionSuffixError = "";
37
- }
38
-
39
- #question() {
40
- return new Promise((resolve) => {
41
- const questionQuery = this.#getQuestionQuery();
42
-
43
- this.rl.question(questionQuery, (answer) => {
44
- this.history.push(questionQuery + answer);
45
- this.mute = false;
46
-
47
- resolve(answer);
48
- });
49
- this.mute = this.#secure;
50
- });
51
- }
52
-
53
- #getQuestionQuery() {
54
- return `${kleur.bold(`${SYMBOLS.QuestionMark} ${this.message}${this.tip}`)} ${this.questionSuffixError}`;
55
- }
56
-
57
- #setQuestionSuffixError(error) {
58
- const suffix = kleur.red(`[${error}] `);
59
- this.questionSuffixError = suffix;
60
- }
61
-
62
- #writeAnswer() {
63
- const prefix = this.answer ? SYMBOLS.Tick : SYMBOLS.Cross;
64
- const answer = kleur.yellow(this.#secure ? "CONFIDENTIAL" : this.answer ?? "");
65
- this.write(`${prefix} ${kleur.bold(this.message)} ${SYMBOLS.Pointer} ${answer}${EOL}`);
66
- }
67
-
68
- #onQuestionAnswer() {
69
- const questionLineCount = Math.ceil(
70
- wcwidth(stripAnsi(this.#getQuestionQuery() + this.answer)) / this.stdout.columns
71
- );
72
-
73
- this.stdout.moveCursor(-this.stdout.columns, -questionLineCount);
74
- this.stdout.clearScreenDown();
75
-
76
- for (const validator of this.#validators) {
77
- if (!validator.validate(this.answer)) {
78
- const error = validator.error(this.answer);
79
- this.#setQuestionSuffixError(error);
80
- this.answer = this.#question();
81
-
82
- return;
83
- }
84
- }
85
-
86
- this.#writeAnswer();
87
- }
88
-
89
- async question() {
90
- if (this.agent.nextAnswers.length > 0) {
91
- this.answer = this.agent.nextAnswers.shift();
92
- this.#writeAnswer();
93
- this.destroy();
94
-
95
- return this.answer;
96
- }
97
-
98
- this.answer = await this.#question();
99
-
100
- if (this.answer === "" && this.defaultValue) {
101
- this.answer = this.defaultValue;
102
- }
103
-
104
- this.#onQuestionAnswer();
105
-
106
- while (this.answer?.constructor.name === "Promise") {
107
- this.answer = await this.answer;
108
- this.#onQuestionAnswer();
109
- }
110
-
111
- this.destroy();
112
-
113
- return this.answer;
114
- }
115
- }
@@ -1,215 +0,0 @@
1
- // Import Node.js Dependencies
2
- import { EOL } from "node:os";
3
-
4
- // Import Third-party Dependencies
5
- import kleur from "kleur";
6
- import wcwidth from "@topcli/wcwidth";
7
-
8
- // Import Internal Dependencies
9
- import { AbstractPrompt } from "./abstract.js";
10
- import { stripAnsi } from "../utils.js";
11
- import { SYMBOLS } from "../constants.js";
12
-
13
- export class SelectPrompt extends AbstractPrompt {
14
- #boundExitEvent = () => void 0;
15
- #boundKeyPressEvent = () => void 0;
16
- activeIndex = 0;
17
-
18
- get choices() {
19
- return this.options.choices;
20
- }
21
-
22
- constructor(message, options) {
23
- const {
24
- stdin = process.stdin,
25
- stdout = process.stdout,
26
- choices
27
- } = options ?? {};
28
-
29
- super(message, stdin, stdout);
30
-
31
- if (!options) {
32
- this.destroy();
33
- throw new TypeError("Missing required options");
34
- }
35
-
36
- this.options = options;
37
-
38
- if (!choices?.length) {
39
- this.destroy();
40
- throw new TypeError("Missing required param: choices");
41
- }
42
-
43
- this.longestChoice = Math.max(...choices.map((choice) => {
44
- if (typeof choice === "string") {
45
- return choice.length;
46
- }
47
-
48
- const kRequiredChoiceProperties = ["label", "value"];
49
-
50
- for (const prop of kRequiredChoiceProperties) {
51
- if (!choice[prop]) {
52
- this.destroy();
53
- throw new TypeError(`Missing ${prop} for choice ${JSON.stringify(choice)}`);
54
- }
55
- }
56
-
57
- return choice.label.length;
58
- }));
59
- }
60
-
61
- #getFormattedChoice(choiceIndex) {
62
- const choice = this.choices[choiceIndex];
63
-
64
- if (typeof choice === "string") {
65
- return { value: choice, label: choice };
66
- }
67
-
68
- return choice;
69
- }
70
-
71
- #getVisibleChoices() {
72
- const maxVisible = this.options.maxVisible || 8;
73
- let startIndex = Math.min(this.choices.length - maxVisible, this.activeIndex - Math.floor(maxVisible / 2));
74
- if (startIndex < 0) {
75
- startIndex = 0;
76
- }
77
-
78
- const endIndex = Math.min(startIndex + maxVisible, this.choices.length);
79
-
80
- return { startIndex, endIndex };
81
- }
82
-
83
- #showChoices() {
84
- const { startIndex, endIndex } = this.#getVisibleChoices();
85
- this.lastRender = { startIndex, endIndex };
86
-
87
- for (let choiceIndex = startIndex; choiceIndex < endIndex; choiceIndex++) {
88
- const choice = this.#getFormattedChoice(choiceIndex);
89
- const isChoiceSelected = choiceIndex === this.activeIndex;
90
- const showPreviousChoicesArrow = startIndex > 0 && choiceIndex === startIndex;
91
- const showNextChoicesArrow = endIndex < this.choices.length && choiceIndex === endIndex - 1;
92
-
93
- let prefixArrow = " ";
94
- if (showPreviousChoicesArrow) {
95
- prefixArrow = SYMBOLS.Previous;
96
- }
97
- else if (showNextChoicesArrow) {
98
- prefixArrow = SYMBOLS.Next;
99
- }
100
-
101
- const prefix = `${prefixArrow}${isChoiceSelected ? `${SYMBOLS.Pointer} ` : " "}`;
102
- const formattedLabel = choice.label.padEnd(
103
- this.longestChoice < 10 ? this.longestChoice : 0
104
- );
105
- const formattedDescription = choice.description ? ` - ${choice.description}` : "";
106
- const color = isChoiceSelected ? kleur.white().bold : kleur.gray;
107
- const str = color(`${prefix}${formattedLabel}${formattedDescription}${EOL}`);
108
-
109
- this.write(str);
110
- }
111
- }
112
-
113
- #showAnsweredQuestion(choice) {
114
- const prefix = `${SYMBOLS.Tick} ${kleur.bold(this.message)} ${SYMBOLS.Pointer}`;
115
- const formattedChoice = kleur.yellow(choice.label ?? choice);
116
-
117
- this.write(`${prefix} ${formattedChoice}${EOL}`);
118
- }
119
-
120
- #onProcessExit() {
121
- this.stdin.off("keypress", this.#boundKeyPressEvent);
122
- this.stdout.moveCursor(-this.stdout.columns, 0);
123
- this.stdout.clearScreenDown();
124
- this.write(SYMBOLS.ShowCursor);
125
- }
126
-
127
- #onKeypress(...args) {
128
- const [resolve, render, _, key] = args;
129
-
130
- if (key.name === "up") {
131
- this.activeIndex = this.activeIndex === 0 ? this.choices.length - 1 : this.activeIndex - 1;
132
- render();
133
- }
134
- else if (key.name === "down") {
135
- this.activeIndex = this.activeIndex === this.choices.length - 1 ? 0 : this.activeIndex + 1;
136
- render();
137
- }
138
- else if (key.name === "return") {
139
- render({ clearRender: true });
140
-
141
- const currentChoice = this.choices[this.activeIndex];
142
- const value = currentChoice.value ?? currentChoice;
143
-
144
- if (!this.options.ignoreValues?.includes(value)) {
145
- this.#showAnsweredQuestion(currentChoice);
146
- }
147
-
148
- this.write(SYMBOLS.ShowCursor);
149
- this.destroy();
150
-
151
- this.#onProcessExit();
152
- process.off("exit", this.#boundExitEvent);
153
- resolve(value);
154
- }
155
- else {
156
- render();
157
- }
158
- }
159
-
160
- async select() {
161
- if (this.agent.nextAnswers.length > 0) {
162
- const answer = this.agent.nextAnswers.shift();
163
- this.#showAnsweredQuestion(answer);
164
- this.destroy();
165
-
166
- return answer;
167
- }
168
-
169
- this.write(SYMBOLS.HideCursor);
170
- this.#showQuestion();
171
-
172
- const render = (options = {}) => {
173
- const {
174
- initialRender = false,
175
- clearRender = false
176
- } = options;
177
-
178
- if (!initialRender) {
179
- let linesToClear = this.lastRender.endIndex - this.lastRender.startIndex;
180
- while (linesToClear > 0) {
181
- this.clearLastLine();
182
- linesToClear--;
183
- }
184
- }
185
-
186
- if (clearRender) {
187
- const questionLineCount = Math.ceil(
188
- wcwidth(stripAnsi(this.questionMessage)) / this.stdout.columns
189
- );
190
-
191
- this.stdout.moveCursor(-this.stdout.columns, -(1 + questionLineCount));
192
- this.stdout.clearScreenDown();
193
-
194
- return;
195
- }
196
-
197
- this.#showChoices();
198
- };
199
-
200
- render({ initialRender: true });
201
-
202
- return new Promise((resolve) => {
203
- this.#boundKeyPressEvent = this.#onKeypress.bind(this, resolve, render);
204
- this.stdin.on("keypress", this.#boundKeyPressEvent);
205
-
206
- this.#boundExitEvent = this.#onProcessExit.bind(this);
207
- process.once("exit", this.#boundExitEvent);
208
- });
209
- }
210
-
211
- #showQuestion() {
212
- this.questionMessage = `${SYMBOLS.QuestionMark} ${kleur.bold(this.message)}`;
213
- this.write(`${this.questionMessage}${EOL}`);
214
- }
215
- }
package/src/utils.js DELETED
@@ -1,43 +0,0 @@
1
- import process from "node:process";
2
-
3
- // CONSTANTS
4
- const kAnsiRegex = ansiRegex();
5
-
6
- /**
7
- * @see https://github.com/chalk/ansi-regex
8
- */
9
- export function ansiRegex({onlyFirst = false} = {}) {
10
- const pattern = [
11
- '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)',
12
- '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))'
13
- ].join('|');
14
-
15
- return new RegExp(pattern, onlyFirst ? undefined : 'g');
16
- }
17
-
18
- /**
19
- * @param {!string} string
20
- * @returns {string}
21
- */
22
- export function stripAnsi(string) {
23
- return string.replace(kAnsiRegex, "");
24
- }
25
-
26
- /**
27
- * @see https://github.com/sindresorhus/is-unicode-supported
28
- * @returns {boolean}
29
- */
30
- export function isUnicodeSupported() {
31
- if (process.platform !== 'win32') {
32
- return process.env.TERM !== 'linux'; // Linux console (kernel)
33
- }
34
-
35
- return Boolean(process.env.WT_SESSION) // Windows Terminal
36
- || Boolean(process.env.TERMINUS_SUBLIME) // Terminus (<0.2.27)
37
- || process.env.ConEmuTask === '{cmd::Cmder}' // ConEmu and cmder
38
- || process.env.TERM_PROGRAM === 'Terminus-Sublime'
39
- || process.env.TERM_PROGRAM === 'vscode'
40
- || process.env.TERM === 'xterm-256color'
41
- || process.env.TERM === 'alacritty'
42
- || process.env.TERMINAL_EMULATOR === 'JetBrains-JediTerm';
43
- }
package/src/validators.js DELETED
@@ -1,6 +0,0 @@
1
- export function required() {
2
- return {
3
- validate: (input) => (Array.isArray(input) ? input.length > 0 : Boolean(input)),
4
- error: () => "required"
5
- };
6
- }