@reliverse/rempts-core 1.6.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.
Files changed (87) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +102 -0
  3. package/bin/core-impl/anykey/anykey-mod.d.ts +12 -0
  4. package/bin/core-impl/anykey/anykey-mod.js +125 -0
  5. package/bin/core-impl/date/date.d.ts +2 -0
  6. package/bin/core-impl/date/date.js +236 -0
  7. package/bin/core-impl/editor/editor-mod.d.ts +25 -0
  8. package/bin/core-impl/editor/editor-mod.js +896 -0
  9. package/bin/core-impl/figures/figures-mod.d.ts +233 -0
  10. package/bin/core-impl/figures/figures-mod.js +286 -0
  11. package/bin/core-impl/figures/figures.test.d.ts +1 -0
  12. package/bin/core-impl/figures/figures.test.js +474 -0
  13. package/bin/core-impl/input/confirm-prompt.d.ts +5 -0
  14. package/bin/core-impl/input/confirm-prompt.js +173 -0
  15. package/bin/core-impl/input/input-prompt.d.ts +16 -0
  16. package/bin/core-impl/input/input-prompt.js +370 -0
  17. package/bin/core-impl/launcher/_parser.d.ts +2 -0
  18. package/bin/core-impl/launcher/_parser.js +122 -0
  19. package/bin/core-impl/launcher/_utils.d.ts +8 -0
  20. package/bin/core-impl/launcher/_utils.js +29 -0
  21. package/bin/core-impl/launcher/args.d.ts +3 -0
  22. package/bin/core-impl/launcher/args.js +89 -0
  23. package/bin/core-impl/launcher/command.d.ts +8 -0
  24. package/bin/core-impl/launcher/command.js +68 -0
  25. package/bin/core-impl/launcher/launcher-mod.d.ts +8 -0
  26. package/bin/core-impl/launcher/launcher-mod.js +34 -0
  27. package/bin/core-impl/launcher/usage.d.ts +3 -0
  28. package/bin/core-impl/launcher/usage.js +104 -0
  29. package/bin/core-impl/msg-fmt/colors.d.ts +30 -0
  30. package/bin/core-impl/msg-fmt/colors.js +42 -0
  31. package/bin/core-impl/msg-fmt/logger.d.ts +17 -0
  32. package/bin/core-impl/msg-fmt/logger.js +106 -0
  33. package/bin/core-impl/msg-fmt/mapping.d.ts +3 -0
  34. package/bin/core-impl/msg-fmt/mapping.js +49 -0
  35. package/bin/core-impl/msg-fmt/messages.d.ts +35 -0
  36. package/bin/core-impl/msg-fmt/messages.js +314 -0
  37. package/bin/core-impl/msg-fmt/terminal.d.ts +15 -0
  38. package/bin/core-impl/msg-fmt/terminal.js +59 -0
  39. package/bin/core-impl/msg-fmt/variants.d.ts +11 -0
  40. package/bin/core-impl/msg-fmt/variants.js +52 -0
  41. package/bin/core-impl/next-steps/next-steps.d.ts +14 -0
  42. package/bin/core-impl/next-steps/next-steps.js +24 -0
  43. package/bin/core-impl/number/number-mod.d.ts +28 -0
  44. package/bin/core-impl/number/number-mod.js +197 -0
  45. package/bin/core-impl/results/results.d.ts +7 -0
  46. package/bin/core-impl/results/results.js +27 -0
  47. package/bin/core-impl/select/multiselect-prompt.d.ts +2 -0
  48. package/bin/core-impl/select/multiselect-prompt.js +341 -0
  49. package/bin/core-impl/select/nummultiselect-prompt.d.ts +6 -0
  50. package/bin/core-impl/select/nummultiselect-prompt.js +105 -0
  51. package/bin/core-impl/select/numselect-prompt.d.ts +7 -0
  52. package/bin/core-impl/select/numselect-prompt.js +115 -0
  53. package/bin/core-impl/select/select-prompt.d.ts +33 -0
  54. package/bin/core-impl/select/select-prompt.js +302 -0
  55. package/bin/core-impl/select/toggle-prompt.d.ts +5 -0
  56. package/bin/core-impl/select/toggle-prompt.js +208 -0
  57. package/bin/core-impl/st-end/end.d.ts +2 -0
  58. package/bin/core-impl/st-end/end.js +42 -0
  59. package/bin/core-impl/st-end/start.d.ts +17 -0
  60. package/bin/core-impl/st-end/start.js +66 -0
  61. package/bin/core-impl/task/progress.d.ts +2 -0
  62. package/bin/core-impl/task/progress.js +57 -0
  63. package/bin/core-impl/task/spinner.d.ts +15 -0
  64. package/bin/core-impl/task/spinner.js +110 -0
  65. package/bin/core-impl/utils/colorize.d.ts +2 -0
  66. package/bin/core-impl/utils/colorize.js +134 -0
  67. package/bin/core-impl/utils/errors.d.ts +1 -0
  68. package/bin/core-impl/utils/errors.js +15 -0
  69. package/bin/core-impl/utils/prevent.d.ts +10 -0
  70. package/bin/core-impl/utils/prevent.js +69 -0
  71. package/bin/core-impl/utils/prompt-end.d.ts +8 -0
  72. package/bin/core-impl/utils/prompt-end.js +33 -0
  73. package/bin/core-impl/utils/stream-text.d.ts +18 -0
  74. package/bin/core-impl/utils/stream-text.js +136 -0
  75. package/bin/core-impl/utils/system.d.ts +6 -0
  76. package/bin/core-impl/utils/system.js +7 -0
  77. package/bin/core-impl/utils/validate.d.ts +22 -0
  78. package/bin/core-impl/utils/validate.js +17 -0
  79. package/bin/core-impl/visual/animate/animate.d.ts +14 -0
  80. package/bin/core-impl/visual/animate/animate.js +64 -0
  81. package/bin/core-impl/visual/ascii-art/ascii-art.d.ts +6 -0
  82. package/bin/core-impl/visual/ascii-art/ascii-art.js +12 -0
  83. package/bin/core-types.d.ts +434 -0
  84. package/bin/core-types.js +0 -0
  85. package/bin/main.d.ts +41 -0
  86. package/bin/main.js +96 -0
  87. package/package.json +58 -0
