@reliverse/rempts 1.7.65 → 2.2.7

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 (131) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +1534 -1431
  3. package/cleanup.mjs +33 -0
  4. package/dist/cancel.d.ts +31 -0
  5. package/dist/cancel.js +28 -0
  6. package/dist/ffi.d.ts +1 -0
  7. package/dist/ffi.js +165 -0
  8. package/dist/group.d.ts +16 -0
  9. package/dist/group.js +22 -0
  10. package/dist/launcher/command.d.ts +8 -0
  11. package/dist/launcher/command.js +10 -0
  12. package/dist/launcher/discovery.d.ts +3 -0
  13. package/dist/launcher/discovery.js +207 -0
  14. package/dist/launcher/errors.d.ts +15 -0
  15. package/dist/launcher/errors.js +31 -0
  16. package/dist/launcher/help.d.ts +3 -0
  17. package/dist/launcher/help.js +145 -0
  18. package/dist/launcher/mod.d.ts +12 -0
  19. package/dist/launcher/mod.js +222 -0
  20. package/dist/launcher/parser.d.ts +14 -0
  21. package/dist/launcher/parser.js +255 -0
  22. package/dist/launcher/registry.d.ts +10 -0
  23. package/dist/launcher/registry.js +42 -0
  24. package/dist/launcher/types.d.ts +78 -0
  25. package/dist/launcher/validator.d.ts +3 -0
  26. package/dist/launcher/validator.js +39 -0
  27. package/dist/mod.d.ts +6 -0
  28. package/dist/mod.js +6 -0
  29. package/dist/prompt.d.ts +13 -0
  30. package/dist/prompt.js +53 -0
  31. package/dist/selection.d.ts +92 -0
  32. package/dist/selection.js +191 -0
  33. package/dist/spinner.d.ts +26 -0
  34. package/dist/spinner.js +141 -0
  35. package/dist/utils.d.ts +3 -0
  36. package/dist/utils.js +11 -0
  37. package/package.json +41 -47
  38. package/bin/libs/animate/animate-mod.ts.txt +0 -78
  39. package/bin/libs/anykey/anykey-mod.d.ts +0 -12
  40. package/bin/libs/anykey/anykey-mod.js +0 -125
  41. package/bin/libs/cancel/cancel.d.ts +0 -45
  42. package/bin/libs/cancel/cancel.js +0 -72
  43. package/bin/libs/confirm/confirm-alias.d.ts +0 -2
  44. package/bin/libs/confirm/confirm-alias.js +0 -2
  45. package/bin/libs/confirm/confirm-mod.d.ts +0 -5
  46. package/bin/libs/confirm/confirm-mod.js +0 -179
  47. package/bin/libs/date/date.d.ts +0 -2
  48. package/bin/libs/date/date.js +0 -254
  49. package/bin/libs/editor/editor-mod.d.ts +0 -25
  50. package/bin/libs/editor/editor-mod.js +0 -1133
  51. package/bin/libs/figures/figures-mod.d.ts +0 -461
  52. package/bin/libs/figures/figures-mod.js +0 -285
  53. package/bin/libs/group/group-mod.d.ts +0 -33
  54. package/bin/libs/group/group-mod.js +0 -89
  55. package/bin/libs/input/input-alias.d.ts +0 -5
  56. package/bin/libs/input/input-alias.js +0 -4
  57. package/bin/libs/input/input-mod.d.ts +0 -16
  58. package/bin/libs/input/input-mod.js +0 -370
  59. package/bin/libs/intro/intro-alias.d.ts +0 -3
  60. package/bin/libs/intro/intro-alias.js +0 -3
  61. package/bin/libs/intro/intro-mod.d.ts +0 -19
  62. package/bin/libs/intro/intro-mod.js +0 -71
  63. package/bin/libs/launcher/command-runner.d.ts +0 -31
  64. package/bin/libs/launcher/command-runner.js +0 -229
  65. package/bin/libs/launcher/launcher-alias.d.ts +0 -2
  66. package/bin/libs/launcher/launcher-alias.js +0 -2
  67. package/bin/libs/launcher/launcher-mod.d.ts +0 -66
  68. package/bin/libs/launcher/launcher-mod.js +0 -1037
  69. package/bin/libs/launcher/launcher-types.d.ts +0 -176
  70. package/bin/libs/launcher/launcher-types.js +0 -0
  71. package/bin/libs/log/log-alias.d.ts +0 -1
  72. package/bin/libs/log/log-alias.js +0 -2
  73. package/bin/libs/msg-fmt/colors.d.ts +0 -30
  74. package/bin/libs/msg-fmt/colors.js +0 -42
  75. package/bin/libs/msg-fmt/mapping.d.ts +0 -3
  76. package/bin/libs/msg-fmt/mapping.js +0 -41
  77. package/bin/libs/msg-fmt/messages.d.ts +0 -35
  78. package/bin/libs/msg-fmt/messages.js +0 -305
  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 -340
  87. package/bin/libs/next-steps/next-steps.d.ts +0 -13
  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 -234
  91. package/bin/libs/outro/outro-alias.d.ts +0 -3
  92. package/bin/libs/outro/outro-alias.js +0 -3
  93. package/bin/libs/outro/outro-mod.d.ts +0 -7
  94. package/bin/libs/outro/outro-mod.js +0 -49
  95. package/bin/libs/reliarg/reliarg-mod.d.ts +0 -76
  96. package/bin/libs/reliarg/reliarg-mod.js +0 -276
  97. package/bin/libs/results/results.d.ts +0 -7
  98. package/bin/libs/results/results.js +0 -27
  99. package/bin/libs/select/nummultiselect-prompt.d.ts +0 -6
  100. package/bin/libs/select/nummultiselect-prompt.js +0 -141
  101. package/bin/libs/select/numselect-prompt.d.ts +0 -7
  102. package/bin/libs/select/numselect-prompt.js +0 -111
  103. package/bin/libs/select/select-alias.d.ts +0 -9
  104. package/bin/libs/select/select-alias.js +0 -9
  105. package/bin/libs/select/select-prompt.d.ts +0 -5
  106. package/bin/libs/select/select-prompt.js +0 -311
  107. package/bin/libs/select/toggle-prompt.d.ts +0 -5
  108. package/bin/libs/select/toggle-prompt.js +0 -207
  109. package/bin/libs/spinner/spinner-impl.d.ts +0 -70
  110. package/bin/libs/spinner/spinner-impl.js +0 -336
  111. package/bin/libs/spinner/spinner-mod.d.ts +0 -167
  112. package/bin/libs/spinner/spinner-mod.js +0 -447
  113. package/bin/libs/utils/colorize.d.ts +0 -2
  114. package/bin/libs/utils/colorize.js +0 -122
  115. package/bin/libs/utils/errors.d.ts +0 -1
  116. package/bin/libs/utils/errors.js +0 -17
  117. package/bin/libs/utils/prevent.d.ts +0 -8
  118. package/bin/libs/utils/prevent.js +0 -62
  119. package/bin/libs/utils/prompt-end.d.ts +0 -8
  120. package/bin/libs/utils/prompt-end.js +0 -36
  121. package/bin/libs/utils/stream-text.d.ts +0 -18
  122. package/bin/libs/utils/stream-text.js +0 -138
  123. package/bin/libs/utils/system.d.ts +0 -6
  124. package/bin/libs/utils/system.js +0 -7
  125. package/bin/libs/utils/validate.d.ts +0 -21
  126. package/bin/libs/utils/validate.js +0 -17
  127. package/bin/libs/visual/visual-mod.ts.txt +0 -19
  128. package/bin/mod.d.ts +0 -50
  129. package/bin/mod.js +0 -127
  130. package/bin/types.d.ts +0 -372
  131. /package/{bin → dist/launcher}/types.js +0 -0
