@reliverse/rempts 1.7.44 → 1.7.45

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.
Files changed (134) hide show
  1. package/README.md +1 -1
  2. package/dist-npm/bin/mod.d.mts +2333 -0
  3. package/dist-npm/bin/mod.mjs +8236 -0
  4. package/package.json +84 -42
  5. package/bin/libs/animate/animate-mod.d.ts +0 -14
  6. package/bin/libs/animate/animate-mod.js +0 -62
  7. package/bin/libs/anykey/anykey-mod.d.ts +0 -12
  8. package/bin/libs/anykey/anykey-mod.js +0 -125
  9. package/bin/libs/cancel/cancel.d.ts +0 -45
  10. package/bin/libs/cancel/cancel.js +0 -72
  11. package/bin/libs/confirm/confirm-alias.d.ts +0 -2
  12. package/bin/libs/confirm/confirm-alias.js +0 -2
  13. package/bin/libs/confirm/confirm-mod.d.ts +0 -5
  14. package/bin/libs/confirm/confirm-mod.js +0 -179
  15. package/bin/libs/date/date.d.ts +0 -2
  16. package/bin/libs/date/date.js +0 -236
  17. package/bin/libs/editor/editor-mod.d.ts +0 -25
  18. package/bin/libs/editor/editor-mod.js +0 -897
  19. package/bin/libs/figures/figures-mod.d.ts +0 -461
  20. package/bin/libs/figures/figures-mod.js +0 -285
  21. package/bin/libs/group/group-mod.d.ts +0 -33
  22. package/bin/libs/group/group-mod.js +0 -93
  23. package/bin/libs/input/input-alias.d.ts +0 -5
  24. package/bin/libs/input/input-alias.js +0 -4
  25. package/bin/libs/input/input-mod.d.ts +0 -16
  26. package/bin/libs/input/input-mod.js +0 -372
  27. package/bin/libs/intro/intro-alias.d.ts +0 -2
  28. package/bin/libs/intro/intro-alias.js +0 -3
  29. package/bin/libs/intro/intro-mod.d.ts +0 -20
  30. package/bin/libs/intro/intro-mod.js +0 -81
  31. package/bin/libs/launcher/command-runner.d.ts +0 -18
  32. package/bin/libs/launcher/command-runner.js +0 -79
  33. package/bin/libs/launcher/command-typed.d.ts +0 -16
  34. package/bin/libs/launcher/command-typed.js +0 -60
  35. package/bin/libs/launcher/launcher-alias.d.ts +0 -2
  36. package/bin/libs/launcher/launcher-alias.js +0 -2
  37. package/bin/libs/launcher/launcher-mod.d.ts +0 -162
  38. package/bin/libs/launcher/launcher-mod.js +0 -1222
  39. package/bin/libs/launcher/launcher-types.d.ts +0 -159
  40. package/bin/libs/launcher/launcher-types.js +0 -0
  41. package/bin/libs/launcher/trpc-orpc-support/completions.d.ts +0 -4
  42. package/bin/libs/launcher/trpc-orpc-support/completions.js +0 -45
  43. package/bin/libs/launcher/trpc-orpc-support/errors.d.ts +0 -11
  44. package/bin/libs/launcher/trpc-orpc-support/errors.js +0 -10
  45. package/bin/libs/launcher/trpc-orpc-support/index.d.ts +0 -34
  46. package/bin/libs/launcher/trpc-orpc-support/index.js +0 -641
  47. package/bin/libs/launcher/trpc-orpc-support/json-schema.d.ts +0 -17
  48. package/bin/libs/launcher/trpc-orpc-support/json-schema.js +0 -168
  49. package/bin/libs/launcher/trpc-orpc-support/json.d.ts +0 -44
  50. package/bin/libs/launcher/trpc-orpc-support/json.js +0 -41
  51. package/bin/libs/launcher/trpc-orpc-support/logging.d.ts +0 -11
  52. package/bin/libs/launcher/trpc-orpc-support/logging.js +0 -26
  53. package/bin/libs/launcher/trpc-orpc-support/parse-procedure.d.ts +0 -2
  54. package/bin/libs/launcher/trpc-orpc-support/parse-procedure.js +0 -486
  55. package/bin/libs/launcher/trpc-orpc-support/prompts.d.ts +0 -18
  56. package/bin/libs/launcher/trpc-orpc-support/prompts.js +0 -534
  57. package/bin/libs/launcher/trpc-orpc-support/standard-schema/contract.d.ts +0 -53
  58. package/bin/libs/launcher/trpc-orpc-support/standard-schema/contract.js +0 -0
  59. package/bin/libs/launcher/trpc-orpc-support/standard-schema/errors.d.ts +0 -9
  60. package/bin/libs/launcher/trpc-orpc-support/standard-schema/errors.js +0 -47
  61. package/bin/libs/launcher/trpc-orpc-support/standard-schema/utils.d.ts +0 -3
  62. package/bin/libs/launcher/trpc-orpc-support/standard-schema/utils.js +0 -6
  63. package/bin/libs/launcher/trpc-orpc-support/trpc-compat.d.ts +0 -71
  64. package/bin/libs/launcher/trpc-orpc-support/trpc-compat.js +0 -11
  65. package/bin/libs/launcher/trpc-orpc-support/types.d.ts +0 -276
  66. package/bin/libs/launcher/trpc-orpc-support/types.js +0 -0
  67. package/bin/libs/launcher/trpc-orpc-support/util.d.ts +0 -9
  68. package/bin/libs/launcher/trpc-orpc-support/util.js +0 -9
  69. package/bin/libs/log/log-alias.d.ts +0 -1
  70. package/bin/libs/log/log-alias.js +0 -2
  71. package/bin/libs/msg-fmt/colors.d.ts +0 -30
  72. package/bin/libs/msg-fmt/colors.js +0 -42
  73. package/bin/libs/msg-fmt/logger.d.ts +0 -17
  74. package/bin/libs/msg-fmt/logger.js +0 -103
  75. package/bin/libs/msg-fmt/mapping.d.ts +0 -3
  76. package/bin/libs/msg-fmt/mapping.js +0 -49
  77. package/bin/libs/msg-fmt/messages.d.ts +0 -35
  78. package/bin/libs/msg-fmt/messages.js +0 -319
  79. package/bin/libs/msg-fmt/terminal.d.ts +0 -15
  80. package/bin/libs/msg-fmt/terminal.js +0 -60
  81. package/bin/libs/msg-fmt/variants.d.ts +0 -11
  82. package/bin/libs/msg-fmt/variants.js +0 -52
  83. package/bin/libs/multiselect/multiselect-alias.d.ts +0 -2
  84. package/bin/libs/multiselect/multiselect-alias.js +0 -2
  85. package/bin/libs/multiselect/multiselect-prompt.d.ts +0 -2
  86. package/bin/libs/multiselect/multiselect-prompt.js +0 -348
  87. package/bin/libs/next-steps/next-steps.d.ts +0 -14
  88. package/bin/libs/next-steps/next-steps.js +0 -24
  89. package/bin/libs/number/number-mod.d.ts +0 -28
  90. package/bin/libs/number/number-mod.js +0 -194
  91. package/bin/libs/outro/outro-alias.d.ts +0 -2
  92. package/bin/libs/outro/outro-alias.js +0 -3
  93. package/bin/libs/outro/outro-mod.d.ts +0 -8
  94. package/bin/libs/outro/outro-mod.js +0 -55
  95. package/bin/libs/results/results.d.ts +0 -7
  96. package/bin/libs/results/results.js +0 -27
  97. package/bin/libs/select/nummultiselect-prompt.d.ts +0 -6
  98. package/bin/libs/select/nummultiselect-prompt.js +0 -105
  99. package/bin/libs/select/numselect-prompt.d.ts +0 -7
  100. package/bin/libs/select/numselect-prompt.js +0 -115
  101. package/bin/libs/select/select-alias.d.ts +0 -9
  102. package/bin/libs/select/select-alias.js +0 -9
  103. package/bin/libs/select/select-prompt.d.ts +0 -5
  104. package/bin/libs/select/select-prompt.js +0 -314
  105. package/bin/libs/select/toggle-prompt.d.ts +0 -5
  106. package/bin/libs/select/toggle-prompt.js +0 -209
  107. package/bin/libs/spinner/spinner-alias.d.ts +0 -1
  108. package/bin/libs/spinner/spinner-alias.js +0 -2
  109. package/bin/libs/spinner/spinner-mod.d.ts +0 -106
  110. package/bin/libs/spinner/spinner-mod.js +0 -265
  111. package/bin/libs/task/progress.d.ts +0 -2
  112. package/bin/libs/task/progress.js +0 -57
  113. package/bin/libs/task/task-spin.d.ts +0 -15
  114. package/bin/libs/task/task-spin.js +0 -110
  115. package/bin/libs/utils/colorize.d.ts +0 -2
  116. package/bin/libs/utils/colorize.js +0 -135
  117. package/bin/libs/utils/errors.d.ts +0 -1
  118. package/bin/libs/utils/errors.js +0 -17
  119. package/bin/libs/utils/prevent.d.ts +0 -8
  120. package/bin/libs/utils/prevent.js +0 -65
  121. package/bin/libs/utils/prompt-end.d.ts +0 -8
  122. package/bin/libs/utils/prompt-end.js +0 -34
  123. package/bin/libs/utils/stream-text.d.ts +0 -18
  124. package/bin/libs/utils/stream-text.js +0 -136
  125. package/bin/libs/utils/system.d.ts +0 -6
  126. package/bin/libs/utils/system.js +0 -7
  127. package/bin/libs/utils/validate.d.ts +0 -21
  128. package/bin/libs/utils/validate.js +0 -17
  129. package/bin/libs/visual/visual-mod.d.ts +0 -6
  130. package/bin/libs/visual/visual-mod.js +0 -13
  131. package/bin/mod.d.ts +0 -69
  132. package/bin/mod.js +0 -159
  133. package/bin/types.d.ts +0 -371
  134. package/bin/types.js +0 -0
