@reliverse/relinka 1.1.2 → 1.1.3

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 (80) hide show
  1. package/dist-npm/components/checkbox/index.js +8 -6
  2. package/dist-npm/components/confirm/index.js +7 -4
  3. package/dist-npm/components/core/Separator.d.ts +0 -4
  4. package/dist-npm/components/core/create-prompt.js +1 -1
  5. package/dist-npm/components/core/key.js +6 -6
  6. package/dist-npm/components/core/lines.d.ts +5 -17
  7. package/dist-npm/components/core/lines.js +6 -2
  8. package/dist-npm/components/core/make-theme.js +3 -1
  9. package/dist-npm/components/core/position.d.ts +0 -8
  10. package/dist-npm/components/core/position.js +9 -3
  11. package/dist-npm/components/core/promise-polyfill.js +2 -2
  12. package/dist-npm/components/core/screen-manager.js +2 -1
  13. package/dist-npm/components/core/theme.d.ts +12 -146
  14. package/dist-npm/components/core/theme.js +1 -1
  15. package/dist-npm/components/core/use-keypress.js +3 -1
  16. package/dist-npm/components/core/use-pagination.d.ts +4 -8
  17. package/dist-npm/components/core/use-prefix.js +1 -1
  18. package/dist-npm/components/core/useKeyPress.js +3 -1
  19. package/dist-npm/components/core/utils.d.ts +0 -11
  20. package/dist-npm/components/date/date.js +1 -1
  21. package/dist-npm/components/expand/index.js +4 -2
  22. package/dist-npm/components/figures/index.js +5 -5
  23. package/dist-npm/components/instance/basic.d.ts +0 -12
  24. package/dist-npm/components/instance/basic.js +1 -1
  25. package/dist-npm/components/instance/browser.d.ts +0 -14
  26. package/dist-npm/components/instance/reporter/browser.js +5 -5
  27. package/dist-npm/components/instance/reporter/fancy.d.ts +1 -1
  28. package/dist-npm/components/instance/reporter/fancy.js +1 -1
  29. package/dist-npm/components/mono/mono.js +9 -9
  30. package/dist-npm/components/mono/monoTwo.d.ts +13 -76
  31. package/dist-npm/components/password/password-main.js +1 -1
  32. package/dist-npm/components/progressbar/ProgressBar.d.ts +3 -14
  33. package/dist-npm/components/progressbar/ProgressBar.js +3 -14
  34. package/dist-npm/components/progressbar/helper.d.ts +2 -18
  35. package/dist-npm/components/prompts/create.d.ts +0 -13
  36. package/dist-npm/components/prompts/prompt.js +3 -3
  37. package/dist-npm/components/prompts/promptTwo.d.ts +34 -252
  38. package/dist-npm/components/prompts/promptTwo.js +6 -27
  39. package/dist-npm/components/prompts/relinka.d.ts +17 -114
  40. package/dist-npm/components/prompts/relinka.js +18 -103
  41. package/dist-npm/components/range/range.d.ts +12 -64
  42. package/dist-npm/components/range/range.js +36 -59
  43. package/dist-npm/components/rawlist/index.js +6 -4
  44. package/dist-npm/components/search/index.js +7 -5
  45. package/dist-npm/components/select/index.js +9 -3
  46. package/dist-npm/components/select/select-main.js +3 -1
  47. package/dist-npm/components/select/select-two.js +3 -1
  48. package/dist-npm/components/toggle/index.js +3 -1
  49. package/dist-npm/testing/index.js +1 -1
  50. package/dist-npm/types/general.d.ts +30 -141
  51. package/dist-npm/types/keypress.d.ts +0 -3
  52. package/dist-npm/types/keypress.js +1 -1
  53. package/dist-npm/types/readline.d.ts +1 -9
  54. package/dist-npm/types/relinka.d.ts +1 -9
  55. package/dist-npm/types/utils.d.ts +0 -12
  56. package/dist-npm/utils/box.d.ts +14 -104
  57. package/dist-npm/utils/color.d.ts +0 -20
  58. package/dist-npm/utils/colorize.js +2 -1
  59. package/dist-npm/utils/component.d.ts +5 -26
  60. package/dist-npm/utils/component.js +1 -2
  61. package/dist-npm/utils/constants.d.ts +0 -21
  62. package/dist-npm/utils/constants.js +8 -8
  63. package/dist-npm/utils/decoder.d.ts +2 -17
  64. package/dist-npm/utils/decoder.js +54 -25
  65. package/dist-npm/utils/error.d.ts +0 -5
  66. package/dist-npm/utils/errors.d.ts +1 -1
  67. package/dist-npm/utils/errors.js +8 -4
  68. package/dist-npm/utils/format.d.ts +0 -12
  69. package/dist-npm/utils/keypress.d.ts +0 -6
  70. package/dist-npm/utils/keypress.js +12 -23
  71. package/dist-npm/utils/log.d.ts +0 -11
  72. package/dist-npm/utils/prompt-tmp.js +2 -2
  73. package/dist-npm/utils/prompt-two.js +2 -2
  74. package/dist-npm/utils/skeleton.d.ts +0 -3
  75. package/dist-npm/utils/skeleton.js +66 -22
  76. package/dist-npm/utils/stream.d.ts +0 -13
  77. package/dist-npm/utils/string.d.ts +0 -45
  78. package/dist-npm/utils/tree.d.ts +5 -34
  79. package/dist-npm/utils/variants.js +9 -9
  80. package/package.json +9 -5