@@ -0,0 +1,17 @@
1
+ import type { PreventWrongTerminalSizeOptions, PromptOptions } from "../../core-types.js";
2
+ type StartPromptOptions = PromptOptions & {
3
+ clearConsole?: boolean;
4
+ horizontalLine?: boolean;
5
+ horizontalLineLength?: number;
6
+ packageName?: string;
7
+ packageVersion?: string;
8
+ terminalSizeOptions?: PreventWrongTerminalSizeOptions;
9
+ isDev?: boolean;
10
+ prevent?: {
11
+ unsupportedTTY?: boolean;
12
+ wrongTerminalSize?: boolean;
13
+ windowsHomeDirRoot?: boolean;
14
+ };
15
+ };
16
+ export declare function startPrompt({ title, titleColor, titleTypography, titleVariant, borderColor, clearConsole, horizontalLine, horizontalLineLength, packageName, packageVersion, terminalSizeOptions, isDev, prevent, }: StartPromptOptions): Promise<void>;
17
+ export {};
@@ -0,0 +1,66 @@
1
+ import { getCurrentTerminalName } from "@reliverse/runtime";
2
+ import { msg } from "../msg-fmt/messages.js";
3
+ import {
4
+ getExactTerminalWidth,
5
+ getTerminalHeight,
6
+ getTerminalWidth
7
+ } from "../msg-fmt/terminal.js";
8
+ import {
9
+ preventWrongTerminalSize,
10
+ preventWindowsHomeDirRoot,
11
+ preventUnsupportedTTY
12
+ } from "../utils/prevent.js";
13
+ import { pm, reliversePrompts } from "../utils/system.js";
14
+ export async function startPrompt({
15
+ title = "",
16
+ titleColor = "inverse",
17
+ titleTypography = "none",
18
+ titleVariant,
19
+ borderColor = "dim",
20
+ clearConsole = false,
21
+ horizontalLine = true,
22
+ horizontalLineLength = 0,
23
+ packageName = reliversePrompts.name,
24
+ packageVersion = reliversePrompts.version,
25
+ terminalSizeOptions = {},
26
+ isDev = false,
27
+ prevent = {
28
+ unsupportedTTY: true,
29
+ wrongTerminalSize: true,
30
+ windowsHomeDirRoot: true
31
+ }
32
+ }) {
33
+ if (prevent.windowsHomeDirRoot) {
34
+ preventWindowsHomeDirRoot(process.cwd());
35
+ }
36
+ if (prevent.unsupportedTTY) {
37
+ preventUnsupportedTTY({ borderColor });
38
+ }
39
+ if (prevent.wrongTerminalSize) {
40
+ await preventWrongTerminalSize({ ...terminalSizeOptions, isDev });
41
+ }
42
+ const terminalWidth = getTerminalWidth();
43
+ const exactTerminalWidth = getExactTerminalWidth();
44
+ const terminalHeight = getTerminalHeight();
45
+ const formattedTitle = title !== "" ? title : `${packageName} v${packageVersion} | ${pm.packageManager} v${pm.version} | ${getCurrentTerminalName()}${isDev && terminalWidth > 80 ? ` | isDev | w${terminalWidth} h${terminalHeight}` : ""}`;
46
+ if (horizontalLineLength === 0) {
47
+ const titleFullLength = titleColor === "inverse" ? `\u2800${formattedTitle}\u2800`.length + 5 : formattedTitle.length + 5;
48
+ horizontalLineLength = Math.max(1, exactTerminalWidth - titleFullLength);
49
+ }
50
+ if (clearConsole) {
51
+ console.clear();
52
+ console.log("");
53
+ } else {
54
+ console.log("");
55
+ }
56
+ msg({
57
+ type: "M_START",
58
+ title: titleColor === "inverse" ? `\u2800${formattedTitle}\u2800` : formattedTitle,
59
+ titleColor,
60
+ titleTypography,
61
+ ...titleVariant ? { titleVariant } : {},
62
+ borderColor,
63
+ horizontalLine,
64
+ horizontalLineLength
65
+ });
66
+ }
@@ -0,0 +1,2 @@
1
+ import type { ProgressBar, ProgressBarOptions } from "../../core-types.js";
2
+ export declare function progressTaskPrompt(options: ProgressBarOptions): Promise<ProgressBar>;
@@ -0,0 +1,57 @@
1
+ import { re } from "@reliverse/relico";
2
+ import { cursor, erase } from "sisteransi";
3
+ export async function progressTaskPrompt(options) {
4
+ if (options.total <= 0) {
5
+ throw new Error("Total must be a positive number");
6
+ }
7
+ const state = {
8
+ total: options.total,
9
+ current: 0,
10
+ width: options.width ?? 40,
11
+ completeChar: options.completeChar ?? "\u2588",
12
+ incompleteChar: options.incompleteChar ?? "\u2591",
13
+ startTime: Date.now(),
14
+ format: options.format ?? "Progress: [:bar] :percent% | Elapsed: :elapsed s",
15
+ colorize: options.colorize ?? false
16
+ };
17
+ const getElapsedTime = () => {
18
+ return ((Date.now() - state.startTime) / 1e3).toFixed(2);
19
+ };
20
+ const getPercentage = () => {
21
+ return (state.current / state.total * 100).toFixed(2);
22
+ };
23
+ const getBar = () => {
24
+ const percent = state.current / state.total;
25
+ const filledLength = Math.round(state.width * percent);
26
+ const emptyLength = state.width - filledLength;
27
+ const filled = state.completeChar.repeat(filledLength);
28
+ const empty = state.incompleteChar.repeat(emptyLength);
29
+ return state.colorize ? re.green(filled) + re.red(empty) : filled + empty;
30
+ };
31
+ const render = async () => {
32
+ const bar = getBar();
33
+ const percentage = getPercentage();
34
+ const elapsed = getElapsedTime();
35
+ const output = state.format.replace(":bar", bar).replace(":percent", percentage).replace(":elapsed", elapsed);
36
+ process.stdout.write(cursor.move(-999, 0) + erase.line);
37
+ process.stdout.write(`${re.green("\u25C6")} ${output}`);
38
+ if (state.current >= state.total) {
39
+ process.stdout.write("\n");
40
+ }
41
+ };
42
+ const update = async (value) => {
43
+ const newValue = Math.min(value, state.total);
44
+ if (newValue !== state.current) {
45
+ state.current = newValue;
46
+ await render();
47
+ }
48
+ };
49
+ const increment = async (amount = 1) => {
50
+ await update(state.current + amount);
51
+ };
52
+ return {
53
+ update,
54
+ increment,
55
+ render
56
+ };
57
+ }
@@ -0,0 +1,15 @@
1
+ import type { SpinnerName } from "cli-spinners";
2
+ type SimpleSpinnerType = "default" | "dottedCircle" | "boxSpinner";
3
+ type OraSpinnerType = Extract<SpinnerName, OraAllowedSpinners>;
4
+ type OraAllowedSpinners = "dots" | "bouncingBar" | "arc";
5
+ type TaskOptions<T extends "simple" | "ora"> = {
6
+ initialMessage: string;
7
+ successMessage?: string;
8
+ errorMessage?: string;
9
+ delay?: number;
10
+ spinnerSolution: T;
11
+ spinnerType?: T extends "simple" ? SimpleSpinnerType : OraSpinnerType;
12
+ action: (updateMessage: (message: string) => void) => Promise<void>;
13
+ };
14
+ export declare function spinnerTaskPrompt<T extends "simple" | "ora">(options: TaskOptions<T>): Promise<void>;
15
+ export {};
@@ -0,0 +1,110 @@
1
+ import { re } from "@reliverse/relico";
2
+ import process from "node:process";
3
+ import ora from "ora";
4
+ import { cursor, erase } from "sisteransi";
5
+ import { msg } from "../msg-fmt/messages.js";
6
+ export async function spinnerTaskPrompt(options) {
7
+ const {
8
+ initialMessage,
9
+ successMessage = "Task completed successfully.",
10
+ errorMessage = "An error occurred during the task.",
11
+ delay = 100,
12
+ spinnerSolution,
13
+ spinnerType,
14
+ action
15
+ } = options;
16
+ let message = initialMessage;
17
+ let interval = null;
18
+ let frameIndex = 0;
19
+ if (spinnerSolution === "ora") {
20
+ const oraSpinner = ora({
21
+ text: initialMessage,
22
+ spinner: spinnerType
23
+ });
24
+ try {
25
+ oraSpinner.start();
26
+ await action((newMessage) => {
27
+ message = newMessage;
28
+ oraSpinner.text = newMessage;
29
+ });
30
+ oraSpinner.stop();
31
+ msg({
32
+ type: "M_INFO",
33
+ title: successMessage,
34
+ titleColor: "cyan"
35
+ });
36
+ } catch (error) {
37
+ oraSpinner.stopAndPersist({
38
+ symbol: re.red("\u2716"),
39
+ text: errorMessage
40
+ });
41
+ msg({
42
+ type: "M_ERROR",
43
+ title: error instanceof Error ? error.message : "An unknown error occurred.",
44
+ titleColor: "red"
45
+ });
46
+ process.exit(1);
47
+ }
48
+ } else {
49
+ const simpleSpinners = {
50
+ default: ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"],
51
+ dottedCircle: ["\u25CB", "\u25D4", "\u25D1", "\u25D5", "\u25CF"],
52
+ boxSpinner: ["\u2596", "\u2598", "\u259D", "\u2597"]
53
+ };
54
+ const frames = spinnerType && spinnerType in simpleSpinners ? simpleSpinners[spinnerType] : simpleSpinners.default;
55
+ const handleInput = (data) => {
56
+ const key = data.toString();
57
+ if (key === "\r" || key === "\n") {
58
+ return;
59
+ }
60
+ };
61
+ try {
62
+ if (process.stdin.isTTY && typeof process.stdin.setRawMode === "function") {
63
+ process.stdin.setRawMode(true);
64
+ process.stdin.resume();
65
+ process.stdin.on("data", handleInput);
66
+ }
67
+ interval = setInterval(() => {
68
+ const frame = re.magenta(frames[frameIndex]);
69
+ process.stdout.write(
70
+ `${cursor.move(-999, 0)}${erase.line}${frame} ${re.cyan(message)}`
71
+ );
72
+ frameIndex = (frameIndex + 1) % frames.length;
73
+ }, delay);
74
+ await action((newMessage) => {
75
+ message = newMessage;
76
+ });
77
+ clearInterval(interval);
78
+ interval = null;
79
+ process.stdout.write(
80
+ `\r${erase.line}${re.green("\u2714")} ${successMessage}
81
+ `
82
+ );
83
+ msg({
84
+ type: "M_INFO",
85
+ title: successMessage,
86
+ titleColor: "cyan"
87
+ });
88
+ } catch (error) {
89
+ if (interval) {
90
+ clearInterval(interval);
91
+ }
92
+ process.stdout.write(
93
+ `\r${erase.line}${re.red("\u2716")} ${error instanceof Error ? errorMessage : "An unknown error occurred."}
94
+ `
95
+ );
96
+ msg({
97
+ type: "M_ERROR",
98
+ title: error instanceof Error ? error.message : "An unknown error occurred.",
99
+ titleColor: "red"
100
+ });
101
+ process.exit(1);
102
+ } finally {
103
+ if (process.stdin.isTTY && typeof process.stdin.setRawMode === "function") {
104
+ process.stdin.setRawMode(false);
105
+ process.stdin.pause();
106
+ process.stdin.removeListener("data", handleInput);
107
+ }
108
+ }
109
+ }
110
+ }
@@ -0,0 +1,2 @@
1
+ import type { ColorName, TypographyName } from "../../core-types.js";
2
+ export declare function colorize(text: string, colorName?: ColorName, typography?: TypographyName): string;
@@ -0,0 +1,134 @@
1
+ import { re } from "@reliverse/relico";
2
+ import gradient, {
3
+ cristal,
4
+ mind,
5
+ passion,
6
+ rainbow,
7
+ vice
8
+ } from "gradient-string";
9
+ function stripAnsi(text) {
10
+ return re.reset(text);
11
+ }
12
+ export function colorize(text, colorName, typography) {
13
+ if (!colorName) return text;
14
+ text = stripAnsi(text);
15
+ let result = text;
16
+ if (colorName.endsWith("Gradient")) {
17
+ switch (colorName) {
18
+ case "gradientGradient":
19
+ result = gradient([
20
+ "red",
21
+ "yellow",
22
+ "green",
23
+ "cyan",
24
+ "blue",
25
+ "magenta"
26
+ ])(result);
27
+ break;
28
+ case "rainbowGradient":
29
+ result = rainbow(result);
30
+ break;
31
+ case "cristalGradient":
32
+ result = cristal(result);
33
+ break;
34
+ case "mindGradient":
35
+ result = mind(result);
36
+ break;
37
+ case "passionGradient":
38
+ result = passion(result);
39
+ break;
40
+ case "viceGradient":
41
+ result = vice(result);
42
+ break;
43
+ case "retroGradient":
44
+ result = gradient(["#ff8a00", "#e52e71"])(result);
45
+ break;
46
+ default:
47
+ break;
48
+ }
49
+ return result;
50
+ }
51
+ switch (colorName) {
52
+ case "inverse":
53
+ result = re.inverse(` ${result} `);
54
+ break;
55
+ case "dim":
56
+ result = re.dim(result);
57
+ break;
58
+ case "black":
59
+ result = re.black(result);
60
+ break;
61
+ case "red":
62
+ result = re.red(result);
63
+ break;
64
+ case "redBright":
65
+ result = re.redBright(result);
66
+ break;
67
+ case "green":
68
+ result = re.green(result);
69
+ break;
70
+ case "greenBright":
71
+ result = re.greenBright(result);
72
+ break;
73
+ case "yellow":
74
+ result = re.yellow(result);
75
+ break;
76
+ case "yellowBright":
77
+ result = re.yellowBright(result);
78
+ break;
79
+ case "blue":
80
+ result = re.blue(result);
81
+ break;
82
+ case "blueBright":
83
+ result = re.blueBright(result);
84
+ break;
85
+ case "magenta":
86
+ result = re.magenta(result);
87
+ break;
88
+ case "magentaBright":
89
+ result = re.magentaBright(result);
90
+ break;
91
+ case "cyan":
92
+ result = re.cyan(result);
93
+ break;
94
+ case "cyanBright":
95
+ result = re.cyanBright(result);
96
+ break;
97
+ case "bgCyan":
98
+ result = re.bgCyan(` ${result} `);
99
+ break;
100
+ case "bgCyanBright":
101
+ result = re.bgCyanBright(` ${result} `);
102
+ break;
103
+ case "white":
104
+ result = re.white(result);
105
+ break;
106
+ case "gray":
107
+ result = re.gray(result);
108
+ break;
109
+ case "none":
110
+ break;
111
+ default:
112
+ console.warn(`Warning: Unknown color "${colorName}"`);
113
+ break;
114
+ }
115
+ if (typography) {
116
+ switch (typography) {
117
+ case "bold":
118
+ result = re.bold(result);
119
+ break;
120
+ case "strikethrough":
121
+ result = re.strikethrough(result);
122
+ break;
123
+ case "underline":
124
+ result = re.underline(result);
125
+ break;
126
+ case "italic":
127
+ result = re.italic(result);
128
+ break;
129
+ default:
130
+ break;
131
+ }
132
+ }
133
+ return result;
134
+ }
@@ -0,0 +1 @@
1
+ export declare const errorHandler: (error: Error, customMessage?: string) => never;
@@ -0,0 +1,15 @@
1
+ export const errorHandler = (error, customMessage) => {
2
+ const separator = "\u2500".repeat(71);
3
+ console.error(`\u2502${separator}`);
4
+ console.error("\u2502 AN ERROR OCCURRED:\n\u2502 ", error.message);
5
+ console.error(`\u2502${separator}`);
6
+ if (customMessage) {
7
+ console.error(`\u2502 ${customMessage}`);
8
+ } else {
9
+ console.error(
10
+ "\u2502 If this issue is related to @reliverse/prompts itself, please\n\u2502 report the details at https://github.com/reliverse/prompts/issues"
11
+ );
12
+ }
13
+ console.error(`\u2570${separator}`);
14
+ process.exit(1);
15
+ };
@@ -0,0 +1,10 @@
1
+ import type { ColorName, PreventWrongTerminalSizeOptions } from "../../core-types.js";
2
+ export declare function preventUnsupportedTTY({ borderColor, }: {
3
+ borderColor?: ColorName;
4
+ }): void;
5
+ /**
6
+ * Prevents EISDIR errors when trying to read Windows home directory as a file
7
+ * @param filePath The file path to check
8
+ */
9
+ export declare function preventWindowsHomeDirRoot(filePath: string): never | undefined;
10
+ export declare function preventWrongTerminalSize({ isDev, shouldExit, minWidth, minHeight, sizeErrorDescription, }: PreventWrongTerminalSizeOptions): Promise<void>;
@@ -0,0 +1,69 @@
1
+ import { re } from "@reliverse/relico";
2
+ import { homedir } from "node:os";
3
+ import terminalSize from "terminal-size";
4
+ import { msg } from "../msg-fmt/messages.js";
5
+ import {
6
+ getExactTerminalWidth,
7
+ getTerminalWidth
8
+ } from "../msg-fmt/terminal.js";
9
+ export function preventUnsupportedTTY({
10
+ borderColor = "redBright"
11
+ }) {
12
+ if (!process.stdout.isTTY) {
13
+ console.error(
14
+ "\u2502 Your terminal does not support cursor manipulations.\n\u2502 It's recommended to use a terminal which supports TTY."
15
+ );
16
+ msg({
17
+ type: "M_BAR",
18
+ borderColor
19
+ });
20
+ }
21
+ }
22
+ export function preventWindowsHomeDirRoot(filePath) {
23
+ if (process.platform !== "win32") {
24
+ return;
25
+ }
26
+ const home = homedir();
27
+ if (filePath === home || filePath === `${home}\\`) {
28
+ msg({
29
+ type: "M_ERROR",
30
+ title: re.redBright("Cannot operate in Windows home directory root"),
31
+ content: `Please use a command like ${re.cyan(`cd ${home}\\Desktop`)} to move to a safe working directory first.`,
32
+ contentColor: "redBright"
33
+ });
34
+ process.exit(1);
35
+ }
36
+ }
37
+ export async function preventWrongTerminalSize({
38
+ isDev = false,
39
+ shouldExit = true,
40
+ minWidth = 80,
41
+ minHeight = 12,
42
+ sizeErrorDescription = "Please increase the terminal size to run the application"
43
+ }) {
44
+ const size = terminalSize();
45
+ const exactTerminalWidth = getExactTerminalWidth();
46
+ const terminalWidth = getTerminalWidth();
47
+ const errors = [];
48
+ if (terminalWidth < minWidth) {
49
+ errors.push(
50
+ isDev ? `Oops! Terminal width is too small. Expected >${minWidth} | Current: ${terminalWidth} (Exact: ${exactTerminalWidth})` : `Oops! Terminal width is too small. Expected >${minWidth} | Current: ${terminalWidth}`
51
+ );
52
+ }
53
+ if (size.rows < minHeight) {
54
+ errors.push(
55
+ `Oops! Terminal height is too small. Expected >${minHeight} | Current: ${size.rows}`
56
+ );
57
+ }
58
+ if (errors.length > 0) {
59
+ msg({
60
+ type: "M_ERROR",
61
+ title: re.redBright(errors.join("\n\u2502\u2502 ")),
62
+ content: size.rows >= 7 && terminalWidth >= 70 ? sizeErrorDescription : "",
63
+ contentColor: "redBright"
64
+ });
65
+ if (shouldExit) {
66
+ process.exit(1);
67
+ }
68
+ }
69
+ }
@@ -0,0 +1,8 @@
1
+ import type { BorderColorName, ColorName, TypographyName, VariantName } from "../../core-types.js";
2
+ /**
3
+ * Ends the prompt by optionally displaying an end message and running the action if confirmed.
4
+ * Preserves the last prompt state unless there's an endTitle.
5
+ */
6
+ export declare function completePrompt(prompt: "input" | "confirm" | "select" | "multiselect" | "toggle", isCtrlC: boolean, _endTitle?: string, _endTitleColor?: ColorName, _titleTypography?: TypographyName, _titleVariant?: VariantName | undefined, _border?: boolean, borderColor?: BorderColorName, action?: () => Promise<void>, value?: boolean): Promise<boolean>;
7
+ export declare function renderEndLine(): void;
8
+ export declare function renderEndLineInput(): void;
@@ -0,0 +1,33 @@
1
+ import { re } from "@reliverse/relico";
2
+ import { msg, symbols } from "../msg-fmt/messages.js";
3
+ import { getExactTerminalWidth } from "../msg-fmt/terminal.js";
4
+ export async function completePrompt(prompt, isCtrlC, _endTitle = "", _endTitleColor = "dim", _titleTypography = "none", _titleVariant = void 0, _border = true, borderColor = "dim", action, value) {
5
+ if (action && value) {
6
+ await action();
7
+ }
8
+ if (prompt === "input") {
9
+ renderEndLineInput();
10
+ return value ?? false;
11
+ }
12
+ if (isCtrlC) {
13
+ renderEndLine();
14
+ } else {
15
+ msg({
16
+ type: "M_BAR",
17
+ borderColor
18
+ });
19
+ }
20
+ return value ?? false;
21
+ }
22
+ export function renderEndLine() {
23
+ const lineLength = getExactTerminalWidth() - 2;
24
+ console.log(re.dim(symbols.middle));
25
+ console.log(re.dim(`${symbols.end}${symbols.line.repeat(lineLength)}\u22B1`));
26
+ console.log();
27
+ }
28
+ export function renderEndLineInput() {
29
+ const lineLength = getExactTerminalWidth() - 2;
30
+ console.log();
31
+ console.log(re.dim(`${symbols.end}${symbols.line.repeat(lineLength)}\u22B1`));
32
+ console.log();
33
+ }
@@ -0,0 +1,18 @@
1
+ import type { BorderColorName, StreamTextOptions } from "../../core-types.js";
2
+ /**
3
+ * Simulates streaming text output in the console, character by character
4
+ */
5
+ export declare function streamText({ text, delay, showCursor, color, newline, clearLine, onProgress, }: StreamTextOptions): Promise<void>;
6
+ /**
7
+ * Simulates streaming text output in a message box
8
+ */
9
+ export declare function streamTextBox({ text, delay, color, borderColor, }: Omit<StreamTextOptions, "showCursor" | "newline" | "clearLine"> & {
10
+ borderColor?: BorderColorName;
11
+ }): Promise<void>;
12
+ /**
13
+ * Simulates streaming text output with a loading spinner using ora
14
+ */
15
+ export declare function streamTextWithSpinner({ text, delay, color, spinnerFrames, spinnerDelay, }: StreamTextOptions & {
16
+ spinnerFrames?: string[];
17
+ spinnerDelay?: number;
18
+ }): Promise<void>;