terminal-richjs 0.1.0
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.
- package/README.md +241 -0
- package/dist/index.cjs +2738 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +751 -0
- package/dist/index.d.ts +751 -0
- package/dist/index.js +2674 -0
- package/dist/index.js.map +1 -0
- package/dist/logging.cjs +4 -0
- package/dist/logging.cjs.map +1 -0
- package/dist/logging.d.cts +2 -0
- package/dist/logging.d.ts +2 -0
- package/dist/logging.js +3 -0
- package/dist/logging.js.map +1 -0
- package/package.json +81 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,751 @@
|
|
|
1
|
+
import cliSpinners, { SpinnerName as SpinnerName$1 } from 'cli-spinners';
|
|
2
|
+
import boxes from 'cli-boxes';
|
|
3
|
+
import tinycolor from 'tinycolor2';
|
|
4
|
+
|
|
5
|
+
type StandardColor = 'black' | 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan' | 'white' | 'bright_black' | 'bright_red' | 'bright_green' | 'bright_yellow' | 'bright_blue' | 'bright_magenta' | 'bright_cyan' | 'bright_white';
|
|
6
|
+
interface RGB {
|
|
7
|
+
r: number;
|
|
8
|
+
g: number;
|
|
9
|
+
b: number;
|
|
10
|
+
}
|
|
11
|
+
type Color$1 = StandardColor | RGB | string | number;
|
|
12
|
+
interface StyleOptions {
|
|
13
|
+
color?: Color$1;
|
|
14
|
+
backgroundColor?: Color$1;
|
|
15
|
+
bold?: boolean;
|
|
16
|
+
italic?: boolean;
|
|
17
|
+
underline?: boolean;
|
|
18
|
+
strikethrough?: boolean;
|
|
19
|
+
dim?: boolean;
|
|
20
|
+
reverse?: boolean;
|
|
21
|
+
blink?: boolean;
|
|
22
|
+
hidden?: boolean;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
declare class Style {
|
|
26
|
+
readonly color?: Color$1;
|
|
27
|
+
readonly backgroundColor?: Color$1;
|
|
28
|
+
readonly bold?: boolean;
|
|
29
|
+
readonly italic?: boolean;
|
|
30
|
+
readonly underline?: boolean;
|
|
31
|
+
readonly strikethrough?: boolean;
|
|
32
|
+
readonly dim?: boolean;
|
|
33
|
+
readonly reverse?: boolean;
|
|
34
|
+
readonly blink?: boolean;
|
|
35
|
+
readonly hidden?: boolean;
|
|
36
|
+
constructor(options?: StyleOptions);
|
|
37
|
+
static null(): Style;
|
|
38
|
+
/**
|
|
39
|
+
* Parse a style string into a Style object.
|
|
40
|
+
* Supports:
|
|
41
|
+
* - Modifiers: bold, italic, underline, dim, strike, reverse, blink, hidden
|
|
42
|
+
* - Named colors: red, green, blue, cyan, magenta, yellow, white, black
|
|
43
|
+
* - Bright colors: bright_red, bright_green, etc.
|
|
44
|
+
* - Hex colors: #ff0000
|
|
45
|
+
* - RGB colors: rgb(255,0,0)
|
|
46
|
+
* - 256 colors: color(196)
|
|
47
|
+
* - Background: on red, on #ff0000, on rgb(255,0,0)
|
|
48
|
+
*/
|
|
49
|
+
static parse(styleString: string): Style;
|
|
50
|
+
/**
|
|
51
|
+
* Parse a single color value.
|
|
52
|
+
* Supports hex (#ff0000), RGB (rgb(255,0,0)), 256-color (color(196)), and named colors.
|
|
53
|
+
*/
|
|
54
|
+
private static parseColor;
|
|
55
|
+
combine(other: Style): Style;
|
|
56
|
+
render(text: string): string;
|
|
57
|
+
/**
|
|
58
|
+
* Apply a color to a chalk instance.
|
|
59
|
+
*/
|
|
60
|
+
private applyColor;
|
|
61
|
+
private isRGB;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
declare class Palette {
|
|
65
|
+
colors: Record<string, string>;
|
|
66
|
+
constructor(colors?: Record<string, string>);
|
|
67
|
+
get(name: string): string | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* Generates a simple palette from a primary color.
|
|
70
|
+
*/
|
|
71
|
+
static fromPrimary(primary: string): Palette;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
declare class Theme {
|
|
75
|
+
styles: Record<string, Style | string>;
|
|
76
|
+
palette: Palette;
|
|
77
|
+
constructor(styles?: Record<string, Style | string>, palette?: Palette);
|
|
78
|
+
get(name: string): Style;
|
|
79
|
+
/**
|
|
80
|
+
* Parses a style string replacing palette references.
|
|
81
|
+
* e.g. "bold primary" -> "bold #007bff"
|
|
82
|
+
*/
|
|
83
|
+
private parseWithPalette;
|
|
84
|
+
static fromPalette(palette: Palette): Theme;
|
|
85
|
+
}
|
|
86
|
+
declare const DEFAULT_THEME: Theme;
|
|
87
|
+
|
|
88
|
+
type ColorSystem = 'standard' | '256' | 'truecolor' | 'none';
|
|
89
|
+
interface ConsoleOptions {
|
|
90
|
+
/**
|
|
91
|
+
* The width of the console in characters.
|
|
92
|
+
* If not provided, it will be detected automatically.
|
|
93
|
+
*/
|
|
94
|
+
width?: number;
|
|
95
|
+
/**
|
|
96
|
+
* The height of the console in lines.
|
|
97
|
+
* If not provided, it will be detected automatically.
|
|
98
|
+
*/
|
|
99
|
+
height?: number;
|
|
100
|
+
/**
|
|
101
|
+
* The color system to use.
|
|
102
|
+
* If not provided, it will be detected automatically.
|
|
103
|
+
*/
|
|
104
|
+
colorSystem?: ColorSystem;
|
|
105
|
+
/**
|
|
106
|
+
* Whether to force terminal output even if not a TTY.
|
|
107
|
+
*/
|
|
108
|
+
forceTerminal?: boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Theme configuration.
|
|
111
|
+
*/
|
|
112
|
+
theme?: Theme;
|
|
113
|
+
/**
|
|
114
|
+
* Whether to record output for later export.
|
|
115
|
+
*/
|
|
116
|
+
record?: boolean;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* A segment of text with a specific style.
|
|
121
|
+
*/
|
|
122
|
+
declare class Segment implements Renderable {
|
|
123
|
+
readonly text: string;
|
|
124
|
+
readonly style: Style;
|
|
125
|
+
readonly isControl: boolean;
|
|
126
|
+
constructor(text: string, style?: Style, isControl?: boolean);
|
|
127
|
+
/**
|
|
128
|
+
* Implementation of Renderable protocol.
|
|
129
|
+
*/
|
|
130
|
+
__rich_console__(_console: Console, _options: ConsoleOptions): RenderResult;
|
|
131
|
+
/**
|
|
132
|
+
* Calculates the cell length of the text.
|
|
133
|
+
*/
|
|
134
|
+
cellLength(): number;
|
|
135
|
+
/**
|
|
136
|
+
* Renders the segment to an ANSI string.
|
|
137
|
+
*/
|
|
138
|
+
render(): string;
|
|
139
|
+
/**
|
|
140
|
+
* Splits the segment into lines.
|
|
141
|
+
*/
|
|
142
|
+
splitLines(_allowEmpty?: boolean): Segment[][];
|
|
143
|
+
/**
|
|
144
|
+
* Creates a new Segment with modified properties.
|
|
145
|
+
*/
|
|
146
|
+
clone(text?: string, style?: Style, isControl?: boolean): Segment;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Result of rendering a Renderable object.
|
|
151
|
+
*/
|
|
152
|
+
interface RenderResult {
|
|
153
|
+
/** The rendered text segments */
|
|
154
|
+
segments: Segment[];
|
|
155
|
+
/** The width in characters */
|
|
156
|
+
width?: number;
|
|
157
|
+
/** The height in lines */
|
|
158
|
+
height?: number;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Protocol for objects that can be rendered to the console.
|
|
162
|
+
*/
|
|
163
|
+
interface Renderable {
|
|
164
|
+
/**
|
|
165
|
+
* Renders the object to segments.
|
|
166
|
+
*
|
|
167
|
+
* @param console - The console instance
|
|
168
|
+
* @param options - Rendering options
|
|
169
|
+
* @returns The render result
|
|
170
|
+
*/
|
|
171
|
+
__rich_console__(console: Console, options: ConsoleOptions): RenderResult | Generator<Segment>;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Type guard to check if an object is renderable.
|
|
175
|
+
*/
|
|
176
|
+
declare function isRenderable(obj: unknown): obj is Renderable;
|
|
177
|
+
|
|
178
|
+
declare class Status {
|
|
179
|
+
private live;
|
|
180
|
+
private spinner;
|
|
181
|
+
private message;
|
|
182
|
+
private interval;
|
|
183
|
+
constructor(message: string, options?: {
|
|
184
|
+
console?: Console;
|
|
185
|
+
spinner?: SpinnerName$1;
|
|
186
|
+
});
|
|
187
|
+
start(): void;
|
|
188
|
+
stop(): void;
|
|
189
|
+
update(message: string): void;
|
|
190
|
+
private render;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
declare class Console {
|
|
194
|
+
private readonly terminal;
|
|
195
|
+
private readonly markupParser;
|
|
196
|
+
private readonly options;
|
|
197
|
+
theme: Theme;
|
|
198
|
+
constructor(options?: ConsoleOptions);
|
|
199
|
+
get width(): number;
|
|
200
|
+
get height(): number;
|
|
201
|
+
/**
|
|
202
|
+
* Prints objects to the console.
|
|
203
|
+
*/
|
|
204
|
+
print(...objects: any[]): void;
|
|
205
|
+
/**
|
|
206
|
+
* Prints a formatted exception.
|
|
207
|
+
*/
|
|
208
|
+
printException(error: Error): void;
|
|
209
|
+
/**
|
|
210
|
+
* Displays a status spinner.
|
|
211
|
+
*/
|
|
212
|
+
status(message: string, options?: {
|
|
213
|
+
spinner?: SpinnerName$1;
|
|
214
|
+
}): {
|
|
215
|
+
start: () => void;
|
|
216
|
+
stop: () => void;
|
|
217
|
+
update: (msg: string) => void;
|
|
218
|
+
} & Promise<void>;
|
|
219
|
+
/**
|
|
220
|
+
* Run a task with a status spinner.
|
|
221
|
+
*/
|
|
222
|
+
withStatus<T>(message: string, task: (status: Status) => Promise<T>, options?: {
|
|
223
|
+
spinner?: SpinnerName$1;
|
|
224
|
+
}): Promise<T>;
|
|
225
|
+
/**
|
|
226
|
+
* Renders a renderable object to a string.
|
|
227
|
+
*/
|
|
228
|
+
render(renderable: Renderable): string;
|
|
229
|
+
/**
|
|
230
|
+
* Internal string rendering with markup and wrapping.
|
|
231
|
+
*/
|
|
232
|
+
private renderString;
|
|
233
|
+
/**
|
|
234
|
+
* Low-level write to stdout.
|
|
235
|
+
*/
|
|
236
|
+
private write;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Parses Rich markup into segments.
|
|
241
|
+
* Example: "[bold red]Hello[/bold red] [green]World[/green]"
|
|
242
|
+
*/
|
|
243
|
+
declare class MarkupParser {
|
|
244
|
+
private static readonly TAG_REGEX;
|
|
245
|
+
private theme;
|
|
246
|
+
constructor(theme?: Theme);
|
|
247
|
+
parse(markup: string): Segment[];
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
type JustifyMethod = 'left' | 'center' | 'right' | 'full';
|
|
251
|
+
type OverflowMethod = 'fold' | 'crop' | 'ellipsis';
|
|
252
|
+
declare class Text implements Renderable {
|
|
253
|
+
readonly style: Style;
|
|
254
|
+
readonly justify: JustifyMethod;
|
|
255
|
+
readonly overflow: OverflowMethod;
|
|
256
|
+
readonly noWrap: boolean;
|
|
257
|
+
private readonly segments;
|
|
258
|
+
constructor(content: string | Segment[], style?: Style, justify?: JustifyMethod, overflow?: OverflowMethod, noWrap?: boolean);
|
|
259
|
+
__rich_console__(console: Console, options: ConsoleOptions): RenderResult;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
interface BoxData {
|
|
263
|
+
topLeft: string;
|
|
264
|
+
top: string;
|
|
265
|
+
topRight: string;
|
|
266
|
+
right: string;
|
|
267
|
+
bottomRight: string;
|
|
268
|
+
bottom: string;
|
|
269
|
+
bottomLeft: string;
|
|
270
|
+
left: string;
|
|
271
|
+
topMid?: string;
|
|
272
|
+
midMid?: string;
|
|
273
|
+
bottomMid?: string;
|
|
274
|
+
leftMid?: string;
|
|
275
|
+
rightMid?: string;
|
|
276
|
+
mid?: string;
|
|
277
|
+
verticalMid?: string;
|
|
278
|
+
[key: string]: string | undefined;
|
|
279
|
+
}
|
|
280
|
+
type BoxStyle = 'none' | 'rounded' | 'round' | 'heavy' | 'bold' | 'double' | 'single' | 'square' | 'ascii' | 'minimal' | 'simple' | 'markdown' | keyof typeof boxes;
|
|
281
|
+
/**
|
|
282
|
+
* Get box drawing characters for a given style.
|
|
283
|
+
*/
|
|
284
|
+
declare function getBox(style: BoxStyle): BoxData | null;
|
|
285
|
+
/**
|
|
286
|
+
* List all available box styles.
|
|
287
|
+
*/
|
|
288
|
+
declare function listBoxStyles(): string[];
|
|
289
|
+
|
|
290
|
+
/** biome-ignore-all assist/source/organizeImports: biome-ignore assist/source/organizeImports */
|
|
291
|
+
/** biome-ignore-all lint/suspicious/noExplicitAny: biome-ignore lint/suspicious/noExplicitAny */
|
|
292
|
+
|
|
293
|
+
interface PanelOptions {
|
|
294
|
+
title?: string;
|
|
295
|
+
titleAlign?: 'left' | 'center' | 'right';
|
|
296
|
+
subtitle?: string;
|
|
297
|
+
subtitleAlign?: 'left' | 'center' | 'right';
|
|
298
|
+
box?: BoxStyle;
|
|
299
|
+
style?: Style | string;
|
|
300
|
+
borderStyle?: Style | string;
|
|
301
|
+
padding?: number | [number, number] | [number, number, number, number];
|
|
302
|
+
width?: number;
|
|
303
|
+
height?: number;
|
|
304
|
+
expand?: boolean;
|
|
305
|
+
highlight?: boolean;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* A bordered panel container for any renderable content.
|
|
309
|
+
* Supports titles, subtitles, various box styles, and padding.
|
|
310
|
+
*/
|
|
311
|
+
declare class Panel implements Renderable {
|
|
312
|
+
readonly renderable: Renderable | string;
|
|
313
|
+
readonly options: PanelOptions;
|
|
314
|
+
constructor(renderable: Renderable | string, options?: PanelOptions);
|
|
315
|
+
/**
|
|
316
|
+
* Create a panel that fits its content (expand=false).
|
|
317
|
+
*/
|
|
318
|
+
static fit(renderable: Renderable | string, options?: PanelOptions): Panel;
|
|
319
|
+
__rich_console__(console: Console, consoleOptions: ConsoleOptions): RenderResult;
|
|
320
|
+
/**
|
|
321
|
+
* Normalize padding to [top, right, bottom, left] format.
|
|
322
|
+
*/
|
|
323
|
+
private normalizePadding;
|
|
324
|
+
/**
|
|
325
|
+
* Render top border with optional title.
|
|
326
|
+
*/
|
|
327
|
+
private renderTopBorder;
|
|
328
|
+
/**
|
|
329
|
+
* Render bottom border with optional subtitle.
|
|
330
|
+
*/
|
|
331
|
+
private renderBottomBorder;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
declare class Rule implements Renderable {
|
|
335
|
+
readonly title: string;
|
|
336
|
+
readonly characters: string;
|
|
337
|
+
readonly style: Style;
|
|
338
|
+
constructor(title?: string, characters?: string, style?: Style);
|
|
339
|
+
__rich_console__(console: Console, options: ConsoleOptions): RenderResult;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/** biome-ignore-all assist/source/organizeImports: biome-ignore assist/source/organizeImports */
|
|
343
|
+
|
|
344
|
+
interface ColumnOptions {
|
|
345
|
+
header?: string;
|
|
346
|
+
footer?: string;
|
|
347
|
+
style?: Style | string;
|
|
348
|
+
headerStyle?: Style | string;
|
|
349
|
+
footerStyle?: Style | string;
|
|
350
|
+
justify?: 'left' | 'center' | 'right';
|
|
351
|
+
vertical?: 'top' | 'middle' | 'bottom';
|
|
352
|
+
width?: number;
|
|
353
|
+
minWidth?: number;
|
|
354
|
+
maxWidth?: number;
|
|
355
|
+
ratio?: number;
|
|
356
|
+
noWrap?: boolean;
|
|
357
|
+
overflow?: 'fold' | 'crop' | 'ellipsis';
|
|
358
|
+
}
|
|
359
|
+
interface TableOptions {
|
|
360
|
+
title?: string;
|
|
361
|
+
caption?: string;
|
|
362
|
+
box?: BoxStyle;
|
|
363
|
+
showHeader?: boolean;
|
|
364
|
+
showFooter?: boolean;
|
|
365
|
+
showEdge?: boolean;
|
|
366
|
+
showLines?: boolean;
|
|
367
|
+
expand?: boolean;
|
|
368
|
+
borderStyle?: Style | string;
|
|
369
|
+
headerStyle?: Style | string;
|
|
370
|
+
footerStyle?: Style | string;
|
|
371
|
+
titleStyle?: Style | string;
|
|
372
|
+
captionStyle?: Style | string;
|
|
373
|
+
rowStyles?: string[];
|
|
374
|
+
padding?: number;
|
|
375
|
+
highlight?: boolean;
|
|
376
|
+
}
|
|
377
|
+
declare class Table implements Renderable {
|
|
378
|
+
readonly options: TableOptions;
|
|
379
|
+
private columns;
|
|
380
|
+
private rows;
|
|
381
|
+
private footerRow;
|
|
382
|
+
constructor(options?: TableOptions);
|
|
383
|
+
addColumn(header: string | ColumnOptions, options?: ColumnOptions): this;
|
|
384
|
+
addRow(...cells: (Renderable | string)[]): this;
|
|
385
|
+
addFooter(...cells: (Renderable | string)[]): this;
|
|
386
|
+
private alignText;
|
|
387
|
+
__rich_console__(console: Console, consoleOptions: ConsoleOptions): RenderResult;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/** biome-ignore-all assist/source/organizeImports: false */
|
|
391
|
+
|
|
392
|
+
interface TreeOptions {
|
|
393
|
+
guideStyle?: string;
|
|
394
|
+
hideRoot?: boolean;
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* Hierarchical tree structure for displaying nested data.
|
|
398
|
+
* Supports any renderable as node content, including Panels, Syntax, and Tables.
|
|
399
|
+
*/
|
|
400
|
+
declare class Tree implements Renderable {
|
|
401
|
+
readonly label: string | Renderable;
|
|
402
|
+
readonly options: TreeOptions;
|
|
403
|
+
private children;
|
|
404
|
+
private guideStyle;
|
|
405
|
+
private guides;
|
|
406
|
+
constructor(label: string | Renderable, options?: TreeOptions);
|
|
407
|
+
/**
|
|
408
|
+
* Add a child node to the tree.
|
|
409
|
+
* Returns the added Tree node for method chaining.
|
|
410
|
+
*/
|
|
411
|
+
add(label: string | Renderable | Tree): Tree;
|
|
412
|
+
__rich_console__(console: Console, options: ConsoleOptions): RenderResult;
|
|
413
|
+
/**
|
|
414
|
+
* Render a label (string or renderable) and add segments.
|
|
415
|
+
*/
|
|
416
|
+
private renderLabel;
|
|
417
|
+
/**
|
|
418
|
+
* Render child nodes with appropriate prefixes.
|
|
419
|
+
*/
|
|
420
|
+
private renderChildren;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
interface LayoutOptions {
|
|
424
|
+
size?: number;
|
|
425
|
+
ratio?: number;
|
|
426
|
+
minimumSize?: number;
|
|
427
|
+
visible?: boolean;
|
|
428
|
+
}
|
|
429
|
+
declare class Layout implements Renderable {
|
|
430
|
+
private _renderable;
|
|
431
|
+
private _children;
|
|
432
|
+
private _direction;
|
|
433
|
+
size: number | undefined;
|
|
434
|
+
ratio: number;
|
|
435
|
+
minimumSize: number;
|
|
436
|
+
visible: boolean;
|
|
437
|
+
constructor(renderable?: Renderable, options?: LayoutOptions);
|
|
438
|
+
/**
|
|
439
|
+
* Split the layout into a row (horizontal split).
|
|
440
|
+
*/
|
|
441
|
+
splitRow(...layouts: (Layout | Renderable)[]): void;
|
|
442
|
+
/**
|
|
443
|
+
* Split the layout into a column (vertical split).
|
|
444
|
+
*/
|
|
445
|
+
splitColumn(...layouts: (Layout | Renderable)[]): void;
|
|
446
|
+
get renderable(): Renderable | null;
|
|
447
|
+
update(renderable: Renderable): void;
|
|
448
|
+
__rich_console__(console: Console, options: ConsoleOptions): RenderResult;
|
|
449
|
+
/**
|
|
450
|
+
* Calculates the size (width for rows, height for columns) for each child
|
|
451
|
+
* based on constraints.
|
|
452
|
+
*/
|
|
453
|
+
private calculateSizes;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
declare class Grid extends Layout {
|
|
457
|
+
constructor();
|
|
458
|
+
/**
|
|
459
|
+
* Adds a row to the grid with optional constraints.
|
|
460
|
+
*/
|
|
461
|
+
addRow(content: Layout | any, options?: LayoutOptions): void;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
type PaddingValue = number | [number, number] | [number, number, number, number];
|
|
465
|
+
declare class Padding implements Renderable {
|
|
466
|
+
renderable: Renderable | string;
|
|
467
|
+
top: number;
|
|
468
|
+
right: number;
|
|
469
|
+
bottom: number;
|
|
470
|
+
left: number;
|
|
471
|
+
constructor(renderable: Renderable | string, padding: PaddingValue);
|
|
472
|
+
__rich_console__(console: Console, options: ConsoleOptions): RenderResult;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
type AlignMethod = 'left' | 'center' | 'right';
|
|
476
|
+
declare class Align implements Renderable {
|
|
477
|
+
renderable: Renderable | string;
|
|
478
|
+
align: AlignMethod;
|
|
479
|
+
style?: any | undefined;
|
|
480
|
+
constructor(renderable: Renderable | string, align: AlignMethod, style?: any | undefined);
|
|
481
|
+
static left(renderable: Renderable | string): Align;
|
|
482
|
+
static center(renderable: Renderable | string): Align;
|
|
483
|
+
static right(renderable: Renderable | string): Align;
|
|
484
|
+
__rich_console__(console: Console, options: ConsoleOptions): RenderResult;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
interface TracebackOptions {
|
|
488
|
+
showLocals?: boolean;
|
|
489
|
+
extraLines?: number;
|
|
490
|
+
theme?: string;
|
|
491
|
+
suppressInternal?: boolean;
|
|
492
|
+
maxFrames?: number;
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* Beautiful error traceback rendering.
|
|
496
|
+
* Displays syntax-highlighted stack traces with optional local variables.
|
|
497
|
+
*/
|
|
498
|
+
declare class Traceback implements Renderable {
|
|
499
|
+
readonly error: Error;
|
|
500
|
+
readonly options: TracebackOptions;
|
|
501
|
+
private frames;
|
|
502
|
+
constructor(error: Error, options?: TracebackOptions);
|
|
503
|
+
__rich_console__(console: Console, consoleOptions: ConsoleOptions): RenderResult;
|
|
504
|
+
}
|
|
505
|
+
/**
|
|
506
|
+
* Install Rich traceback handler as the default for uncaught exceptions.
|
|
507
|
+
*/
|
|
508
|
+
declare function installTracebackHandler(options?: TracebackOptions): void;
|
|
509
|
+
|
|
510
|
+
interface PromptOptions<T> {
|
|
511
|
+
console?: Console;
|
|
512
|
+
password?: boolean;
|
|
513
|
+
choices?: string[];
|
|
514
|
+
default?: T;
|
|
515
|
+
validate?: (input: string) => boolean | string;
|
|
516
|
+
}
|
|
517
|
+
declare class Prompt {
|
|
518
|
+
static ask<T = string>(message: string, options?: PromptOptions<T>): Promise<T>;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
declare class Confirm {
|
|
522
|
+
static ask(message: string, options?: {
|
|
523
|
+
default?: boolean;
|
|
524
|
+
console?: Console;
|
|
525
|
+
}): Promise<boolean>;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
declare function install(consoleOptions?: {}): void;
|
|
529
|
+
|
|
530
|
+
interface SyntaxOptions {
|
|
531
|
+
theme?: string;
|
|
532
|
+
lineNumbers?: boolean;
|
|
533
|
+
startLine?: number;
|
|
534
|
+
highlightLines?: number[];
|
|
535
|
+
wordWrap?: boolean;
|
|
536
|
+
}
|
|
537
|
+
/**
|
|
538
|
+
* Syntax highlighted code renderable.
|
|
539
|
+
* Uses highlight.js for tokenization and applies Rich-style themes.
|
|
540
|
+
*/
|
|
541
|
+
declare class Syntax implements Renderable {
|
|
542
|
+
readonly code: string;
|
|
543
|
+
readonly lexer: string;
|
|
544
|
+
readonly options: SyntaxOptions;
|
|
545
|
+
private readonly syntaxTheme;
|
|
546
|
+
constructor(code: string, lexer: string, options?: SyntaxOptions);
|
|
547
|
+
/**
|
|
548
|
+
* Create Syntax from a file path (convenience method).
|
|
549
|
+
*/
|
|
550
|
+
static fromPath(filePath: string, options?: SyntaxOptions): Syntax;
|
|
551
|
+
__rich_console__(_console: Console, _options: ConsoleOptions): RenderResult;
|
|
552
|
+
/**
|
|
553
|
+
* Parse highlight.js HTML output into styled tokens.
|
|
554
|
+
*/
|
|
555
|
+
private parseHighlightedHtml;
|
|
556
|
+
/**
|
|
557
|
+
* Decode HTML entities to their character equivalents.
|
|
558
|
+
*/
|
|
559
|
+
private decodeHtmlEntities;
|
|
560
|
+
/**
|
|
561
|
+
* Get style for a highlight.js scope/class.
|
|
562
|
+
*/
|
|
563
|
+
private getStyleForScope;
|
|
564
|
+
/**
|
|
565
|
+
* Group tokens by line (split on newlines).
|
|
566
|
+
*/
|
|
567
|
+
private groupTokensByLine;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
interface SyntaxTheme {
|
|
571
|
+
name: string;
|
|
572
|
+
styles: Record<string, Style>;
|
|
573
|
+
background?: string;
|
|
574
|
+
}
|
|
575
|
+
declare const MONOKAI: SyntaxTheme;
|
|
576
|
+
declare const DRACULA: SyntaxTheme;
|
|
577
|
+
declare const GITHUB_LIGHT: SyntaxTheme;
|
|
578
|
+
declare const ONE_DARK: SyntaxTheme;
|
|
579
|
+
declare const SYNTAX_THEMES: Record<string, SyntaxTheme>;
|
|
580
|
+
declare function getTheme(name: string): SyntaxTheme;
|
|
581
|
+
declare const MONOKAI_THEME: {
|
|
582
|
+
keyword: Style;
|
|
583
|
+
string: Style;
|
|
584
|
+
number: Style;
|
|
585
|
+
comment: Style;
|
|
586
|
+
operator: Style;
|
|
587
|
+
function: Style;
|
|
588
|
+
class: Style;
|
|
589
|
+
title: Style;
|
|
590
|
+
};
|
|
591
|
+
|
|
592
|
+
declare class Markdown implements Renderable {
|
|
593
|
+
readonly markup: string;
|
|
594
|
+
constructor(markup: string);
|
|
595
|
+
__rich_console__(_console: Console, _options: ConsoleOptions): RenderResult;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
/** biome-ignore-all assist/source/organizeImports: falses */
|
|
599
|
+
|
|
600
|
+
interface ProgressBarOptions {
|
|
601
|
+
width?: number;
|
|
602
|
+
completeStyle?: string;
|
|
603
|
+
finishedStyle?: string;
|
|
604
|
+
remainingStyle?: string;
|
|
605
|
+
pulseStyle?: string;
|
|
606
|
+
pulse?: boolean;
|
|
607
|
+
completeChar?: string;
|
|
608
|
+
remainingChar?: string;
|
|
609
|
+
}
|
|
610
|
+
/**
|
|
611
|
+
* Visual progress bar component.
|
|
612
|
+
* Supports customizable styles, pulse animation, and gradient colors.
|
|
613
|
+
*/
|
|
614
|
+
declare class ProgressBar implements Renderable {
|
|
615
|
+
readonly total: number;
|
|
616
|
+
readonly completed: number;
|
|
617
|
+
readonly options: ProgressBarOptions;
|
|
618
|
+
private pulseOffset;
|
|
619
|
+
private lastPulseTime;
|
|
620
|
+
constructor(total?: number, completed?: number, options?: ProgressBarOptions);
|
|
621
|
+
__rich_console__(console: Console, consoleOptions: ConsoleOptions): RenderResult;
|
|
622
|
+
}
|
|
623
|
+
/**
|
|
624
|
+
* Compact progress indicator showing percentage.
|
|
625
|
+
*/
|
|
626
|
+
declare class PercentageColumn implements Renderable {
|
|
627
|
+
readonly percentage: number;
|
|
628
|
+
readonly style?: string | undefined;
|
|
629
|
+
constructor(percentage: number, style?: string | undefined);
|
|
630
|
+
__rich_console__(_console: Console, _options: ConsoleOptions): RenderResult;
|
|
631
|
+
}
|
|
632
|
+
/**
|
|
633
|
+
* Time elapsed display for progress tracking.
|
|
634
|
+
*/
|
|
635
|
+
declare class TimeElapsedColumn implements Renderable {
|
|
636
|
+
readonly elapsedMs: number;
|
|
637
|
+
readonly style?: string | undefined;
|
|
638
|
+
constructor(elapsedMs: number, style?: string | undefined);
|
|
639
|
+
__rich_console__(_console: Console, _options: ConsoleOptions): RenderResult;
|
|
640
|
+
}
|
|
641
|
+
/**
|
|
642
|
+
* Estimated time remaining display.
|
|
643
|
+
*/
|
|
644
|
+
declare class TimeRemainingColumn implements Renderable {
|
|
645
|
+
readonly percentage: number;
|
|
646
|
+
readonly elapsedMs: number;
|
|
647
|
+
readonly style?: string | undefined;
|
|
648
|
+
constructor(percentage: number, elapsedMs: number, style?: string | undefined);
|
|
649
|
+
__rich_console__(_console: Console, _options: ConsoleOptions): RenderResult;
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
interface ProgressOptions {
|
|
653
|
+
console?: Console;
|
|
654
|
+
autoRefresh?: boolean;
|
|
655
|
+
}
|
|
656
|
+
declare class Progress {
|
|
657
|
+
private tasks;
|
|
658
|
+
private live;
|
|
659
|
+
private console;
|
|
660
|
+
private taskIdCounter;
|
|
661
|
+
constructor(options?: ProgressOptions);
|
|
662
|
+
addTask(description: string, options?: {
|
|
663
|
+
total?: number;
|
|
664
|
+
completed?: number;
|
|
665
|
+
}): number;
|
|
666
|
+
update(taskId: number, options: {
|
|
667
|
+
completed?: number;
|
|
668
|
+
description?: string;
|
|
669
|
+
}): void;
|
|
670
|
+
start(): void;
|
|
671
|
+
stop(): void;
|
|
672
|
+
private refresh;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
/**
|
|
676
|
+
* Track progress of an iterable.
|
|
677
|
+
*/
|
|
678
|
+
declare function track<T>(sequence: Iterable<T> | T[], description?: string): Generator<T>;
|
|
679
|
+
|
|
680
|
+
type SpinnerName = keyof typeof cliSpinners;
|
|
681
|
+
declare class Spinner implements Renderable {
|
|
682
|
+
readonly name: SpinnerName;
|
|
683
|
+
readonly style: Style;
|
|
684
|
+
private frame;
|
|
685
|
+
private readonly spinner;
|
|
686
|
+
constructor(name?: SpinnerName, style?: Style);
|
|
687
|
+
get currentFrame(): string;
|
|
688
|
+
__rich_console__(_console: Console, _options: ConsoleOptions): RenderResult;
|
|
689
|
+
nextFrame(): void;
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
declare class Color {
|
|
693
|
+
private tc;
|
|
694
|
+
constructor(color: string | tinycolor.ColorInput);
|
|
695
|
+
static parse(color: string): Color;
|
|
696
|
+
get hex(): string;
|
|
697
|
+
get rgb(): {
|
|
698
|
+
r: number;
|
|
699
|
+
g: number;
|
|
700
|
+
b: number;
|
|
701
|
+
};
|
|
702
|
+
get isDark(): boolean;
|
|
703
|
+
get isLight(): boolean;
|
|
704
|
+
contrast(other: Color): number;
|
|
705
|
+
lighten(amount?: number): Color;
|
|
706
|
+
darken(amount?: number): Color;
|
|
707
|
+
/**
|
|
708
|
+
* Returns a readable foreground color (black or white) for this background color.
|
|
709
|
+
*/
|
|
710
|
+
getContrastColor(): Color;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
714
|
+
interface LogRecord {
|
|
715
|
+
level: LogLevel;
|
|
716
|
+
message: string;
|
|
717
|
+
timestamp: Date;
|
|
718
|
+
context?: Record<string, any>;
|
|
719
|
+
}
|
|
720
|
+
declare class RichHandler {
|
|
721
|
+
private console;
|
|
722
|
+
constructor(console?: Console);
|
|
723
|
+
handle(record: LogRecord): void;
|
|
724
|
+
private getLevelStyle;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
declare class Logger {
|
|
728
|
+
private handler;
|
|
729
|
+
constructor(console?: Console);
|
|
730
|
+
debug(message: string, context?: Record<string, any>): void;
|
|
731
|
+
info(message: string, context?: Record<string, any>): void;
|
|
732
|
+
warn(message: string, context?: Record<string, any>): void;
|
|
733
|
+
error(message: string, context?: Record<string, any>): void;
|
|
734
|
+
private log;
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
interface InspectOptions {
|
|
738
|
+
title?: string;
|
|
739
|
+
depth?: number;
|
|
740
|
+
private?: boolean;
|
|
741
|
+
}
|
|
742
|
+
/**
|
|
743
|
+
* Inspects an object and prints a formatted representation.
|
|
744
|
+
*/
|
|
745
|
+
declare function inspect(obj: any, options?: InspectOptions): void;
|
|
746
|
+
|
|
747
|
+
/** biome-ignore-all assist/source/organizeImports: biome-ignore assist/source/organizeImports */
|
|
748
|
+
|
|
749
|
+
declare const print: (...objects: any[]) => void;
|
|
750
|
+
|
|
751
|
+
export { Align, type BoxData, type BoxStyle, Color, type ColorSystem, Confirm, Console, type ConsoleOptions, DEFAULT_THEME, DRACULA, GITHUB_LIGHT, Grid, Layout, Logger, MONOKAI, MONOKAI_THEME, Markdown, MarkupParser, ONE_DARK, Padding, Palette, Panel, PercentageColumn, Progress, ProgressBar, Prompt, type RGB, type RenderResult, type Renderable, RichHandler, Rule, SYNTAX_THEMES, Segment, Spinner, type StandardColor, Status, Style, type StyleOptions, Syntax, type SyntaxTheme, Table, Text, Theme, TimeElapsedColumn, TimeRemainingColumn, Traceback, Tree, getBox, getTheme, inspect, install, installTracebackHandler, isRenderable, listBoxStyles, print, track };
|