@reliverse/relinka 1.1.6 → 1.1.8
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/anykey/index.js +57 -77
- package/dist-npm/components/block/block.js +48 -61
- package/dist-npm/components/checkbox/index.js +178 -211
- package/dist-npm/components/confirm/confirm-main.js +85 -122
- package/dist-npm/components/confirm/confirm-three.js +24 -27
- package/dist-npm/components/confirm/index.js +36 -45
- package/dist-npm/components/core/Separator.js +15 -17
- package/dist-npm/components/core/create-prompt.js +101 -124
- package/dist-npm/components/core/errors.js +19 -15
- package/dist-npm/components/core/hook-engine.js +91 -120
- package/dist-npm/components/core/index.js +12 -12
- package/dist-npm/components/core/key.js +16 -6
- package/dist-npm/components/core/lines.js +45 -54
- package/dist-npm/components/core/make-theme.js +21 -30
- package/dist-npm/components/core/position.js +27 -23
- package/dist-npm/components/core/promise-polyfill.js +11 -14
- package/dist-npm/components/core/screen-manager.js +59 -74
- package/dist-npm/components/core/theme.js +22 -32
- package/dist-npm/components/core/use-effect.js +9 -15
- package/dist-npm/components/core/use-keypress.js +19 -23
- package/dist-npm/components/core/use-memo.js +10 -16
- package/dist-npm/components/core/use-pagination.js +33 -32
- package/dist-npm/components/core/use-prefix.js +40 -38
- package/dist-npm/components/core/use-ref.js +2 -5
- package/dist-npm/components/core/use-state.js +15 -23
- package/dist-npm/components/core/useKeyPress.js +14 -17
- package/dist-npm/components/core/usePromptState.js +8 -14
- package/dist-npm/components/core/utils.js +7 -16
- package/dist-npm/components/date/date.js +173 -204
- package/dist-npm/components/editor/index.js +71 -92
- package/dist-npm/components/expand/index.js +96 -124
- package/dist-npm/components/figures/index.js +283 -294
- package/dist-npm/components/input/index.js +61 -87
- package/dist-npm/components/input/text-main.js +97 -124
- package/dist-npm/components/input/text.js +24 -28
- package/dist-npm/components/instance/basic.js +17 -25
- package/dist-npm/components/instance/browser.js +14 -18
- package/dist-npm/components/instance/reporter/basic.js +46 -65
- package/dist-npm/components/instance/reporter/browser.js +44 -47
- package/dist-npm/components/instance/reporter/fancy.js +83 -96
- package/dist-npm/components/instance/shared.js +2 -2
- package/dist-npm/components/mono/mono.js +52 -62
- package/dist-npm/components/mono/monoTwo.js +35 -49
- package/dist-npm/components/multiselect/group-multiselect.js +55 -71
- package/dist-npm/components/multiselect/multi-select-two.js +97 -130
- package/dist-npm/components/multiselect/multi-select.js +43 -49
- package/dist-npm/components/multiselect/multiselect-main.d.ts +1 -0
- package/dist-npm/components/multiselect/multiselect-main.js +158 -145
- package/dist-npm/components/multiselect/num-multi-select.js +97 -130
- package/dist-npm/components/multiselect/num-multiselect-main.js +24 -35
- package/dist-npm/components/next-steps/next-steps.js +23 -25
- package/dist-npm/components/number/index.js +78 -112
- package/dist-npm/components/number/number-main.js +95 -2
- package/dist-npm/components/password/index.js +54 -73
- package/dist-npm/components/password/password-main.js +119 -2
- package/dist-npm/components/password/password-three.js +26 -30
- package/dist-npm/components/progressbar/ProgressBar.js +45 -64
- package/dist-npm/components/progressbar/helper.js +33 -40
- package/dist-npm/components/progressbar/index.js +1 -1
- package/dist-npm/components/prompts/create.js +29 -44
- package/dist-npm/components/prompts/index.d.ts +1 -0
- package/dist-npm/components/prompts/index.js +46 -45
- package/dist-npm/components/prompts/prompt.js +211 -260
- package/dist-npm/components/prompts/promptTwo.js +561 -605
- package/dist-npm/components/prompts/relinka.js +237 -295
- package/dist-npm/components/range/range.js +247 -294
- package/dist-npm/components/rawlist/index.js +87 -107
- package/dist-npm/components/results/results.js +31 -37
- package/dist-npm/components/search/index.js +148 -193
- package/dist-npm/components/select/index.js +148 -186
- package/dist-npm/components/select/num-select-main.js +27 -27
- package/dist-npm/components/select/num-select.js +124 -5
- package/dist-npm/components/select/select-key.js +24 -25
- package/dist-npm/components/select/select-main.d.ts +1 -0
- package/dist-npm/components/select/select-main.js +143 -133
- package/dist-npm/components/select/select-three.js +32 -36
- package/dist-npm/components/select/select-two.js +94 -87
- package/dist-npm/components/spinner/index.js +107 -136
- package/dist-npm/components/st-end/end.js +34 -26
- package/dist-npm/components/st-end/start.js +29 -15
- package/dist-npm/components/toggle/index.js +113 -137
- package/dist-npm/components/visual/animate/animate.js +53 -10
- package/dist-npm/components/visual/ascii-art/ascii-art.js +12 -1
- package/dist-npm/main.js +1 -0
- package/dist-npm/testing/index.js +58 -83
- package/dist-npm/types/general.d.ts +1 -1
- package/dist-npm/types/general.js +0 -1
- package/dist-npm/types/index.js +2 -3
- package/dist-npm/types/keypress.js +35 -36
- package/dist-npm/types/readline.js +0 -1
- package/dist-npm/types/relinka.js +0 -1
- package/dist-npm/types/utils.js +0 -1
- package/dist-npm/utils/box.js +135 -137
- package/dist-npm/utils/color.js +65 -74
- package/dist-npm/utils/colorize.js +124 -156
- package/dist-npm/utils/component.js +532 -657
- package/dist-npm/utils/constants.js +64 -63
- package/dist-npm/utils/core.js +2 -3
- package/dist-npm/utils/decoder.js +244 -223
- package/dist-npm/utils/error.js +4 -9
- package/dist-npm/utils/errors.js +14 -4
- package/dist-npm/utils/format.js +19 -24
- package/dist-npm/utils/keypress.js +316 -414
- package/dist-npm/utils/log.js +11 -15
- package/dist-npm/utils/mapping.js +45 -52
- package/dist-npm/utils/messages.js +196 -183
- package/dist-npm/utils/platforms.js +16 -20
- package/dist-npm/utils/prompt-tmp.js +235 -286
- package/dist-npm/utils/prompt-two.js +235 -286
- package/dist-npm/utils/readline.js +5 -7
- package/dist-npm/utils/skeleton.js +130 -170
- package/dist-npm/utils/stream.js +2 -2
- package/dist-npm/utils/string.js +44 -58
- package/dist-npm/utils/terminal.js +23 -34
- package/dist-npm/utils/tree.js +30 -41
- package/dist-npm/utils/types.js +0 -1
- package/dist-npm/utils/utils.js +8 -8
- package/dist-npm/utils/variants.js +36 -44
- package/package.json +14 -14
- package/dist-npm/mod.js +0 -2
- /package/dist-npm/{mod.d.ts → main.d.ts} +0 -0
package/dist-npm/utils/log.js
CHANGED
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
export function isPlainObject(obj) {
|
|
2
|
-
|
|
2
|
+
return Object.prototype.toString.call(obj) === "[object Object]";
|
|
3
3
|
}
|
|
4
|
-
|
|
5
4
|
export function isLogObj(arg) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return true;
|
|
5
|
+
if (!isPlainObject(arg)) {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
if (!arg.message && !arg.args) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
if (arg.stack) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
return true;
|
|
19
15
|
}
|
|
@@ -1,56 +1,49 @@
|
|
|
1
|
-
import chalk from
|
|
2
|
-
import gradient, {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
passion,
|
|
6
|
-
retro,
|
|
7
|
-
vice,
|
|
8
|
-
rainbow,
|
|
9
|
-
} from 'gradient-string';
|
|
10
|
-
import colors from 'picocolors';
|
|
11
|
-
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import gradient, { cristal, mind, passion, retro, vice } from "gradient-string";
|
|
3
|
+
import { rainbow } from "gradient-string";
|
|
4
|
+
import colors from "picocolors";
|
|
12
5
|
export const colorMap = {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
6
|
+
none: colors.reset,
|
|
7
|
+
inverse: colors.inverse,
|
|
8
|
+
black: colors.black,
|
|
9
|
+
blue: colors.blue,
|
|
10
|
+
blueBright: colors.blueBright,
|
|
11
|
+
cyan: colors.cyan,
|
|
12
|
+
cyanBright: colors.cyanBright,
|
|
13
|
+
bgCyan: colors.bgCyan,
|
|
14
|
+
bgCyanBright: colors.bgCyanBright,
|
|
15
|
+
dim: colors.dim,
|
|
16
|
+
gray: colors.gray,
|
|
17
|
+
green: colors.green,
|
|
18
|
+
greenBright: colors.greenBright,
|
|
19
|
+
bgGreen: colors.bgGreen,
|
|
20
|
+
bgGreenBright: colors.bgGreenBright,
|
|
21
|
+
magenta: colors.magenta,
|
|
22
|
+
red: colors.red,
|
|
23
|
+
redBright: colors.redBright,
|
|
24
|
+
bgRed: colors.bgRed,
|
|
25
|
+
bgRedBright: colors.bgRedBright,
|
|
26
|
+
white: colors.white,
|
|
27
|
+
yellow: colors.yellow,
|
|
28
|
+
yellowBright: colors.yellowBright,
|
|
29
|
+
cristalGradient: cristal,
|
|
30
|
+
mindGradient: mind,
|
|
31
|
+
passionGradient: passion,
|
|
32
|
+
rainbowGradient: rainbow,
|
|
33
|
+
retroGradient: retro,
|
|
34
|
+
viceGradient: vice,
|
|
35
|
+
gradientGradient: gradient([
|
|
36
|
+
"red",
|
|
37
|
+
"yellow",
|
|
38
|
+
"green",
|
|
39
|
+
"cyan",
|
|
40
|
+
"blue",
|
|
41
|
+
"magenta"
|
|
42
|
+
])
|
|
50
43
|
};
|
|
51
44
|
export const typographyMap = {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
45
|
+
bold: chalk.bold,
|
|
46
|
+
italic: chalk.italic,
|
|
47
|
+
underline: chalk.underline,
|
|
48
|
+
strikethrough: chalk.strikethrough
|
|
56
49
|
};
|
|
@@ -1,200 +1,213 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} from 'picocolors';
|
|
6
|
-
import {colorMap, typographyMap} from '../utils/mapping.js';
|
|
7
|
-
import {isUnicodeSupported} from '../utils/platforms.js';
|
|
8
|
-
import {variantMap} from '../utils/variants.js';
|
|
9
|
-
|
|
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";
|
|
10
5
|
const unicode = isUnicodeSupported();
|
|
11
6
|
const u = (c, fallback) => unicode ? c : fallback;
|
|
12
|
-
|
|
13
7
|
export const symbols = {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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")
|
|
23
17
|
};
|
|
24
|
-
function applyStyles(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
+
);
|
|
33
27
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
+
);
|
|
37
34
|
}
|
|
38
|
-
|
|
39
|
-
|
|
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;
|
|
40
44
|
}
|
|
41
|
-
|
|
42
|
-
|
|
45
|
+
export const bar = ({
|
|
46
|
+
borderColor = "viceGradient"
|
|
47
|
+
}) => colorMap[borderColor](symbols.middle);
|
|
43
48
|
export function fmt(opts) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
},
|
|
75
|
-
M_START: {
|
|
76
|
-
symbol: '',
|
|
77
|
-
prefix: prefixStartLine,
|
|
78
|
-
suffix: ` ${suffixStartLine}
|
|
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
79
|
${formattedBar}`,
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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 ? `
|
|
114
127
|
${formattedBar}
|
|
115
128
|
${prefixEndLine}${suffixEndLine}
|
|
116
|
-
` :
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
},
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
const config = MSG_CONFIGS[opts.type];
|
|
129
|
-
|
|
130
|
-
if (!config) {
|
|
131
|
-
throw Error(`Invalid message type: ${opts.type}`);
|
|
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
|
|
132
138
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
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 += `
|
|
152
166
|
${borderWithSpace}${colorMap.blueBright(opts.hint)}`;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
if (opts.errorMessage) {
|
|
156
|
-
const formattedError = applyStyles(opts.errorMessage, 'red', 'bold', '', opts.borderColor);
|
|
157
|
-
|
|
158
|
-
formattedTitle += `
|
|
159
|
-
${borderError} ${formattedError}`;
|
|
160
|
-
}
|
|
161
167
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
if (opts.type !== 'M_START') {
|
|
173
|
-
return `${borderWithSpace}${styledLine}`;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
return styledLine;
|
|
177
|
-
})
|
|
178
|
-
.join('\n');
|
|
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}`;
|
|
179
178
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
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(`
|
|
184
199
|
`);
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
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));
|
|
198
213
|
}
|
|
199
|
-
|
|
200
|
-
export function msg() {}
|
|
@@ -1,26 +1,22 @@
|
|
|
1
|
-
import process from
|
|
2
|
-
|
|
1
|
+
import process from "node:process";
|
|
3
2
|
const platforms = {
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
linux: process.platform !== "win32",
|
|
4
|
+
win32: process.platform === "win32"
|
|
6
5
|
};
|
|
7
|
-
|
|
8
6
|
const terminals = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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"
|
|
18
16
|
};
|
|
19
|
-
|
|
20
17
|
export function isUnicodeSupported() {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return terminals.windowsTerminal || terminals.terminusSublimeOld || terminals.cmderTerminal || terminals.terminusSublimeNew || terminals.visualStudioCode || terminals.xterm256color || terminals.alacrittyTerminal || terminals.jetbrainsJediTerm;
|
|
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;
|
|
26
22
|
}
|