@reliverse/relinka 1.1.2 → 1.1.3
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-npm/components/checkbox/index.js +8 -6
- package/dist-npm/components/confirm/index.js +7 -4
- package/dist-npm/components/core/Separator.d.ts +0 -4
- package/dist-npm/components/core/create-prompt.js +1 -1
- package/dist-npm/components/core/key.js +6 -6
- package/dist-npm/components/core/lines.d.ts +5 -17
- package/dist-npm/components/core/lines.js +6 -2
- package/dist-npm/components/core/make-theme.js +3 -1
- package/dist-npm/components/core/position.d.ts +0 -8
- package/dist-npm/components/core/position.js +9 -3
- package/dist-npm/components/core/promise-polyfill.js +2 -2
- package/dist-npm/components/core/screen-manager.js +2 -1
- package/dist-npm/components/core/theme.d.ts +12 -146
- package/dist-npm/components/core/theme.js +1 -1
- package/dist-npm/components/core/use-keypress.js +3 -1
- package/dist-npm/components/core/use-pagination.d.ts +4 -8
- package/dist-npm/components/core/use-prefix.js +1 -1
- package/dist-npm/components/core/useKeyPress.js +3 -1
- package/dist-npm/components/core/utils.d.ts +0 -11
- package/dist-npm/components/date/date.js +1 -1
- package/dist-npm/components/expand/index.js +4 -2
- package/dist-npm/components/figures/index.js +5 -5
- package/dist-npm/components/instance/basic.d.ts +0 -12
- package/dist-npm/components/instance/basic.js +1 -1
- package/dist-npm/components/instance/browser.d.ts +0 -14
- package/dist-npm/components/instance/reporter/browser.js +5 -5
- package/dist-npm/components/instance/reporter/fancy.d.ts +1 -1
- package/dist-npm/components/instance/reporter/fancy.js +1 -1
- package/dist-npm/components/mono/mono.js +9 -9
- package/dist-npm/components/mono/monoTwo.d.ts +13 -76
- package/dist-npm/components/password/password-main.js +1 -1
- package/dist-npm/components/progressbar/ProgressBar.d.ts +3 -14
- package/dist-npm/components/progressbar/ProgressBar.js +3 -14
- package/dist-npm/components/progressbar/helper.d.ts +2 -18
- package/dist-npm/components/prompts/create.d.ts +0 -13
- package/dist-npm/components/prompts/prompt.js +3 -3
- package/dist-npm/components/prompts/promptTwo.d.ts +34 -252
- package/dist-npm/components/prompts/promptTwo.js +6 -27
- package/dist-npm/components/prompts/relinka.d.ts +17 -114
- package/dist-npm/components/prompts/relinka.js +18 -103
- package/dist-npm/components/range/range.d.ts +12 -64
- package/dist-npm/components/range/range.js +36 -59
- package/dist-npm/components/rawlist/index.js +6 -4
- package/dist-npm/components/search/index.js +7 -5
- package/dist-npm/components/select/index.js +9 -3
- package/dist-npm/components/select/select-main.js +3 -1
- package/dist-npm/components/select/select-two.js +3 -1
- package/dist-npm/components/toggle/index.js +3 -1
- package/dist-npm/testing/index.js +1 -1
- package/dist-npm/types/general.d.ts +30 -141
- package/dist-npm/types/keypress.d.ts +0 -3
- package/dist-npm/types/keypress.js +1 -1
- package/dist-npm/types/readline.d.ts +1 -9
- package/dist-npm/types/relinka.d.ts +1 -9
- package/dist-npm/types/utils.d.ts +0 -12
- package/dist-npm/utils/box.d.ts +14 -104
- package/dist-npm/utils/color.d.ts +0 -20
- package/dist-npm/utils/colorize.js +2 -1
- package/dist-npm/utils/component.d.ts +5 -26
- package/dist-npm/utils/component.js +1 -2
- package/dist-npm/utils/constants.d.ts +0 -21
- package/dist-npm/utils/constants.js +8 -8
- package/dist-npm/utils/decoder.d.ts +2 -17
- package/dist-npm/utils/decoder.js +54 -25
- package/dist-npm/utils/error.d.ts +0 -5
- package/dist-npm/utils/errors.d.ts +1 -1
- package/dist-npm/utils/errors.js +8 -4
- package/dist-npm/utils/format.d.ts +0 -12
- package/dist-npm/utils/keypress.d.ts +0 -6
- package/dist-npm/utils/keypress.js +12 -23
- package/dist-npm/utils/log.d.ts +0 -11
- package/dist-npm/utils/prompt-tmp.js +2 -2
- package/dist-npm/utils/prompt-two.js +2 -2
- package/dist-npm/utils/skeleton.d.ts +0 -3
- package/dist-npm/utils/skeleton.js +66 -22
- package/dist-npm/utils/stream.d.ts +0 -13
- package/dist-npm/utils/string.d.ts +0 -45
- package/dist-npm/utils/tree.d.ts +5 -34
- package/dist-npm/utils/variants.js +9 -9
- package/package.json +9 -5
|
@@ -47,7 +47,9 @@ function check(checked) {
|
|
|
47
47
|
}
|
|
48
48
|
function normalizeChoices(choices) {
|
|
49
49
|
return choices.map((choice) => {
|
|
50
|
-
if (Separator.isSeparator(choice))
|
|
50
|
+
if (Separator.isSeparator(choice)) {
|
|
51
|
+
return choice;
|
|
52
|
+
}
|
|
51
53
|
if (typeof choice === "string") {
|
|
52
54
|
return {
|
|
53
55
|
value: choice,
|
|
@@ -59,16 +61,16 @@ function normalizeChoices(choices) {
|
|
|
59
61
|
}
|
|
60
62
|
const name = choice.name ?? String(choice.value);
|
|
61
63
|
return {
|
|
62
|
-
|
|
64
|
+
|
|
63
65
|
value: choice.value,
|
|
64
66
|
name,
|
|
65
|
-
|
|
67
|
+
|
|
66
68
|
short: choice.short ?? name,
|
|
67
|
-
|
|
69
|
+
|
|
68
70
|
description: choice.description,
|
|
69
|
-
|
|
71
|
+
|
|
70
72
|
disabled: choice.disabled ?? false,
|
|
71
|
-
|
|
73
|
+
|
|
72
74
|
checked: choice.checked ?? false
|
|
73
75
|
};
|
|
74
76
|
});
|
|
@@ -14,9 +14,12 @@ export default createPrompt((config, done) => {
|
|
|
14
14
|
const prefix = usePrefix({ status, theme });
|
|
15
15
|
useKeypress((key, rl) => {
|
|
16
16
|
if (isEnterKey(key)) {
|
|
17
|
-
let answer = config.default
|
|
18
|
-
if (/^(y|yes)/i.test(value))
|
|
19
|
-
|
|
17
|
+
let answer = config.default;
|
|
18
|
+
if (/^(y|yes)/i.test(value)) {
|
|
19
|
+
answer = true;
|
|
20
|
+
} else if (/^(n|no)/i.test(value)) {
|
|
21
|
+
answer = false;
|
|
22
|
+
}
|
|
20
23
|
setValue(transformer(answer));
|
|
21
24
|
setStatus("done");
|
|
22
25
|
done(answer);
|
|
@@ -30,7 +33,7 @@ export default createPrompt((config, done) => {
|
|
|
30
33
|
formattedValue = theme.style.answer(value);
|
|
31
34
|
} else {
|
|
32
35
|
defaultValue = ` ${theme.style.defaultAnswer(
|
|
33
|
-
config.default
|
|
36
|
+
!config.default ? "y/N" : "Y/n"
|
|
34
37
|
)}`;
|
|
35
38
|
}
|
|
36
39
|
const message = theme.style.message(config.message, status);
|
|
@@ -30,7 +30,7 @@ export function createPrompt(view) {
|
|
|
30
30
|
const callerFilename = callSites[1]?.getFileName?.();
|
|
31
31
|
const prompt = (config, context = {}) => {
|
|
32
32
|
const { input = process.stdin, signal } = context;
|
|
33
|
-
const cleanups =
|
|
33
|
+
const cleanups = new Set();
|
|
34
34
|
const output = new MuteStream();
|
|
35
35
|
output.pipe(context.output ?? process.stdout);
|
|
36
36
|
const rl = readline.createInterface({
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
export const isUpKey = (key) => (
|
|
2
|
-
|
|
3
|
-
key.name === "up" ||
|
|
4
|
-
key.name === "k" ||
|
|
2
|
+
|
|
3
|
+
key.name === "up" ||
|
|
4
|
+
key.name === "k" ||
|
|
5
5
|
key.ctrl && key.name === "p"
|
|
6
6
|
);
|
|
7
7
|
export const isDownKey = (key) => (
|
|
8
|
-
|
|
9
|
-
key.name === "down" ||
|
|
10
|
-
key.name === "j" ||
|
|
8
|
+
|
|
9
|
+
key.name === "down" ||
|
|
10
|
+
key.name === "j" ||
|
|
11
11
|
key.ctrl && key.name === "n"
|
|
12
12
|
);
|
|
13
13
|
export const isSpaceKey = (key) => key.name === "space";
|
|
@@ -1,26 +1,14 @@
|
|
|
1
1
|
import { type Prettify } from "../../types/index.js";
|
|
2
|
-
/** Represents an item that's part of a layout, about to be rendered */
|
|
3
2
|
export type Layout<T> = {
|
|
4
3
|
item: T;
|
|
5
4
|
index: number;
|
|
6
5
|
isActive: boolean;
|
|
7
6
|
};
|
|
8
|
-
/**
|
|
9
|
-
* Renders a page of items as lines that fit within the given width ensuring
|
|
10
|
-
* that the number of lines is not greater than the page size, and the active
|
|
11
|
-
* item renders at the provided position, while prioritizing that as many lines
|
|
12
|
-
* of the active item get rendered as possible.
|
|
13
|
-
*/
|
|
14
7
|
export declare function lines<T>({ items, width, renderItem, active, position: requested, pageSize, }: {
|
|
15
8
|
items: readonly T[];
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
active: number;
|
|
22
|
-
/** The position on the page at which to render the active item. */
|
|
23
|
-
position: number;
|
|
24
|
-
/** The number of lines to render per page. */
|
|
25
|
-
pageSize: number;
|
|
9
|
+
width: number;
|
|
10
|
+
renderItem: (layout: Prettify<Layout<T>>) => string;
|
|
11
|
+
active: number;
|
|
12
|
+
position: number;
|
|
13
|
+
pageSize: number;
|
|
26
14
|
}): string[];
|
|
@@ -31,7 +31,9 @@ export function lines({
|
|
|
31
31
|
while (bufferPointer < pageSize && layoutPointer < layoutsInPage.length) {
|
|
32
32
|
for (const line of renderItemAt(layoutPointer)) {
|
|
33
33
|
pageBuffer[bufferPointer++] = line;
|
|
34
|
-
if (bufferPointer >= pageSize)
|
|
34
|
+
if (bufferPointer >= pageSize) {
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
35
37
|
}
|
|
36
38
|
layoutPointer++;
|
|
37
39
|
}
|
|
@@ -40,7 +42,9 @@ export function lines({
|
|
|
40
42
|
while (bufferPointer >= 0 && layoutPointer >= 0) {
|
|
41
43
|
for (const line of renderItemAt(layoutPointer).reverse()) {
|
|
42
44
|
pageBuffer[bufferPointer--] = line;
|
|
43
|
-
if (bufferPointer < 0)
|
|
45
|
+
if (bufferPointer < 0) {
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
44
48
|
}
|
|
45
49
|
layoutPointer--;
|
|
46
50
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { defaultTheme } from "./theme.js";
|
|
2
2
|
function isPlainObject(value) {
|
|
3
|
-
if (typeof value !== "object" || value === null)
|
|
3
|
+
if (typeof value !== "object" || value === null) {
|
|
4
|
+
return false;
|
|
5
|
+
}
|
|
4
6
|
let proto = value;
|
|
5
7
|
while (Object.getPrototypeOf(proto) !== null) {
|
|
6
8
|
proto = Object.getPrototypeOf(proto);
|
|
@@ -1,16 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates the next position for the active item considering a finite list of
|
|
3
|
-
* items to be rendered on a page.
|
|
4
|
-
*/
|
|
5
1
|
export declare function finite({ active, pageSize, total, }: {
|
|
6
2
|
active: number;
|
|
7
3
|
pageSize: number;
|
|
8
4
|
total: number;
|
|
9
5
|
}): number;
|
|
10
|
-
/**
|
|
11
|
-
* Creates the next position for the active item considering an infinitely
|
|
12
|
-
* looping list of items to be rendered on the page.
|
|
13
|
-
*/
|
|
14
6
|
export declare function infinite({ active, lastActive, total, pageSize, pointer, }: {
|
|
15
7
|
active: number;
|
|
16
8
|
lastActive: number;
|
|
@@ -4,8 +4,12 @@ export function finite({
|
|
|
4
4
|
total
|
|
5
5
|
}) {
|
|
6
6
|
const middle = Math.floor(pageSize / 2);
|
|
7
|
-
if (total <= pageSize || active < middle)
|
|
8
|
-
|
|
7
|
+
if (total <= pageSize || active < middle) {
|
|
8
|
+
return active;
|
|
9
|
+
}
|
|
10
|
+
if (active >= total - middle) {
|
|
11
|
+
return active + pageSize - total;
|
|
12
|
+
}
|
|
9
13
|
return middle;
|
|
10
14
|
}
|
|
11
15
|
export function infinite({
|
|
@@ -15,7 +19,9 @@ export function infinite({
|
|
|
15
19
|
pageSize,
|
|
16
20
|
pointer
|
|
17
21
|
}) {
|
|
18
|
-
if (total <= pageSize)
|
|
22
|
+
if (total <= pageSize) {
|
|
23
|
+
return active;
|
|
24
|
+
}
|
|
19
25
|
if (lastActive < active && active - lastActive < pageSize) {
|
|
20
26
|
return Math.min(Math.floor(pageSize / 2), pointer + active - lastActive);
|
|
21
27
|
}
|
|
@@ -39,8 +39,9 @@ export default class ScreenManager {
|
|
|
39
39
|
let output = content + (bottomContent ? "\n" + bottomContent : "");
|
|
40
40
|
const promptLineUpDiff = Math.floor(rawPromptLine.length / width) - this.cursorPos.rows;
|
|
41
41
|
const bottomContentHeight = promptLineUpDiff + (bottomContent ? height(bottomContent) : 0);
|
|
42
|
-
if (bottomContentHeight > 0)
|
|
42
|
+
if (bottomContentHeight > 0) {
|
|
43
43
|
output += ansiEscapes.cursorUp(bottomContentHeight);
|
|
44
|
+
}
|
|
44
45
|
output += ansiEscapes.cursorTo(this.cursorPos.cols);
|
|
45
46
|
this.write(
|
|
46
47
|
cursorDown(this.extraLinesUnderPrompt) + ansiEscapes.eraseLines(this.height) + output
|
|
@@ -1,153 +1,19 @@
|
|
|
1
1
|
import type { Prettify } from "../../types/index.js";
|
|
2
|
-
/**
|
|
3
|
-
* Union type representing the possible statuses of a prompt.
|
|
4
|
-
*
|
|
5
|
-
* - `'loading'`: The prompt is currently loading.
|
|
6
|
-
* - `'idle'`: The prompt is loaded and currently waiting for the user to
|
|
7
|
-
* submit an answer.
|
|
8
|
-
* - `'done'`: The user has submitted an answer and the prompt is finished.
|
|
9
|
-
* - `string`: Any other string: The prompt is in a custom state.
|
|
10
|
-
*/
|
|
11
2
|
export type Status = "loading" | "idle" | "done" | (string & {});
|
|
12
3
|
type DefaultTheme = {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
*
|
|
18
|
-
* @remarks
|
|
19
|
-
* If `status === 'loading'`, this property is ignored and the spinner (styled
|
|
20
|
-
* by the `spinner` property) will be displayed instead.
|
|
21
|
-
*
|
|
22
|
-
* @defaultValue
|
|
23
|
-
* ```ts
|
|
24
|
-
* // import colors from 'yoctocolors-cjs';
|
|
25
|
-
* (status) => status === 'done' ? colors.green('✔') : colors.blue('?')
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
prefix: string | Prettify<Omit<Record<Status, string>, "loading">>;
|
|
29
|
-
/**
|
|
30
|
-
* Configuration for the spinner that is displayed when the prompt is in the
|
|
31
|
-
* `'loading'` state.
|
|
32
|
-
*
|
|
33
|
-
* We recommend the use of {@link https://github.com/sindresorhus/cli-spinners|cli-spinners} for a list of available spinners.
|
|
34
|
-
*/
|
|
35
|
-
spinner: {
|
|
36
|
-
/**
|
|
37
|
-
* The time interval between frames, in milliseconds.
|
|
38
|
-
*
|
|
39
|
-
* @defaultValue
|
|
40
|
-
* ```ts
|
|
41
|
-
* 80
|
|
42
|
-
* ```
|
|
43
|
-
*/
|
|
44
|
-
interval: number;
|
|
45
|
-
/**
|
|
46
|
-
* A list of frames to show for the spinner.
|
|
47
|
-
*
|
|
48
|
-
* @defaultValue
|
|
49
|
-
* ```ts
|
|
50
|
-
* ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏']
|
|
51
|
-
* ```
|
|
52
|
-
*/
|
|
53
|
-
frames: string[];
|
|
4
|
+
prefix: string | Prettify<Omit<Record<Status, string>, "loading">>;
|
|
5
|
+
spinner: {
|
|
6
|
+
interval: number;
|
|
7
|
+
frames: string[];
|
|
54
8
|
};
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
* @returns The styled answer.
|
|
64
|
-
*
|
|
65
|
-
* @defaultValue
|
|
66
|
-
* ```ts
|
|
67
|
-
* // import colors from 'yoctocolors-cjs';
|
|
68
|
-
* (text) => colors.cyan(text)
|
|
69
|
-
* ```
|
|
70
|
-
*/
|
|
71
|
-
answer: (text: string) => string;
|
|
72
|
-
/**
|
|
73
|
-
* Style to apply to the message displayed to the user.
|
|
74
|
-
*
|
|
75
|
-
* @param text - The message to style.
|
|
76
|
-
* @param status - The current status of the prompt.
|
|
77
|
-
* @returns The styled message.
|
|
78
|
-
*
|
|
79
|
-
* @defaultValue
|
|
80
|
-
* ```ts
|
|
81
|
-
* // import colors from 'yoctocolors-cjs';
|
|
82
|
-
* (text, status) => colors.bold(text)
|
|
83
|
-
* ```
|
|
84
|
-
*/
|
|
85
|
-
message: (text: string, status: Status) => string;
|
|
86
|
-
/**
|
|
87
|
-
* Style to apply to error messages.
|
|
88
|
-
*
|
|
89
|
-
* @param text - The error message.
|
|
90
|
-
* @returns The styled error message.
|
|
91
|
-
*
|
|
92
|
-
* @defaultValue
|
|
93
|
-
* ```ts
|
|
94
|
-
* // import colors from 'yoctocolors-cjs';
|
|
95
|
-
* (text) => colors.red(`> ${text}`)
|
|
96
|
-
* ```
|
|
97
|
-
*/
|
|
98
|
-
error: (text: string) => string;
|
|
99
|
-
/**
|
|
100
|
-
* Style to apply to the default answer when one is provided.
|
|
101
|
-
*
|
|
102
|
-
* @param text - The default answer.
|
|
103
|
-
* @returns The styled default answer.
|
|
104
|
-
*
|
|
105
|
-
* @defaultValue
|
|
106
|
-
* ```ts
|
|
107
|
-
* // import colors from 'yoctocolors-cjs';
|
|
108
|
-
* (text) => colors.dim(`(${text})`)
|
|
109
|
-
* ```
|
|
110
|
-
*/
|
|
111
|
-
defaultAnswer: (text: string) => string;
|
|
112
|
-
/**
|
|
113
|
-
* Style to apply to help text.
|
|
114
|
-
*
|
|
115
|
-
* @param text - The help text.
|
|
116
|
-
* @returns The styled help text.
|
|
117
|
-
*
|
|
118
|
-
* @defaultValue
|
|
119
|
-
* ```ts
|
|
120
|
-
* // import colors from 'yoctocolors-cjs';
|
|
121
|
-
* (text) => colors.dim(text)
|
|
122
|
-
* ```
|
|
123
|
-
*/
|
|
124
|
-
help: (text: string) => string;
|
|
125
|
-
/**
|
|
126
|
-
* Style to apply to highlighted text.
|
|
127
|
-
*
|
|
128
|
-
* @param text - The text to highlight.
|
|
129
|
-
* @returns The highlighted text.
|
|
130
|
-
*
|
|
131
|
-
* @defaultValue
|
|
132
|
-
* ```ts
|
|
133
|
-
* // import colors from 'yoctocolors-cjs';
|
|
134
|
-
* (text) => colors.cyan(text)
|
|
135
|
-
* ```
|
|
136
|
-
*/
|
|
137
|
-
highlight: (text: string) => string;
|
|
138
|
-
/**
|
|
139
|
-
* Style to apply to keyboard keys referred to in help texts.
|
|
140
|
-
*
|
|
141
|
-
* @param text - The key to style.
|
|
142
|
-
* @returns The styled key.
|
|
143
|
-
*
|
|
144
|
-
* @defaultValue
|
|
145
|
-
* ```ts
|
|
146
|
-
* // import colors from 'yoctocolors-cjs';
|
|
147
|
-
* (text) => colors.cyan(colors.bold(`<${text}>`))
|
|
148
|
-
* ```
|
|
149
|
-
*/
|
|
150
|
-
key: (text: string) => string;
|
|
9
|
+
style: {
|
|
10
|
+
answer: (text: string) => string;
|
|
11
|
+
message: (text: string, status: Status) => string;
|
|
12
|
+
error: (text: string) => string;
|
|
13
|
+
defaultAnswer: (text: string) => string;
|
|
14
|
+
help: (text: string) => string;
|
|
15
|
+
highlight: (text: string) => string;
|
|
16
|
+
key: (text: string) => string;
|
|
151
17
|
};
|
|
152
18
|
};
|
|
153
19
|
export type Theme<Extension extends object = object> = Prettify<Extension & DefaultTheme>;
|
|
@@ -7,7 +7,9 @@ export function useKeypress(userHandler) {
|
|
|
7
7
|
useEffect((rl) => {
|
|
8
8
|
let ignore = false;
|
|
9
9
|
const handler = withUpdates((_input, event) => {
|
|
10
|
-
if (ignore)
|
|
10
|
+
if (ignore) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
11
13
|
void signal.current(event, rl);
|
|
12
14
|
});
|
|
13
15
|
rl.input.on("keypress", handler);
|
|
@@ -3,13 +3,9 @@ import { type Layout } from "./lines.js";
|
|
|
3
3
|
import { type Theme } from "./theme.js";
|
|
4
4
|
export declare function usePagination<T>({ items, active, renderItem, pageSize, loop, }: {
|
|
5
5
|
items: readonly T[];
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
/** The size of the page. */
|
|
11
|
-
pageSize: number;
|
|
12
|
-
/** Allows creating an infinitely looping list. `true` if unspecified. */
|
|
13
|
-
loop?: boolean;
|
|
6
|
+
active: number;
|
|
7
|
+
renderItem: (layout: Prettify<Layout<T>>) => string;
|
|
8
|
+
pageSize: number;
|
|
9
|
+
loop?: boolean;
|
|
14
10
|
theme?: Theme;
|
|
15
11
|
}): string;
|
|
@@ -38,5 +38,5 @@ export function usePrefix({
|
|
|
38
38
|
return spinner.frames[tick];
|
|
39
39
|
}
|
|
40
40
|
const iconName = status === "loading" ? "idle" : status;
|
|
41
|
-
return typeof prefix === "string" ? prefix : prefix[iconName] ?? prefix
|
|
41
|
+
return typeof prefix === "string" ? prefix : prefix[iconName] ?? prefix.idle;
|
|
42
42
|
}
|
|
@@ -2,7 +2,9 @@ import { stdin } from "node:process";
|
|
|
2
2
|
import readline from "node:readline";
|
|
3
3
|
export function useKeyPress(callback) {
|
|
4
4
|
readline.emitKeypressEvents(stdin);
|
|
5
|
-
if (stdin.isTTY)
|
|
5
|
+
if (stdin.isTTY) {
|
|
6
|
+
stdin.setRawMode(true);
|
|
7
|
+
}
|
|
6
8
|
const onKeypress = (str, key) => {
|
|
7
9
|
callback(str, key);
|
|
8
10
|
};
|
|
@@ -1,13 +1,2 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Force line returns at specific width. This function is ANSI code friendly and it'll
|
|
3
|
-
* ignore invisible codes during width calculation.
|
|
4
|
-
* @param {string} content
|
|
5
|
-
* @param {number} width
|
|
6
|
-
* @return {string}
|
|
7
|
-
*/
|
|
8
1
|
export declare function breakLines(content: string, width: number): string;
|
|
9
|
-
/**
|
|
10
|
-
* Returns the width of the active readline, or 80 as default value.
|
|
11
|
-
* @returns {number}
|
|
12
|
-
*/
|
|
13
2
|
export declare function readlineWidth(): number;
|
|
@@ -96,7 +96,7 @@ export async function datePrompt(options) {
|
|
|
96
96
|
} else {
|
|
97
97
|
date = new Date(answer);
|
|
98
98
|
}
|
|
99
|
-
if (isNaN(date.getTime()) || date.getFullYear() < 1900 || date >
|
|
99
|
+
if (isNaN(date.getTime()) || date.getFullYear() < 1900 || date > new Date()) {
|
|
100
100
|
errorMessage = "Please enter a valid birthday date (e.g., 14.09.1999).";
|
|
101
101
|
continue;
|
|
102
102
|
}
|
|
@@ -32,7 +32,7 @@ const expand = createPrompt(
|
|
|
32
32
|
(config, done) => {
|
|
33
33
|
const { default: defaultKey = "h" } = config;
|
|
34
34
|
const choices = useMemo(
|
|
35
|
-
|
|
35
|
+
|
|
36
36
|
() => normalizeChoices(config.choices),
|
|
37
37
|
[config.choices]
|
|
38
38
|
);
|
|
@@ -76,7 +76,9 @@ const expand = createPrompt(
|
|
|
76
76
|
const allChoices = expanded ? choices : [...choices, helpChoice];
|
|
77
77
|
let longChoices = "";
|
|
78
78
|
let shortChoices = allChoices.map((choice) => {
|
|
79
|
-
if (Separator.isSeparator(choice))
|
|
79
|
+
if (Separator.isSeparator(choice)) {
|
|
80
|
+
return "";
|
|
81
|
+
}
|
|
80
82
|
if (choice.key === defaultKey) {
|
|
81
83
|
return choice.key.toUpperCase();
|
|
82
84
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import process from "node:process";
|
|
2
2
|
function isUnicodeSupported() {
|
|
3
3
|
if (process.platform !== "win32") {
|
|
4
|
-
return process.env
|
|
4
|
+
return process.env.TERM !== "linux";
|
|
5
5
|
}
|
|
6
|
-
return Boolean(process.env
|
|
7
|
-
Boolean(process.env
|
|
8
|
-
process.env
|
|
9
|
-
process.env
|
|
6
|
+
return Boolean(process.env.WT_SESSION) ||
|
|
7
|
+
Boolean(process.env.TERMINUS_SUBLIME) ||
|
|
8
|
+
process.env.ConEmuTask === "{cmd::Cmder}" ||
|
|
9
|
+
process.env.TERM_PROGRAM === "Terminus-Sublime" || process.env.TERM_PROGRAM === "vscode" || process.env.TERM === "xterm-256color" || process.env.TERM === "alacritty" || process.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
10
10
|
}
|
|
11
11
|
const common = {
|
|
12
12
|
circleQuestionMark: "(?)",
|
|
@@ -1,20 +1,8 @@
|
|
|
1
1
|
import type { RelinkaInstance } from "../../components/prompts/relinka.js";
|
|
2
2
|
import type { RelinkaOptions } from "../../types/general.js";
|
|
3
3
|
export * from "../../components/instance/shared.js";
|
|
4
|
-
/**
|
|
5
|
-
* Factory function to create a new Relinka instance
|
|
6
|
-
*
|
|
7
|
-
* @param {Partial<RelinkaOptions & { fancy: boolean }>} [options={}] - Optional configuration options. See {@link RelinkaOptions}.
|
|
8
|
-
* @returns {RelinkaInstance} A new Relinka instance configured with the given options.
|
|
9
|
-
*/
|
|
10
4
|
export declare function createRelinka(options?: Partial<RelinkaOptions & {
|
|
11
5
|
fancy: boolean;
|
|
12
6
|
}>): RelinkaInstance;
|
|
13
|
-
/**
|
|
14
|
-
* Creates and exports a standard instance of Relinka with the default configuration.
|
|
15
|
-
* This instance can be used directly for logging throughout the application.
|
|
16
|
-
*
|
|
17
|
-
* @type {RelinkaInstance} relinka - The default instance of Relinka.
|
|
18
|
-
*/
|
|
19
7
|
export declare const relinka: RelinkaInstance;
|
|
20
8
|
export default relinka;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BasicReporter } from "../../components/instance/reporter/basic.js";
|
|
2
|
-
import { LogLevels } from "../../utils/constants.js";
|
|
3
2
|
import { createRelinka as _createRelinka } from "../../components/prompts/relinka.js";
|
|
3
|
+
import { LogLevels } from "../../utils/constants.js";
|
|
4
4
|
export * from "../../components/instance/shared.js";
|
|
5
5
|
export function createRelinka(options = {}) {
|
|
6
6
|
let level = LogLevels.info;
|
|
@@ -1,19 +1,5 @@
|
|
|
1
1
|
import type { RelinkaOptions } from "../../types/general.js";
|
|
2
2
|
export * from "../../components/instance/shared.js";
|
|
3
|
-
/**
|
|
4
|
-
* Creates a new Relinka instance configured specifically for browser environments.
|
|
5
|
-
* This function sets up default reporters and a prompt method tailored to the browser's dialogue APIs.
|
|
6
|
-
*
|
|
7
|
-
* @param {Partial<RelinkaOptions>} [options={}] - Optional configuration options.
|
|
8
|
-
* The options can override the default reporter and prompt behavior. See {@link RelinkaOptions}.
|
|
9
|
-
* @returns {RelinkaInstance} A new Relinka instance optimized for use in browser environments.
|
|
10
|
-
*/
|
|
11
3
|
export declare function createRelinka(options?: Partial<RelinkaOptions>): any;
|
|
12
|
-
/**
|
|
13
|
-
* A standard Relinka instance created with browser-specific configurations.
|
|
14
|
-
* This instance can be used throughout a browser-based project.
|
|
15
|
-
*
|
|
16
|
-
* @type {RelinkaInstance} relinka - The default browser-configured Relinka instance.
|
|
17
|
-
*/
|
|
18
4
|
export declare const relinka: any;
|
|
19
5
|
export default relinka;
|
|
@@ -8,15 +8,15 @@ export class BrowserReporter {
|
|
|
8
8
|
this.defaultColor = "#7f8c8d";
|
|
9
9
|
this.levelColorMap = {
|
|
10
10
|
0: "#c0392b",
|
|
11
|
-
|
|
11
|
+
|
|
12
12
|
1: "#f39c12",
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
3: "#00BCD4"
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
};
|
|
17
17
|
this.typeColorMap = {
|
|
18
18
|
success: "#2ecc71"
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
22
|
_getLogFn(level) {
|
|
@@ -45,7 +45,7 @@ export class BrowserReporter {
|
|
|
45
45
|
consoleLogFn(
|
|
46
46
|
`${badge}%c ${logObj.args[0]}`,
|
|
47
47
|
style,
|
|
48
|
-
|
|
48
|
+
|
|
49
49
|
"",
|
|
50
50
|
...logObj.args.slice(1)
|
|
51
51
|
);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { LogLevel, LogType } from "../../../utils/constants.js";
|
|
2
1
|
import type { FormatOptions, LogObject } from "../../../types/general.js";
|
|
2
|
+
import type { LogLevel, LogType } from "../../../utils/constants.js";
|
|
3
3
|
import { BasicReporter } from "./basic.js";
|
|
4
4
|
export declare const TYPE_COLOR_MAP: Partial<Record<LogType, string>>;
|
|
5
5
|
export declare const LEVEL_COLOR_MAP: Partial<Record<LogLevel, string>>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import isUnicodeSupported from "is-unicode-supported";
|
|
2
2
|
import _stringWidth from "string-width";
|
|
3
|
-
import { stripAnsi } from "../../../utils/utils.js";
|
|
4
3
|
import { box } from "../../../utils/box.js";
|
|
5
4
|
import { colors } from "../../../utils/color.js";
|
|
6
5
|
import { parseStack } from "../../../utils/error.js";
|
|
6
|
+
import { stripAnsi } from "../../../utils/utils.js";
|
|
7
7
|
import { BasicReporter } from "./basic.js";
|
|
8
8
|
export const TYPE_COLOR_MAP = {
|
|
9
9
|
info: "cyan",
|
|
@@ -27,15 +27,15 @@ export async function prompt(options) {
|
|
|
27
27
|
case "numSelect":
|
|
28
28
|
value = await numSelectPrompt(options);
|
|
29
29
|
break;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
39
|
case "password":
|
|
40
40
|
value = await passwordPrompt(options);
|
|
41
41
|
break;
|