@@ -1,179 +0,0 @@
1
- import { stdin as input, stdout as output } from "node:process";
2
- import readline from "node:readline/promises";
3
- import { re } from "@reliverse/relico";
4
- import { bar, msg } from "../msg-fmt/messages.js";
5
- import { deleteLastLine } from "../msg-fmt/terminal.js";
6
- import { completePrompt } from "../utils/prompt-end.js";
7
- function renderPrompt(params) {
8
- const {
9
- title,
10
- content,
11
- borderColor,
12
- titleColor,
13
- titleTypography,
14
- titleVariant,
15
- contentColor,
16
- contentTypography,
17
- contentVariant,
18
- hintPlaceholderColor,
19
- border,
20
- variantOptions,
21
- errorMessage,
22
- displayInstructions,
23
- instructions,
24
- isRerender = false
25
- } = params;
26
- let uiLineCount = 0;
27
- if (!isRerender) {
28
- msg({
29
- hintPlaceholderColor,
30
- type: errorMessage ? "M_ERROR" : "M_GENERAL",
31
- title,
32
- titleColor,
33
- titleTypography,
34
- ...titleVariant ? { titleVariant } : {},
35
- ...content ? {
36
- content: content.split("\n").map((line) => line.trim()).join("\n")
37
- } : {},
38
- contentColor,
39
- contentTypography,
40
- ...contentVariant ? { contentVariant } : {},
41
- borderColor,
42
- variantOptions,
43
- errorMessage,
44
- border
45
- });
46
- }
47
- if (displayInstructions && !isRerender) {
48
- msg({
49
- type: "M_NULL",
50
- title: re.blue(instructions)
51
- });
52
- uiLineCount++;
53
- }
54
- if (errorMessage) {
55
- msg({
56
- type: "M_NULL",
57
- title: re.redBright(errorMessage)
58
- });
59
- uiLineCount++;
60
- }
61
- return uiLineCount;
62
- }
63
- export async function confirmPrompt(options) {
64
- const {
65
- title = "",
66
- message,
67
- // Alias for title
68
- defaultValue,
69
- initialValue,
70
- // Alias for defaultValue
71
- content,
72
- titleColor = "cyan",
73
- titleTypography = "none",
74
- titleVariant,
75
- contentColor = "dim",
76
- contentTypography = "italic",
77
- contentVariant,
78
- borderColor = "dim",
79
- hintPlaceholderColor = "blue",
80
- variantOptions,
81
- action,
82
- displayInstructions = false,
83
- endTitle = "",
84
- endTitleColor = "dim",
85
- border = true
86
- } = options;
87
- const finalTitle = message && title ? `${title}: ${message}` : message ?? title ?? "Confirm";
88
- const finalDefaultValue = defaultValue ?? initialValue;
89
- const rl = readline.createInterface({ input, output });
90
- let errorMessage = "";
91
- const effectiveDefault = finalDefaultValue ?? true;
92
- const defaultHint = effectiveDefault ? "[Y/n]" : "[y/N]";
93
- const adjustedTitle = displayInstructions ? finalTitle : `${re.blue(defaultHint)} ${finalTitle}`;
94
- const instructions = `Use <y/n> to confirm or deny, <Enter> for default (${effectiveDefault ? "Y" : "N"}), <Ctrl+C> to exit`;
95
- let lastUILineCount = 0;
96
- function endPrompt(isCtrlC = false) {
97
- if (endTitle !== "") {
98
- msg({
99
- type: "M_END",
100
- title: endTitle,
101
- titleColor: endTitleColor,
102
- titleTypography,
103
- ...titleVariant ? { titleVariant } : {},
104
- border,
105
- borderColor
106
- });
107
- }
108
- rl.close();
109
- if (isCtrlC) {
110
- process.exit(0);
111
- }
112
- }
113
- rl.on("SIGINT", () => {
114
- endPrompt(true);
115
- });
116
- try {
117
- while (true) {
118
- if (lastUILineCount > 0) {
119
- for (let i = 0; i < lastUILineCount; i++) {
120
- process.stdout.write("\x1B[1A\x1B[2K");
121
- }
122
- }
123
- lastUILineCount = renderPrompt({
124
- title: adjustedTitle,
125
- ...content ? { content } : {},
126
- borderColor,
127
- titleColor,
128
- titleTypography,
129
- ...titleVariant ? { titleVariant } : {},
130
- contentColor,
131
- contentTypography,
132
- ...contentVariant ? { contentVariant } : {},
133
- hintPlaceholderColor,
134
- border,
135
- variantOptions,
136
- errorMessage,
137
- effectiveDefault,
138
- displayInstructions,
139
- defaultHint,
140
- instructions,
141
- isRerender: errorMessage !== ""
142
- // Only rerender if there's an error
143
- });
144
- const formattedBar = bar({ borderColor });
145
- const answer = (await rl.question(`${formattedBar} `)).toLowerCase().trim();
146
- let result;
147
- if (!answer) {
148
- deleteLastLine();
149
- msg({
150
- type: "M_NULL",
151
- title: `${formattedBar} ${effectiveDefault ? "y" : "n"}`
152
- });
153
- result = effectiveDefault;
154
- } else if (answer === "y" || answer === "yes") {
155
- result = true;
156
- } else if (answer === "n" || answer === "no") {
157
- result = false;
158
- } else {
159
- errorMessage = 'Please answer with "y" or "n".';
160
- deleteLastLine();
161
- continue;
162
- }
163
- return await completePrompt(
164
- "confirm",
165
- false,
166
- endTitle,
167
- endTitleColor,
168
- titleTypography,
169
- titleVariant ? titleVariant : void 0,
170
- border,
171
- borderColor,
172
- action,
173
- result
174
- );
175
- }
176
- } finally {
177
- rl.close();
178
- }
179
- }
@@ -1,2 +0,0 @@
1
- import type { DatePromptOptions } from "../../types";
2
- export declare function datePrompt(opts: DatePromptOptions): Promise<string>;
@@ -1,254 +0,0 @@
1
- import { stdin as input, stdout as output } from "node:process";
2
- import readline from "node:readline/promises";
3
- import { re } from "@reliverse/relico";
4
- import { buildRegExp, digit, endOfString, repeat, startOfString } from "ts-regex-builder";
5
- import { fmt, msg, symbols } from "../msg-fmt/messages.js";
6
- import { countLines, deleteLastLine, deleteLastLines } from "../msg-fmt/terminal.js";
7
- const twoDigits = repeat(digit, 2);
8
- const fourDigits = repeat(digit, 4);
9
- const separatorDot = ".";
10
- const separatorSlash = "/";
11
- const regexDDMMYYYY = buildRegExp([
12
- startOfString,
13
- twoDigits,
14
- // DD
15
- separatorDot,
16
- twoDigits,
17
- // MM
18
- separatorDot,
19
- fourDigits,
20
- // YYYY
21
- endOfString
22
- ]);
23
- const regexMMDDYYYY = buildRegExp([
24
- startOfString,
25
- twoDigits,
26
- // MM
27
- separatorSlash,
28
- twoDigits,
29
- // DD
30
- separatorSlash,
31
- fourDigits,
32
- // YYYY
33
- endOfString
34
- ]);
35
- const regexYYYYMMDD = buildRegExp([
36
- startOfString,
37
- fourDigits,
38
- // YYYY
39
- separatorDot,
40
- twoDigits,
41
- // MM
42
- separatorDot,
43
- twoDigits,
44
- // DD
45
- endOfString
46
- ]);
47
- async function askForInput(prompt) {
48
- return new Promise((resolve) => {
49
- let buffer = "";
50
- process.stdout.write(prompt);
51
- const onData = (data) => {
52
- const str = data.toString("utf-8");
53
- for (const char of str) {
54
- if (char === "\n" || char === "\r") {
55
- process.stdout.write("\n");
56
- cleanup();
57
- resolve(buffer);
58
- return;
59
- }
60
- if (char === "") {
61
- cleanup();
62
- resolve(null);
63
- return;
64
- }
65
- if (char === "\x7F" || char === "\b") {
66
- if (buffer.length > 0) {
67
- buffer = buffer.slice(0, -1);
68
- }
69
- redrawPrompt(buffer, prompt);
70
- continue;
71
- }
72
- buffer += char;
73
- redrawPrompt(buffer, prompt);
74
- }
75
- };
76
- process.stdin.on("data", onData);
77
- const cleanup = () => {
78
- process.stdin.removeListener("data", onData);
79
- };
80
- const redrawPrompt = (inputBuffer, textPrompt) => {
81
- process.stdout.clearLine(0);
82
- process.stdout.cursorTo(0);
83
- process.stdout.write(textPrompt + inputBuffer);
84
- };
85
- });
86
- }
87
- export async function datePrompt(opts) {
88
- const {
89
- title = "",
90
- dateFormat,
91
- dateKind,
92
- hint,
93
- hintPlaceholderColor = "blue",
94
- validate,
95
- defaultValue = "",
96
- titleColor = "cyan",
97
- titleTypography = "none",
98
- titleVariant,
99
- content,
100
- contentColor = "dim",
101
- contentTypography = "italic",
102
- contentVariant,
103
- borderColor = "dim",
104
- variantOptions,
105
- endTitle = "",
106
- endTitleColor = "dim",
107
- border = true
108
- } = opts;
109
- const rl = readline.createInterface({ input, output });
110
- rl.on("SIGINT", () => {
111
- rl.close();
112
- if (endTitle !== "") {
113
- msg({
114
- type: "M_END",
115
- title: endTitle,
116
- titleColor: endTitleColor,
117
- titleTypography,
118
- border,
119
- borderColor
120
- });
121
- }
122
- process.exit(0);
123
- });
124
- let linesToDelete = 0;
125
- let errorMessage = "";
126
- try {
127
- while (true) {
128
- if (linesToDelete > 0) {
129
- deleteLastLines(linesToDelete);
130
- linesToDelete = 0;
131
- }
132
- const { text: questionText } = fmt({
133
- type: errorMessage !== "" ? "M_ERROR_NULL" : "M_GENERAL_NULL",
134
- title: `${title} [${dateFormat}]`,
135
- titleColor,
136
- titleTypography,
137
- ...titleVariant !== void 0 && { titleVariant },
138
- content,
139
- contentColor,
140
- contentTypography,
141
- ...contentVariant !== void 0 && { contentVariant },
142
- borderColor,
143
- hint: `${hint ? `${hint} ` : ""}${defaultValue ? `Default: ${defaultValue}` : ""}`,
144
- hintPlaceholderColor,
145
- ...variantOptions !== void 0 && { variantOptions },
146
- errorMessage
147
- });
148
- const questionLines = countLines(questionText);
149
- linesToDelete = questionLines + 1;
150
- msg({
151
- type: errorMessage !== "" ? "M_ERROR" : "M_GENERAL",
152
- title: questionText
153
- });
154
- if (errorMessage !== "") {
155
- deleteLastLine();
156
- deleteLastLine();
157
- }
158
- const answerInput = await askForInput(`${re.dim(symbols.middle)} `);
159
- if (answerInput === null) {
160
- rl.close();
161
- if (endTitle !== "") {
162
- msg({
163
- type: "M_END",
164
- title: endTitle,
165
- titleColor: endTitleColor,
166
- titleTypography,
167
- border,
168
- borderColor
169
- });
170
- }
171
- process.exit(0);
172
- }
173
- const answer = answerInput.trim() || defaultValue;
174
- if (errorMessage !== "") {
175
- deleteLastLine();
176
- }
177
- deleteLastLine();
178
- msg({
179
- type: "M_MIDDLE",
180
- title: ` ${answer}`,
181
- titleColor: "none"
182
- });
183
- if (!(regexDDMMYYYY.test(answer) || regexMMDDYYYY.test(answer) || regexYYYYMMDD.test(answer))) {
184
- if (errorMessage !== "") {
185
- deleteLastLine();
186
- deleteLastLine();
187
- }
188
- errorMessage = `Please enter a valid date in ${dateFormat} format.`;
189
- msg({ type: "M_ERROR", title: errorMessage });
190
- linesToDelete = countLines(errorMessage) + 1;
191
- continue;
192
- }
193
- let matchedFormat = null;
194
- if (regexDDMMYYYY.test(answer)) {
195
- matchedFormat = "DD.MM.YYYY";
196
- } else if (regexMMDDYYYY.test(answer)) {
197
- matchedFormat = "MM/DD/YYYY";
198
- } else if (regexYYYYMMDD.test(answer)) {
199
- matchedFormat = "YYYY.MM.DD";
200
- }
201
- if (dateKind === "birthday" && matchedFormat) {
202
- const parts = answer.split(/[./-]/);
203
- let date;
204
- if (matchedFormat === "DD.MM.YYYY") {
205
- date = new Date(Number(parts[2]), Number(parts[1]) - 1, Number(parts[0]));
206
- } else if (matchedFormat === "MM/DD/YYYY") {
207
- date = new Date(Number(parts[2]), Number(parts[0]) - 1, Number(parts[1]));
208
- } else if (matchedFormat === "YYYY.MM.DD") {
209
- date = new Date(Number(parts[0]), Number(parts[1]) - 1, Number(parts[2]));
210
- } else {
211
- date = new Date(answer);
212
- }
213
- if (Number.isNaN(date.getTime()) || date.getFullYear() < 1900 || date > /* @__PURE__ */ new Date()) {
214
- errorMessage = "Please enter a valid birthday date (e.g., 14.09.1999).";
215
- msg({ type: "M_ERROR", title: errorMessage });
216
- linesToDelete = countLines(errorMessage) + 1;
217
- continue;
218
- }
219
- }
220
- let isValid = true;
221
- let gotError = false;
222
- if (errorMessage !== "") {
223
- gotError = true;
224
- }
225
- errorMessage = "";
226
- if (validate && isValid) {
227
- const validation = await validate(answer);
228
- if (validation !== true) {
229
- isValid = false;
230
- errorMessage = typeof validation === "string" ? validation : "Invalid input.";
231
- msg({ type: "M_ERROR", title: errorMessage });
232
- gotError = true;
233
- linesToDelete = countLines(errorMessage) + 1;
234
- continue;
235
- }
236
- }
237
- if (isValid) {
238
- if (gotError) {
239
- deleteLastLine();
240
- deleteLastLine();
241
- msg({ type: "M_MIDDLE", title: ` ${answer}` });
242
- }
243
- msg({
244
- type: "M_BAR",
245
- borderColor
246
- });
247
- rl.close();
248
- return answer;
249
- }
250
- }
251
- } finally {
252
- rl.close();
253
- }
254
- }
@@ -1,25 +0,0 @@
1
- import type { EditorExitResult } from "../../types";
2
- interface EditorConfig {
3
- syntaxHighlighting?: boolean;
4
- theme?: "auto" | "light" | "dark";
5
- defaultAllowSaveAs?: boolean;
6
- defaultAllowOpen?: boolean;
7
- defaultAutoCloseOnSave?: boolean;
8
- defaultReturnContentOnSave?: boolean;
9
- [key: string]: any;
10
- }
11
- interface EditorOptions {
12
- filename?: string | null;
13
- initialContent?: string | null;
14
- onSave?: (content: string, filename: string | null) => Promise<string | boolean | undefined> | string | boolean | undefined;
15
- onExit?: (content: string | null, saved: boolean, filename: string | null) => Promise<void> | void;
16
- configOverrides?: Partial<EditorConfig>;
17
- allowSaveAs?: boolean;
18
- allowOpen?: boolean;
19
- autoCloseOnSave?: boolean;
20
- returnContentOnSave?: boolean;
21
- mode?: string;
22
- cwd?: string;
23
- }
24
- export declare function startEditor(options?: EditorOptions): Promise<EditorExitResult>;
25
- export {};