@@ -27,7 +27,9 @@ function isSelectable(item) {
27
27
  }
28
28
  function normalizeChoices(choices) {
29
29
  return choices.map((choice) => {
30
- if (Separator.isSeparator(choice)) return choice;
30
+ if (Separator.isSeparator(choice)) {
31
+ return choice;
32
+ }
31
33
  if (typeof choice === "string") {
32
34
  return {
33
35
  value: choice,
@@ -38,14 +40,14 @@ function normalizeChoices(choices) {
38
40
  }
39
41
  const name = choice.name ?? String(choice.value);
40
42
  return {
41
- // @ts-expect-error -- TODO: fix ts
43
+
42
44
  value: choice.value,
43
45
  name,
44
- // @ts-expect-error -- TODO: fix ts
46
+
45
47
  description: choice.description,
46
- // @ts-expect-error -- TODO: fix ts
48
+
47
49
  short: choice.short ?? name,
48
- // @ts-expect-error -- TODO: fix ts
50
+
49
51
  disabled: choice.disabled ?? false
50
52
  };
51
53
  });
@@ -32,7 +32,9 @@ function isSelectable(item) {
32
32
  }
33
33
  function normalizeChoices(choices) {
34
34
  return choices.map((choice) => {
35
- if (Separator.isSeparator(choice)) return choice;
35
+ if (Separator.isSeparator(choice)) {
36
+ return choice;
37
+ }
36
38
  if (typeof choice === "string") {
37
39
  return {
38
40
  value: choice,
@@ -74,7 +76,9 @@ const select = createPrompt(
74
76
  return { first, last };
75
77
  }, [items]);
76
78
  const defaultItemIndex = useMemo(() => {
77
- if (!("default" in config)) return -1;
79
+ if (!("default" in config)) {
80
+ return -1;
81
+ }
78
82
  return items.findIndex(
79
83
  (item) => isSelectable(item) && item.value === config.default
80
84
  );
@@ -110,7 +114,9 @@ const select = createPrompt(
110
114
  } else {
111
115
  const searchTerm = rl.line.toLowerCase();
112
116
  const matchIndex = items.findIndex((item) => {
113
- if (Separator.isSeparator(item) || !isSelectable(item)) return false;
117
+ if (Separator.isSeparator(item) || !isSelectable(item)) {
118
+ return false;
119
+ }
114
120
  return item.name.toLowerCase().startsWith(searchTerm);
115
121
  });
116
122
  if (matchIndex !== -1) {
@@ -19,7 +19,9 @@ export async function selectPrompt(params) {
19
19
  endTitleColor = "passionGradient"
20
20
  } = params;
21
21
  let selectedIndex = initial ? options.findIndex((option) => option.value === initial) : 0;
22
- if (selectedIndex === -1) selectedIndex = 0;
22
+ if (selectedIndex === -1) {
23
+ selectedIndex = 0;
24
+ }
23
25
  const rl = readline.createInterface({ input, output });
24
26
  readline.emitKeypressEvents(input, rl);
25
27
  if (typeof input.setRawMode === "function") {
@@ -26,7 +26,9 @@ export async function selectPrompt(options) {
26
26
  let selectedIndex = defaultValue !== void 0 ? choices.findIndex(
27
27
  (choice, index) => choice.id === defaultValue || index + 1 === Number(defaultValue)
28
28
  ) : 0;
29
- if (selectedIndex === -1) selectedIndex = 0;
29
+ if (selectedIndex === -1) {
30
+ selectedIndex = 0;
31
+ }
30
32
  function renderChoices() {
31
33
  if (!choices) {
32
34
  throw new Error("Choices are required for select prompt.");
@@ -17,7 +17,9 @@ export async function togglePrompt(params) {
17
17
  endTitleColor = "passionGradient"
18
18
  } = params;
19
19
  let selectedIndex = initial ? options.findIndex((option) => option === initial) : 0;
20
- if (selectedIndex === -1) selectedIndex = 0;
20
+ if (selectedIndex === -1) {
21
+ selectedIndex = 0;
22
+ }
21
23
  const rl = readline.createInterface({ input, output });
22
24
  readline.emitKeypressEvents(input, rl);
23
25
  if (typeof input.setRawMode === "function") {
@@ -2,7 +2,7 @@ import ansiEscapes from "ansi-escapes";
2
2
  import MuteStream from "mute-stream";
3
3
  import { Stream } from "node:stream";
4
4
  import stripAnsi from "strip-ansi";
5
- const ignoredAnsi = /* @__PURE__ */ new Set([ansiEscapes.cursorHide, ansiEscapes.cursorShow]);
5
+ const ignoredAnsi = new Set([ansiEscapes.cursorHide, ansiEscapes.cursorShow]);
6
6
  class BufferedStream extends Stream.Writable {
7
7
  #_fullOutput = "";
8
8
  #_chunks = [];
@@ -90,155 +90,44 @@ export type ChoiceOptionalOptions = {
90
90
  export type ChoiceOptions = ChoiceRequiredOptions & ChoiceOptionalOptions;
91
91
  export type PromptType = "text" | "number" | "confirm" | "numSelect" | "select" | "multiselect" | "password" | "date" | "start" | "nextSteps" | "end";
92
92
  export type RelinkaOptions = {
93
- /**
94
- * An array of RelinkaReporter instances used to handle and output log messages.
95
- */
96
- reporters: RelinkaReporter[];
97
- /**
98
- * A record mapping LogType to InputLogObject, defining the log configuration for each log type.
99
- * See {@link LogType} and {@link InputLogObject}.
100
- */
101
- types: Record<LogType, InputLogObject>;
102
- /**
103
- * The minimum log level to output. See {@link LogLevel}.
104
- */
105
- level: LogLevel;
106
- /**
107
- * Default properties applied to all log messages unless overridden. See {@link InputLogObject}.
108
- */
109
- defaults: InputLogObject;
110
- /**
111
- * The maximum number of times a log message can be repeated within a given frame of time.
112
- */
113
- throttle: number;
114
- /**
115
- * The minimum time in milliseconds that must elapse before a throttled log message can be logged again.
116
- */
117
- throttleMin: number;
118
- /**
119
- * The Node writable stream for standard output. See {@link NodeJS.WriteStream}.
120
- * @optional
121
- */
122
- stdout?: NodeJS.WriteStream;
123
- /**
124
- * The Node writeable stream for standard error output. See {@link NodeJS.WriteStream}.
125
- * @optional
126
- */
127
- stderr?: NodeJS.WriteStream;
128
- /**
129
- * A function that allows you to mock log messages for testing purposes.
130
- * @optional
131
- */
132
- mockFn?: (type: LogType, defaults: InputLogObject) => (...args: any) => void;
133
- /**
134
- * Custom prompt function to use. It can be undefined.
135
- * @optional
136
- */
137
- prompt?: typeof import("../components/mono/monoTwo.js").prompt | undefined;
138
- /**
139
- * Configuration options for formatting log messages. See {@link FormatOptions}.
140
- */
141
- formatOptions: FormatOptions;
93
+ reporters: RelinkaReporter[];
94
+ types: Record<LogType, InputLogObject>;
95
+ level: LogLevel;
96
+ defaults: InputLogObject;
97
+ throttle: number;
98
+ throttleMin: number;
99
+ stdout?: NodeJS.WriteStream;
100
+ stderr?: NodeJS.WriteStream;
101
+ mockFn?: (type: LogType, defaults: InputLogObject) => (...args: any) => void;
102
+ prompt?: typeof import("../components/mono/monoTwo.js").prompt | undefined;
103
+ formatOptions: FormatOptions;
142
104
  };
143
- /**
144
- * @see https://nodejs.org/api/util.html#util_util_inspect_object_showhidden_depth_colors
145
- */
146
105
  export type FormatOptions = {
147
- /**
148
- * The maximum number of columns to output, affects formatting.
149
- * @optional
150
- */
151
- columns?: number;
152
- /**
153
- * Whether to include timestamp information in log messages.
154
- * @optional
155
- */
156
- date?: boolean;
157
- /**
158
- * Whether to use colors in the output.
159
- * @optional
160
- */
161
- colors?: boolean;
162
- /**
163
- * Specifies whether or not the output should be compact. Accepts a boolean or numeric level of compactness.
164
- * @optional
165
- */
166
- compact?: boolean | number;
167
- /**
168
- * Allows additional custom formatting options.
169
- */
170
- [key: string]: unknown;
106
+ columns?: number;
107
+ date?: boolean;
108
+ colors?: boolean;
109
+ compact?: boolean | number;
110
+ [key: string]: unknown;
171
111
  };
172
112
  export type InputLogObject = {
173
- /**
174
- * The logging level of the message. See {@link LogLevel}.
175
- * @optional
176
- */
177
- level?: LogLevel;
178
- /**
179
- * A string tag to categorize or identify the log message.
180
- * @optional
181
- */
182
- tag?: string;
183
- /**
184
- * The type of log message, which affects how it's processed and displayed. See {@link LogType}.
185
- * @optional
186
- */
187
- type?: LogType;
188
- /**
189
- * The main log message text.
190
- * @optional
191
- */
192
- message?: string;
193
- /**
194
- * Additional text or texts to be logged with the message.
195
- * @optional
196
- */
197
- additional?: string | string[];
198
- /**
199
- * Additional arguments to be logged with the message.
200
- * @optional
201
- */
202
- args?: any[];
203
- /**
204
- * The date and time when the log message was created.
205
- * @optional
206
- */
207
- date?: Date;
113
+ level?: LogLevel;
114
+ tag?: string;
115
+ type?: LogType;
116
+ message?: string;
117
+ additional?: string | string[];
118
+ args?: any[];
119
+ date?: Date;
208
120
  };
209
121
  export type LogObject = {
210
- /**
211
- * The logging level of the message, overridden if required. See {@link LogLevel}.
212
- */
213
- level: LogLevel;
214
- /**
215
- * The type of log message, overridden if required. See {@link LogType}.
216
- */
217
- type: LogType;
218
- /**
219
- * A string tag to categorize or identify the log message, overridden if necessary.
220
- */
221
- tag: string;
222
- /**
223
- * Additional arguments to be logged with the message, overridden if necessary.
224
- */
225
- args: any[];
226
- /**
227
- * The date and time the log message was created, overridden if necessary.
228
- */
229
- date: Date;
230
- /**
231
- * Allows additional custom properties to be set on the log object.
232
- */
233
- [key: string]: unknown;
122
+ level: LogLevel;
123
+ type: LogType;
124
+ tag: string;
125
+ args: any[];
126
+ date: Date;
127
+ [key: string]: unknown;
234
128
  } & InputLogObject;
235
129
  export type RelinkaReporter = {
236
- /**
237
- * Defines how a log message is processed and displayed by this reporter.
238
- * @param logObj The LogObject containing the log information to process. See {@link LogObject}.
239
- * @param ctx An object containing context information such as options. See {@link RelinkaOptions}.
240
- */
241
- log: (logObj: LogObject, ctx: {
130
+ log: (logObj: LogObject, ctx: {
242
131
  options: RelinkaOptions;
243
132
  }) => void;
244
133
  };
@@ -44,9 +44,6 @@ export type Keypress = {
44
44
  raw: string;
45
45
  };
46
46
  export type KeypressCallback = (key: Keypress) => void;
47
- /**
48
- * Type definition for the listenForKeys function
49
- */
50
47
  export type ListenForKeys = {
51
48
  (stream: Readable, callback: KeypressCallback): () => void;
52
49
  parse: (s: string | Buffer, enc?: string) => Keypress | Keypress[];
@@ -1,4 +1,4 @@
1
- export var KeyName = /* @__PURE__ */ ((KeyName2) => {
1
+ export var KeyName = ((KeyName2) => {
2
2
  KeyName2["RETURN"] = "return";
3
3
  KeyName2["ENTER"] = "enter";
4
4
  KeyName2["TAB"] = "tab";
@@ -1,11 +1,4 @@
1
1
  import type { Duplex } from "node:stream";
2
- /**
3
- * `RelinkaReadline` is a re-implementation of `readline.Interface` from Node.
4
- * It is reimplemented because of 3 reasons:
5
- * 1. The `readline.Interface` API is not complete; it's missing for example `clearLine`.
6
- * 2. The input/output streams are not generics, meaning they're inexact.
7
- * 3. Since ReadLine isn't built-in Typescript Global NodeJS type, it'd force us to ship `@types/node` as a dependency to all users.
8
- */
9
2
  export type RelinkaReadline = {
10
3
  output: Duplex & {
11
4
  mute: () => void;
@@ -33,6 +26,5 @@ export type Context = {
33
26
  signal?: AbortSignal;
34
27
  };
35
28
  export type Prompt<Value, Config> = (config: Config, context?: Context) => Promise<Value> & {
36
- /** @deprecated pass an AbortSignal in the context options instead. */
37
- cancel: () => void;
29
+ cancel: () => void;
38
30
  };
@@ -1,11 +1,4 @@
1
1
  import type { Duplex } from "node:stream";
2
- /**
3
- * `RelinkaReadline` is a re-implementation of `readline.Interface` from Node.js.
4
- * It's reimplemented because of 3 reasons:
5
- * 1. The `readline.Interface` API is not complete; it's missing for example `clearLine`.
6
- * 2. The input/output streams are not generics, meaning they're inexact.
7
- * 3. Since ReadLine isn't built-in Typescript Global NodeJS type, it'd force us to ship `@types/node` as a dependency to all users.
8
- */
9
2
  export type RelinkaReadline = {
10
3
  output: Duplex & {
11
4
  mute: () => void;
@@ -33,6 +26,5 @@ export type Context = {
33
26
  signal?: AbortSignal;
34
27
  };
35
28
  export type Prompt<Value, Config> = (config: Config, context?: Context) => Promise<Value> & {
36
- /** @deprecated pass an AbortSignal in the context options instead. See {@link https://github.com/SBoudrias/Relinka.js#canceling-prompt} */
37
- cancel: () => void;
29
+ cancel: () => void;
38
30
  };
@@ -9,21 +9,9 @@ export type LiteralUnion<T extends F, F = string> = T | (F & {});
9
9
  export type KeyUnion<T> = LiteralUnion<Extract<keyof T, string>>;
10
10
  export type DistributiveMerge<A, B> = A extends any ? Prettify<Omit<A, keyof B> & B> : never;
11
11
  export type UnionToIntersection<T> = (T extends any ? (input: T) => void : never) extends (input: infer Intersection) => void ? Intersection : never;
12
- /**
13
- * @hidden
14
- */
15
12
  type __Pick<O extends object, K extends keyof O> = {
16
13
  [P in K]: O[P];
17
14
  } & {};
18
- /**
19
- * @hidden
20
- */
21
15
  export type _Pick<O extends object, K extends Key> = __Pick<O, keyof O & K>;
22
- /**
23
- * Extract out of `O` the fields of key `K`
24
- * @param O to extract from
25
- * @param K to chose fields
26
- * @returns [[Object]]
27
- */
28
16
  export type Pick<O extends object, K extends Key> = O extends unknown ? _Pick<O, K> : never;
29
17
  export {};
@@ -1,114 +1,24 @@
1
1
  export type BoxBorderStyle = {
2
- /**
3
- * Top left corner
4
- * @example `┌`
5
- * @example `╔`
6
- * @example `╓`
7
- */
8
- tl: string;
9
- /**
10
- * Top right corner
11
- * @example `┐`
12
- * @example `╗`
13
- * @example `╖`
14
- */
15
- tr: string;
16
- /**
17
- * Bottom left corner
18
- * @example `└`
19
- * @example `╚`
20
- * @example `╙`
21
- */
22
- bl: string;
23
- /**
24
- * Bottom right corner
25
- * @example `┘`
26
- * @example `╝`
27
- * @example `╜`
28
- */
29
- br: string;
30
- /**
31
- * Horizontal line
32
- * @example `─`
33
- * @example `═`
34
- * @example `─`
35
- */
36
- h: string;
37
- /**
38
- * Vertical line
39
- * @example `│`
40
- * @example `║`
41
- * @example `║`
42
- */
43
- v: string;
2
+ tl: string;
3
+ tr: string;
4
+ bl: string;
5
+ br: string;
6
+ h: string;
7
+ v: string;
44
8
  };
45
9
  declare const boxStylePresets: Record<string, BoxBorderStyle>;
46
10
  export type BoxStyle = {
47
- /**
48
- * The border color
49
- * @default 'white'
50
- */
51
- borderColor: "black" | "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white" | "gray" | "blackBright" | "redBright" | "greenBright" | "yellowBright" | "blueBright" | "magentaBright" | "cyanBright" | "whiteBright";
52
- /**
53
- * The border style
54
- * @default 'solid'
55
- * @example 'single-double-rounded'
56
- * @example
57
- * ```ts
58
- * {
59
- * tl: '┌',
60
- * tr: '┐',
61
- * bl: '└',
62
- * br: '┘',
63
- * h: '─',
64
- * v: '│',
65
- * }
66
- * ```
67
- */
68
- borderStyle: BoxBorderStyle | keyof typeof boxStylePresets;
69
- /**
70
- * The vertical alignment of the text
71
- * @default 'center'
72
- */
73
- valign: "top" | "center" | "bottom";
74
- /**
75
- * The padding of the box
76
- * @default 2
77
- */
78
- padding: number;
79
- /**
80
- * The left margin of the box
81
- * @default 1
82
- */
83
- marginLeft: number;
84
- /**
85
- * The top margin of the box
86
- * @default 1
87
- */
88
- marginTop: number;
89
- /**
90
- * The top margin of the box
91
- * @default 1
92
- */
93
- marginBottom: number;
11
+ borderColor: "black" | "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white" | "gray" | "blackBright" | "redBright" | "greenBright" | "yellowBright" | "blueBright" | "magentaBright" | "cyanBright" | "whiteBright";
12
+ borderStyle: BoxBorderStyle | keyof typeof boxStylePresets;
13
+ valign: "top" | "center" | "bottom";
14
+ padding: number;
15
+ marginLeft: number;
16
+ marginTop: number;
17
+ marginBottom: number;
94
18
  };
95
- /**
96
- * The border options of the box
97
- */
98
19
  export type BoxOpts = {
99
- /**
100
- * Title that will be displayed on top of the box
101
- * @example 'Hello World'
102
- * @example 'Hello {name}'
103
- */
104
- title?: string;
20
+ title?: string;
105
21
  style?: Partial<BoxStyle>;
106
22
  };
107
- /**
108
- * Creates a styled box with text content, customizable via options.
109
- * @param {string} text - The text to display in the box.
110
- * @param {BoxOpts} [_opts={}] - Optional settings for the appearance and behavior of the box. See {@link BoxOpts}.
111
- * @returns {string} The formatted box as a string, ready for printing or logging.
112
- */
113
23
  export declare function box(text: string, _opts?: BoxOpts): string;
114
24
  export {};
@@ -1,8 +1,3 @@
1
- /**
2
- * Based on https://github.com/jorgebucaran/colorette
3
- * Read LICENSE file for more information
4
- * https://github.com/jorgebucaran/colorette/blob/20fc196d07d0f87c61e0256eadd7831c79b24108/index
5
- */
6
1
  declare const colorDefs: {
7
2
  reset: (string: string) => string;
8
3
  bold: (string: string) => string;
@@ -48,22 +43,7 @@ declare const colorDefs: {
48
43
  };
49
44
  export type ColorName = keyof typeof colorDefs;
50
45
  export type ColorFunction = (text: string | number) => string;
51
- /**
52
- * An object containing functions for coloring text. Each function corresponds to a terminal color. See {@link ColorName} for available colors.
53
- */
54
46
  export declare const colors: Record<ColorName, ColorFunction>;
55
- /**
56
- * Gets a color function by name, with an option for a fallback color if the requested color is not found.
57
- * @param {ColorName} color - The name of the color function to get. See {@link ColorName}.
58
- * @param {ColorName} [fallback="reset"] - The name of the fallback color function if the requested color is not found. See {@link ColorName}.
59
- * @returns {ColorFunction} The color function that corresponds to the requested color, or the fallback color function. See {@link ColorFunction}.
60
- */
61
47
  export declare function getColor(color: ColorName, fallback?: ColorName): ColorFunction;
62
- /**
63
- * Applies a specified color to a given text string or number.
64
- * @param {ColorName} color - The color to apply. See {@link ColorName}.
65
- * @param {string | number} text - The text to color.
66
- * @returns {string} The colored text.
67
- */
68
48
  export declare function colorize(color: ColorName, text: string | number): string;
69
49
  export {};
@@ -103,10 +103,11 @@ export function colorize(text, colorName, typography) {
103
103
  "rainbowGradient",
104
104
  "viceGradient"
105
105
  ];
106
- if (gradientColors.includes(colorName ?? "") && typography)
106
+ if (gradientColors.includes(colorName ?? "") && typography) {
107
107
  throw new Error(
108
108
  "[colorize] Cannot apply typography to gradient color.\n\u2502 Use regular colorize()'s color or remove typography."
109
109
  );
110
+ }
110
111
  if (!gradientColors.includes(colorName ?? "") && typography) {
111
112
  switch (typography) {
112
113
  case "bold":
@@ -68,8 +68,7 @@ export declare const log: {
68
68
  success: (message: string) => void;
69
69
  step: (message: string) => void;
70
70
  warn: (message: string) => void;
71
- /** alias for `log.warn()`. */
72
- warning: (message: string) => void;
71
+ warning: (message: string) => void;
73
72
  error: (message: string) => void;
74
73
  };
75
74
  export declare const spinner: () => {
@@ -81,11 +80,7 @@ export type PromptGroupAwaitedReturn<T> = {
81
80
  [P in keyof T]: Exclude<Awaited<T[P]>, symbol>;
82
81
  };
83
82
  export type PromptGroupOptions<T> = {
84
- /**
85
- * Control how the group can be canceled
86
- * if one of the prompts is canceled.
87
- */
88
- onCancel?: (opts: {
83
+ onCancel?: (opts: {
89
84
  results: Prettify<Partial<PromptGroupAwaitedReturn<T>>>;
90
85
  }) => void;
91
86
  };
@@ -97,26 +92,10 @@ export type PromptGroup<T> = {
97
92
  results: Prettify<Partial<PromptGroupAwaitedReturn<Omit<T, P>>>>;
98
93
  }) => void | Promise<T[P] | void>;
99
94
  };
100
- /**
101
- * Define a group of prompts to be displayed
102
- * and return a results of objects within the group
103
- */
104
95
  export declare const group: <T>(prompts: PromptGroup<T>, opts?: PromptGroupOptions<T>) => Promise<Prettify<PromptGroupAwaitedReturn<T>>>;
105
96
  export type Task = {
106
- /**
107
- * Task title
108
- */
109
- title: string;
110
- /**
111
- * Task function
112
- */
113
- task: (message: (string: string) => void) => string | Promise<string> | void | Promise<void>;
114
- /**
115
- * If enabled === false the task will be skipped
116
- */
117
- enabled?: boolean;
97
+ title: string;
98
+ task: (message: (string: string) => void) => string | Promise<string> | void | Promise<void>;
99
+ enabled?: boolean;
118
100
  };
119
- /**
120
- * Define a group of tasks to be executed
121
- */
122
101
  export declare const tasks: (tasks: Task[]) => Promise<void>;
@@ -517,8 +517,7 @@ export const log = {
517
517
  warn: (message) => {
518
518
  log.message(message, { symbol: color.yellow(S_WARN) });
519
519
  },
520
- /** alias for `log.warn()`. */
521
- warning: (message) => {
520
+ warning: (message) => {
522
521
  log.warn(message);
523
522
  },
524
523
  error: (message) => {
@@ -1,26 +1,5 @@
1
1
  import type { LogObject } from "../types/general.js";
2
- /**
3
- * Defines the level of logs as specific numbers or special number types.
4
- *
5
- * @type {0 | 1 | 2 | 3 | 4 | 5 | (number & {})} LogLevel - Represents the log level.
6
- * @default 0 - Represents the default log level.
7
- */
8
2
  export type LogLevel = 0 | 1 | 2 | 3 | 4 | 5 | (number & {});
9
- /**
10
- * A mapping of `LogType` to its corresponding numeric log level.
11
- *
12
- * @type {Record<LogType, number>} LogLevels - key-value pairs of log types to their numeric levels. See {@link LogType}.
13
- */
14
3
  export declare const LogLevels: Record<LogType, number>;
15
- /**
16
- * Lists the types of log messages supported by the system.
17
- *
18
- * @type {"silent" | "fatal" | "error" | "warn" | "log" | "info" | "success" | "fail" | "ready" | "start" | "box" | "debug" | "trace" | "verbose"} LogType - Represents the specific type of log message.
19
- */
20
4
  export type LogType = "silent" | "fatal" | "error" | "warn" | "log" | "info" | "success" | "fail" | "ready" | "start" | "box" | "debug" | "trace" | "verbose";
21
- /**
22
- * Maps `LogType` to a `Partial<LogObject>`, primarily defining the log level.
23
- *
24
- * @type {Record<LogType, Partial<LogObject>>} LogTypes - key-value pairs of log types to partial log objects, specifying log levels. See {@link LogType} and {@link LogObject}.
25
- */
26
5
  export declare const LogTypes: Record<LogType, Partial<LogObject>>;