@reliverse/relinka 1.1.2 → 1.1.4

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 (85) hide show
  1. package/README.md +35 -28
  2. package/dist-npm/components/checkbox/index.js +8 -6
  3. package/dist-npm/components/confirm/index.js +7 -4
  4. package/dist-npm/components/core/Separator.d.ts +0 -4
  5. package/dist-npm/components/core/create-prompt.js +1 -1
  6. package/dist-npm/components/core/key.js +6 -6
  7. package/dist-npm/components/core/lines.d.ts +5 -17
  8. package/dist-npm/components/core/lines.js +6 -2
  9. package/dist-npm/components/core/make-theme.js +3 -1
  10. package/dist-npm/components/core/position.d.ts +0 -8
  11. package/dist-npm/components/core/position.js +9 -3
  12. package/dist-npm/components/core/promise-polyfill.js +2 -2
  13. package/dist-npm/components/core/screen-manager.js +2 -1
  14. package/dist-npm/components/core/theme.d.ts +12 -146
  15. package/dist-npm/components/core/theme.js +1 -1
  16. package/dist-npm/components/core/use-keypress.js +3 -1
  17. package/dist-npm/components/core/use-pagination.d.ts +4 -8
  18. package/dist-npm/components/core/use-prefix.js +1 -1
  19. package/dist-npm/components/core/useKeyPress.js +3 -1
  20. package/dist-npm/components/core/utils.d.ts +0 -11
  21. package/dist-npm/components/date/date.d.ts +1 -1
  22. package/dist-npm/components/date/date.js +74 -12
  23. package/dist-npm/components/expand/index.js +4 -2
  24. package/dist-npm/components/figures/index.js +5 -5
  25. package/dist-npm/components/instance/basic.d.ts +0 -12
  26. package/dist-npm/components/instance/basic.js +1 -1
  27. package/dist-npm/components/instance/browser.d.ts +0 -14
  28. package/dist-npm/components/instance/reporter/browser.js +5 -5
  29. package/dist-npm/components/instance/reporter/fancy.d.ts +1 -1
  30. package/dist-npm/components/instance/reporter/fancy.js +1 -1
  31. package/dist-npm/components/mono/mono.js +9 -9
  32. package/dist-npm/components/mono/monoTwo.d.ts +13 -76
  33. package/dist-npm/components/multiselect/multiselect-main.d.ts +4 -2
  34. package/dist-npm/components/multiselect/multiselect-main.js +12 -10
  35. package/dist-npm/components/password/password-main.js +1 -1
  36. package/dist-npm/components/progressbar/ProgressBar.d.ts +3 -14
  37. package/dist-npm/components/progressbar/ProgressBar.js +3 -14
  38. package/dist-npm/components/progressbar/helper.d.ts +2 -18
  39. package/dist-npm/components/prompts/create.d.ts +0 -13
  40. package/dist-npm/components/prompts/prompt.js +3 -3
  41. package/dist-npm/components/prompts/promptTwo.d.ts +34 -252
  42. package/dist-npm/components/prompts/promptTwo.js +6 -27
  43. package/dist-npm/components/prompts/relinka.d.ts +17 -114
  44. package/dist-npm/components/prompts/relinka.js +18 -103
  45. package/dist-npm/components/range/range.d.ts +12 -64
  46. package/dist-npm/components/range/range.js +36 -59
  47. package/dist-npm/components/rawlist/index.js +6 -4
  48. package/dist-npm/components/search/index.js +7 -5
  49. package/dist-npm/components/select/index.js +9 -3
  50. package/dist-npm/components/select/select-main.d.ts +1 -1
  51. package/dist-npm/components/select/select-main.js +4 -3
  52. package/dist-npm/components/select/select-two.js +3 -1
  53. package/dist-npm/components/toggle/index.js +3 -1
  54. package/dist-npm/testing/index.js +1 -1
  55. package/dist-npm/types/general.d.ts +30 -141
  56. package/dist-npm/types/keypress.d.ts +0 -3
  57. package/dist-npm/types/keypress.js +1 -1
  58. package/dist-npm/types/readline.d.ts +1 -9
  59. package/dist-npm/types/relinka.d.ts +1 -9
  60. package/dist-npm/types/utils.d.ts +0 -12
  61. package/dist-npm/utils/box.d.ts +14 -104
  62. package/dist-npm/utils/color.d.ts +0 -20
  63. package/dist-npm/utils/colorize.js +2 -1
  64. package/dist-npm/utils/component.d.ts +5 -26
  65. package/dist-npm/utils/component.js +1 -2
  66. package/dist-npm/utils/constants.d.ts +0 -21
  67. package/dist-npm/utils/constants.js +8 -8
  68. package/dist-npm/utils/decoder.d.ts +2 -17
  69. package/dist-npm/utils/decoder.js +54 -25
  70. package/dist-npm/utils/error.d.ts +0 -5
  71. package/dist-npm/utils/errors.d.ts +1 -1
  72. package/dist-npm/utils/errors.js +8 -4
  73. package/dist-npm/utils/format.d.ts +0 -12
  74. package/dist-npm/utils/keypress.d.ts +0 -6
  75. package/dist-npm/utils/keypress.js +12 -23
  76. package/dist-npm/utils/log.d.ts +0 -11
  77. package/dist-npm/utils/prompt-tmp.js +2 -2
  78. package/dist-npm/utils/prompt-two.js +2 -2
  79. package/dist-npm/utils/skeleton.d.ts +0 -3
  80. package/dist-npm/utils/skeleton.js +66 -22
  81. package/dist-npm/utils/stream.d.ts +0 -13
  82. package/dist-npm/utils/string.d.ts +0 -45
  83. package/dist-npm/utils/tree.d.ts +5 -34
  84. package/dist-npm/utils/variants.js +9 -9
  85. package/package.json +12 -5
