@reliverse/rempts 1.7.43 → 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 -76
  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,348 +0,0 @@
1
- import { re } from "@reliverse/relico";
2
- import { relinka } from "@reliverse/relinka";
3
- import { stdin as input, stdout as output } from "node:process";
4
- import readline from "node:readline";
5
- import { msg, symbols } from "../msg-fmt/messages.js";
6
- import { deleteLastLine } from "../msg-fmt/terminal.js";
7
- import { completePrompt } from "../utils/prompt-end.js";
8
- function isSelectOption(option) {
9
- return !("separator" in option);
10
- }
11
- function renderPromptUI(params) {
12
- const {
13
- title,
14
- content,
15
- options,
16
- pointer,
17
- selectedOptions,
18
- errorMessage,
19
- displayInstructions,
20
- instructions,
21
- allDisabled,
22
- titleColor,
23
- contentColor,
24
- contentTypography,
25
- debug,
26
- titleVariant,
27
- titleTypography,
28
- isRerender = false
29
- } = params;
30
- if (!isRerender) {
31
- msg({
32
- type: "M_NULL",
33
- title,
34
- titleColor,
35
- ...titleTypography ? { titleTypography } : {},
36
- ...titleVariant ? { titleVariant } : {}
37
- });
38
- if (content) {
39
- msg({
40
- type: "M_NULL",
41
- content,
42
- contentColor,
43
- contentTypography
44
- });
45
- }
46
- }
47
- let uiLineCount = 0;
48
- if (errorMessage) {
49
- msg({
50
- type: "M_NULL",
51
- title: `${re.redBright(symbols.step_error)} ${re.redBright(errorMessage)}`
52
- });
53
- uiLineCount++;
54
- } else if (allDisabled) {
55
- msg({ type: "M_NULL", title: re.redBright("All options are disabled.") });
56
- uiLineCount++;
57
- } else if (displayInstructions && !isRerender) {
58
- msg({ type: "M_NULL", title: re.blue(instructions) });
59
- uiLineCount++;
60
- }
61
- for (let index = 0; index < options.length; index++) {
62
- const option = options[index];
63
- if (!option) continue;
64
- if (!isSelectOption(option)) {
65
- const width = option.width ?? 20;
66
- const symbolKey = option.symbol ?? "line";
67
- const lineSymbol = symbolKey in symbols ? symbols[symbolKey] : "\u2500";
68
- msg({ type: "M_NULL", title: re.dim(lineSymbol.repeat(width)) });
69
- uiLineCount++;
70
- continue;
71
- }
72
- const isSelected = selectedOptions.has(index);
73
- const isHighlighted = index === pointer;
74
- const isDisabled = option.disabled;
75
- const checkbox = isSelected ? "[x]" : "[ ]";
76
- const prefix = isHighlighted ? re.yellow(re.reset("> ")) : " ";
77
- const labelColor = isDisabled ? re.dim(re.reset(option.label)) : isHighlighted ? re.reset(re.yellow(option.label)) : re.reset(option.label);
78
- const hint = option.hint ? re.reset(
79
- ` (${isDisabled ? re.dim(option.hint) : re.gray(option.hint)})`
80
- ) : "";
81
- const formattedCheckbox = isHighlighted ? re.yellow(checkbox) : checkbox;
82
- msg({
83
- type: "M_NULL",
84
- title: `${prefix}${formattedCheckbox} ${labelColor}${hint}`
85
- });
86
- uiLineCount++;
87
- }
88
- if (debug) {
89
- relinka("log", "", { optionsCount: options.length });
90
- }
91
- return uiLineCount;
92
- }
93
- export async function multiselectPrompt(params) {
94
- const {
95
- title = "",
96
- message,
97
- content = "",
98
- options,
99
- defaultValue = [],
100
- initialValues,
101
- borderColor = "dim",
102
- titleColor = "cyan",
103
- titleTypography = "none",
104
- titleVariant,
105
- contentColor = "dim",
106
- contentTypography = "italic",
107
- border = true,
108
- endTitle = "",
109
- endTitleColor = "dim",
110
- debug = false,
111
- terminalWidth: customTerminalWidth = 90,
112
- displayInstructions = false,
113
- required = false,
114
- minSelect = 0,
115
- maxSelect,
116
- selectAll = false
117
- } = params;
118
- const finalTitle = message && title ? `${title}: ${message}` : message ?? title ?? "Select options";
119
- const finalDefaultValue = defaultValue ?? initialValues;
120
- const effectiveMinSelect = required ? Math.max(1, minSelect) : minSelect;
121
- let pointer = finalDefaultValue.length > 0 ? options.findIndex(
122
- (opt) => opt && isSelectOption(opt) && finalDefaultValue.includes(opt.value) && !opt.disabled
123
- ) : 0;
124
- if (pointer === -1) {
125
- pointer = options.findIndex(
126
- (opt) => opt && isSelectOption(opt) && !opt.disabled
127
- );
128
- if (pointer === -1) {
129
- pointer = 0;
130
- }
131
- }
132
- const selectedOptions = new Set(
133
- selectAll ? options.map(
134
- (opt, index) => opt && isSelectOption(opt) && !opt.disabled ? index : -1
135
- ).filter((i) => i !== -1) : finalDefaultValue.map(
136
- (val) => options.findIndex((o) => o && isSelectOption(o) && o.value === val)
137
- ).filter(
138
- (i) => i >= 0 && options[i] && isSelectOption(options[i]) && !options[i].disabled
139
- )
140
- );
141
- const rl = readline.createInterface({ input, output });
142
- readline.emitKeypressEvents(input, rl);
143
- if (typeof input.setRawMode === "function") {
144
- input.setRawMode(true);
145
- }
146
- let errorMessage = "";
147
- const allDisabled = options.filter(isSelectOption).every((option) => option.disabled);
148
- const instructions = "Use <\u2191/\u2193> to navigate, <Space> to toggle, <A> to toggle all";
149
- function toggleSelectAll() {
150
- const selectableIndexes = options.map((opt, i) => isSelectOption(opt) && !opt.disabled ? i : -1).filter((i) => i !== -1);
151
- const allSelected = selectableIndexes.every((i) => selectedOptions.has(i));
152
- if (allSelected) {
153
- for (const i of selectableIndexes) {
154
- selectedOptions.delete(i);
155
- }
156
- } else {
157
- for (const i of selectableIndexes) {
158
- selectedOptions.add(i);
159
- }
160
- }
161
- }
162
- function movePointerUp() {
163
- const originalPointer = pointer;
164
- do {
165
- pointer = (pointer - 1 + options.length) % options.length;
166
- const currentOption = options[pointer];
167
- if (currentOption && isSelectOption(currentOption) && !currentOption.disabled) {
168
- break;
169
- }
170
- } while (pointer !== originalPointer);
171
- errorMessage = "";
172
- }
173
- function movePointerDown() {
174
- const originalPointer = pointer;
175
- do {
176
- pointer = (pointer + 1) % options.length;
177
- const currentOption = options[pointer];
178
- if (currentOption && isSelectOption(currentOption) && !currentOption.disabled) {
179
- break;
180
- }
181
- } while (pointer !== originalPointer);
182
- errorMessage = "";
183
- }
184
- let lastUILineCount = 0;
185
- function renderOptions() {
186
- if (lastUILineCount > 0) {
187
- for (let i = 0; i < lastUILineCount; i++) {
188
- process.stdout.write("\x1B[1A\x1B[2K");
189
- }
190
- }
191
- lastUILineCount = renderPromptUI({
192
- title: finalTitle,
193
- content,
194
- options,
195
- pointer,
196
- selectedOptions,
197
- errorMessage,
198
- displayInstructions,
199
- instructions,
200
- allDisabled,
201
- titleColor,
202
- contentColor,
203
- contentTypography,
204
- debug,
205
- borderColor,
206
- titleVariant,
207
- titleTypography,
208
- terminalWidth: customTerminalWidth,
209
- resized: false,
210
- isRerender: true
211
- });
212
- }
213
- lastUILineCount = renderPromptUI({
214
- title: finalTitle,
215
- content,
216
- options,
217
- pointer,
218
- selectedOptions,
219
- errorMessage,
220
- displayInstructions,
221
- instructions,
222
- allDisabled,
223
- titleColor,
224
- contentColor,
225
- contentTypography,
226
- debug,
227
- borderColor,
228
- titleVariant,
229
- titleTypography,
230
- terminalWidth: customTerminalWidth,
231
- resized: false,
232
- isRerender: false
233
- });
234
- return new Promise((resolve) => {
235
- function cleanup(isCtrlC = false) {
236
- if (typeof input.setRawMode === "function") {
237
- input.setRawMode(false);
238
- }
239
- rl.close();
240
- input.removeListener("keypress", handleKeypress);
241
- if (isCtrlC) {
242
- process.exit(0);
243
- }
244
- }
245
- async function endPrompt(isCtrlC = false) {
246
- await completePrompt(
247
- "multiselect",
248
- isCtrlC,
249
- endTitle,
250
- endTitleColor,
251
- titleTypography,
252
- titleVariant ? titleVariant : void 0,
253
- border,
254
- borderColor,
255
- void 0,
256
- false
257
- );
258
- cleanup(isCtrlC);
259
- }
260
- async function confirmSelection() {
261
- const selectedCount = selectedOptions.size;
262
- if (selectedCount < effectiveMinSelect) {
263
- deleteLastLine();
264
- errorMessage = `You must select at least ${effectiveMinSelect} option${effectiveMinSelect !== 1 ? "s" : ""}.`;
265
- renderOptions();
266
- return;
267
- }
268
- if (maxSelect !== void 0 && selectedCount > maxSelect) {
269
- deleteLastLine();
270
- errorMessage = `You can select at most ${maxSelect} option${maxSelect !== 1 ? "s" : ""}.`;
271
- renderOptions();
272
- return;
273
- }
274
- const selectedValues = Array.from(selectedOptions).filter((idx) => {
275
- const opt = options[idx];
276
- return opt && isSelectOption(opt) && !opt.disabled;
277
- }).map((idx) => {
278
- const opt = options[idx];
279
- return opt && isSelectOption(opt) ? opt.value : null;
280
- }).filter((val) => val !== null && val !== void 0);
281
- cleanup();
282
- resolve(selectedValues);
283
- deleteLastLine();
284
- await completePrompt(
285
- "multiselect",
286
- false,
287
- endTitle,
288
- endTitleColor,
289
- titleTypography,
290
- titleVariant ? titleVariant : void 0,
291
- border,
292
- borderColor,
293
- void 0,
294
- true
295
- );
296
- }
297
- function handleKeypress(_str, key) {
298
- if (allDisabled) {
299
- if (key.name === "c" && key.ctrl) {
300
- void endPrompt(true);
301
- return;
302
- }
303
- return;
304
- }
305
- switch (key.name) {
306
- case "up":
307
- case "k":
308
- movePointerUp();
309
- renderOptions();
310
- break;
311
- case "down":
312
- case "j":
313
- movePointerDown();
314
- renderOptions();
315
- break;
316
- case "space": {
317
- const currentOption = options[pointer];
318
- if (!currentOption || !isSelectOption(currentOption) || currentOption.disabled) {
319
- errorMessage = "This option is disabled";
320
- } else {
321
- if (selectedOptions.has(pointer)) {
322
- selectedOptions.delete(pointer);
323
- } else {
324
- selectedOptions.add(pointer);
325
- }
326
- errorMessage = "";
327
- }
328
- renderOptions();
329
- break;
330
- }
331
- case "return":
332
- void confirmSelection();
333
- break;
334
- case "c":
335
- if (key.ctrl) {
336
- void endPrompt(true);
337
- }
338
- break;
339
- case "a":
340
- toggleSelectAll();
341
- errorMessage = "";
342
- renderOptions();
343
- break;
344
- }
345
- }
346
- input.on("keypress", handleKeypress);
347
- });
348
- }
@@ -1,14 +0,0 @@
1
- import type { TypographyName, ColorName } from "../../types.js";
2
- import type { VariantName } from "../../types.js";
3
- interface NextStepsPromptOptions {
4
- title?: string;
5
- titleColor?: ColorName;
6
- titleVariant?: VariantName;
7
- titleTypography?: TypographyName;
8
- content: string[];
9
- contentColor?: ColorName;
10
- contentVariant?: VariantName;
11
- contentTypography?: TypographyName;
12
- }
13
- export declare function nextStepsPrompt(options: NextStepsPromptOptions): Promise<void>;
14
- export {};
@@ -1,24 +0,0 @@
1
- import { msg } from "../msg-fmt/messages.js";
2
- export async function nextStepsPrompt(options) {
3
- const {
4
- title = "",
5
- titleColor = "cyan",
6
- titleVariant,
7
- titleTypography = "none",
8
- content = [],
9
- contentColor = "dim",
10
- contentVariant,
11
- contentTypography = "italic"
12
- } = options;
13
- msg({
14
- type: "M_INFO",
15
- title,
16
- titleColor,
17
- titleTypography,
18
- ...titleVariant ? { titleVariant } : {},
19
- content: Array.isArray(content) ? content.join("\n") : content,
20
- contentColor,
21
- contentTypography,
22
- ...contentVariant ? { contentVariant } : {}
23
- });
24
- }
@@ -1,28 +0,0 @@
1
- import type { BorderColorName, ColorName, FmtMsgOptions, TypographyName } from "../../types.js";
2
- type VariantName = FmtMsgOptions["titleVariant"];
3
- interface NumberPromptOptions {
4
- title: string;
5
- hint?: string;
6
- hintPlaceholderColor?: ColorName;
7
- validate?: (value: number) => string | undefined | boolean | Promise<string | undefined | boolean>;
8
- defaultValue?: string | number;
9
- schema?: any;
10
- titleColor?: ColorName;
11
- titleTypography?: TypographyName;
12
- titleVariant?: VariantName;
13
- content?: string;
14
- contentColor?: ColorName;
15
- contentTypography?: TypographyName;
16
- contentVariant?: VariantName;
17
- borderColor?: BorderColorName;
18
- variantOptions?: any;
19
- endTitle?: string;
20
- endTitleColor?: ColorName;
21
- border?: boolean;
22
- hardcoded?: {
23
- userInput?: string;
24
- errorMessage?: string;
25
- };
26
- }
27
- export declare function numberPrompt(opts: NumberPromptOptions): Promise<number>;
28
- export {};
@@ -1,194 +0,0 @@
1
- import { stdin as input, stdout as output } from "node:process";
2
- import readline from "node:readline/promises";
3
- import { bar, msg } from "../msg-fmt/messages.js";
4
- import { deleteLastLine, deleteLastLines } from "../msg-fmt/terminal.js";
5
- function renderPromptUI(params) {
6
- const {
7
- title,
8
- hint,
9
- content,
10
- contentColor = "dim",
11
- contentTypography = "italic",
12
- contentVariant,
13
- titleColor = "cyan",
14
- titleTypography = "none",
15
- titleVariant,
16
- borderColor = "dim",
17
- userInput,
18
- errorMessage
19
- } = params;
20
- let lineCount = 0;
21
- const type = errorMessage !== "" ? "M_ERROR" : "M_GENERAL";
22
- const msgParams = {
23
- type,
24
- title,
25
- titleColor,
26
- titleTypography,
27
- titleVariant: titleVariant ?? "none",
28
- content: content ?? "",
29
- contentColor,
30
- contentTypography,
31
- contentVariant: contentVariant ?? "none",
32
- borderColor,
33
- hint: hint ?? "",
34
- errorMessage
35
- };
36
- msg(msgParams);
37
- lineCount++;
38
- if (userInput !== "") {
39
- msg({ type: "M_MIDDLE", title: ` ${userInput}` });
40
- lineCount++;
41
- }
42
- return lineCount;
43
- }
44
- export async function numberPrompt(opts) {
45
- const {
46
- title = "",
47
- hint,
48
- hintPlaceholderColor = "blue",
49
- validate,
50
- defaultValue,
51
- titleColor = "cyan",
52
- titleTypography = "none",
53
- titleVariant,
54
- content,
55
- contentColor = "dim",
56
- contentTypography = "italic",
57
- contentVariant,
58
- borderColor = "dim",
59
- hardcoded,
60
- endTitle = "",
61
- endTitleColor = "dim",
62
- border = true
63
- } = opts;
64
- const rl = readline.createInterface({ input, output });
65
- rl.on("SIGINT", () => {
66
- if (endTitle !== "") {
67
- msg({
68
- type: "M_END",
69
- title: endTitle,
70
- titleColor: endTitleColor,
71
- titleTypography,
72
- border,
73
- borderColor
74
- });
75
- }
76
- rl.close();
77
- process.exit(0);
78
- });
79
- let currentInput = hardcoded?.userInput || "";
80
- let errorMessage = hardcoded?.errorMessage || "";
81
- let isRerender = false;
82
- let lastLineCount = 0;
83
- const effectiveDefault = typeof defaultValue === "string" ? Number(defaultValue) : defaultValue;
84
- if (hardcoded?.userInput !== void 0) {
85
- renderPromptUI({
86
- title,
87
- hint,
88
- hintPlaceholderColor,
89
- content,
90
- contentColor,
91
- contentTypography,
92
- contentVariant,
93
- titleColor,
94
- titleTypography,
95
- titleVariant,
96
- borderColor,
97
- userInput: currentInput,
98
- errorMessage,
99
- border,
100
- isRerender
101
- });
102
- const num = Number(currentInput);
103
- if (Number.isNaN(num)) {
104
- throw new Error("Please enter a valid number.");
105
- }
106
- const validated = await validateInput(num, validate);
107
- if (validated.isValid) {
108
- msg({ type: "M_MIDDLE", title: ` ${num}` });
109
- msg({ type: "M_BAR", borderColor });
110
- rl.close();
111
- return num;
112
- }
113
- rl.close();
114
- throw new Error(validated.errorMessage || "Invalid input.");
115
- }
116
- while (true) {
117
- if (isRerender) {
118
- deleteLastLines(lastLineCount + 1);
119
- }
120
- lastLineCount = renderPromptUI({
121
- title,
122
- hint,
123
- hintPlaceholderColor,
124
- content,
125
- contentColor,
126
- contentTypography,
127
- contentVariant,
128
- titleColor,
129
- titleTypography,
130
- titleVariant,
131
- borderColor,
132
- userInput: currentInput,
133
- errorMessage,
134
- border,
135
- isRerender
136
- });
137
- const formattedBar = bar({ borderColor });
138
- const answerInput = await rl.question(`${formattedBar} `);
139
- isRerender = true;
140
- if (answerInput === null) {
141
- if (endTitle !== "") {
142
- msg({
143
- type: "M_END",
144
- title: endTitle,
145
- titleColor: endTitleColor,
146
- titleTypography,
147
- border,
148
- borderColor
149
- });
150
- }
151
- rl.close();
152
- process.exit(0);
153
- }
154
- currentInput = answerInput.trim();
155
- if (!currentInput && effectiveDefault !== void 0) {
156
- deleteLastLine();
157
- msg({ type: "M_MIDDLE", title: ` ${effectiveDefault}` });
158
- msg({ type: "M_BAR", borderColor });
159
- rl.close();
160
- return effectiveDefault;
161
- }
162
- const num = Number(currentInput);
163
- if (Number.isNaN(num)) {
164
- errorMessage = "Please enter a valid number.";
165
- continue;
166
- }
167
- const validated = await validateInput(num, validate);
168
- if (validated.isValid) {
169
- deleteLastLine();
170
- msg({ type: "M_MIDDLE", title: ` ${num}` });
171
- msg({ type: "M_BAR", borderColor });
172
- rl.close();
173
- return num;
174
- }
175
- errorMessage = validated.errorMessage;
176
- }
177
- }
178
- async function validateInput(input2, validate) {
179
- let isValid = true;
180
- let errorMessage = "";
181
- if (validate && isValid) {
182
- const validationResult = await validate(input2);
183
- if (validationResult === true || validationResult === void 0) {
184
- isValid = true;
185
- } else if (typeof validationResult === "string") {
186
- isValid = false;
187
- errorMessage = validationResult;
188
- } else {
189
- isValid = false;
190
- errorMessage = "Invalid input.";
191
- }
192
- }
193
- return { isValid, errorMessage };
194
- }
@@ -1,2 +0,0 @@
1
- export declare const endPrompt: any;
2
- export declare const outro: any;
@@ -1,3 +0,0 @@
1
- import { outroPrompt } from "./outro-mod.js";
2
- export const endPrompt = outroPrompt;
3
- export const outro = outroPrompt;
@@ -1,8 +0,0 @@
1
- import type { Fonts } from "figlet";
2
- import type { PromptOptions } from "../../types.js";
3
- type EndPromptOptions = PromptOptions & {
4
- variant?: "footer" | "ascii-art";
5
- asciiArtFont?: Fonts;
6
- };
7
- export declare function outroPrompt(optionsOrTitle: EndPromptOptions | string): Promise<void>;
8
- export {};
@@ -1,55 +0,0 @@
1
- import { animateText } from "../animate/animate-mod.js";
2
- import { msg } from "../msg-fmt/messages.js";
3
- import { getExactTerminalWidth } from "../msg-fmt/terminal.js";
4
- import { createAsciiArt } from "../visual/visual-mod.js";
5
- export async function outroPrompt(optionsOrTitle) {
6
- const options = typeof optionsOrTitle === "string" ? { title: optionsOrTitle } : optionsOrTitle;
7
- const {
8
- title = "",
9
- titleColor = "cyan",
10
- titleTypography = "none",
11
- titleVariant,
12
- titleAnimation,
13
- titleAnimationDelay,
14
- border = true,
15
- borderColor = "dim",
16
- horizontalLineLength: initialHorizontalLineLength = 0,
17
- variant = "footer",
18
- asciiArtFont
19
- } = options;
20
- let horizontalLineLength = initialHorizontalLineLength;
21
- if (variant === "ascii-art") {
22
- await createAsciiArt({
23
- message: title || " ",
24
- font: asciiArtFont
25
- });
26
- return;
27
- }
28
- if (horizontalLineLength === 0) {
29
- horizontalLineLength = getExactTerminalWidth() - 3;
30
- }
31
- if (titleAnimation) {
32
- await animateText({
33
- title: title ? title : " ",
34
- anim: titleAnimation,
35
- delay: titleAnimationDelay,
36
- type: "M_END",
37
- titleColor,
38
- titleTypography,
39
- border,
40
- borderColor,
41
- horizontalLineLength
42
- });
43
- } else {
44
- msg({
45
- type: "M_END",
46
- title: title ? title : " ",
47
- titleColor,
48
- titleTypography,
49
- titleVariant,
50
- border,
51
- borderColor,
52
- horizontalLineLength
53
- });
54
- }
55
- }
@@ -1,7 +0,0 @@
1
- export interface ResultsType {
2
- username: string;
3
- }
4
- export declare function resultPrompt({ results, inline, }: {
5
- results: ResultsType;
6
- inline?: boolean;
7
- }): Promise<void>;