@@ -1,319 +0,0 @@
1
- import { re } from "@reliverse/relico";
2
- import { relinka } from "@reliverse/relinka";
3
- import { isUnicodeSupported } from "@reliverse/runtime";
4
- import wrapAnsi from "wrap-ansi";
5
- import { colorMap, typographyMap } from "./mapping.js";
6
- import {
7
- deleteLastLines,
8
- getExactTerminalWidth,
9
- getTerminalWidth
10
- } from "./terminal.js";
11
- import { isValidVariant, variantMap } from "./variants.js";
12
- const unicode = isUnicodeSupported();
13
- const u = (c, fallback) => unicode ? c : fallback;
14
- export const symbols = {
15
- pointer: u("\u{1F449}", ">"),
16
- start: u("\u256D", "*"),
17
- middle: u("\u2502", "|"),
18
- end: u("\u2570", "*"),
19
- line: u("\u2500", "\u2014"),
20
- corner_top_right: u("\u256D", "*"),
21
- step_active: u("\u25C6", "\u2666"),
22
- step_error: u("\u{1F5F4}", "x"),
23
- info: u("\u2139", "i"),
24
- log: u("\u2502", "|"),
25
- success: u("\u2705", "\u2713"),
26
- warn: u("\u26A0", "!"),
27
- error: u("\u274C", "x")
28
- };
29
- function wrapThenStyle(input, wrap, typographyName, colorName, variantName, borderColor) {
30
- if (!input) return "";
31
- const width = getTerminalWidth();
32
- const wrappedText = wrap ? wrapAnsi(input, width, { hard: false, trim: true }) : input;
33
- return wrappedText.split("\n").map(
34
- (line) => applyStyles(line, colorName, typographyName, variantName, borderColor)
35
- ).join("\n");
36
- }
37
- function applyStyles(text, colorName, typographyName, variantName, borderColor) {
38
- let styledText = text;
39
- if (variantName && isValidVariant(variantName)) {
40
- styledText = variantMap[variantName](
41
- [styledText],
42
- void 0,
43
- borderColor
44
- ).toString();
45
- return styledText;
46
- }
47
- if (colorName && colorMap[colorName]) {
48
- styledText = colorMap[colorName](styledText);
49
- }
50
- if (typographyName && typographyMap[typographyName]) {
51
- styledText = typographyMap[typographyName](styledText);
52
- }
53
- return styledText;
54
- }
55
- export const bar = ({
56
- borderColor = "dim"
57
- } = {}) => {
58
- if (borderColor.endsWith("Gradient")) {
59
- relinka(
60
- "error",
61
- "Gradient colors are not supported for bars. Please use a solid color instead."
62
- );
63
- return colorMap.dim(symbols.middle);
64
- }
65
- return colorMap[borderColor](symbols.middle);
66
- };
67
- function countLines(text) {
68
- return text.split("\n").length;
69
- }
70
- function getColoredSymbol(customSymbol, symbolName, symbolColor) {
71
- if (customSymbol) {
72
- return symbolColor && colorMap[symbolColor] ? colorMap[symbolColor](customSymbol) : customSymbol;
73
- }
74
- if (symbolName && symbols[symbolName]) {
75
- return symbolColor && colorMap[symbolColor] ? colorMap[symbolColor](symbols[symbolName]) : symbols[symbolName];
76
- }
77
- return void 0;
78
- }
79
- function formatTitle(opts, borderTwoSpaces, borderError) {
80
- let formattedTitle = "";
81
- if (!opts.title) return formattedTitle;
82
- const wrappedOrStyledTitle = wrapThenStyle(
83
- opts.title,
84
- opts.wrapTitle ?? true,
85
- opts.titleTypography ?? "bold",
86
- opts.titleColor ?? "cyan",
87
- opts.titleVariant,
88
- opts.borderColor
89
- );
90
- formattedTitle += wrappedOrStyledTitle;
91
- if (opts.hint) {
92
- const hintColor = opts.hintPlaceholderColor ?? "blue";
93
- const wrappedHint = wrapThenStyle(
94
- opts.hint,
95
- opts.wrapTitle ?? true,
96
- // same wrap logic as title by default
97
- opts.hintTypography ?? "italic",
98
- hintColor,
99
- void 0,
100
- opts.borderColor
101
- );
102
- formattedTitle += `
103
- ${borderTwoSpaces}${wrappedHint}`;
104
- }
105
- if (opts.placeholder && opts.type === "M_GENERAL") {
106
- const placeHolderColor = opts.hintPlaceholderColor ?? "blue";
107
- formattedTitle += `
108
- ${borderTwoSpaces}${colorMap[placeHolderColor](opts.placeholder)}`;
109
- }
110
- if (opts.errorMessage) {
111
- const formattedError = applyStyles(
112
- opts.errorMessage,
113
- "red",
114
- "bold",
115
- void 0,
116
- opts.borderColor
117
- );
118
- formattedTitle += `
119
- ${borderError} ${formattedError}`;
120
- }
121
- return formattedTitle;
122
- }
123
- function formatContent(opts) {
124
- if (!opts.content) return "";
125
- return wrapThenStyle(
126
- opts.content,
127
- opts.wrapContent ?? true,
128
- opts.contentTypography ?? "italic",
129
- opts.contentColor ?? "dim",
130
- opts.contentVariant,
131
- opts.borderColor
132
- );
133
- }
134
- export function fmt(opts) {
135
- if (!opts.borderColor) {
136
- opts.borderColor = "dim";
137
- }
138
- const borderColored = applyStyles(symbols.middle, opts.borderColor);
139
- const borderError = applyStyles(symbols.middle, "red");
140
- const borderTwoSpaces = `${borderColored} `;
141
- const prefixStartLine = opts.borderColor ? colorMap[opts.borderColor](symbols.start + symbols.line) : symbols.start + symbols.line;
142
- const prefixEndLine = opts.borderColor ? colorMap[opts.borderColor](symbols.end + symbols.line) : symbols.end + symbols.line;
143
- const lineLength = opts.horizontalLineLength === 0 ? getExactTerminalWidth() - 3 : opts.horizontalLineLength ?? getExactTerminalWidth() - 3;
144
- const suffixStartLine = opts.borderColor ? colorMap[opts.borderColor](`${symbols.line.repeat(lineLength)}\u22B1`) : `${symbols.line.repeat(lineLength)}\u22B1`;
145
- const suffixEndLine = opts.borderColor ? colorMap[opts.borderColor](`${symbols.line.repeat(lineLength)}\u22B1`) : `${symbols.line.repeat(lineLength)}\u22B1`;
146
- const computedSymbol = getColoredSymbol(opts.customSymbol, opts.symbol, opts.symbolColor) ?? re.green(symbols.step_active);
147
- const MESSAGE_CONFIG_MAP = {
148
- M_NULL: {
149
- symbol: "",
150
- prefix: borderTwoSpaces,
151
- suffix: "",
152
- newLineBefore: opts.addNewLineBefore ?? false,
153
- newLineAfter: opts.addNewLineAfter ?? false
154
- },
155
- M_BAR: {
156
- symbol: "",
157
- prefix: "",
158
- suffix: "",
159
- newLineBefore: false,
160
- newLineAfter: false
161
- },
162
- M_INFO_NULL: {
163
- symbol: "",
164
- prefix: borderTwoSpaces,
165
- suffix: "",
166
- newLineBefore: opts.addNewLineBefore ?? false,
167
- newLineAfter: opts.addNewLineAfter ?? false
168
- },
169
- M_START: {
170
- symbol: "",
171
- prefix: "",
172
- suffix: `
173
- ${borderTwoSpaces}`,
174
- newLineBefore: opts.addNewLineBefore ?? false,
175
- newLineAfter: opts.addNewLineAfter ?? false
176
- },
177
- M_MIDDLE: {
178
- symbol: "",
179
- prefix: borderTwoSpaces,
180
- suffix: "",
181
- newLineBefore: opts.addNewLineBefore ?? false,
182
- newLineAfter: opts.addNewLineAfter ?? false
183
- },
184
- M_GENERAL: {
185
- symbol: computedSymbol,
186
- prefix: borderTwoSpaces,
187
- suffix: "",
188
- newLineBefore: opts.addNewLineBefore ?? false,
189
- newLineAfter: opts.addNewLineAfter ?? false
190
- },
191
- M_GENERAL_NULL: {
192
- symbol: "",
193
- prefix: borderTwoSpaces,
194
- suffix: opts.placeholder ? colorMap[opts.hintPlaceholderColor ?? "blue"](opts.placeholder) : "",
195
- newLineBefore: opts.addNewLineBefore ?? false,
196
- newLineAfter: opts.addNewLineAfter ?? false
197
- },
198
- M_INFO: {
199
- symbol: computedSymbol || re.green(symbols.info),
200
- prefix: borderTwoSpaces,
201
- suffix: "",
202
- newLineBefore: opts.addNewLineBefore ?? false,
203
- newLineAfter: opts.addNewLineAfter ?? true
204
- },
205
- M_ERROR: {
206
- symbol: computedSymbol || re.redBright(symbols.step_error),
207
- prefix: borderTwoSpaces,
208
- suffix: "",
209
- newLineBefore: opts.addNewLineBefore ?? false,
210
- newLineAfter: opts.addNewLineAfter ?? false
211
- },
212
- M_ERROR_NULL: {
213
- symbol: "",
214
- prefix: borderTwoSpaces,
215
- suffix: "",
216
- newLineBefore: opts.addNewLineBefore ?? false,
217
- newLineAfter: opts.addNewLineAfter ?? false
218
- },
219
- M_END: {
220
- symbol: "",
221
- prefix: "",
222
- suffix: "",
223
- newLineBefore: opts.addNewLineBefore ?? false,
224
- newLineAfter: opts.addNewLineAfter ?? false
225
- },
226
- M_NEWLINE: {
227
- symbol: "",
228
- prefix: borderTwoSpaces,
229
- suffix: "",
230
- newLineBefore: opts.addNewLineBefore ?? false,
231
- newLineAfter: opts.addNewLineAfter ?? false
232
- }
233
- };
234
- const config = MESSAGE_CONFIG_MAP[opts.type];
235
- if (!config) {
236
- throw new Error(`Invalid message type: ${opts.type}`);
237
- }
238
- const { symbol, suffix, newLineBefore, newLineAfter } = config;
239
- const finalTitle = formatTitle(opts, borderTwoSpaces, borderError);
240
- const finalContent = formatContent(opts);
241
- let text = "";
242
- if (opts.type === "M_BAR") {
243
- text = bar({ borderColor: opts.borderColor });
244
- } else {
245
- text = [finalTitle, finalContent].filter(Boolean).join("\n");
246
- }
247
- const fullText = [
248
- newLineBefore ? `
249
- ${borderTwoSpaces}` : "",
250
- text,
251
- newLineAfter ? `
252
- ${borderTwoSpaces}` : "",
253
- suffix
254
- ].filter(Boolean).join("");
255
- const lines = fullText.split("\n").map((line, index) => {
256
- if (opts.type === "M_START") {
257
- if (index === 0) {
258
- return `${prefixStartLine} ${line} ${suffixStartLine}`;
259
- }
260
- if (index === 1) {
261
- return borderTwoSpaces;
262
- }
263
- }
264
- if (opts.type === "M_END" && opts.border && index === 0) {
265
- if (!opts.title) return "";
266
- return `${bar({ borderColor: opts.borderColor ?? "dim" })} ${line}`;
267
- }
268
- if (!line.trim() || line.includes(symbols.middle)) {
269
- return line;
270
- }
271
- if (index === 0 && symbol) {
272
- return `${symbol} ${line}`;
273
- }
274
- return `${config.prefix}${line}`;
275
- });
276
- if (opts.type === "M_END" && opts.border) {
277
- lines.push(`${prefixEndLine}${suffixEndLine}
278
- `);
279
- }
280
- const finalText = lines.join("\n");
281
- const lineCount = countLines(finalText);
282
- return { text: finalText, lineCount };
283
- }
284
- const printedLineStack = [];
285
- export function msg(opts) {
286
- const { text, lineCount } = fmt(opts);
287
- if (opts.type === "M_BAR" && opts.noNewLine) {
288
- process.stdout.write(text);
289
- } else {
290
- process.stdout.write(`${text}
291
- `);
292
- }
293
- printedLineStack.push(
294
- opts.type === "M_BAR" && opts.noNewLine ? lineCount : lineCount + 1
295
- );
296
- }
297
- export function msgUndo(count = 1) {
298
- for (let i = 0; i < count; i++) {
299
- const linesToDelete = printedLineStack.pop();
300
- if (typeof linesToDelete === "number" && linesToDelete > 0) {
301
- deleteLastLines(linesToDelete);
302
- }
303
- }
304
- }
305
- export function msgUndoAll() {
306
- while (printedLineStack.length > 0) {
307
- const linesToDelete = printedLineStack.pop();
308
- if (typeof linesToDelete === "number" && linesToDelete > 0) {
309
- deleteLastLines(linesToDelete);
310
- }
311
- }
312
- }
313
- export function printLineBar(text, indent = 2) {
314
- if (text === "") {
315
- relinka("log", re.dim("\u2502"));
316
- } else {
317
- relinka("log", `${re.dim("\u2502")}${" ".repeat(indent)}${text}`);
318
- }
319
- }
@@ -1,15 +0,0 @@
1
- export declare function getTerminalHeight(): number;
2
- export declare function getExactTerminalWidth(): number;
3
- export declare function getTerminalWidth(terminalWidth?: number): number;
4
- /**
5
- * Force line returns at specific width. This function is ANSI code friendly and it'll
6
- * ignore invisible codes during width calculation.
7
- * @param {string} content
8
- * @return {string}
9
- */
10
- export declare function breakLines(content: string, terminalWidth?: number): string;
11
- export declare function removeCursor(): void;
12
- export declare function restoreCursor(): void;
13
- export declare function deleteLastLine(): void;
14
- export declare function deleteLastLines(count: number): void;
15
- export declare function countLines(text: string): number;
@@ -1,60 +0,0 @@
1
- import { relinka } from "@reliverse/relinka";
2
- import ansiEscapes from "ansi-escapes";
3
- import { cursor } from "sisteransi";
4
- import terminalSize from "terminal-size";
5
- import wrapAnsi from "wrap-ansi";
6
- export function getTerminalHeight() {
7
- return terminalSize().rows ?? 24;
8
- }
9
- export function getExactTerminalWidth() {
10
- return terminalSize().columns ?? 80;
11
- }
12
- export function getTerminalWidth(terminalWidth = 0) {
13
- if (terminalWidth === 0) {
14
- terminalWidth = getExactTerminalWidth();
15
- }
16
- if (terminalWidth > 150) {
17
- return terminalWidth - 40;
18
- }
19
- if (terminalWidth > 120) {
20
- return terminalWidth - 30;
21
- }
22
- if (terminalWidth > 100) {
23
- return terminalWidth - 20;
24
- }
25
- return terminalWidth;
26
- }
27
- export function breakLines(content, terminalWidth = 0) {
28
- if (terminalWidth === 0) {
29
- terminalWidth = getTerminalWidth();
30
- }
31
- return content.split("\n").flatMap(
32
- (line) => wrapAnsi(line, terminalWidth, { trim: false, hard: true }).split("\n").map((str) => str.trimEnd())
33
- ).join("\n");
34
- }
35
- export function removeCursor() {
36
- process.stdout.write(cursor.hide);
37
- }
38
- export function restoreCursor() {
39
- process.stdout.write(cursor.show);
40
- }
41
- export function deleteLastLine() {
42
- process.stdout.write(ansiEscapes.cursorUp(1) + ansiEscapes.eraseLine);
43
- }
44
- export function deleteLastLines(count) {
45
- if (count <= 0) {
46
- relinka("error", "Count is less than or equal to 0. Nothing to delete.");
47
- return;
48
- }
49
- process.stdout.write(ansiEscapes.eraseLines(count));
50
- }
51
- export function countLines(text) {
52
- const adjustedWidth = getTerminalWidth();
53
- const lines = text.split("\n");
54
- let lineCount = 0;
55
- for (const line of lines) {
56
- const wrapped = wrapAnsi(line, adjustedWidth, { hard: true });
57
- lineCount += wrapped.split("\n").length;
58
- }
59
- return lineCount;
60
- }
@@ -1,11 +0,0 @@
1
- import type { ColorName, VariantName } from "../../types.js";
2
- export declare const variantMap: {
3
- doubleBox: typeof createDoubleBox;
4
- };
5
- type ValidVariant = keyof typeof variantMap;
6
- export declare function isValidVariant(variant: string | undefined): variant is ValidVariant;
7
- export declare function applyVariant(lines: string[] | string, variant?: VariantName, options?: {
8
- limit?: number;
9
- }, borderColor?: ColorName): Promise<string>;
10
- declare function createDoubleBox(lines: string[], limit?: number, borderColor?: ColorName): string;
11
- export {};
@@ -1,52 +0,0 @@
1
- import { colorMap } from "./mapping.js";
2
- export const variantMap = {
3
- // box: createBox,
4
- doubleBox: createDoubleBox
5
- // banner: createBanner,
6
- // underline: createUnderline,
7
- };
8
- export function isValidVariant(variant) {
9
- return variant !== void 0 && variant !== "none" && variant in variantMap;
10
- }
11
- export async function applyVariant(lines, variant, options, borderColor) {
12
- const linesArray = Array.isArray(lines) ? lines : [lines];
13
- switch (variant) {
14
- // case "box":
15
- // return createBox(linesArray, options?.limit);
16
- case "doubleBox":
17
- return createDoubleBox(linesArray, options?.limit, borderColor);
18
- // case "banner":
19
- // return createBanner(linesArray);
20
- // case "underline":
21
- // return createUnderline(linesArray);
22
- default:
23
- return linesArray.join("\n");
24
- }
25
- }
26
- function createDoubleBox(lines, limit, borderColor) {
27
- const processedLines = processLines(lines, limit);
28
- const maxLength = Math.max(...processedLines.map((line) => line.length));
29
- const indentation = "";
30
- if (borderColor === void 0) {
31
- borderColor = "dim";
32
- }
33
- const topBorder = borderColor ? colorMap[borderColor](`${"\u2550".repeat(maxLength)}\u2557`) : `${"\u2550".repeat(maxLength)}\u2557`;
34
- const bottomBorder = borderColor ? colorMap[borderColor](`${indentation}\u255A${"\u2550".repeat(maxLength + 2)}\u255D`) : `${indentation}\u255A${"\u2550".repeat(maxLength + 2)}\u255D`;
35
- const middle = processedLines.map((line, index) => {
36
- const lineIndentation = index === 0 ? indentation : `${indentation} `;
37
- return `${lineIndentation}${borderColor ? colorMap[borderColor]("\u2551") : "\u2551"} ${colorMap[borderColor](line.padEnd(maxLength))} ${borderColor ? colorMap[borderColor]("\u2551") : "\u2551"}`;
38
- }).join("\n");
39
- return `${topBorder}
40
- ${middle}
41
- ${bottomBorder}`;
42
- }
43
- function processLines(lines, limit) {
44
- const linesArray = Array.isArray(lines) ? lines : [lines];
45
- return linesArray.map((line) => {
46
- let truncatedLine = line;
47
- if (limit && line.length > limit) {
48
- truncatedLine = `${line.slice(0, limit - 3)}...`;
49
- }
50
- return truncatedLine.padEnd(limit || truncatedLine.length);
51
- });
52
- }
@@ -1,2 +0,0 @@
1
- import type { MultiselectPromptParams } from "../../types.js";
2
- export declare const multiselect: <T extends string>(params: MultiselectPromptParams<T>) => Promise<T[]>;
@@ -1,2 +0,0 @@
1
- import { multiselectPrompt } from "./multiselect-prompt.js";
2
- export const multiselect = multiselectPrompt;
@@ -1,2 +0,0 @@
1
- import type { MultiselectPromptParams } from "../../types.js";
2
- export declare function multiselectPrompt<T extends string>(params: MultiselectPromptParams<T>): Promise<T[]>;