@reliverse/relinka 1.1.5 → 1.1.6

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 (115) hide show
  1. package/dist-npm/components/anykey/index.js +77 -57
  2. package/dist-npm/components/block/block.js +61 -48
  3. package/dist-npm/components/checkbox/index.js +211 -178
  4. package/dist-npm/components/confirm/confirm-main.js +122 -85
  5. package/dist-npm/components/confirm/confirm-three.js +27 -24
  6. package/dist-npm/components/confirm/index.js +45 -36
  7. package/dist-npm/components/core/Separator.js +17 -15
  8. package/dist-npm/components/core/create-prompt.js +124 -101
  9. package/dist-npm/components/core/errors.js +15 -19
  10. package/dist-npm/components/core/hook-engine.js +120 -91
  11. package/dist-npm/components/core/index.js +12 -12
  12. package/dist-npm/components/core/key.js +6 -16
  13. package/dist-npm/components/core/lines.js +54 -45
  14. package/dist-npm/components/core/make-theme.js +30 -21
  15. package/dist-npm/components/core/position.js +23 -27
  16. package/dist-npm/components/core/promise-polyfill.js +14 -11
  17. package/dist-npm/components/core/screen-manager.js +74 -59
  18. package/dist-npm/components/core/theme.js +32 -22
  19. package/dist-npm/components/core/use-effect.js +15 -9
  20. package/dist-npm/components/core/use-keypress.js +23 -19
  21. package/dist-npm/components/core/use-memo.js +16 -10
  22. package/dist-npm/components/core/use-pagination.js +32 -33
  23. package/dist-npm/components/core/use-prefix.js +38 -40
  24. package/dist-npm/components/core/use-ref.js +5 -2
  25. package/dist-npm/components/core/use-state.js +23 -15
  26. package/dist-npm/components/core/useKeyPress.js +17 -14
  27. package/dist-npm/components/core/usePromptState.js +14 -8
  28. package/dist-npm/components/core/utils.js +16 -7
  29. package/dist-npm/components/date/date.js +204 -167
  30. package/dist-npm/components/editor/index.js +92 -71
  31. package/dist-npm/components/expand/index.js +124 -96
  32. package/dist-npm/components/figures/index.js +294 -283
  33. package/dist-npm/components/input/index.js +87 -61
  34. package/dist-npm/components/input/text-main.js +124 -97
  35. package/dist-npm/components/input/text.js +28 -24
  36. package/dist-npm/components/instance/basic.js +25 -17
  37. package/dist-npm/components/instance/browser.js +18 -14
  38. package/dist-npm/components/instance/reporter/basic.js +65 -46
  39. package/dist-npm/components/instance/reporter/browser.js +47 -44
  40. package/dist-npm/components/instance/reporter/fancy.js +96 -83
  41. package/dist-npm/components/instance/shared.js +2 -2
  42. package/dist-npm/components/mono/mono.js +62 -52
  43. package/dist-npm/components/mono/monoTwo.js +49 -35
  44. package/dist-npm/components/multiselect/group-multiselect.js +71 -55
  45. package/dist-npm/components/multiselect/multi-select-two.js +130 -97
  46. package/dist-npm/components/multiselect/multi-select.js +49 -43
  47. package/dist-npm/components/multiselect/multiselect-main.js +146 -120
  48. package/dist-npm/components/multiselect/num-multi-select.js +130 -97
  49. package/dist-npm/components/multiselect/num-multiselect-main.js +35 -24
  50. package/dist-npm/components/next-steps/next-steps.js +25 -23
  51. package/dist-npm/components/number/index.js +112 -78
  52. package/dist-npm/components/number/number-main.js +2 -95
  53. package/dist-npm/components/password/index.js +73 -54
  54. package/dist-npm/components/password/password-main.js +2 -119
  55. package/dist-npm/components/password/password-three.js +30 -26
  56. package/dist-npm/components/progressbar/ProgressBar.js +64 -45
  57. package/dist-npm/components/progressbar/helper.js +40 -33
  58. package/dist-npm/components/progressbar/index.js +1 -1
  59. package/dist-npm/components/prompts/create.js +44 -29
  60. package/dist-npm/components/prompts/index.js +45 -45
  61. package/dist-npm/components/prompts/prompt.js +260 -211
  62. package/dist-npm/components/prompts/promptTwo.js +605 -561
  63. package/dist-npm/components/prompts/relinka.js +295 -237
  64. package/dist-npm/components/range/range.js +294 -247
  65. package/dist-npm/components/rawlist/index.js +107 -87
  66. package/dist-npm/components/results/results.js +37 -31
  67. package/dist-npm/components/search/index.js +193 -148
  68. package/dist-npm/components/select/index.js +186 -148
  69. package/dist-npm/components/select/num-select-main.js +27 -27
  70. package/dist-npm/components/select/num-select.js +5 -124
  71. package/dist-npm/components/select/select-key.js +25 -24
  72. package/dist-npm/components/select/select-main.js +133 -109
  73. package/dist-npm/components/select/select-three.js +36 -32
  74. package/dist-npm/components/select/select-two.js +87 -94
  75. package/dist-npm/components/spinner/index.js +136 -107
  76. package/dist-npm/components/st-end/end.js +26 -34
  77. package/dist-npm/components/st-end/start.js +15 -29
  78. package/dist-npm/components/toggle/index.js +137 -113
  79. package/dist-npm/components/visual/animate/animate.js +10 -53
  80. package/dist-npm/components/visual/ascii-art/ascii-art.js +1 -12
  81. package/dist-npm/mod.js +2 -1
  82. package/dist-npm/testing/index.js +83 -58
  83. package/dist-npm/types/general.js +1 -0
  84. package/dist-npm/types/index.js +3 -2
  85. package/dist-npm/types/keypress.js +36 -35
  86. package/dist-npm/types/readline.js +1 -0
  87. package/dist-npm/types/relinka.js +1 -0
  88. package/dist-npm/types/utils.js +1 -0
  89. package/dist-npm/utils/box.js +137 -135
  90. package/dist-npm/utils/color.js +74 -65
  91. package/dist-npm/utils/colorize.js +156 -124
  92. package/dist-npm/utils/component.js +657 -532
  93. package/dist-npm/utils/constants.js +63 -64
  94. package/dist-npm/utils/core.js +3 -2
  95. package/dist-npm/utils/decoder.js +223 -244
  96. package/dist-npm/utils/error.js +9 -4
  97. package/dist-npm/utils/errors.js +4 -14
  98. package/dist-npm/utils/format.js +24 -19
  99. package/dist-npm/utils/keypress.js +414 -316
  100. package/dist-npm/utils/log.js +15 -11
  101. package/dist-npm/utils/mapping.js +52 -45
  102. package/dist-npm/utils/messages.js +183 -183
  103. package/dist-npm/utils/platforms.js +20 -16
  104. package/dist-npm/utils/prompt-tmp.js +286 -235
  105. package/dist-npm/utils/prompt-two.js +286 -235
  106. package/dist-npm/utils/readline.js +7 -5
  107. package/dist-npm/utils/skeleton.js +170 -130
  108. package/dist-npm/utils/stream.js +2 -2
  109. package/dist-npm/utils/string.js +58 -44
  110. package/dist-npm/utils/terminal.js +34 -23
  111. package/dist-npm/utils/tree.js +41 -30
  112. package/dist-npm/utils/types.js +1 -0
  113. package/dist-npm/utils/utils.js +8 -8
  114. package/dist-npm/utils/variants.js +44 -36
  115. package/package.json +20 -28
