@reliverse/relinka 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -41
- package/dist-npm/components/core/core.d.ts +2 -0
- package/dist-npm/components/core/core.js +2 -0
- package/dist-npm/{utils/constants.d.ts → components/levels/levels.d.ts} +1 -1
- package/dist-npm/components/{prompts/create.d.ts → modes/basic.d.ts} +3 -3
- package/dist-npm/components/{instance → modes}/basic.js +4 -4
- package/dist-npm/components/{instance → modes}/browser.d.ts +2 -2
- package/dist-npm/components/modes/browser.js +12 -0
- package/dist-npm/components/modes/shared.d.ts +5 -0
- package/dist-npm/components/modes/shared.js +2 -0
- package/dist-npm/components/{prompts → relinka}/relinka.d.ts +2 -4
- package/dist-npm/components/{prompts → relinka}/relinka.js +1 -7
- package/dist-npm/components/{instance/reporter → reporters}/basic.d.ts +1 -1
- package/dist-npm/components/{instance/reporter → reporters}/basic.js +2 -2
- package/dist-npm/components/{instance/reporter → reporters}/browser.d.ts +1 -1
- package/dist-npm/components/{instance/reporter → reporters}/fancy.d.ts +3 -3
- package/dist-npm/components/{instance/reporter → reporters}/fancy.js +5 -7
- package/dist-npm/main.d.ts +8 -1
- package/dist-npm/main.js +34 -1
- package/dist-npm/types/mod.d.ts +42 -0
- package/dist-npm/utils/color.js +4 -1
- package/dist-npm/utils/mod.d.ts +3 -0
- package/dist-npm/utils/mod.js +9 -0
- package/package.json +1 -1
- package/dist-npm/components/anykey/index.d.ts +0 -7
- package/dist-npm/components/anykey/index.js +0 -61
- package/dist-npm/components/block/block.d.ts +0 -10
- package/dist-npm/components/block/block.js +0 -52
- package/dist-npm/components/checkbox/index.d.ts +0 -3
- package/dist-npm/components/checkbox/index.js +0 -217
- package/dist-npm/components/confirm/confirm-main.d.ts +0 -3
- package/dist-npm/components/confirm/confirm-main.js +0 -98
- package/dist-npm/components/confirm/confirm-three.d.ts +0 -13
- package/dist-npm/components/confirm/confirm-three.js +0 -26
- package/dist-npm/components/confirm/index.d.ts +0 -2
- package/dist-npm/components/confirm/index.js +0 -41
- package/dist-npm/components/core/Separator.d.ts +0 -6
- package/dist-npm/components/core/Separator.js +0 -18
- package/dist-npm/components/core/create-prompt.d.ts +0 -4
- package/dist-npm/components/core/create-prompt.js +0 -107
- package/dist-npm/components/core/errors.d.ts +0 -20
- package/dist-npm/components/core/errors.js +0 -21
- package/dist-npm/components/core/hook-engine.d.ts +0 -23
- package/dist-npm/components/core/hook-engine.js +0 -109
- package/dist-npm/components/core/index.d.ts +0 -13
- package/dist-npm/components/core/index.js +0 -12
- package/dist-npm/components/core/key.d.ts +0 -10
- package/dist-npm/components/core/key.js +0 -16
- package/dist-npm/components/core/lines.d.ts +0 -14
- package/dist-npm/components/core/lines.js +0 -52
- package/dist-npm/components/core/make-theme.d.ts +0 -3
- package/dist-npm/components/core/make-theme.js +0 -28
- package/dist-npm/components/core/position.d.ts +0 -12
- package/dist-npm/components/core/position.js +0 -29
- package/dist-npm/components/core/promise-polyfill.d.ts +0 -7
- package/dist-npm/components/core/promise-polyfill.js +0 -13
- package/dist-npm/components/core/screen-manager.d.ts +0 -14
- package/dist-npm/components/core/screen-manager.js +0 -67
- package/dist-npm/components/core/theme.d.ts +0 -21
- package/dist-npm/components/core/theme.js +0 -24
- package/dist-npm/components/core/use-effect.d.ts +0 -2
- package/dist-npm/components/core/use-effect.js +0 -11
- package/dist-npm/components/core/use-keypress.d.ts +0 -3
- package/dist-npm/components/core/use-keypress.js +0 -21
- package/dist-npm/components/core/use-memo.d.ts +0 -1
- package/dist-npm/components/core/use-memo.js +0 -12
- package/dist-npm/components/core/use-pagination.d.ts +0 -11
- package/dist-npm/components/core/use-pagination.js +0 -34
- package/dist-npm/components/core/use-prefix.d.ts +0 -5
- package/dist-npm/components/core/use-prefix.js +0 -42
- package/dist-npm/components/core/use-ref.d.ts +0 -6
- package/dist-npm/components/core/use-ref.js +0 -4
- package/dist-npm/components/core/use-state.d.ts +0 -4
- package/dist-npm/components/core/use-state.js +0 -17
- package/dist-npm/components/core/useKeyPress.d.ts +0 -4
- package/dist-npm/components/core/useKeyPress.js +0 -16
- package/dist-npm/components/core/usePromptState.d.ts +0 -6
- package/dist-npm/components/core/usePromptState.js +0 -10
- package/dist-npm/components/core/utils.d.ts +0 -2
- package/dist-npm/components/core/utils.js +0 -11
- package/dist-npm/components/date/date.d.ts +0 -6
- package/dist-npm/components/date/date.js +0 -210
- package/dist-npm/components/editor/index.d.ts +0 -2
- package/dist-npm/components/editor/index.js +0 -78
- package/dist-npm/components/expand/index.d.ts +0 -3
- package/dist-npm/components/expand/index.js +0 -119
- package/dist-npm/components/figures/index.d.ts +0 -465
- package/dist-npm/components/figures/index.js +0 -299
- package/dist-npm/components/input/index.d.ts +0 -2
- package/dist-npm/components/input/index.js +0 -66
- package/dist-npm/components/input/text-main.d.ts +0 -3
- package/dist-npm/components/input/text-main.js +0 -103
- package/dist-npm/components/input/text.d.ts +0 -11
- package/dist-npm/components/input/text.js +0 -26
- package/dist-npm/components/instance/basic.d.ts +0 -8
- package/dist-npm/components/instance/browser.js +0 -18
- package/dist-npm/components/instance/shared.d.ts +0 -6
- package/dist-npm/components/instance/shared.js +0 -2
- package/dist-npm/components/mono/mono.d.ts +0 -5
- package/dist-npm/components/mono/mono.js +0 -64
- package/dist-npm/components/mono/monoTwo.d.ts +0 -30
- package/dist-npm/components/mono/monoTwo.js +0 -37
- package/dist-npm/components/multiselect/group-multiselect.d.ts +0 -23
- package/dist-npm/components/multiselect/group-multiselect.js +0 -58
- package/dist-npm/components/multiselect/multi-select-two.d.ts +0 -3
- package/dist-npm/components/multiselect/multi-select-two.js +0 -111
- package/dist-npm/components/multiselect/multi-select.d.ts +0 -21
- package/dist-npm/components/multiselect/multi-select.js +0 -45
- package/dist-npm/components/multiselect/multiselect-main.d.ts +0 -18
- package/dist-npm/components/multiselect/multiselect-main.js +0 -166
- package/dist-npm/components/multiselect/num-multi-select.d.ts +0 -3
- package/dist-npm/components/multiselect/num-multi-select.js +0 -111
- package/dist-npm/components/multiselect/num-multiselect-main.d.ts +0 -6
- package/dist-npm/components/multiselect/num-multiselect-main.js +0 -28
- package/dist-npm/components/next-steps/next-steps.d.ts +0 -2
- package/dist-npm/components/next-steps/next-steps.js +0 -24
- package/dist-npm/components/number/index.d.ts +0 -2
- package/dist-npm/components/number/index.js +0 -100
- package/dist-npm/components/number/number-main.d.ts +0 -3
- package/dist-npm/components/number/number-main.js +0 -95
- package/dist-npm/components/password/index.d.ts +0 -2
- package/dist-npm/components/password/index.js +0 -59
- package/dist-npm/components/password/password-main.d.ts +0 -3
- package/dist-npm/components/password/password-main.js +0 -119
- package/dist-npm/components/password/password-three.d.ts +0 -13
- package/dist-npm/components/password/password-three.js +0 -28
- package/dist-npm/components/progressbar/ProgressBar.d.ts +0 -22
- package/dist-npm/components/progressbar/ProgressBar.js +0 -53
- package/dist-npm/components/progressbar/helper.d.ts +0 -6
- package/dist-npm/components/progressbar/helper.js +0 -38
- package/dist-npm/components/progressbar/index.d.ts +0 -2
- package/dist-npm/components/progressbar/index.js +0 -1
- package/dist-npm/components/prompts/create.js +0 -35
- package/dist-npm/components/prompts/index.d.ts +0 -49
- package/dist-npm/components/prompts/index.js +0 -46
- package/dist-npm/components/prompts/prompt.d.ts +0 -36
- package/dist-npm/components/prompts/prompt.js +0 -232
- package/dist-npm/components/prompts/promptTwo.d.ts +0 -92
- package/dist-npm/components/prompts/promptTwo.js +0 -653
- package/dist-npm/components/range/range.d.ts +0 -62
- package/dist-npm/components/range/range.js +0 -270
- package/dist-npm/components/rawlist/index.d.ts +0 -3
- package/dist-npm/components/rawlist/index.js +0 -104
- package/dist-npm/components/results/results.d.ts +0 -10
- package/dist-npm/components/results/results.js +0 -34
- package/dist-npm/components/search/index.d.ts +0 -3
- package/dist-npm/components/search/index.js +0 -186
- package/dist-npm/components/select/index.d.ts +0 -3
- package/dist-npm/components/select/index.js +0 -176
- package/dist-npm/components/select/num-select-main.d.ts +0 -8
- package/dist-npm/components/select/num-select-main.js +0 -30
- package/dist-npm/components/select/num-select.d.ts +0 -5
- package/dist-npm/components/select/num-select.js +0 -125
- package/dist-npm/components/select/select-key.d.ts +0 -15
- package/dist-npm/components/select/select-key.js +0 -26
- package/dist-npm/components/select/select-main.d.ts +0 -19
- package/dist-npm/components/select/select-main.js +0 -151
- package/dist-npm/components/select/select-three.d.ts +0 -18
- package/dist-npm/components/select/select-three.js +0 -35
- package/dist-npm/components/select/select-two.d.ts +0 -2
- package/dist-npm/components/select/select-two.js +0 -98
- package/dist-npm/components/spinner/index.d.ts +0 -15
- package/dist-npm/components/spinner/index.js +0 -110
- package/dist-npm/components/st-end/end.d.ts +0 -2
- package/dist-npm/components/st-end/end.js +0 -35
- package/dist-npm/components/st-end/start.d.ts +0 -2
- package/dist-npm/components/st-end/start.js +0 -32
- package/dist-npm/components/toggle/index.d.ts +0 -13
- package/dist-npm/components/toggle/index.js +0 -121
- package/dist-npm/components/visual/animate/animate.d.ts +0 -13
- package/dist-npm/components/visual/animate/animate.js +0 -55
- package/dist-npm/components/visual/ascii-art/ascii-art.d.ts +0 -6
- package/dist-npm/components/visual/ascii-art/ascii-art.js +0 -12
- package/dist-npm/testing/index.d.ts +0 -18
- package/dist-npm/testing/index.js +0 -64
- package/dist-npm/types/general.d.ts +0 -134
- package/dist-npm/types/index.d.ts +0 -2
- package/dist-npm/types/index.js +0 -2
- package/dist-npm/types/keypress.d.ts +0 -52
- package/dist-npm/types/keypress.js +0 -37
- package/dist-npm/types/readline.d.ts +0 -30
- package/dist-npm/types/readline.js +0 -0
- package/dist-npm/types/relinka.d.ts +0 -30
- package/dist-npm/types/relinka.js +0 -0
- package/dist-npm/types/utils.d.ts +0 -17
- package/dist-npm/types/utils.js +0 -0
- package/dist-npm/utils/colorize.d.ts +0 -2
- package/dist-npm/utils/colorize.js +0 -130
- package/dist-npm/utils/component.d.ts +0 -101
- package/dist-npm/utils/component.js +0 -630
- package/dist-npm/utils/core.d.ts +0 -2
- package/dist-npm/utils/core.js +0 -2
- package/dist-npm/utils/decoder.d.ts +0 -14
- package/dist-npm/utils/decoder.js +0 -281
- package/dist-npm/utils/errors.d.ts +0 -1
- package/dist-npm/utils/errors.js +0 -15
- package/dist-npm/utils/keypress.d.ts +0 -7
- package/dist-npm/utils/keypress.js +0 -327
- package/dist-npm/utils/mapping.d.ts +0 -4
- package/dist-npm/utils/mapping.js +0 -49
- package/dist-npm/utils/messages.d.ts +0 -17
- package/dist-npm/utils/messages.js +0 -213
- package/dist-npm/utils/platforms.d.ts +0 -1
- package/dist-npm/utils/platforms.js +0 -22
- package/dist-npm/utils/prompt-tmp.d.ts +0 -13
- package/dist-npm/utils/prompt-tmp.js +0 -254
- package/dist-npm/utils/prompt-two.d.ts +0 -13
- package/dist-npm/utils/prompt-two.js +0 -254
- package/dist-npm/utils/readline.d.ts +0 -2
- package/dist-npm/utils/readline.js +0 -9
- package/dist-npm/utils/skeleton.d.ts +0 -7
- package/dist-npm/utils/skeleton.js +0 -145
- package/dist-npm/utils/terminal.d.ts +0 -5
- package/dist-npm/utils/terminal.js +0 -33
- package/dist-npm/utils/types.d.ts +0 -0
- package/dist-npm/utils/types.js +0 -0
- package/dist-npm/utils/utils.d.ts +0 -3
- package/dist-npm/utils/utils.js +0 -9
- package/dist-npm/utils/variants.d.ts +0 -9
- package/dist-npm/utils/variants.js +0 -49
- /package/dist-npm/{utils/constants.js → components/levels/levels.js} +0 -0
- /package/dist-npm/components/{instance/reporter → reporters}/browser.js +0 -0
- /package/dist-npm/types/{general.js → mod.js} +0 -0
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
import { greenBright, redBright, dim } from "picocolors";
|
|
2
|
-
import { colorMap, typographyMap } from "../utils/mapping.js";
|
|
3
|
-
import { isUnicodeSupported } from "../utils/platforms.js";
|
|
4
|
-
import { variantMap } from "../utils/variants.js";
|
|
5
|
-
const unicode = isUnicodeSupported();
|
|
6
|
-
const u = (c, fallback) => unicode ? c : fallback;
|
|
7
|
-
export const symbols = {
|
|
8
|
-
pointer: u("\u{1F449}", ">"),
|
|
9
|
-
start: u("\u256D", "T"),
|
|
10
|
-
middle: u("\u2502", "|"),
|
|
11
|
-
end: u("\u2570", "*"),
|
|
12
|
-
line: u("\u2500", "\u2014"),
|
|
13
|
-
corner_top_right: u("\xBB", "T"),
|
|
14
|
-
step_active: u("\u25C6", "\u2666"),
|
|
15
|
-
step_error: u("\u{1F5F4}", "x"),
|
|
16
|
-
info: u("\u2139", "i")
|
|
17
|
-
};
|
|
18
|
-
function applyStyles(text, colorName = "", typographyName = "", variantName = "", borderColor = "") {
|
|
19
|
-
let styledText = text;
|
|
20
|
-
if (!variantName) {
|
|
21
|
-
if (colorName && colorMap[colorName]) {
|
|
22
|
-
styledText = colorMap[colorName](styledText);
|
|
23
|
-
} else if (colorName) {
|
|
24
|
-
console.warn(
|
|
25
|
-
`Warning: Invalid color "${colorName}" provided to applyStyles.`
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
if (typographyName && typographyMap[typographyName]) {
|
|
29
|
-
styledText = typographyMap[typographyName](styledText);
|
|
30
|
-
} else if (typographyName) {
|
|
31
|
-
console.warn(
|
|
32
|
-
`Warning: Invalid typography "${typographyName}" provided to applyStyles.`
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
if (variantName && variantMap[variantName]) {
|
|
37
|
-
styledText = variantMap[variantName](styledText, borderColor);
|
|
38
|
-
} else if (variantName) {
|
|
39
|
-
console.warn(
|
|
40
|
-
`Warning: Invalid variant "${variantName}" provided to applyStyles.`
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
return styledText;
|
|
44
|
-
}
|
|
45
|
-
export const bar = ({
|
|
46
|
-
borderColor = "viceGradient"
|
|
47
|
-
}) => colorMap[borderColor](symbols.middle);
|
|
48
|
-
export function fmt(opts) {
|
|
49
|
-
if (opts.title?.includes("\u2502 ") && !opts.dontRemoveBar) {
|
|
50
|
-
opts.title = opts.title.replace("\u2502 ", "");
|
|
51
|
-
}
|
|
52
|
-
if (!opts.borderColor) {
|
|
53
|
-
opts.borderColor = "viceGradient";
|
|
54
|
-
}
|
|
55
|
-
const formattedBar = bar({ borderColor: opts.borderColor });
|
|
56
|
-
const prefixStartLine = opts.borderColor ? colorMap[opts.borderColor](symbols.start + symbols.line) : symbols.start + symbols.line;
|
|
57
|
-
const prefixEndLine = opts.borderColor ? colorMap[opts.borderColor](symbols.end + symbols.line) : symbols.end + symbols.line;
|
|
58
|
-
const suffixStartLine = opts.borderColor ? colorMap[opts.borderColor](`${symbols.line.repeat(28)}\u22B1`) : `${symbols.line.repeat(28)}\u22B1`;
|
|
59
|
-
const suffixEndLine = opts.borderColor ? colorMap[opts.borderColor](`${symbols.line.repeat(58)}\u22B1`) : `${symbols.line.repeat(58)}\u22B1`;
|
|
60
|
-
const MSG_CONFIGS = {
|
|
61
|
-
M_NULL: {
|
|
62
|
-
symbol: "",
|
|
63
|
-
prefix: "",
|
|
64
|
-
suffix: "",
|
|
65
|
-
newLineBefore: opts.addNewLineBefore ?? false,
|
|
66
|
-
newLineAfter: opts.addNewLineAfter ?? false
|
|
67
|
-
},
|
|
68
|
-
M_INFO_NULL: {
|
|
69
|
-
symbol: "",
|
|
70
|
-
prefix: formattedBar,
|
|
71
|
-
suffix: "",
|
|
72
|
-
newLineBefore: opts.addNewLineBefore ?? false,
|
|
73
|
-
newLineAfter: opts.addNewLineAfter ?? false
|
|
74
|
-
},
|
|
75
|
-
M_START: {
|
|
76
|
-
symbol: "",
|
|
77
|
-
prefix: prefixStartLine,
|
|
78
|
-
suffix: ` ${suffixStartLine}
|
|
79
|
-
${formattedBar}`,
|
|
80
|
-
newLineBefore: opts.addNewLineBefore ?? false,
|
|
81
|
-
newLineAfter: opts.addNewLineAfter ?? false
|
|
82
|
-
},
|
|
83
|
-
M_MIDDLE: {
|
|
84
|
-
symbol: formattedBar,
|
|
85
|
-
prefix: "",
|
|
86
|
-
suffix: "",
|
|
87
|
-
newLineBefore: opts.addNewLineBefore ?? false,
|
|
88
|
-
newLineAfter: opts.addNewLineAfter ?? false
|
|
89
|
-
},
|
|
90
|
-
M_GENERAL: {
|
|
91
|
-
symbol: "",
|
|
92
|
-
prefix: greenBright(symbols.step_active),
|
|
93
|
-
suffix: opts.placeholder ? dim(opts.placeholder) + "\n" + formattedBar + " " : "",
|
|
94
|
-
newLineBefore: opts.addNewLineBefore ?? false,
|
|
95
|
-
newLineAfter: opts.addNewLineAfter ?? true
|
|
96
|
-
},
|
|
97
|
-
M_GENERAL_NULL: {
|
|
98
|
-
symbol: "",
|
|
99
|
-
prefix: "",
|
|
100
|
-
suffix: opts.placeholder ? dim(opts.placeholder) + "\n" + formattedBar + " " : "",
|
|
101
|
-
newLineBefore: opts.addNewLineBefore ?? false,
|
|
102
|
-
newLineAfter: opts.addNewLineAfter ?? true
|
|
103
|
-
},
|
|
104
|
-
M_INFO: {
|
|
105
|
-
symbol: "",
|
|
106
|
-
prefix: greenBright(symbols.info),
|
|
107
|
-
suffix: "",
|
|
108
|
-
newLineBefore: opts.addNewLineBefore ?? false,
|
|
109
|
-
newLineAfter: opts.addNewLineAfter ?? true
|
|
110
|
-
},
|
|
111
|
-
M_ERROR: {
|
|
112
|
-
symbol: "",
|
|
113
|
-
prefix: redBright(symbols.step_error),
|
|
114
|
-
newLineBefore: opts.addNewLineBefore ?? false,
|
|
115
|
-
newLineAfter: opts.addNewLineAfter ?? true
|
|
116
|
-
},
|
|
117
|
-
M_ERROR_NULL: {
|
|
118
|
-
symbol: "",
|
|
119
|
-
prefix: "",
|
|
120
|
-
newLineBefore: opts.addNewLineBefore ?? false,
|
|
121
|
-
newLineAfter: opts.addNewLineAfter ?? true
|
|
122
|
-
},
|
|
123
|
-
M_END: {
|
|
124
|
-
symbol: "",
|
|
125
|
-
prefix: greenBright(symbols.info),
|
|
126
|
-
suffix: opts.border ? `
|
|
127
|
-
${formattedBar}
|
|
128
|
-
${prefixEndLine}${suffixEndLine}
|
|
129
|
-
` : "",
|
|
130
|
-
newLineBefore: opts.addNewLineBefore ?? false,
|
|
131
|
-
newLineAfter: opts.addNewLineAfter ?? false
|
|
132
|
-
},
|
|
133
|
-
M_NEWLINE: {
|
|
134
|
-
symbol: "",
|
|
135
|
-
prefix: formattedBar,
|
|
136
|
-
newLineBefore: opts.addNewLineBefore ?? false,
|
|
137
|
-
newLineAfter: opts.addNewLineAfter ?? false
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
const config = MSG_CONFIGS[opts.type];
|
|
141
|
-
if (!config) {
|
|
142
|
-
throw new Error(`Invalid message type: ${opts.type}`);
|
|
143
|
-
}
|
|
144
|
-
const {
|
|
145
|
-
symbol = "",
|
|
146
|
-
prefix = "",
|
|
147
|
-
suffix = "",
|
|
148
|
-
newLineBefore = false,
|
|
149
|
-
newLineAfter = false
|
|
150
|
-
} = config;
|
|
151
|
-
const formattedPrefix = prefix ? `${prefix}${opts.type === "M_START" ? " " : " "}` : "";
|
|
152
|
-
const border = applyStyles(symbols.middle, opts.borderColor);
|
|
153
|
-
const borderError = applyStyles(symbols.middle, "red");
|
|
154
|
-
const borderWithSpace = `${border} `;
|
|
155
|
-
let formattedTitle = "";
|
|
156
|
-
if (opts.title) {
|
|
157
|
-
formattedTitle = applyStyles(
|
|
158
|
-
opts.title,
|
|
159
|
-
opts.titleColor,
|
|
160
|
-
opts.titleTypography,
|
|
161
|
-
opts.titleVariant,
|
|
162
|
-
opts.borderColor
|
|
163
|
-
);
|
|
164
|
-
if (opts.hint) {
|
|
165
|
-
formattedTitle += `
|
|
166
|
-
${borderWithSpace}${colorMap.blueBright(opts.hint)}`;
|
|
167
|
-
}
|
|
168
|
-
if (opts.errorMessage) {
|
|
169
|
-
const formattedError = applyStyles(
|
|
170
|
-
opts.errorMessage,
|
|
171
|
-
"red",
|
|
172
|
-
"bold",
|
|
173
|
-
"",
|
|
174
|
-
opts.borderColor
|
|
175
|
-
);
|
|
176
|
-
formattedTitle += `
|
|
177
|
-
${borderError} ${formattedError}`;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
let formattedContent = "";
|
|
181
|
-
if (opts.content) {
|
|
182
|
-
const contentLines = opts.content.split("\n");
|
|
183
|
-
formattedContent = contentLines.map((line) => {
|
|
184
|
-
const styledLine = applyStyles(
|
|
185
|
-
line,
|
|
186
|
-
opts.contentColor,
|
|
187
|
-
opts.contentTypography,
|
|
188
|
-
opts.contentVariant,
|
|
189
|
-
opts.borderColor
|
|
190
|
-
);
|
|
191
|
-
if (opts.type !== "M_START") {
|
|
192
|
-
return `${borderWithSpace}${styledLine}`;
|
|
193
|
-
} else {
|
|
194
|
-
return styledLine;
|
|
195
|
-
}
|
|
196
|
-
}).join("\n");
|
|
197
|
-
}
|
|
198
|
-
const text = [formattedTitle, formattedContent].filter(Boolean).join(`
|
|
199
|
-
`);
|
|
200
|
-
return [
|
|
201
|
-
symbol,
|
|
202
|
-
newLineBefore ? `
|
|
203
|
-
${formattedBar} ` : "",
|
|
204
|
-
formattedPrefix,
|
|
205
|
-
text,
|
|
206
|
-
newLineAfter ? `
|
|
207
|
-
${formattedBar} ` : "",
|
|
208
|
-
suffix
|
|
209
|
-
].filter(Boolean).join("");
|
|
210
|
-
}
|
|
211
|
-
export function msg(opts) {
|
|
212
|
-
console[opts.type === "M_ERROR" || opts.type === "M_ERROR_NULL" ? "error" : "log"](fmt(opts));
|
|
213
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function isUnicodeSupported(): boolean;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import process from "node:process";
|
|
2
|
-
const platforms = {
|
|
3
|
-
linux: process.platform !== "win32",
|
|
4
|
-
win32: process.platform === "win32"
|
|
5
|
-
};
|
|
6
|
-
const terminals = {
|
|
7
|
-
linuxConsoleKernel: process.env.TERM !== "linux",
|
|
8
|
-
windowsTerminal: Boolean(process.env.WT_SESSION),
|
|
9
|
-
terminusSublimeOld: Boolean(process.env.TERMINUS_SUBLIME),
|
|
10
|
-
cmderTerminal: process.env.ConEmuTask === "{cmd::Cmder}",
|
|
11
|
-
terminusSublimeNew: process.env.TERM_PROGRAM === "Terminus-Sublime",
|
|
12
|
-
visualStudioCode: process.env.TERM_PROGRAM === "vscode",
|
|
13
|
-
xterm256color: process.env.TERM === "xterm-256color",
|
|
14
|
-
alacrittyTerminal: process.env.TERM === "alacritty",
|
|
15
|
-
jetbrainsJediTerm: process.env.TERMINAL_EMULATOR === "JetBrains-JediTerm"
|
|
16
|
-
};
|
|
17
|
-
export function isUnicodeSupported() {
|
|
18
|
-
if (platforms.linux) {
|
|
19
|
-
return terminals.linuxConsoleKernel;
|
|
20
|
-
}
|
|
21
|
-
return terminals.windowsTerminal || terminals.terminusSublimeOld || terminals.cmderTerminal || terminals.terminusSublimeNew || terminals.visualStudioCode || terminals.xterm256color || terminals.alacrittyTerminal || terminals.jetbrainsJediTerm;
|
|
22
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Readable, Writable } from "node:stream";
|
|
2
|
-
export declare function isCancel(value: unknown): value is symbol;
|
|
3
|
-
export type PromptOptions<Self> = {
|
|
4
|
-
render(this: Omit<Self, "prompt">): string | void;
|
|
5
|
-
placeholder?: string;
|
|
6
|
-
initialValue?: any;
|
|
7
|
-
validate?: ((value: any) => string | void) | undefined;
|
|
8
|
-
input?: Readable;
|
|
9
|
-
output?: Writable;
|
|
10
|
-
debug?: boolean;
|
|
11
|
-
};
|
|
12
|
-
export type StateDeprecated = "initial" | "active" | "cancel" | "submit" | "error";
|
|
13
|
-
export declare function createPrompt({ render: renderFn, input, output, ...opts }: PromptOptions<any>, trackValue?: boolean): any;
|
|
@@ -1,254 +0,0 @@
|
|
|
1
|
-
import { stdin, stdout } from "node:process";
|
|
2
|
-
import readline from "node:readline";
|
|
3
|
-
import { WriteStream } from "node:tty";
|
|
4
|
-
import { cursor, erase } from "sisteransi";
|
|
5
|
-
import wrap from "wrap-ansi";
|
|
6
|
-
function diffLines(a, b) {
|
|
7
|
-
if (a === b) {
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
const aLines = a.split("\n");
|
|
11
|
-
const bLines = b.split("\n");
|
|
12
|
-
const diff = [];
|
|
13
|
-
for (let i = 0; i < Math.max(aLines.length, bLines.length); i++) {
|
|
14
|
-
if (aLines[i] !== bLines[i]) {
|
|
15
|
-
diff.push(i);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
return diff;
|
|
19
|
-
}
|
|
20
|
-
const cancel = Symbol("rp:cancel");
|
|
21
|
-
export function isCancel(value) {
|
|
22
|
-
return value === cancel;
|
|
23
|
-
}
|
|
24
|
-
function setRawMode(input, value) {
|
|
25
|
-
if (input.isTTY) {
|
|
26
|
-
input.setRawMode(value);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
const aliases = new Map([
|
|
30
|
-
["k", "up"],
|
|
31
|
-
["j", "down"],
|
|
32
|
-
["h", "left"],
|
|
33
|
-
["l", "right"]
|
|
34
|
-
]);
|
|
35
|
-
const keys = new Set(["up", "down", "left", "right", "space", "enter"]);
|
|
36
|
-
export function createPrompt({
|
|
37
|
-
render: renderFn,
|
|
38
|
-
input = stdin,
|
|
39
|
-
output = stdout,
|
|
40
|
-
...opts
|
|
41
|
-
}, trackValue = true) {
|
|
42
|
-
const _input = input;
|
|
43
|
-
const _output = output;
|
|
44
|
-
let _rl;
|
|
45
|
-
const _opts = opts;
|
|
46
|
-
const _track = trackValue;
|
|
47
|
-
let _cursor = 0;
|
|
48
|
-
let state = "initial";
|
|
49
|
-
let value = _opts.initialValue ?? "";
|
|
50
|
-
let error = "";
|
|
51
|
-
const subscribers = /* @__PURE__ */ new Map();
|
|
52
|
-
let _prevFrame = "";
|
|
53
|
-
const self = {};
|
|
54
|
-
const _render = () => renderFn.call(self);
|
|
55
|
-
function prompt() {
|
|
56
|
-
const sink = new WriteStream(0);
|
|
57
|
-
sink._write = (chunk, encoding, done) => {
|
|
58
|
-
if (_track) {
|
|
59
|
-
value = _rl.line.replace(/\t/g, "");
|
|
60
|
-
_cursor = _rl.cursor;
|
|
61
|
-
emit("value", value);
|
|
62
|
-
}
|
|
63
|
-
done();
|
|
64
|
-
};
|
|
65
|
-
_input.pipe(sink);
|
|
66
|
-
_rl = readline.createInterface({
|
|
67
|
-
input: _input,
|
|
68
|
-
output: sink,
|
|
69
|
-
tabSize: 2,
|
|
70
|
-
prompt: "",
|
|
71
|
-
escapeCodeTimeout: 50
|
|
72
|
-
});
|
|
73
|
-
readline.emitKeypressEvents(_input, _rl);
|
|
74
|
-
_rl.prompt();
|
|
75
|
-
if (_opts.initialValue !== void 0 && _track) {
|
|
76
|
-
_rl.write(_opts.initialValue);
|
|
77
|
-
}
|
|
78
|
-
_input.on("keypress", onKeypress);
|
|
79
|
-
setRawMode(_input, true);
|
|
80
|
-
_output.on("resize", render);
|
|
81
|
-
render();
|
|
82
|
-
return new Promise((resolve) => {
|
|
83
|
-
once("submit", () => {
|
|
84
|
-
_output.write(cursor.show);
|
|
85
|
-
_output.off("resize", render);
|
|
86
|
-
setRawMode(_input, false);
|
|
87
|
-
resolve(value);
|
|
88
|
-
});
|
|
89
|
-
once("cancel", () => {
|
|
90
|
-
_output.write(cursor.show);
|
|
91
|
-
_output.off("resize", render);
|
|
92
|
-
setRawMode(_input, false);
|
|
93
|
-
resolve(cancel);
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
function on(event, cb) {
|
|
98
|
-
const arr = subscribers.get(event) ?? [];
|
|
99
|
-
arr.push({ cb });
|
|
100
|
-
subscribers.set(event, arr);
|
|
101
|
-
}
|
|
102
|
-
function once(event, cb) {
|
|
103
|
-
const arr = subscribers.get(event) ?? [];
|
|
104
|
-
arr.push({ cb, once: true });
|
|
105
|
-
subscribers.set(event, arr);
|
|
106
|
-
}
|
|
107
|
-
function emit(event, ...data) {
|
|
108
|
-
const cbs = subscribers.get(event) ?? [];
|
|
109
|
-
const cleanup = [];
|
|
110
|
-
for (const subscriber of cbs) {
|
|
111
|
-
subscriber.cb(...data);
|
|
112
|
-
if (subscriber.once) {
|
|
113
|
-
cleanup.push(() => cbs.splice(cbs.indexOf(subscriber), 1));
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
for (const cb of cleanup) {
|
|
117
|
-
cb();
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
function unsubscribe() {
|
|
121
|
-
subscribers.clear();
|
|
122
|
-
}
|
|
123
|
-
function onKeypress(char, key) {
|
|
124
|
-
if (state === "error") {
|
|
125
|
-
state = "active";
|
|
126
|
-
}
|
|
127
|
-
if (key?.name && !_track && aliases.has(key.name)) {
|
|
128
|
-
emit("cursor", aliases.get(key.name));
|
|
129
|
-
}
|
|
130
|
-
if (key?.name && keys.has(key.name)) {
|
|
131
|
-
emit("cursor", key.name);
|
|
132
|
-
}
|
|
133
|
-
if (char && (char.toLowerCase() === "y" || char.toLowerCase() === "n")) {
|
|
134
|
-
emit("confirm", char.toLowerCase() === "y");
|
|
135
|
-
}
|
|
136
|
-
if (char === " " && _opts.placeholder) {
|
|
137
|
-
if (!value) {
|
|
138
|
-
_rl.write(_opts.placeholder);
|
|
139
|
-
emit("value", _opts.placeholder);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
if (char) {
|
|
143
|
-
emit("key", char.toLowerCase());
|
|
144
|
-
}
|
|
145
|
-
if (key?.name === "return") {
|
|
146
|
-
if (_opts.validate) {
|
|
147
|
-
const problem = _opts.validate(value);
|
|
148
|
-
if (problem) {
|
|
149
|
-
error = problem;
|
|
150
|
-
state = "error";
|
|
151
|
-
_rl.write(value);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
if (state !== "error") {
|
|
155
|
-
state = "submit";
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
if (char === "") {
|
|
159
|
-
state = "cancel";
|
|
160
|
-
}
|
|
161
|
-
if (state === "submit" || state === "cancel") {
|
|
162
|
-
emit("finalize");
|
|
163
|
-
}
|
|
164
|
-
render();
|
|
165
|
-
if (state === "submit" || state === "cancel") {
|
|
166
|
-
close();
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
function close() {
|
|
170
|
-
_input.unpipe();
|
|
171
|
-
_input.removeListener("keypress", onKeypress);
|
|
172
|
-
_output.write("\n");
|
|
173
|
-
setRawMode(_input, false);
|
|
174
|
-
_rl.close();
|
|
175
|
-
emit(state, value);
|
|
176
|
-
unsubscribe();
|
|
177
|
-
}
|
|
178
|
-
function restoreCursor() {
|
|
179
|
-
const lines = wrap(_prevFrame, process.stdout.columns, { hard: true }).split("\n").length - 1;
|
|
180
|
-
_output.write(cursor.move(-999, lines * -1));
|
|
181
|
-
}
|
|
182
|
-
function render() {
|
|
183
|
-
const frame = wrap(_render() || "", process.stdout.columns, {
|
|
184
|
-
hard: true
|
|
185
|
-
});
|
|
186
|
-
if (frame === _prevFrame) {
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
|
-
if (state === "initial") {
|
|
190
|
-
_output.write(cursor.hide);
|
|
191
|
-
} else {
|
|
192
|
-
const diff = diffLines(_prevFrame, frame);
|
|
193
|
-
restoreCursor();
|
|
194
|
-
if (diff && diff.length === 1) {
|
|
195
|
-
const diffLine = diff[0];
|
|
196
|
-
_output.write(cursor.move(0, diffLine));
|
|
197
|
-
_output.write(erase.lines(1));
|
|
198
|
-
const lines = frame.split("\n");
|
|
199
|
-
_output.write(lines[diffLine]);
|
|
200
|
-
_prevFrame = frame;
|
|
201
|
-
_output.write(cursor.move(0, lines.length - diffLine - 1));
|
|
202
|
-
return;
|
|
203
|
-
} else if (diff && diff.length > 1) {
|
|
204
|
-
const diffLine = diff[0];
|
|
205
|
-
_output.write(cursor.move(0, diffLine));
|
|
206
|
-
_output.write(erase.down());
|
|
207
|
-
const lines = frame.split("\n");
|
|
208
|
-
const newLines = lines.slice(diffLine);
|
|
209
|
-
_output.write(newLines.join("\n"));
|
|
210
|
-
_prevFrame = frame;
|
|
211
|
-
return;
|
|
212
|
-
}
|
|
213
|
-
_output.write(erase.down());
|
|
214
|
-
}
|
|
215
|
-
_output.write(frame);
|
|
216
|
-
if (state === "initial") {
|
|
217
|
-
state = "active";
|
|
218
|
-
}
|
|
219
|
-
_prevFrame = frame;
|
|
220
|
-
}
|
|
221
|
-
Object.assign(self, {
|
|
222
|
-
prompt,
|
|
223
|
-
on,
|
|
224
|
-
once,
|
|
225
|
-
emit,
|
|
226
|
-
close,
|
|
227
|
-
render,
|
|
228
|
-
get state() {
|
|
229
|
-
return state;
|
|
230
|
-
},
|
|
231
|
-
set state(val) {
|
|
232
|
-
state = val;
|
|
233
|
-
},
|
|
234
|
-
get value() {
|
|
235
|
-
return value;
|
|
236
|
-
},
|
|
237
|
-
set value(val) {
|
|
238
|
-
value = val;
|
|
239
|
-
},
|
|
240
|
-
get error() {
|
|
241
|
-
return error;
|
|
242
|
-
},
|
|
243
|
-
set error(val) {
|
|
244
|
-
error = val;
|
|
245
|
-
},
|
|
246
|
-
_cursor,
|
|
247
|
-
_track,
|
|
248
|
-
_input,
|
|
249
|
-
_output,
|
|
250
|
-
_rl,
|
|
251
|
-
_opts
|
|
252
|
-
});
|
|
253
|
-
return self;
|
|
254
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Readable, Writable } from "node:stream";
|
|
2
|
-
export declare function isCancel(value: unknown): value is symbol;
|
|
3
|
-
export type PromptOptions<Self> = {
|
|
4
|
-
render(this: Omit<Self, "prompt">): string | void;
|
|
5
|
-
placeholder?: string;
|
|
6
|
-
initialValue?: any;
|
|
7
|
-
validate?: ((value: any) => string | void) | undefined;
|
|
8
|
-
input?: Readable;
|
|
9
|
-
output?: Writable;
|
|
10
|
-
debug?: boolean;
|
|
11
|
-
};
|
|
12
|
-
export type StateDeprecated = "initial" | "active" | "cancel" | "submit" | "error";
|
|
13
|
-
export declare function createPrompt({ render: renderFn, input, output, ...opts }: PromptOptions<any>, trackValue?: boolean): any;
|