index.d.ts 4.92 KB
Newer Older
Rosanny Sihombing's avatar
Rosanny Sihombing committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
// Imported from DefinitelyTyped project.
// TypeScript definitions for ansi-colors
// Definitions by: Rogier Schouten <https://github.com/rogierschouten>
// Integrated by: Jordan Mele <https://github.com/Silic0nS0ldier>

interface SymbolsType {
  /**
   * `undefined` on windows, `✘` on other platforms.
   */
  ballotCross?: "";
  ballotDisabled: "";
  ballotOff: "";
  ballotOn: "";
  bullet: "";
  bulletWhite: "";
  /**
   * `√` on windows, `✔` on other platforms.
   */
  check: "" | "";
  /**
   * `×` on windows, `✖` on other platforms.
   */
  cross: "×" | "";
  /**
   * `...` on windows, `⋯` on other platforms.
   */
  ellipsisLarge: "..." | "";
  /**
   * `...` on windows, `…` on other platforms.
   */
  ellipsis: "..." | "";
  fullBlock: "";
  heart: "";
  identicalTo: "";
  info: "i" | "";
  line: "";
  mark: "";
  middot: "·";
  minus: "";
  multiplication: "×";
  obelus: "÷";
  pencilDownRight: "";
  pencilRight: "";
  pencilUpRight: "";
  percent: "%";
  pilcrow2: "";
  pilcrow: "";
  plusMinus: "±";
  /**
   * `>` on windows, `▸` on linux, and `❯` on other platforms.
   */
  pointer: ">" | "" | "";
  /**
   * `»` on windows, `‣` on linux, and `›` on other platforms.
   */
  pointerSmall: "»" | "" | "";
  question: "?";
  /**
   * `undefined` on windows, `?` on other platforms.
   */
  questionFull?: "";
  /**
   * `?` on windows, `﹖` on other platforms.
   */
  questionSmall: "?" | "";
  /**
   * `( )` on windows, `◯` on other platforms.
   */
  radioOff: "( )" | "";
  /**
   * `(*)` on windows, `◉` on other platforms.
   */
  radioOn: "(*)" | "";
  section: "§";
  starsOff: "";
  starsOn: "";
  upDownArrow: "";
  /**
   * `‼` on windows, `⚠` on other platforms.
   */
  warning: "" | "";
}

type StyleArrayStructure = [number, number];
interface StyleArrayProperties {
  open: string;
  close: string;
  closeRe: string;
}

type StyleType = StyleArrayStructure & StyleArrayProperties;


interface StylesType<T> {
  // modifiers
  reset: T;
  bold: T;
  dim: T;
  italic: T;
  underline: T;
  inverse: T;
  hidden: T;
  strikethrough: T;

  // colors
  black: T;
  red: T;
  green: T;
  yellow: T;
  blue: T;
  magenta: T;
  cyan: T;
  white: T;
  gray: T;
  grey: T;

  // bright colors
  blackBright: T;
  redBright: T;
  greenBright: T;
  yellowBright: T;
  blueBright: T;
  magentaBright: T;
  cyanBright: T;
  whiteBright: T;

  // background colors
  bgBlack: T;
  bgRed: T;
  bgGreen: T;
  bgYellow: T;
  bgBlue: T;
  bgMagenta: T;
  bgCyan: T;
  bgWhite: T;

  // bright background colors
  bgBlackBright: T;
  bgRedBright: T;
  bgGreenBright: T;
  bgYellowBright: T;
  bgBlueBright: T;
  bgMagentaBright: T;
  bgCyanBright: T;
  bgWhiteBright: T;
}

declare namespace ansiColors {
  interface StyleFunction extends StylesType<StyleFunction> {
    (s: string): string;
  }

  // modifiers
  const reset: StyleFunction;
  const bold: StyleFunction;
  const dim: StyleFunction;
  const italic: StyleFunction;
  const underline: StyleFunction;
  const inverse: StyleFunction;
  const hidden: StyleFunction;
  const strikethrough: StyleFunction;

  // colors
  const black: StyleFunction;
  const red: StyleFunction;
  const green: StyleFunction;
  const yellow: StyleFunction;
  const blue: StyleFunction;
  const magenta: StyleFunction;
  const cyan: StyleFunction;
  const white: StyleFunction;
  const gray: StyleFunction;
  const grey: StyleFunction;

  // bright colors
  const blackBright: StyleFunction;
  const redBright: StyleFunction;
  const greenBright: StyleFunction;
  const yellowBright: StyleFunction;
  const blueBright: StyleFunction;
  const magentaBright: StyleFunction;
  const cyanBright: StyleFunction;
  const whiteBright: StyleFunction;

  // background colors
  const bgBlack: StyleFunction;
  const bgRed: StyleFunction;
  const bgGreen: StyleFunction;
  const bgYellow: StyleFunction;
  const bgBlue: StyleFunction;
  const bgMagenta: StyleFunction;
  const bgCyan: StyleFunction;
  const bgWhite: StyleFunction;

  // bright background colors
  const bgBlackBright: StyleFunction;
  const bgRedBright: StyleFunction;
  const bgGreenBright: StyleFunction;
  const bgYellowBright: StyleFunction;
  const bgBlueBright: StyleFunction;
  const bgMagentaBright: StyleFunction;
  const bgCyanBright: StyleFunction;
  const bgWhiteBright: StyleFunction;

  let enabled: boolean;
  let visible: boolean;
  const ansiRegex: RegExp;

  /**
   * Remove styles from string
   */
  function stripColor(s: string): string;

  /**
   * Remove styles from string
   */
  function strip(s: string): string;

  /**
   * Remove styles from string
   */
  function unstyle(s: string): string;

  const styles: StylesType<StyleType>;
  const symbols: SymbolsType;

  /**
   * Outputs a string with check-symbol as prefix
   */
  function ok(...args: string[]): string;

  function create(): typeof ansiColors;
}

export = ansiColors;