@@ -1,145 +1,185 @@
1
- import differ from "ansi-diff-stream";
2
- import esc from "ansi-escapes";
3
- import windowSize from "window-size";
4
- import listenForKeys from "../utils/keypress.js";
1
+ import differ from 'ansi-diff-stream';
2
+ import esc from 'ansi-escapes';
3
+ import process from 'node:process';
4
+ import listenForKeys from '../utils/keypress.js';
5
+
6
+ const isFn = (a) => typeof a === 'function';
7
+
5
8
  export const action = (key) => {
6
- const code = key.raw.charCodeAt(0);
7
- if (key.ctrl) {
8
- if (key.name === "a") {
9
- return "first";
9
+ const code = key.raw.charCodeAt(0);
10
+
11
+ if (key.ctrl) {
12
+ if (key.name === 'a') {
13
+ return 'first';
14
+ }
15
+
16
+ if (key.name === 'c') {
17
+ return 'abort';
18
+ }
19
+
20
+ if (key.name === 'd') {
21
+ return 'abort';
22
+ }
23
+
24
+ if (key.name === 'e') {
25
+ return 'last';
26
+ }
27
+
28
+ if (key.name === 'g') {
29
+ return 'reset';
30
+ }
10
31
  }
11
- if (key.name === "c") {
12
- return "abort";
32
+
33
+ if (key.name === 'return') {
34
+ return 'submit';
13
35
  }
14
- if (key.name === "d") {
15
- return "abort";
36
+
37
+ if (key.name === 'enter') {
38
+ return 'submit';
16
39
  }
17
- if (key.name === "e") {
18
- return "last";
40
+
41
+ if (key.name === 'backspace') {
42
+ return 'delete';
19
43
  }
20
- if (key.name === "g") {
21
- return "reset";
44
+
45
+ if (key.name === 'abort') {
46
+ return 'abort';
22
47
  }
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";
59
- }
60
- return false;
61
- };
62
- const onResize = (stream, cb) => {
63
- stream.on("resize", cb);
64
- const stopListening = () => {
65
- stream.removeListener("resize", cb);
66
- };
67
- return stopListening;
68
- };
69
- const wrap = (p) => {
70
- const wrappedPrompt = p;
71
- wrappedPrompt.out = differ();
72
- wrappedPrompt.out.pipe(process.stdout);
73
- wrappedPrompt.bell = () => {
74
- process.stdout.write(esc.beep);
75
- };
76
- if (typeof wrappedPrompt._ !== "function") {
77
- wrappedPrompt._ = wrappedPrompt.bell;
78
- }
79
- const onKey = (key) => {
80
- const a = action(key);
81
- if (a === "abort") {
82
- return wrappedPrompt.close();
48
+
49
+ if (key.name === 'escape') {
50
+ return 'abort';
51
+ }
52
+
53
+ if (key.name === 'tab') {
54
+ return 'next';
83
55
  }
84
- if (a === false) {
85
- return wrappedPrompt._(key.raw);
56
+
57
+ if (key.name === 'up') {
58
+ return 'up';
86
59
  }
87
- if (typeof wrappedPrompt[a] === "function") {
88
- wrappedPrompt[a](key);
89
- } else {
90
- wrappedPrompt.bell();
60
+
61
+ if (key.name === 'down') {
62
+ return 'down';
91
63
  }
92
- };
93
- const onNewSize = () => {
94
- const { width, height } = windowSize;
95
- wrappedPrompt.out.reset();
96
- wrappedPrompt.render(true);
97
- };
98
- let offKeypress = null;
99
- let offResize = null;
100
- const pause = () => {
101
- if (!offKeypress) {
102
- return;
64
+
65
+ if (key.name === 'right') {
66
+ return 'right';
103
67
  }
104
- offKeypress();
105
- offKeypress = null;
106
- if (offResize) {
107
- offResize();
108
- offResize = null;
68
+
69
+ if (key.name === 'left') {
70
+ return 'left';
109
71
  }
110
- process.stdout.write(esc.cursorShow);
111
- };
112
- const resume = () => {
113
- if (offKeypress) {
114
- return;
72
+
73
+ if (code === 8747) {
74
+ return 'left';
115
75
  }
116
- offKeypress = listenForKeys(process.stdin, onKey);
117
- offResize = onResize(process.stdout, onNewSize);
118
- process.stdout.write(esc.cursorHide);
119
- };
120
- wrappedPrompt.pause = pause;
121
- wrappedPrompt.resume = resume;
122
- return new Promise((resolve, reject) => {
123
- let isClosed = false;
124
- wrappedPrompt.close = () => {
125
- if (isClosed) {
126
- return;
127
- }
128
- isClosed = true;
129
- wrappedPrompt.out.unpipe(process.stdout);
130
- pause();
131
- if (wrappedPrompt.aborted) {
132
- reject(new Error("Prompt aborted"));
133
- } else {
134
- resolve(wrappedPrompt.value);
135
- }
76
+
77
+ if (code === 402) {
78
+ return 'right';
79
+ }
80
+
81
+ return false;
82
+ };
83
+ const onResize = (stream, cb) => {
84
+ stream.on('resize', cb);
85
+
86
+ const stopListening = () => {
87
+ stream.removeListener('resize', cb);
136
88
  };
137
- process.on("beforeExit", () => wrappedPrompt.close());
138
- if (typeof wrappedPrompt.submit !== "function") {
139
- wrappedPrompt.submit = wrappedPrompt.close;
89
+
90
+ return stopListening;
91
+ };
92
+
93
+ const wrap = (wrappedPrompt) => {
94
+ wrappedPrompt.out = differ();
95
+ wrappedPrompt.out.pipe(process.stdout);
96
+ wrappedPrompt.bell = () => {
97
+ process.stdout.write(esc.beep);
98
+ };
99
+ if (!isFn(wrappedPrompt._)) {
100
+ wrappedPrompt._ = wrappedPrompt.bell;
140
101
  }
141
- resume();
142
- wrappedPrompt.render(true);
143
- });
102
+
103
+ const onKey = (key) => {
104
+ const a = action(key);
105
+
106
+ if (a === 'abort') {
107
+ return wrappedPrompt.close();
108
+ }
109
+
110
+ if (!a) {
111
+ return wrappedPrompt._(key.raw);
112
+ }
113
+
114
+ if (isFn(wrappedPrompt[a])) {
115
+ wrappedPrompt[a](key);
116
+ } else {
117
+ wrappedPrompt.bell();
118
+ }
119
+ };
120
+
121
+ const onNewSize = () => {
122
+ wrappedPrompt.out.reset();
123
+ wrappedPrompt.render(true);
124
+ };
125
+
126
+ let offKeypress = null;
127
+ let offResize = null;
128
+
129
+ const pause = () => {
130
+ if (!offKeypress) {
131
+ return;
132
+ }
133
+
134
+ offKeypress();
135
+ offKeypress = null;
136
+ if (offResize) {
137
+ offResize();
138
+ offResize = null;
139
+ }
140
+
141
+ process.stdout.write(esc.cursorShow);
142
+ };
143
+
144
+ const resume = () => {
145
+ if (offKeypress) {
146
+ return;
147
+ }
148
+
149
+ offKeypress = listenForKeys(process.stdin, onKey);
150
+ offResize = onResize(process.stdout, onNewSize);
151
+ process.stdout.write(esc.cursorHide);
152
+ };
153
+
154
+ wrappedPrompt.pause = pause;
155
+ wrappedPrompt.resume = resume;
156
+ return new Promise((resolve, reject) => {
157
+ let isClosed = false;
158
+
159
+ wrappedPrompt.close = () => {
160
+ if (isClosed) {
161
+ return;
162
+ }
163
+
164
+ isClosed = true;
165
+ wrappedPrompt.out.unpipe(process.stdout);
166
+ pause();
167
+ if (wrappedPrompt.aborted) {
168
+ reject(Error('Prompt aborted'));
169
+ } else {
170
+ resolve(wrappedPrompt.value);
171
+ }
172
+ };
173
+ process.on('beforeExit', () => wrappedPrompt.close());
174
+ if (!isFn(wrappedPrompt.submit)) {
175
+ wrappedPrompt.submit = wrappedPrompt.close;
176
+ }
177
+
178
+ resume();
179
+ wrappedPrompt.render(true);
180
+ });
144
181
  };
145
- export default Object.assign(wrap, { action });
182
+
183
+ export default Object.assign(wrap, {
184
+ action,
185
+ });
@@ -1,4 +1,4 @@
1
1
  export function writeStream(data, stream) {
2
- const write = stream.__write || stream.write;
3
- return write.call(stream, data);
2
+ const write = stream.__write || stream.write;
3
+ return write.call(stream, data);
4
4
  }
@@ -1,53 +1,67 @@
1
1
  const ansiRegex = [
2
- String.raw`[\u001B\u009B][[\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\d\/#&.:=?%@~_]+)*|[a-zA-Z\d]+(?:;[-a-zA-Z\d\/#&.:=?%@~_]*)*)?\u0007)`,
3
- String.raw`(?:(?:\d{1,4}(?:;\d{0,4})*)?[\dA-PR-TZcf-nq-uy=><~]))`
4
- ].join("|");
2
+ String.raw`[\u001B\u009B][[\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\d/#&.:=?%@~_]+)*|[a-zA-Z\d]+(?:;[-a-zA-Z\d/#&.:=?%@~_]*)*)?\u0007)`,
3
+ String.raw`(?:(?:\d{1,4}(?:;\d{0,4})*)?[\dA-PR-TZcf-nq-uy=><~]))`,
4
+ ].join('|');
5
+
5
6
  export function stripAnsi(text) {
6
- return text.replace(new RegExp(ansiRegex, "g"), "");
7
+ return text.replace(new RegExp(ansiRegex, 'g'), '');
7
8
  }
8
- export function centerAlign(str, len, space = " ") {
9
- const free = len - str.length;
10
- if (free <= 0) {
11
- return str;
12
- }
13
- const freeLeft = Math.floor(free / 2);
14
- let _str = "";
15
- for (let i = 0; i < len; i++) {
16
- _str += i < freeLeft || i >= freeLeft + str.length ? space : str[i - freeLeft];
17
- }
18
- return _str;
19
- }
20
- export function rightAlign(str, len, space = " ") {
21
- const free = len - str.length;
22
- if (free <= 0) {
23
- return str;
24
- }
25
- let _str = "";
26
- for (let i = 0; i < len; i++) {
27
- _str += i < free ? space : str[i - free];
28
- }
29
- return _str;
30
- }
31
- export function leftAlign(str, len, space = " ") {
32
- let _str = "";
33
- for (let i = 0; i < len; i++) {
34
- _str += i < str.length ? str[i] : space;
35
- }
36
- return _str;
9
+
10
+ export function centerAlign(str, len, space = ' ') {
11
+ const free = len - str.length;
12
+
13
+ if (free <= 0) {
14
+ return str;
15
+ }
16
+
17
+ const freeLeft = Math.floor(free / 2);
18
+ let _str = '';
19
+
20
+ for (let i = 0; i < len; i++) {
21
+ _str += i < freeLeft || i >= freeLeft + str.length ? space : str[i - freeLeft];
22
+ }
23
+
24
+ return _str;
37
25
  }
38
- export function align(alignment, str, len, space = " ") {
39
- switch (alignment) {
40
- case "left": {
41
- return leftAlign(str, len, space);
26
+
27
+ export function rightAlign(str, len, space = ' ') {
28
+ const free = len - str.length;
29
+
30
+ if (free <= 0) {
31
+ return str;
42
32
  }
43
- case "right": {
44
- return rightAlign(str, len, space);
33
+
34
+ let _str = '';
35
+
36
+ for (let i = 0; i < len; i++) {
37
+ _str += i < free ? space : str[i - free];
45
38
  }
46
- case "center": {
47
- return centerAlign(str, len, space);
39
+
40
+ return _str;
41
+ }
42
+
43
+ export function leftAlign(str, len, space = ' ') {
44
+ let _str = '';
45
+
46
+ for (let i = 0; i < len; i++) {
47
+ _str += i < str.length ? str[i] : space;
48
48
  }
49
- default: {
50
- return str;
49
+
50
+ return _str;
51
+ }
52
+
53
+ export function align(alignment, str, len, space = ' ') {
54
+ switch(alignment) {
55
+ case 'left':
56
+ return leftAlign(str, len, space);
57
+
58
+ case 'right':
59
+ return rightAlign(str, len, space);
60
+
61
+ case 'center':
62
+ return centerAlign(str, len, space);
63
+
64
+ default:
65
+ return str;
51
66
  }
52
- }
53
67
  }
@@ -1,33 +1,44 @@
1
- import ansiEscapes from "ansi-escapes";
2
- import { cursor } from "sisteransi";
3
- import wrapAnsi from "wrap-ansi";
4
- import { msg } from "./messages.js";
1
+ import ansiEscapes from 'ansi-escapes';
2
+ import {cursor} from 'sisteransi';
3
+ import wrapAnsi from 'wrap-ansi';
4
+ import process from 'node:process';
5
+ import {msg} from './messages.js';
6
+
5
7
  export function removeCursor() {
6
- process.stdout.write(cursor.hide);
8
+ process.stdout.write(cursor.hide);
7
9
  }
10
+
8
11
  export function restoreCursor() {
9
- process.stdout.write(cursor.show);
12
+ process.stdout.write(cursor.show);
10
13
  }
14
+
11
15
  export function deleteLastLine() {
12
- process.stdout.write(ansiEscapes.cursorUp(1) + ansiEscapes.eraseLine);
16
+ process.stdout.write(ansiEscapes.cursorUp(1) + ansiEscapes.eraseLine);
13
17
  }
18
+
14
19
  export function deleteLastLines(count) {
15
- if (count <= 0) {
16
- msg({
17
- type: "M_ERROR",
18
- title: "Count is less than or equal to 0. Nothing to delete."
19
- });
20
- return;
21
- }
22
- process.stdout.write(ansiEscapes.eraseLines(count));
20
+ if (count <= 0) {
21
+ msg({
22
+ type: 'M_ERROR',
23
+ title: 'Count is less than or equal to 0. Nothing to delete.',
24
+ });
25
+ return;
26
+ }
27
+
28
+ process.stdout.write(ansiEscapes.eraseLines(count));
23
29
  }
30
+
24
31
  export function countLines(text) {
25
- const terminalWidth = process.stdout.columns || 80;
26
- const lines = text.split("\n");
27
- let lineCount = 0;
28
- for (const line of lines) {
29
- const wrapped = wrapAnsi(line, terminalWidth, { hard: true });
30
- lineCount += wrapped.split("\n").length;
31
- }
32
- return lineCount;
32
+ const terminalWidth = process.stdout.columns || 80;
33
+ const lines = text.split('\n');
34
+ let lineCount = 0;
35
+
36
+ for (const line of lines) {
37
+ const wrapped = wrapAnsi(line, terminalWidth, {
38
+ hard: true,
39
+ });
40
+ lineCount += wrapped.split('\n').length;
41
+ }
42
+
43
+ return lineCount;
33
44
  }
@@ -1,37 +1,48 @@
1
- import { colorize } from "./color.js";
1
+ import {colorize} from './color.js';
2
+
3
+ const isString = (a) => typeof a === 'string';
4
+
2
5
  export function formatTree(items, options) {
3
- options = {
4
- prefix: " ",
5
- ...options
6
- };
7
- const tree = _buildTree(items, options).join("");
8
- if (options?.color) {
9
- return colorize(options.color, tree);
10
- }
11
- return tree;
6
+ options = {
7
+ prefix: ' ',
8
+ ...options,
9
+ };
10
+ const tree = _buildTree(items, options).join('');
11
+
12
+ if (options?.color) {
13
+ return colorize(options.color, tree);
14
+ }
15
+
16
+ return tree;
12
17
  }
18
+
13
19
  function _buildTree(items, options) {
14
- const chunks = [];
15
- const total = items.length - 1;
16
- for (let i = 0; i <= total; i++) {
17
- const item = items[i];
18
- const isLast = i === total;
19
- const prefix = isLast ? `${options?.prefix}\u2514\u2500` : `${options?.prefix}\u251C\u2500`;
20
- if (typeof item === "string") {
21
- chunks.push(`${prefix}${item}
20
+ const chunks = [];
21
+ const total = items.length - 1;
22
+
23
+ for (let i = 0; i <= total; i++) {
24
+ const item = items[i];
25
+ const isLast = i === total;
26
+ const prefix = isLast ? `${options?.prefix}\u2514\u2500` : `${options?.prefix}\u251C\u2500`;
27
+
28
+ if (isString(item)) {
29
+ chunks.push(`${prefix}${item}
22
30
  `);
23
- } else {
24
- const log = `${prefix}${item.text}
31
+ } else {
32
+ const log = `${prefix}${item.text}
25
33
  `;
26
- chunks.push(item.color ? colorize(item.color, log) : log);
27
- if (item.children) {
28
- const _tree = _buildTree(item.children, {
29
- ...options,
30
- prefix: `${options?.prefix}${isLast ? " " : "\u2502 "}`
31
- });
32
- chunks.push(..._tree);
33
- }
34
+
35
+ chunks.push(item.color ? colorize(item.color, log) : log);
36
+ if (item.children) {
37
+ const _tree = _buildTree(item.children, {
38
+ ...options,
39
+ prefix: `${options?.prefix}${isLast ? ' ' : '\u2502 '}`,
40
+ });
41
+
42
+ chunks.push(..._tree);
43
+ }
44
+ }
34
45
  }
35
- }
36
- return chunks;
46
+
47
+ return chunks;
37
48
  }
@@ -0,0 +1 @@
1
+
@@ -1,9 +1,9 @@
1
- export * from "./box.js";
2
- export * from "./color.js";
1
+ export * from './box.js';
2
+ export * from './color.js';
3
3
  export {
4
- stripAnsi,
5
- centerAlign,
6
- rightAlign,
7
- leftAlign,
8
- align
9
- } from "./string.js";
4
+ stripAnsi,
5
+ centerAlign,
6
+ rightAlign,
7
+ leftAlign,
8
+ align,
9
+ } from './string.js';