@@ -19,7 +19,9 @@ const isEncoding = Buffer.isEncoding || function(encoding) {
19
19
  }
20
20
  };
21
21
  function _normalizeEncoding(enc) {
22
- if (!enc) return "utf8";
22
+ if (!enc) {
23
+ return "utf8";
24
+ }
23
25
  let retried = false;
24
26
  let encoding = String(enc);
25
27
  while (true) {
@@ -40,7 +42,9 @@ function _normalizeEncoding(enc) {
40
42
  case "hex":
41
43
  return encoding;
42
44
  default:
43
- if (retried) return void 0;
45
+ if (retried) {
46
+ return void 0;
47
+ }
44
48
  encoding = encoding.toLowerCase();
45
49
  retried = true;
46
50
  }
@@ -90,18 +94,17 @@ export class StringDecoder {
90
94
  this.lastChar = Buffer.allocUnsafe(nb);
91
95
  this.writeFn = this.write.bind(this);
92
96
  }
93
- /**
94
- * Writes the buffer and returns the decoded string.
95
- * @param buf - The buffer to write.
96
- * @returns The decoded string.
97
- */
98
- write(buf) {
99
- if (buf.length === 0) return "";
97
+ write(buf) {
98
+ if (buf.length === 0) {
99
+ return "";
100
+ }
100
101
  let r;
101
102
  let i;
102
103
  if (this.lastNeed) {
103
104
  r = this.fillLast(buf);
104
- if (r === void 0) return "";
105
+ if (r === void 0) {
106
+ return "";
107
+ }
105
108
  i = this.lastNeed;
106
109
  this.lastNeed = 0;
107
110
  } else {
@@ -125,7 +128,9 @@ export class StringDecoder {
125
128
  function utf8FillLast(buf) {
126
129
  const p = this.lastTotal - this.lastNeed;
127
130
  const r = utf8CheckExtraBytes(this, buf, p);
128
- if (r !== void 0) return r;
131
+ if (r !== void 0) {
132
+ return r;
133
+ }
129
134
  if (this.lastNeed <= buf.length) {
130
135
  buf.copy(this.lastChar, p, 0, this.lastNeed);
131
136
  return this.lastChar.toString(this.encoding, 0, this.lastTotal);
@@ -135,7 +140,9 @@ function utf8FillLast(buf) {
135
140
  }
136
141
  function utf8Text(buf, i) {
137
142
  const total = utf8CheckIncomplete(this, buf, i);
138
- if (!this.lastNeed) return buf.toString("utf8", i);
143
+ if (!this.lastNeed) {
144
+ return buf.toString("utf8", i);
145
+ }
139
146
  this.lastTotal = total;
140
147
  const end = buf.length - (total - this.lastNeed);
141
148
  buf.copy(this.lastChar, 0, end);
@@ -143,36 +150,56 @@ function utf8Text(buf, i) {
143
150
  }
144
151
  function utf8End(buf) {
145
152
  const r = buf?.length ? this.write(buf) : "";
146
- if (this.lastNeed) return r + "\uFFFD";
153
+ if (this.lastNeed) {
154
+ return r + "\uFFFD";
155
+ }
147
156
  return r;
148
157
  }
149
158
  function utf8CheckByte(byte) {
150
- if (byte <= 127) return 0;
151
- else if (byte >> 5 === 6) return 2;
152
- else if (byte >> 4 === 14) return 3;
153
- else if (byte >> 3 === 30) return 4;
159
+ if (byte <= 127) {
160
+ return 0;
161
+ } else if (byte >> 5 === 6) {
162
+ return 2;
163
+ } else if (byte >> 4 === 14) {
164
+ return 3;
165
+ } else if (byte >> 3 === 30) {
166
+ return 4;
167
+ }
154
168
  return byte >> 6 === 2 ? -1 : -2;
155
169
  }
156
170
  function utf8CheckIncomplete(self, buf, i) {
157
171
  let j = buf.length - 1;
158
- if (j < i) return 0;
172
+ if (j < i) {
173
+ return 0;
174
+ }
159
175
  let nb = utf8CheckByte(buf[j]);
160
176
  if (nb >= 0) {
161
- if (nb > 0) self.lastNeed = nb - 1;
177
+ if (nb > 0) {
178
+ self.lastNeed = nb - 1;
179
+ }
162
180
  return nb;
163
181
  }
164
- if (--j < i || nb === -2) return 0;
182
+ if (--j < i || nb === -2) {
183
+ return 0;
184
+ }
165
185
  nb = utf8CheckByte(buf[j]);
166
186
  if (nb >= 0) {
167
- if (nb > 0) self.lastNeed = nb - 2;
187
+ if (nb > 0) {
188
+ self.lastNeed = nb - 2;
189
+ }
168
190
  return nb;
169
191
  }
170
- if (--j < i || nb === -2) return 0;
192
+ if (--j < i || nb === -2) {
193
+ return 0;
194
+ }
171
195
  nb = utf8CheckByte(buf[j]);
172
196
  if (nb >= 0) {
173
197
  if (nb > 0) {
174
- if (nb === 2) nb = 0;
175
- else self.lastNeed = nb - 3;
198
+ if (nb === 2) {
199
+ nb = 0;
200
+ } else {
201
+ self.lastNeed = nb - 3;
202
+ }
176
203
  }
177
204
  return nb;
178
205
  }
@@ -226,7 +253,9 @@ function utf16End(buf) {
226
253
  }
227
254
  function base64Text(buf, i) {
228
255
  const n = (buf.length - i) % 3;
229
- if (n === 0) return buf.toString("base64", i);
256
+ if (n === 0) {
257
+ return buf.toString("base64", i);
258
+ }
230
259
  this.lastNeed = 3 - n;
231
260
  this.lastTotal = 3;
232
261
  if (n === 1) {
@@ -1,6 +1 @@
1
- /**
2
- * Parses a stack trace string and normalizes its paths by removing the current working directory and the "file://" protocol.
3
- * @param {string} stack - The stack trace string.
4
- * @returns {string[]} An array of stack trace lines with normalized paths.
5
- */
6
1
  export declare function parseStack(stack: string): string[];
@@ -1 +1 @@
1
- export declare const errorHandler: (error: Error) => never;
1
+ export declare const errorHandler: (error: Error, customMessage?: string) => never;
@@ -1,11 +1,15 @@
1
- export const errorHandler = (error) => {
1
+ export const errorHandler = (error, customMessage) => {
2
2
  const separator = "\u2500".repeat(71);
3
3
  console.error("\u2502" + separator);
4
4
  console.error("\u2502 AN ERROR OCCURRED:\n\u2502 ", error.message);
5
5
  console.error("\u2502" + separator);
6
- console.error(
7
- "\u2502 If this issue is related to @reliverse/relinka itself, please\n\u2502 report the details at https://github.com/reliverse/prompts/issues"
8
- );
6
+ if (customMessage) {
7
+ console.error("\u2502 " + customMessage);
8
+ } else {
9
+ console.error(
10
+ "\u2502 If this issue is related to @reliverse/relinka itself, please\n\u2502 report the details at https://github.com/reliverse/prompts/issues"
11
+ );
12
+ }
9
13
  console.error("\u2570" + separator);
10
14
  process.exit(1);
11
15
  };
@@ -1,14 +1,2 @@
1
- /**
2
- * Compiles a format string by replacing placeholders with appropriate position indices.
3
- * Caches compiled formats for efficiency.
4
- * @param {string} format - The format string containing the placeholders to replace.
5
- * @returns {string} The compiled format string with placeholders replaced by positional indices.
6
- */
7
1
  export declare function compileFormat(format: string): any;
8
- /**
9
- * Formats a string according to a custom format, using vsprintf for string formatting.
10
- * @param {string} format - The custom format string.
11
- * @param {any[]} argv - The arguments to format into the string.
12
- * @returns {string} The formatted string.
13
- */
14
2
  export declare function formatString(format: string, argv: any): string;
@@ -1,11 +1,5 @@
1
1
  import type { Readable } from "stream";
2
2
  import type { Keypress } from "../types/keypress.js";
3
- /**
4
- * Listen for keypress events on a given stream
5
- * @param stream - The input stream (e.g., process.stdin)
6
- * @param callback - The callback to execute on keypress
7
- * @returns A function to remove the keypress listener
8
- */
9
3
  declare const listenForKeys: {
10
4
  (stream: Readable, callback: (key: Keypress) => void): (() => void);
11
5
  parse: (s: string | Buffer, enc?: BufferEncoding) => Keypress | Keypress[];
@@ -1,7 +1,7 @@
1
1
  import { StringDecoder } from "./decoder.js";
2
2
  const metaKeyCodeRe = /^(?:\u001b)([a-zA-Z0-9])$/;
3
3
  const functionKeyCodeRe = (
4
- // biome-ignore lint/suspicious/noControlCharactersInRegex: <explanation>
4
+
5
5
  /^(?:\u001b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/
6
6
  );
7
7
  const parse = (s, enc) => {
@@ -58,8 +58,7 @@ const parse = (s, enc) => {
58
58
  key.shift = !!(modifier & 1);
59
59
  key.code = code;
60
60
  switch (code) {
61
- /* xterm/gnome ESC O letter */
62
- case "OP":
61
+ case "OP":
63
62
  key.name = "f1";
64
63
  break;
65
64
  case "OQ":
@@ -71,8 +70,7 @@ const parse = (s, enc) => {
71
70
  case "OS":
72
71
  key.name = "f4";
73
72
  break;
74
- /* xterm/rxvt ESC [ number ~ */
75
- case "[11~":
73
+ case "[11~":
76
74
  key.name = "f1";
77
75
  break;
78
76
  case "[12~":
@@ -84,8 +82,7 @@ const parse = (s, enc) => {
84
82
  case "[14~":
85
83
  key.name = "f4";
86
84
  break;
87
- /* from Cygwin and used in libuv */
88
- case "[[A":
85
+ case "[[A":
89
86
  key.name = "f1";
90
87
  break;
91
88
  case "[[B":
@@ -100,8 +97,7 @@ const parse = (s, enc) => {
100
97
  case "[[E":
101
98
  key.name = "f5";
102
99
  break;
103
- /* common */
104
- case "[15~":
100
+ case "[15~":
105
101
  key.name = "f5";
106
102
  break;
107
103
  case "[17~":
@@ -125,8 +121,7 @@ const parse = (s, enc) => {
125
121
  case "[24~":
126
122
  key.name = "f12";
127
123
  break;
128
- /* xterm ESC [ letter */
129
- case "[A":
124
+ case "[A":
130
125
  key.name = "up";
131
126
  break;
132
127
  case "[B":
@@ -147,8 +142,7 @@ const parse = (s, enc) => {
147
142
  case "[H":
148
143
  key.name = "home";
149
144
  break;
150
- /* xterm/gnome ESC O letter */
151
- case "OA":
145
+ case "OA":
152
146
  key.name = "up";
153
147
  break;
154
148
  case "OB":
@@ -169,8 +163,7 @@ const parse = (s, enc) => {
169
163
  case "OH":
170
164
  key.name = "home";
171
165
  break;
172
- /* xterm/rxvt ESC [ number ~ */
173
- case "[1~":
166
+ case "[1~":
174
167
  key.name = "home";
175
168
  break;
176
169
  case "[2~":
@@ -188,22 +181,19 @@ const parse = (s, enc) => {
188
181
  case "[6~":
189
182
  key.name = "pagedown";
190
183
  break;
191
- /* putty */
192
- case "[[5~":
184
+ case "[[5~":
193
185
  key.name = "pageup";
194
186
  break;
195
187
  case "[[6~":
196
188
  key.name = "pagedown";
197
189
  break;
198
- /* rxvt */
199
- case "[7~":
190
+ case "[7~":
200
191
  key.name = "home";
201
192
  break;
202
193
  case "[8~":
203
194
  key.name = "end";
204
195
  break;
205
- /* rxvt keys with modifiers */
206
- case "[a":
196
+ case "[a":
207
197
  key.name = "up";
208
198
  key.shift = true;
209
199
  break;
@@ -291,8 +281,7 @@ const parse = (s, enc) => {
291
281
  key.name = "end";
292
282
  key.ctrl = true;
293
283
  break;
294
- /* misc. */
295
- case "[Z":
284
+ case "[Z":
296
285
  key.name = "tab";
297
286
  key.shift = true;
298
287
  break;
@@ -1,13 +1,2 @@
1
- /**
2
- * Checks if the given argument is a simple JavaScript object.
3
- * @param {any} obj - The object to test.
4
- * @returns {boolean} `true` if the argument is a plain object, otherwise `false`.
5
- */
6
1
  export declare function isPlainObject(obj: any): boolean;
7
- /**
8
- * Determines whether the given argument is a protocol object. A log object must be a simple object and
9
- * must contain either a 'message' or 'args' field, but not a 'stack' field.
10
- * @param {any} arg - The argument to check.
11
- * @returns {boolean} `true` if the argument is a log object according to the specified criteria, otherwise `false`.
12
- */
13
2
  export declare function isLogObj(arg: any): boolean;
@@ -26,13 +26,13 @@ function setRawMode(input, value) {
26
26
  input.setRawMode(value);
27
27
  }
28
28
  }
29
- const aliases = /* @__PURE__ */ new Map([
29
+ const aliases = new Map([
30
30
  ["k", "up"],
31
31
  ["j", "down"],
32
32
  ["h", "left"],
33
33
  ["l", "right"]
34
34
  ]);
35
- const keys = /* @__PURE__ */ new Set(["up", "down", "left", "right", "space", "enter"]);
35
+ const keys = new Set(["up", "down", "left", "right", "space", "enter"]);
36
36
  export function createPrompt({
37
37
  render: renderFn,
38
38
  input = stdin,
@@ -26,13 +26,13 @@ function setRawMode(input, value) {
26
26
  input.setRawMode(value);
27
27
  }
28
28
  }
29
- const aliases = /* @__PURE__ */ new Map([
29
+ const aliases = new Map([
30
30
  ["k", "up"],
31
31
  ["j", "down"],
32
32
  ["h", "left"],
33
33
  ["l", "right"]
34
34
  ]);
35
- const keys = /* @__PURE__ */ new Set(["up", "down", "left", "right", "space", "enter"]);
35
+ const keys = new Set(["up", "down", "left", "right", "space", "enter"]);
36
36
  export function createPrompt({
37
37
  render: renderFn,
38
38
  input = stdin,
@@ -1,8 +1,5 @@
1
1
  import type { RangePrompt } from "../components/range/range.js";
2
2
  import type { Keypress } from "../types/keypress.js";
3
- /**
4
- * Action mapping based on keypress
5
- */
6
3
  export declare const action: (key: Keypress) => string | false;
7
4
  declare const _default: ((p: RangePrompt) => Promise<number | null>) & {
8
5
  action: (key: Keypress) => string | false;
@@ -5,24 +5,58 @@ import listenForKeys from "../utils/keypress.js";
5
5
  export const action = (key) => {
6
6
  const code = key.raw.charCodeAt(0);
7
7
  if (key.ctrl) {
8
- if (key.name === "a") return "first";
9
- if (key.name === "c") return "abort";
10
- if (key.name === "d") return "abort";
11
- if (key.name === "e") return "last";
12
- if (key.name === "g") return "reset";
8
+ if (key.name === "a") {
9
+ return "first";
10
+ }
11
+ if (key.name === "c") {
12
+ return "abort";
13
+ }
14
+ if (key.name === "d") {
15
+ return "abort";
16
+ }
17
+ if (key.name === "e") {
18
+ return "last";
19
+ }
20
+ if (key.name === "g") {
21
+ return "reset";
22
+ }
23
+ }
24
+ if (key.name === "return") {
25
+ return "submit";
26
+ }
27
+ if (key.name === "enter") {
28
+ return "submit";
29
+ }
30
+ if (key.name === "backspace") {
31
+ return "delete";
32
+ }
33
+ if (key.name === "abort") {
34
+ return "abort";
35
+ }
36
+ if (key.name === "escape") {
37
+ return "abort";
38
+ }
39
+ if (key.name === "tab") {
40
+ return "next";
41
+ }
42
+ if (key.name === "up") {
43
+ return "up";
44
+ }
45
+ if (key.name === "down") {
46
+ return "down";
47
+ }
48
+ if (key.name === "right") {
49
+ return "right";
50
+ }
51
+ if (key.name === "left") {
52
+ return "left";
53
+ }
54
+ if (code === 8747) {
55
+ return "left";
56
+ }
57
+ if (code === 402) {
58
+ return "right";
13
59
  }
14
- if (key.name === "return") return "submit";
15
- if (key.name === "enter") return "submit";
16
- if (key.name === "backspace") return "delete";
17
- if (key.name === "abort") return "abort";
18
- if (key.name === "escape") return "abort";
19
- if (key.name === "tab") return "next";
20
- if (key.name === "up") return "up";
21
- if (key.name === "down") return "down";
22
- if (key.name === "right") return "right";
23
- if (key.name === "left") return "left";
24
- if (code === 8747) return "left";
25
- if (code === 402) return "right";
26
60
  return false;
27
61
  };
28
62
  const onResize = (stream, cb) => {
@@ -44,8 +78,12 @@ const wrap = (p) => {
44
78
  }
45
79
  const onKey = (key) => {
46
80
  const a = action(key);
47
- if (a === "abort") return wrappedPrompt.close();
48
- if (a === false) return wrappedPrompt._(key.raw);
81
+ if (a === "abort") {
82
+ return wrappedPrompt.close();
83
+ }
84
+ if (a === false) {
85
+ return wrappedPrompt._(key.raw);
86
+ }
49
87
  if (typeof wrappedPrompt[a] === "function") {
50
88
  wrappedPrompt[a](key);
51
89
  } else {
@@ -60,7 +98,9 @@ const wrap = (p) => {
60
98
  let offKeypress = null;
61
99
  let offResize = null;
62
100
  const pause = () => {
63
- if (!offKeypress) return;
101
+ if (!offKeypress) {
102
+ return;
103
+ }
64
104
  offKeypress();
65
105
  offKeypress = null;
66
106
  if (offResize) {
@@ -70,7 +110,9 @@ const wrap = (p) => {
70
110
  process.stdout.write(esc.cursorShow);
71
111
  };
72
112
  const resume = () => {
73
- if (offKeypress) return;
113
+ if (offKeypress) {
114
+ return;
115
+ }
74
116
  offKeypress = listenForKeys(process.stdin, onKey);
75
117
  offResize = onResize(process.stdout, onNewSize);
76
118
  process.stdout.write(esc.cursorHide);
@@ -80,7 +122,9 @@ const wrap = (p) => {
80
122
  return new Promise((resolve, reject) => {
81
123
  let isClosed = false;
82
124
  wrappedPrompt.close = () => {
83
- if (isClosed) return;
125
+ if (isClosed) {
126
+ return;
127
+ }
84
128
  isClosed = true;
85
129
  wrappedPrompt.out.unpipe(process.stdout);
86
130
  pause();
@@ -1,14 +1 @@
1
- /**
2
- * Writes data to a specified NodeJS writable stream. This function supports streams that have a custom
3
- * `__write' method, and will fall back to the default `write' method if `__write' is not present.
4
- *
5
- * @param {any} data - The data to write to the stream. This can be a string, a buffer, or any data type
6
- * supported by the stream's `write' or `__write' method.
7
- * @param {NodeJS.WriteStream} stream - The writable stream to write the data to. This stream
8
- * must implement the `write' method, and can optionally implement a custom `__write' method.
9
- * @returns {boolean} `true` if the data has been completely processed by the write operation,
10
- * indicating that further writes can be performed immediately. Returns `false` if the data is
11
- * buffered by the stream, indicating that the `drain` event should be waited for before writing
12
- * more data.
13
- */
14
1
  export declare function writeStream(data: any, stream: NodeJS.WriteStream): any;
@@ -1,50 +1,5 @@
1
- /**
2
- * Removes ANSI escape codes from a given string. This is particularly useful for
3
- * processing text that contains formatting codes, such as colors or styles, so that the
4
- * the raw text without any visual formatting.
5
- *
6
- * @param {string} text - The text string from which to strip the ANSI escape codes.
7
- * @returns {string} The text without ANSI escape codes.
8
- */
9
1
  export declare function stripAnsi(text: string): string;
10
- /**
11
- * Centers a string within a specified total width, padding it with spaces or another specified character.
12
- * If the string is longer than the total width, it is returned as is.
13
- *
14
- * @param {string} str - The string to centre.
15
- * @param {number} len - The total width in which to centre the string.
16
- * @param {string} [space=" "] - The character to use for padding. Defaults to a space.
17
- * @returns {string} The centred string.
18
- */
19
2
  export declare function centerAlign(str: string, len: number, space?: string): string;
20
- /**
21
- * Right-justifies a string within a given total width, padding it with whitespace or another specified character.
22
- * If the string is longer than the total width, it is returned as is.
23
- *
24
- * @param {string} str - The string to right-justify.
25
- * @param {number} len - The total width to align the string.
26
- * @param {string} [space=" "] - The character to use for padding. Defaults to a space.
27
- * @returns {string} The right-justified string.
28
- */
29
3
  export declare function rightAlign(str: string, len: number, space?: string): string;
30
- /**
31
- * Left-aligns a string within a given total width, padding it with whitespace or another specified character on the right.
32
- * If the string is longer than the total width, it is returned as is.
33
- *
34
- * @param {string} str - The string to align left.
35
- * @param {number} len - The total width to align the string.
36
- * @param {string} [space=" "] - The character to use for padding. Defaults to a space.
37
- * @returns {string} The left-justified string.
38
- */
39
4
  export declare function leftAlign(str: string, len: number, space?: string): string;
40
- /**
41
- * Aligns a string (left, right, or centre) within a given total width, padding it with spaces or another specified character.
42
- * If the string is longer than the total width, it is returned as is. This function acts as a wrapper for individual alignment functions.
43
- *
44
- * @param {"left" | "right" | "centre"} alignment - The desired alignment of the string.
45
- * @param {string} str - The string to align.
46
- * @param {number} len - The total width in which to align the string.
47
- * @param {string} [space=" "] - The character to use for padding. Defaults to a space.
48
- * @returns {string} The aligned string, according to the given alignment.
49
- */
50
5
  export declare function align(alignment: "left" | "right" | "center", str: string, len: number, space?: string): string;
@@ -1,41 +1,12 @@
1
1
  import { type ColorName } from "./color.js";
2
2
  export type TreeItemObject = {
3
- /**
4
- * Text of the item
5
- */
6
- text: string;
7
- /**
8
- * Children of the item
9
- */
10
- children?: TreeItem[];
11
- /**
12
- * Color of the item
13
- */
14
- color?: ColorName;
3
+ text: string;
4
+ children?: TreeItem[];
5
+ color?: ColorName;
15
6
  };
16
7
  export type TreeItem = string | TreeItemObject;
17
8
  export type TreeOptions = {
18
- /**
19
- * Color of the tree
20
- */
21
- color?: ColorName;
22
- /**
23
- * Prefix of the tree
24
- *
25
- * @default " "
26
- */
27
- prefix?: string;
9
+ color?: ColorName;
10
+ prefix?: string;
28
11
  };
29
- /**
30
- * Formats a hierarchical list of items into a string representing a tree structure.
31
- * Each item in the tree can be a simple string or an object defining the text of the item,
32
- * optional children, and color. The tree structure can be customized with options
33
- * Specify the overall color and the prefix used for indentation and tree lines.
34
- *
35
- * @param {TreeItem[]} items - An array of items to include in the tree. Each item can be
36
- * either a string or an object with `text', `children' and `color' properties.
37
- * @param {TreeOptions} [options] - Optional settings to customize the appearance of the tree, including
38
- * the color of the tree text and the prefix for branches. See {@link TreeOptions}.
39
- * @returns {string} The formatted tree as a string, ready for printing to the console or elsewhere.
40
- */
41
12
  export declare function formatTree(items: TreeItem[], options?: TreeOptions): string;
@@ -1,21 +1,21 @@
1
1
  import { colorMap } from "./mapping.js";
2
2
  export const variantMap = {
3
- // box: createBox,
3
+
4
4
  doubleBox: createDoubleBox
5
- // banner: createBanner,
6
- // underline: createUnderline,
5
+
6
+
7
7
  };
8
8
  export async function applyVariant(lines, variant, options, borderColor) {
9
9
  const linesArray = Array.isArray(lines) ? lines : [lines];
10
10
  switch (variant) {
11
- // case "box":
12
- // return createBox(linesArray, options?.limit);
11
+
12
+
13
13
  case "doubleBox":
14
14
  return createDoubleBox(linesArray, options?.limit, borderColor);
15
- // case "banner":
16
- // return createBanner(linesArray);
17
- // case "underline":
18
- // return createUnderline(linesArray);
15
+
16
+
17
+
18
+
19
19
  default:
20
20
  return linesArray.join("\n");
21
21
  }