@mdxui/terminal 2.0.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 +571 -0
- package/dist/ansi-css-Sk5mWtdK.d.ts +119 -0
- package/dist/ansi-css-V6JIHGsM.d.ts +119 -0
- package/dist/ansi-css-_3eSEU9d.d.ts +119 -0
- package/dist/chunk-3EFDH7PK.js +5235 -0
- package/dist/chunk-3RG5ZIWI.js +10 -0
- package/dist/chunk-3X5IR6WE.js +884 -0
- package/dist/chunk-4FV5ZDCE.js +5236 -0
- package/dist/chunk-4OVMSF2J.js +243 -0
- package/dist/chunk-63FEETIS.js +4048 -0
- package/dist/chunk-B43KP7XJ.js +884 -0
- package/dist/chunk-BMTJXWUV.js +655 -0
- package/dist/chunk-C3SVH4N7.js +882 -0
- package/dist/chunk-EVWR7Y47.js +874 -0
- package/dist/chunk-F6A5VWUC.js +1285 -0
- package/dist/chunk-FD7KW7GE.js +882 -0
- package/dist/chunk-GBQ6UD6I.js +655 -0
- package/dist/chunk-GMDD3M6U.js +5227 -0
- package/dist/chunk-JBHRXOXM.js +1058 -0
- package/dist/chunk-JFOO3EYO.js +1182 -0
- package/dist/chunk-JQ5H3WXL.js +1291 -0
- package/dist/chunk-JQD5NASE.js +234 -0
- package/dist/chunk-KRHJP5R7.js +592 -0
- package/dist/chunk-KWF6WVJE.js +962 -0
- package/dist/chunk-LHYQVN3H.js +1038 -0
- package/dist/chunk-M3TLQLGC.js +1032 -0
- package/dist/chunk-MVW4Q5OP.js +240 -0
- package/dist/chunk-NXCZSWLU.js +1294 -0
- package/dist/chunk-O25TNRO6.js +607 -0
- package/dist/chunk-PNECDA2I.js +884 -0
- package/dist/chunk-QIHWRLJR.js +962 -0
- package/dist/chunk-QW5YMQ7K.js +882 -0
- package/dist/chunk-R5U7XKVJ.js +16 -0
- package/dist/chunk-RP2MVQLR.js +962 -0
- package/dist/chunk-TP6RXGXA.js +1087 -0
- package/dist/chunk-TQQSTITZ.js +655 -0
- package/dist/chunk-X24GWXQV.js +1281 -0
- package/dist/components/index.d.ts +802 -0
- package/dist/components/index.js +149 -0
- package/dist/data/index.d.ts +2554 -0
- package/dist/data/index.js +51 -0
- package/dist/forms/index.d.ts +1596 -0
- package/dist/forms/index.js +464 -0
- package/dist/index-CQRFZntR.d.ts +867 -0
- package/dist/index.d.ts +579 -0
- package/dist/index.js +786 -0
- package/dist/interactive-D0JkWosD.d.ts +217 -0
- package/dist/keyboard/index.d.ts +2 -0
- package/dist/keyboard/index.js +43 -0
- package/dist/renderers/index.d.ts +546 -0
- package/dist/renderers/index.js +2157 -0
- package/dist/storybook/index.d.ts +396 -0
- package/dist/storybook/index.js +641 -0
- package/dist/theme/index.d.ts +1339 -0
- package/dist/theme/index.js +123 -0
- package/dist/types-Bxu5PAgA.d.ts +710 -0
- package/dist/types-CIlop5Ji.d.ts +701 -0
- package/dist/types-Ca8p_p5X.d.ts +710 -0
- package/package.json +90 -0
- package/src/__tests__/components/data/card.test.ts +458 -0
- package/src/__tests__/components/data/list.test.ts +473 -0
- package/src/__tests__/components/data/metrics.test.ts +541 -0
- package/src/__tests__/components/data/table.test.ts +448 -0
- package/src/__tests__/components/input/field.test.ts +555 -0
- package/src/__tests__/components/input/form.test.ts +870 -0
- package/src/__tests__/components/input/search.test.ts +1238 -0
- package/src/__tests__/components/input/select.test.ts +658 -0
- package/src/__tests__/components/navigation/breadcrumb.test.ts +923 -0
- package/src/__tests__/components/navigation/command-palette.test.ts +1095 -0
- package/src/__tests__/components/navigation/sidebar.test.ts +1018 -0
- package/src/__tests__/components/navigation/tabs.test.ts +995 -0
- package/src/__tests__/components.test.tsx +1197 -0
- package/src/__tests__/core/compiler.test.ts +986 -0
- package/src/__tests__/core/parser.test.ts +785 -0
- package/src/__tests__/core/tier-switcher.test.ts +1103 -0
- package/src/__tests__/core/types.test.ts +1398 -0
- package/src/__tests__/data/collections.test.ts +1337 -0
- package/src/__tests__/data/db.test.ts +1265 -0
- package/src/__tests__/data/reactive.test.ts +1010 -0
- package/src/__tests__/data/sync.test.ts +1614 -0
- package/src/__tests__/errors.test.ts +660 -0
- package/src/__tests__/forms/integration.test.ts +444 -0
- package/src/__tests__/integration.test.ts +905 -0
- package/src/__tests__/keyboard.test.ts +1791 -0
- package/src/__tests__/renderer.test.ts +489 -0
- package/src/__tests__/renderers/ansi-css.test.ts +948 -0
- package/src/__tests__/renderers/ansi.test.ts +1366 -0
- package/src/__tests__/renderers/ascii.test.ts +1360 -0
- package/src/__tests__/renderers/interactive.test.ts +2353 -0
- package/src/__tests__/renderers/markdown.test.ts +1483 -0
- package/src/__tests__/renderers/text.test.ts +1369 -0
- package/src/__tests__/renderers/unicode.test.ts +1307 -0
- package/src/__tests__/theme.test.ts +639 -0
- package/src/__tests__/utils/assertions.ts +685 -0
- package/src/__tests__/utils/index.ts +115 -0
- package/src/__tests__/utils/test-renderer.ts +381 -0
- package/src/__tests__/utils/utils.test.ts +560 -0
- package/src/components/containers/card.ts +56 -0
- package/src/components/containers/dialog.ts +53 -0
- package/src/components/containers/index.ts +9 -0
- package/src/components/containers/panel.ts +59 -0
- package/src/components/feedback/badge.ts +40 -0
- package/src/components/feedback/index.ts +8 -0
- package/src/components/feedback/spinner.ts +23 -0
- package/src/components/helpers.ts +81 -0
- package/src/components/index.ts +153 -0
- package/src/components/layout/breadcrumb.ts +31 -0
- package/src/components/layout/index.ts +10 -0
- package/src/components/layout/list.ts +29 -0
- package/src/components/layout/sidebar.ts +79 -0
- package/src/components/layout/table.ts +62 -0
- package/src/components/primitives/box.ts +95 -0
- package/src/components/primitives/button.ts +54 -0
- package/src/components/primitives/index.ts +11 -0
- package/src/components/primitives/input.ts +88 -0
- package/src/components/primitives/select.ts +97 -0
- package/src/components/primitives/text.ts +60 -0
- package/src/components/render.ts +155 -0
- package/src/components/templates/app.ts +43 -0
- package/src/components/templates/index.ts +8 -0
- package/src/components/templates/site.ts +54 -0
- package/src/components/types.ts +777 -0
- package/src/core/compiler.ts +718 -0
- package/src/core/parser.ts +127 -0
- package/src/core/tier-switcher.ts +607 -0
- package/src/core/types.ts +672 -0
- package/src/data/collection.ts +316 -0
- package/src/data/collections.ts +50 -0
- package/src/data/context.tsx +174 -0
- package/src/data/db.ts +127 -0
- package/src/data/hooks.ts +532 -0
- package/src/data/index.ts +138 -0
- package/src/data/reactive.ts +1225 -0
- package/src/data/saas-collections.ts +375 -0
- package/src/data/sync.ts +1213 -0
- package/src/data/types.ts +660 -0
- package/src/forms/converters.ts +512 -0
- package/src/forms/index.ts +133 -0
- package/src/forms/schemas.ts +403 -0
- package/src/forms/types.ts +476 -0
- package/src/index.ts +542 -0
- package/src/keyboard/focus.ts +748 -0
- package/src/keyboard/index.ts +96 -0
- package/src/keyboard/integration.ts +371 -0
- package/src/keyboard/manager.ts +377 -0
- package/src/keyboard/presets.ts +90 -0
- package/src/renderers/ansi-css.ts +576 -0
- package/src/renderers/ansi.ts +802 -0
- package/src/renderers/ascii.ts +680 -0
- package/src/renderers/breadcrumb.ts +480 -0
- package/src/renderers/command-palette.ts +802 -0
- package/src/renderers/components/field.ts +210 -0
- package/src/renderers/components/form.ts +327 -0
- package/src/renderers/components/index.ts +21 -0
- package/src/renderers/components/search.ts +449 -0
- package/src/renderers/components/select.ts +222 -0
- package/src/renderers/index.ts +101 -0
- package/src/renderers/interactive/component-handlers.ts +622 -0
- package/src/renderers/interactive/cursor-manager.ts +147 -0
- package/src/renderers/interactive/focus-manager.ts +279 -0
- package/src/renderers/interactive/index.ts +661 -0
- package/src/renderers/interactive/input-handler.ts +164 -0
- package/src/renderers/interactive/keyboard-handler.ts +212 -0
- package/src/renderers/interactive/mouse-handler.ts +167 -0
- package/src/renderers/interactive/state-manager.ts +109 -0
- package/src/renderers/interactive/types.ts +338 -0
- package/src/renderers/interactive-string.ts +299 -0
- package/src/renderers/interactive.ts +59 -0
- package/src/renderers/markdown.ts +950 -0
- package/src/renderers/sidebar.ts +549 -0
- package/src/renderers/tabs.ts +682 -0
- package/src/renderers/text.ts +791 -0
- package/src/renderers/unicode.ts +917 -0
- package/src/renderers/utils.ts +942 -0
- package/src/router/adapters.ts +383 -0
- package/src/router/types.ts +140 -0
- package/src/router/utils.ts +452 -0
- package/src/schemas.ts +205 -0
- package/src/storybook/index.ts +91 -0
- package/src/storybook/interactive-decorator.tsx +659 -0
- package/src/storybook/keyboard-simulator.ts +501 -0
- package/src/theme/ansi-codes.ts +80 -0
- package/src/theme/box-drawing.ts +132 -0
- package/src/theme/color-convert.ts +254 -0
- package/src/theme/color-support.ts +321 -0
- package/src/theme/index.ts +134 -0
- package/src/theme/strip-ansi.ts +50 -0
- package/src/theme/tailwind-map.ts +469 -0
- package/src/theme/text-styles.ts +206 -0
- package/src/theme/theme-system.ts +568 -0
- package/src/types.ts +103 -0
|
@@ -0,0 +1,1339 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* ANSI Escape Code Constants
|
|
5
|
+
*
|
|
6
|
+
* Standard ANSI escape sequences for terminal text styling.
|
|
7
|
+
* These codes work in all terminals that support ANSI escape codes.
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* ANSI escape code constants for terminal styling.
|
|
13
|
+
*
|
|
14
|
+
* Includes:
|
|
15
|
+
* - Reset code to clear all styles
|
|
16
|
+
* - Text styling (bold, dim, italic, underline, strikethrough)
|
|
17
|
+
* - Standard 8 foreground colors (black through white)
|
|
18
|
+
* - Bright variants of all 8 foreground colors
|
|
19
|
+
* - Standard 8 background colors
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```tsx
|
|
23
|
+
* // Apply bold cyan text
|
|
24
|
+
* console.log(`${ANSI.bold}${ANSI.cyan}Hello${ANSI.reset}`)
|
|
25
|
+
*
|
|
26
|
+
* // Use with styled helper
|
|
27
|
+
* console.log(styled('Error!', ANSI.bold, ANSI.red))
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
declare const ANSI: {
|
|
31
|
+
readonly reset: "\u001B[0m";
|
|
32
|
+
readonly bold: "\u001B[1m";
|
|
33
|
+
readonly dim: "\u001B[2m";
|
|
34
|
+
readonly italic: "\u001B[3m";
|
|
35
|
+
readonly underline: "\u001B[4m";
|
|
36
|
+
readonly inverse: "\u001B[7m";
|
|
37
|
+
readonly strikethrough: "\u001B[9m";
|
|
38
|
+
readonly black: "\u001B[30m";
|
|
39
|
+
readonly red: "\u001B[31m";
|
|
40
|
+
readonly green: "\u001B[32m";
|
|
41
|
+
readonly yellow: "\u001B[33m";
|
|
42
|
+
readonly blue: "\u001B[34m";
|
|
43
|
+
readonly magenta: "\u001B[35m";
|
|
44
|
+
readonly cyan: "\u001B[36m";
|
|
45
|
+
readonly white: "\u001B[37m";
|
|
46
|
+
readonly brightBlack: "\u001B[90m";
|
|
47
|
+
readonly brightRed: "\u001B[91m";
|
|
48
|
+
readonly brightGreen: "\u001B[92m";
|
|
49
|
+
readonly brightYellow: "\u001B[93m";
|
|
50
|
+
readonly brightBlue: "\u001B[94m";
|
|
51
|
+
readonly brightMagenta: "\u001B[95m";
|
|
52
|
+
readonly brightCyan: "\u001B[96m";
|
|
53
|
+
readonly brightWhite: "\u001B[97m";
|
|
54
|
+
readonly bgBlack: "\u001B[40m";
|
|
55
|
+
readonly bgRed: "\u001B[41m";
|
|
56
|
+
readonly bgGreen: "\u001B[42m";
|
|
57
|
+
readonly bgYellow: "\u001B[43m";
|
|
58
|
+
readonly bgBlue: "\u001B[44m";
|
|
59
|
+
readonly bgMagenta: "\u001B[45m";
|
|
60
|
+
readonly bgCyan: "\u001B[46m";
|
|
61
|
+
readonly bgWhite: "\u001B[47m";
|
|
62
|
+
readonly bgBrightBlack: "\u001B[100m";
|
|
63
|
+
readonly bgBrightRed: "\u001B[101m";
|
|
64
|
+
readonly bgBrightGreen: "\u001B[102m";
|
|
65
|
+
readonly bgBrightYellow: "\u001B[103m";
|
|
66
|
+
readonly bgBrightBlue: "\u001B[104m";
|
|
67
|
+
readonly bgBrightMagenta: "\u001B[105m";
|
|
68
|
+
readonly bgBrightCyan: "\u001B[106m";
|
|
69
|
+
readonly bgBrightWhite: "\u001B[107m";
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Parse hex color to RGB values.
|
|
74
|
+
*
|
|
75
|
+
* Handles edge cases:
|
|
76
|
+
* - Empty string returns black (0, 0, 0)
|
|
77
|
+
* - Invalid hex returns black (0, 0, 0)
|
|
78
|
+
* - Supports with/without # prefix
|
|
79
|
+
* - Supports 3-character shorthand (#fff)
|
|
80
|
+
*/
|
|
81
|
+
declare function hexToRgb(hex: string): {
|
|
82
|
+
r: number;
|
|
83
|
+
g: number;
|
|
84
|
+
b: number;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Options for RGB to ANSI conversion.
|
|
88
|
+
*/
|
|
89
|
+
interface RgbToAnsiOptions {
|
|
90
|
+
/** If true, generates background color code; otherwise foreground */
|
|
91
|
+
background?: boolean;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Converts RGB color values to an ANSI 256 escape sequence.
|
|
95
|
+
*
|
|
96
|
+
* @param r - Red component (0-255)
|
|
97
|
+
* @param g - Green component (0-255)
|
|
98
|
+
* @param b - Blue component (0-255)
|
|
99
|
+
* @param opts - Optional settings for background/foreground
|
|
100
|
+
* @returns ANSI escape sequence string
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```tsx
|
|
104
|
+
* // Coral foreground color
|
|
105
|
+
* console.log(`${rgbToAnsi(255, 127, 80)}Coral text${ANSI.reset}`)
|
|
106
|
+
*
|
|
107
|
+
* // Blue background
|
|
108
|
+
* console.log(`${rgbToAnsi(0, 0, 255, { background: true })}Blue bg${ANSI.reset}`)
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
declare function rgbToAnsi(r: number, g: number, b: number, opts?: RgbToAnsiOptions): string;
|
|
112
|
+
/**
|
|
113
|
+
* Converts a hex color string to an ANSI 256 escape sequence.
|
|
114
|
+
*
|
|
115
|
+
* Supports both 3-character (#RGB) and 6-character (#RRGGBB) hex formats.
|
|
116
|
+
* The '#' prefix is optional.
|
|
117
|
+
*
|
|
118
|
+
* @param hex - Hex color string (e.g., '#ff7f50', 'ff7f50', '#f00')
|
|
119
|
+
* @param opts - Optional settings for background/foreground
|
|
120
|
+
* @returns ANSI escape sequence string
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```tsx
|
|
124
|
+
* // Tomato red foreground
|
|
125
|
+
* console.log(`${hexToAnsi('#ff6347')}Tomato${ANSI.reset}`)
|
|
126
|
+
*
|
|
127
|
+
* // Short-form hex with background
|
|
128
|
+
* console.log(`${hexToAnsi('#f00', { background: true })}Red bg${ANSI.reset}`)
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
131
|
+
declare function hexToAnsi(hex: string, opts?: RgbToAnsiOptions): string;
|
|
132
|
+
/**
|
|
133
|
+
* Generate ANSI 256-color foreground escape code.
|
|
134
|
+
*
|
|
135
|
+
* @param n - ANSI 256 color code (0-255)
|
|
136
|
+
* @returns ANSI escape sequence string
|
|
137
|
+
* @throws {ZodError} If n is not a valid ANSI 256 code (0-255)
|
|
138
|
+
*/
|
|
139
|
+
declare function ansi256(n: number): string;
|
|
140
|
+
/**
|
|
141
|
+
* Generate ANSI 256-color background escape code.
|
|
142
|
+
*
|
|
143
|
+
* @param n - ANSI 256 color code (0-255)
|
|
144
|
+
* @returns ANSI escape sequence string
|
|
145
|
+
* @throws {ZodError} If n is not a valid ANSI 256 code (0-255)
|
|
146
|
+
*/
|
|
147
|
+
declare function ansi256Bg(n: number): string;
|
|
148
|
+
/**
|
|
149
|
+
* Generate true color (24-bit) foreground escape code.
|
|
150
|
+
*
|
|
151
|
+
* @param r - Red component (0-255)
|
|
152
|
+
* @param g - Green component (0-255)
|
|
153
|
+
* @param b - Blue component (0-255)
|
|
154
|
+
* @returns ANSI escape sequence string
|
|
155
|
+
* @throws {ZodError} If any component is not in range 0-255
|
|
156
|
+
*/
|
|
157
|
+
declare function rgb(r: number, g: number, b: number): string;
|
|
158
|
+
/**
|
|
159
|
+
* Generate true color (24-bit) background escape code.
|
|
160
|
+
*
|
|
161
|
+
* @param r - Red component (0-255)
|
|
162
|
+
* @param g - Green component (0-255)
|
|
163
|
+
* @param b - Blue component (0-255)
|
|
164
|
+
* @returns ANSI escape sequence string
|
|
165
|
+
* @throws {ZodError} If any component is not in range 0-255
|
|
166
|
+
*/
|
|
167
|
+
declare function rgbBg(r: number, g: number, b: number): string;
|
|
168
|
+
/**
|
|
169
|
+
* Generate true color foreground from hex color.
|
|
170
|
+
*
|
|
171
|
+
* @param color - Hex color string (#RGB, RGB, #RRGGBB, or RRGGBB)
|
|
172
|
+
* @returns ANSI escape sequence string
|
|
173
|
+
* @throws {ZodError} If color is not a valid hex color format
|
|
174
|
+
*/
|
|
175
|
+
declare function hex(color: string): string;
|
|
176
|
+
/**
|
|
177
|
+
* Generate true color background from hex color.
|
|
178
|
+
*
|
|
179
|
+
* @param color - Hex color string (#RGB, RGB, #RRGGBB, or RRGGBB)
|
|
180
|
+
* @returns ANSI escape sequence string
|
|
181
|
+
* @throws {ZodError} If color is not a valid hex color format
|
|
182
|
+
*/
|
|
183
|
+
declare function hexBg(color: string): string;
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Tailwind CSS to ANSI Color Mapping
|
|
187
|
+
*
|
|
188
|
+
* Converts Tailwind CSS class names to ANSI escape sequences for terminal output.
|
|
189
|
+
* Supports text colors, background colors, and font styles.
|
|
190
|
+
*
|
|
191
|
+
* @module
|
|
192
|
+
*/
|
|
193
|
+
/**
|
|
194
|
+
* Tailwind color hex values for all standard colors and shades.
|
|
195
|
+
*/
|
|
196
|
+
declare const TAILWIND_COLORS: Record<string, Record<string, string>>;
|
|
197
|
+
/**
|
|
198
|
+
* Converts a single Tailwind CSS class to an ANSI 256 escape sequence.
|
|
199
|
+
*
|
|
200
|
+
* Supports:
|
|
201
|
+
* - Text colors: `text-{color}-{shade}`, `text-white`, `text-black`
|
|
202
|
+
* - Background colors: `bg-{color}-{shade}`
|
|
203
|
+
* - Font styles: `font-bold`, `italic`, `underline`, `line-through`
|
|
204
|
+
*
|
|
205
|
+
* @param className - A single Tailwind CSS class name
|
|
206
|
+
* @returns ANSI escape sequence, or empty string if class is not recognized
|
|
207
|
+
*
|
|
208
|
+
* @example
|
|
209
|
+
* ```tsx
|
|
210
|
+
* const blue = tailwindToAnsi('text-blue-500')
|
|
211
|
+
* const bold = tailwindToAnsi('font-bold')
|
|
212
|
+
* console.log(`${blue}${bold}Styled text${ANSI.reset}`)
|
|
213
|
+
* ```
|
|
214
|
+
*/
|
|
215
|
+
declare function tailwindToAnsi(className: string): string;
|
|
216
|
+
/**
|
|
217
|
+
* Converts multiple Tailwind CSS classes to ANSI escape codes.
|
|
218
|
+
*
|
|
219
|
+
* Takes a space-separated string of Tailwind classes and returns
|
|
220
|
+
* the combined ANSI escape codes.
|
|
221
|
+
*
|
|
222
|
+
* @deprecated Use {@link tailwindToAnsi} for single classes,
|
|
223
|
+
* or use the theme system for semantic colors.
|
|
224
|
+
*
|
|
225
|
+
* @param classes - Space-separated Tailwind class names
|
|
226
|
+
* @returns Combined ANSI escape codes
|
|
227
|
+
*
|
|
228
|
+
* @example
|
|
229
|
+
* ```tsx
|
|
230
|
+
* const codes = tailwindToTerminal('text-primary font-bold')
|
|
231
|
+
* console.log(`${codes}Styled text${ANSI.reset}`)
|
|
232
|
+
* ```
|
|
233
|
+
*/
|
|
234
|
+
declare function tailwindToTerminal(classes: string): string;
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Theme System
|
|
238
|
+
*
|
|
239
|
+
* Terminal theme creation, composition, and management utilities.
|
|
240
|
+
* Provides dark/light mode themes with semantic color tokens.
|
|
241
|
+
*
|
|
242
|
+
* All public APIs include runtime validation via Zod schemas.
|
|
243
|
+
*
|
|
244
|
+
* @module
|
|
245
|
+
*/
|
|
246
|
+
/**
|
|
247
|
+
* Color tokens for a terminal theme.
|
|
248
|
+
*
|
|
249
|
+
* All values are ANSI escape sequences that can be directly concatenated
|
|
250
|
+
* with text to apply styling.
|
|
251
|
+
*/
|
|
252
|
+
interface TerminalThemeColors {
|
|
253
|
+
/** Primary brand/accent color for key UI elements */
|
|
254
|
+
primary: string;
|
|
255
|
+
/** Secondary color for less prominent elements */
|
|
256
|
+
secondary: string;
|
|
257
|
+
/** Accent color for highlights and special elements */
|
|
258
|
+
accent: string;
|
|
259
|
+
/** Muted/dimmed color for less important text */
|
|
260
|
+
muted: string;
|
|
261
|
+
/** Success state indicator (green) */
|
|
262
|
+
success: string;
|
|
263
|
+
/** Warning state indicator (yellow/orange) */
|
|
264
|
+
warning: string;
|
|
265
|
+
/** Error state indicator (red) */
|
|
266
|
+
error: string;
|
|
267
|
+
/** Informational state indicator (blue) */
|
|
268
|
+
info: string;
|
|
269
|
+
/** Border/divider color */
|
|
270
|
+
border: string;
|
|
271
|
+
/** Background color (usually includes background escape) */
|
|
272
|
+
background: string;
|
|
273
|
+
/** Default text/foreground color */
|
|
274
|
+
foreground: string;
|
|
275
|
+
/** Selection/highlight background */
|
|
276
|
+
selection: string;
|
|
277
|
+
/** Focus indicator color */
|
|
278
|
+
focus: string;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* A complete terminal theme with color mode and color tokens.
|
|
282
|
+
*
|
|
283
|
+
* @example
|
|
284
|
+
* ```tsx
|
|
285
|
+
* const theme = createTerminalTheme({ mode: 'dark' })
|
|
286
|
+
* console.log(`${theme.colors.primary}Primary text${ANSI.reset}`)
|
|
287
|
+
* ```
|
|
288
|
+
*/
|
|
289
|
+
interface TerminalTheme {
|
|
290
|
+
/** Color mode: 'dark' or 'light' */
|
|
291
|
+
mode: 'dark' | 'light';
|
|
292
|
+
/** Color token values */
|
|
293
|
+
colors: TerminalThemeColors;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Legacy theme interface for backward compatibility.
|
|
297
|
+
*
|
|
298
|
+
* @deprecated Use {@link TerminalTheme} with {@link createTerminalTheme} instead.
|
|
299
|
+
*/
|
|
300
|
+
interface LegacyTerminalTheme {
|
|
301
|
+
primary: string;
|
|
302
|
+
secondary: string;
|
|
303
|
+
accent: string;
|
|
304
|
+
muted: string;
|
|
305
|
+
success: string;
|
|
306
|
+
warning: string;
|
|
307
|
+
error: string;
|
|
308
|
+
info: string;
|
|
309
|
+
border: string;
|
|
310
|
+
background: string;
|
|
311
|
+
foreground: string;
|
|
312
|
+
selection: string;
|
|
313
|
+
focus: string;
|
|
314
|
+
}
|
|
315
|
+
interface LegacyTerminalThemeWithExtras extends LegacyTerminalTheme {
|
|
316
|
+
typography?: {
|
|
317
|
+
headingWeight: string;
|
|
318
|
+
bodyWeight: string;
|
|
319
|
+
codeFont: string;
|
|
320
|
+
};
|
|
321
|
+
spacing?: {
|
|
322
|
+
xs: number;
|
|
323
|
+
sm: number;
|
|
324
|
+
md: number;
|
|
325
|
+
lg: number;
|
|
326
|
+
xl: number;
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Options for creating a terminal theme.
|
|
331
|
+
*/
|
|
332
|
+
interface CreateTerminalThemeOptions {
|
|
333
|
+
/** Color mode: 'dark' (default) or 'light' */
|
|
334
|
+
mode?: 'dark' | 'light';
|
|
335
|
+
/** Custom color overrides */
|
|
336
|
+
colors?: Partial<TerminalThemeColors>;
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Creates a terminal theme with dark or light mode base colors.
|
|
340
|
+
*
|
|
341
|
+
* Provides sensible defaults for all color tokens based on the selected mode,
|
|
342
|
+
* with optional overrides for individual colors.
|
|
343
|
+
*
|
|
344
|
+
* @param options - Theme creation options
|
|
345
|
+
* @returns A complete terminal theme object
|
|
346
|
+
* @throws {ZodError} If options are invalid (invalid mode or color format)
|
|
347
|
+
*
|
|
348
|
+
* @example
|
|
349
|
+
* ```tsx
|
|
350
|
+
* // Dark theme with defaults
|
|
351
|
+
* const darkTheme = createTerminalTheme({ mode: 'dark' })
|
|
352
|
+
*
|
|
353
|
+
* // Light theme with custom primary color
|
|
354
|
+
* const customTheme = createTerminalTheme({
|
|
355
|
+
* mode: 'light',
|
|
356
|
+
* colors: { primary: '\x1b[38;5;27m' }
|
|
357
|
+
* })
|
|
358
|
+
* ```
|
|
359
|
+
*/
|
|
360
|
+
declare function createTerminalTheme(options: CreateTerminalThemeOptions): TerminalTheme;
|
|
361
|
+
/**
|
|
362
|
+
* Gets a color value from a theme by its key name.
|
|
363
|
+
*
|
|
364
|
+
* @param theme - The terminal theme to get the color from
|
|
365
|
+
* @param key - The color key (e.g., 'primary', 'error')
|
|
366
|
+
* @param fallback - Optional fallback if the key is not found
|
|
367
|
+
* @returns The ANSI color escape sequence
|
|
368
|
+
* @throws If key is not found and no fallback is provided
|
|
369
|
+
*
|
|
370
|
+
* @example
|
|
371
|
+
* ```tsx
|
|
372
|
+
* const theme = createTerminalTheme({ mode: 'dark' })
|
|
373
|
+
* const errorColor = getThemeColor(theme, 'error')
|
|
374
|
+
* console.log(`${errorColor}Error message${ANSI.reset}`)
|
|
375
|
+
* ```
|
|
376
|
+
*/
|
|
377
|
+
declare function getThemeColor(theme: TerminalTheme, key: keyof TerminalThemeColors, fallback?: string): string;
|
|
378
|
+
/**
|
|
379
|
+
* Maps a CSS custom property name to its ANSI theme color.
|
|
380
|
+
*
|
|
381
|
+
* Useful for converting web-based CSS variable references to terminal colors.
|
|
382
|
+
*
|
|
383
|
+
* @param cssVar - CSS variable name (e.g., '--primary', '--error')
|
|
384
|
+
* @param theme - The terminal theme to look up colors from
|
|
385
|
+
* @returns ANSI escape sequence, or empty string if not found
|
|
386
|
+
*
|
|
387
|
+
* @example
|
|
388
|
+
* ```tsx
|
|
389
|
+
* const theme = createTerminalTheme({ mode: 'dark' })
|
|
390
|
+
* const primary = cssVarToAnsi('--primary', theme)
|
|
391
|
+
* const error = cssVarToAnsi('--destructive', theme) // maps to error
|
|
392
|
+
* ```
|
|
393
|
+
*/
|
|
394
|
+
declare function cssVarToAnsi(cssVar: string, theme: TerminalTheme): string;
|
|
395
|
+
/**
|
|
396
|
+
* Applies a theme color to text with automatic reset.
|
|
397
|
+
*
|
|
398
|
+
* A convenience function that wraps text with a theme color and
|
|
399
|
+
* appends the reset code.
|
|
400
|
+
*
|
|
401
|
+
* @param text - The text to style
|
|
402
|
+
* @param theme - The terminal theme to use
|
|
403
|
+
* @param styleKey - The theme color key to apply
|
|
404
|
+
* @returns Styled text with ANSI codes
|
|
405
|
+
*
|
|
406
|
+
* @example
|
|
407
|
+
* ```tsx
|
|
408
|
+
* const theme = createTerminalTheme({ mode: 'dark' })
|
|
409
|
+
* console.log(applyThemeStyles('Error!', theme, 'error'))
|
|
410
|
+
* console.log(applyThemeStyles('Success!', theme, 'success'))
|
|
411
|
+
* ```
|
|
412
|
+
*/
|
|
413
|
+
declare function applyThemeStyles(text: string, theme: TerminalTheme, styleKey: keyof TerminalThemeColors): string;
|
|
414
|
+
declare const defaultTheme: LegacyTerminalThemeWithExtras;
|
|
415
|
+
/**
|
|
416
|
+
* Named color constants matching theme semantic colors.
|
|
417
|
+
*/
|
|
418
|
+
declare const colors: {
|
|
419
|
+
primary: "\u001B[36m";
|
|
420
|
+
secondary: "\u001B[34m";
|
|
421
|
+
accent: "\u001B[35m";
|
|
422
|
+
muted: "\u001B[90m";
|
|
423
|
+
success: "\u001B[32m";
|
|
424
|
+
warning: "\u001B[33m";
|
|
425
|
+
error: "\u001B[31m";
|
|
426
|
+
info: "\u001B[34m";
|
|
427
|
+
};
|
|
428
|
+
/**
|
|
429
|
+
* Theme tokens for semantic access.
|
|
430
|
+
*/
|
|
431
|
+
declare const themeTokens: {
|
|
432
|
+
readonly primary: "primary";
|
|
433
|
+
readonly secondary: "secondary";
|
|
434
|
+
readonly accent: "accent";
|
|
435
|
+
readonly muted: "muted";
|
|
436
|
+
readonly success: "success";
|
|
437
|
+
readonly warning: "warning";
|
|
438
|
+
readonly error: "error";
|
|
439
|
+
readonly info: "info";
|
|
440
|
+
};
|
|
441
|
+
declare const darkTheme: LegacyTerminalThemeWithExtras;
|
|
442
|
+
declare const lightTheme: LegacyTerminalThemeWithExtras;
|
|
443
|
+
declare const highContrastTheme: LegacyTerminalThemeWithExtras;
|
|
444
|
+
declare const themePresets: {
|
|
445
|
+
default: LegacyTerminalThemeWithExtras;
|
|
446
|
+
dark: LegacyTerminalThemeWithExtras;
|
|
447
|
+
light: LegacyTerminalThemeWithExtras;
|
|
448
|
+
highContrast: LegacyTerminalThemeWithExtras;
|
|
449
|
+
};
|
|
450
|
+
/**
|
|
451
|
+
* Creates a legacy theme with partial overrides from defaults.
|
|
452
|
+
*
|
|
453
|
+
* @deprecated Use {@link createTerminalTheme} for new code.
|
|
454
|
+
*
|
|
455
|
+
* @param partial - Partial theme overrides
|
|
456
|
+
* @returns Complete legacy theme with overrides applied
|
|
457
|
+
* @throws {ZodError} If any color value is not a valid ANSI escape sequence
|
|
458
|
+
*
|
|
459
|
+
* @example
|
|
460
|
+
* ```tsx
|
|
461
|
+
* const theme = createTheme({
|
|
462
|
+
* primary: ANSI.brightGreen,
|
|
463
|
+
* error: ANSI.brightRed,
|
|
464
|
+
* })
|
|
465
|
+
* ```
|
|
466
|
+
*/
|
|
467
|
+
declare function createTheme(partial: Partial<LegacyTerminalThemeWithExtras>): LegacyTerminalThemeWithExtras;
|
|
468
|
+
/**
|
|
469
|
+
* Extends a base theme with overrides.
|
|
470
|
+
*
|
|
471
|
+
* Performs a deep merge of the override values onto the base theme,
|
|
472
|
+
* allowing nested properties (like typography, spacing) to be
|
|
473
|
+
* partially overridden.
|
|
474
|
+
*
|
|
475
|
+
* @param base - The base theme to extend
|
|
476
|
+
* @param overrides - Values to override in the base theme
|
|
477
|
+
* @returns New theme with overrides applied
|
|
478
|
+
*
|
|
479
|
+
* @example
|
|
480
|
+
* ```tsx
|
|
481
|
+
* const customTheme = extendTheme(defaultTheme, {
|
|
482
|
+
* primary: ANSI.brightMagenta,
|
|
483
|
+
* typography: { headingWeight: 'bold' },
|
|
484
|
+
* })
|
|
485
|
+
* ```
|
|
486
|
+
*/
|
|
487
|
+
declare function extendTheme<T extends LegacyTerminalThemeWithExtras>(base: T, overrides: Partial<T> & Record<string, unknown>): T & Record<string, unknown>;
|
|
488
|
+
/**
|
|
489
|
+
* Composes multiple theme objects into one.
|
|
490
|
+
*
|
|
491
|
+
* Later themes in the argument list override values from earlier themes.
|
|
492
|
+
* Useful for building up themes from multiple partial configurations.
|
|
493
|
+
*
|
|
494
|
+
* @param themes - Theme objects to compose (later overrides earlier)
|
|
495
|
+
* @returns Merged theme object
|
|
496
|
+
*
|
|
497
|
+
* @example
|
|
498
|
+
* ```tsx
|
|
499
|
+
* const theme = composeThemes(
|
|
500
|
+
* baseTheme,
|
|
501
|
+
* brandColorOverrides,
|
|
502
|
+
* userPreferences
|
|
503
|
+
* )
|
|
504
|
+
* ```
|
|
505
|
+
*/
|
|
506
|
+
declare function composeThemes<T extends Record<string, unknown>>(...themes: T[]): T;
|
|
507
|
+
/**
|
|
508
|
+
* Creates a named theme variant from a base theme.
|
|
509
|
+
*
|
|
510
|
+
* Convenience function for creating theme variants. The name parameter
|
|
511
|
+
* is currently unused but reserved for future theme registry features.
|
|
512
|
+
*
|
|
513
|
+
* @param base - The base theme to start from
|
|
514
|
+
* @param _name - Name for the variant (reserved for future use)
|
|
515
|
+
* @param overrides - Values to override in the base theme
|
|
516
|
+
* @returns New theme variant
|
|
517
|
+
*
|
|
518
|
+
* @example
|
|
519
|
+
* ```tsx
|
|
520
|
+
* const warningTheme = createThemeVariant(defaultTheme, 'warning', {
|
|
521
|
+
* primary: ANSI.yellow,
|
|
522
|
+
* accent: ANSI.brightYellow,
|
|
523
|
+
* })
|
|
524
|
+
* ```
|
|
525
|
+
*/
|
|
526
|
+
declare function createThemeVariant(base: LegacyTerminalThemeWithExtras, _name: string, overrides: Partial<LegacyTerminalThemeWithExtras>): LegacyTerminalThemeWithExtras;
|
|
527
|
+
/**
|
|
528
|
+
* Detect system color scheme preference (dark/light)
|
|
529
|
+
*/
|
|
530
|
+
declare function detectColorScheme(): 'dark' | 'light';
|
|
531
|
+
|
|
532
|
+
/**
|
|
533
|
+
* Text Styling Utilities
|
|
534
|
+
*
|
|
535
|
+
* Functions for applying ANSI styles to text with automatic reset.
|
|
536
|
+
* Includes semantic color helpers and compound style application.
|
|
537
|
+
*
|
|
538
|
+
* @module
|
|
539
|
+
*/
|
|
540
|
+
|
|
541
|
+
/**
|
|
542
|
+
* Applies a foreground color to text with automatic reset.
|
|
543
|
+
*
|
|
544
|
+
* Accepts either a semantic color name ('primary', 'error', etc.) or
|
|
545
|
+
* a raw ANSI escape sequence.
|
|
546
|
+
*
|
|
547
|
+
* @param colorName - Semantic color name or ANSI escape sequence
|
|
548
|
+
* @param text - The text to colorize
|
|
549
|
+
* @returns Colored text with ANSI codes
|
|
550
|
+
*
|
|
551
|
+
* @example
|
|
552
|
+
* ```tsx
|
|
553
|
+
* console.log(fg('error', 'Something went wrong'))
|
|
554
|
+
* console.log(fg('success', 'Operation completed'))
|
|
555
|
+
* console.log(fg(ANSI.brightCyan, 'Custom color'))
|
|
556
|
+
* ```
|
|
557
|
+
*/
|
|
558
|
+
declare function fg(colorName: keyof typeof colors | string, text: string): string;
|
|
559
|
+
/**
|
|
560
|
+
* Applies a background color to text with automatic reset.
|
|
561
|
+
*
|
|
562
|
+
* Accepts either a semantic color name ('primary', 'error', etc.) or
|
|
563
|
+
* a raw ANSI escape sequence.
|
|
564
|
+
*
|
|
565
|
+
* @param colorName - Semantic color name or ANSI escape sequence
|
|
566
|
+
* @param text - The text to highlight
|
|
567
|
+
* @returns Highlighted text with ANSI codes
|
|
568
|
+
*
|
|
569
|
+
* @example
|
|
570
|
+
* ```tsx
|
|
571
|
+
* console.log(bg('error', 'ALERT'))
|
|
572
|
+
* console.log(bg('success', ' OK '))
|
|
573
|
+
* ```
|
|
574
|
+
*/
|
|
575
|
+
declare function bg(colorName: keyof typeof colors | string, text: string): string;
|
|
576
|
+
/**
|
|
577
|
+
* Applies bold styling to text.
|
|
578
|
+
*
|
|
579
|
+
* @param text - The text to make bold
|
|
580
|
+
* @returns Bold text with ANSI codes
|
|
581
|
+
*/
|
|
582
|
+
declare function bold(text: string): string;
|
|
583
|
+
/**
|
|
584
|
+
* Applies dim/faint styling to text.
|
|
585
|
+
*
|
|
586
|
+
* @param text - The text to dim
|
|
587
|
+
* @returns Dimmed text with ANSI codes
|
|
588
|
+
*/
|
|
589
|
+
declare function dim(text: string): string;
|
|
590
|
+
/**
|
|
591
|
+
* Applies italic styling to text.
|
|
592
|
+
*
|
|
593
|
+
* Note: Not all terminals support italic text.
|
|
594
|
+
*
|
|
595
|
+
* @param text - The text to italicize
|
|
596
|
+
* @returns Italic text with ANSI codes
|
|
597
|
+
*/
|
|
598
|
+
declare function italic(text: string): string;
|
|
599
|
+
/**
|
|
600
|
+
* Applies underline styling to text.
|
|
601
|
+
*
|
|
602
|
+
* @param text - The text to underline
|
|
603
|
+
* @returns Underlined text with ANSI codes
|
|
604
|
+
*/
|
|
605
|
+
declare function underline(text: string): string;
|
|
606
|
+
/**
|
|
607
|
+
* Applies strikethrough styling to text.
|
|
608
|
+
*
|
|
609
|
+
* Note: Not all terminals support strikethrough text.
|
|
610
|
+
*
|
|
611
|
+
* @param text - The text to strike through
|
|
612
|
+
* @returns Strikethrough text with ANSI codes
|
|
613
|
+
*/
|
|
614
|
+
declare function strikethrough(text: string): string;
|
|
615
|
+
/**
|
|
616
|
+
* Applies multiple style modifiers to text.
|
|
617
|
+
*
|
|
618
|
+
* Accepts an array of modifier names (e.g., 'bold', 'red', 'underline')
|
|
619
|
+
* and applies all of them to the text.
|
|
620
|
+
*
|
|
621
|
+
* @param text - The text to style
|
|
622
|
+
* @param modifiers - Array of modifier names
|
|
623
|
+
* @returns Styled text with ANSI codes
|
|
624
|
+
*
|
|
625
|
+
* @example
|
|
626
|
+
* ```tsx
|
|
627
|
+
* console.log(style('Important', ['bold', 'red', 'underline']))
|
|
628
|
+
* console.log(style('Info', ['cyan', 'italic']))
|
|
629
|
+
* ```
|
|
630
|
+
*/
|
|
631
|
+
declare function style(text: string, modifiers: string[]): string;
|
|
632
|
+
/**
|
|
633
|
+
* Wraps text with ANSI escape codes and automatically appends reset.
|
|
634
|
+
*
|
|
635
|
+
* The primary utility for applying multiple ANSI styles to text.
|
|
636
|
+
* Accepts any number of ANSI escape code strings.
|
|
637
|
+
*
|
|
638
|
+
* @param text - The text to style (returns empty string if null/undefined)
|
|
639
|
+
* @param codes - ANSI escape code strings to apply
|
|
640
|
+
* @returns Styled text with reset appended
|
|
641
|
+
*
|
|
642
|
+
* @example
|
|
643
|
+
* ```tsx
|
|
644
|
+
* // Bold cyan text
|
|
645
|
+
* console.log(styled('Hello', ANSI.bold, ANSI.cyan))
|
|
646
|
+
*
|
|
647
|
+
* // Error styling
|
|
648
|
+
* console.log(styled('Error!', ANSI.bold, ANSI.red, ANSI.bgBlack))
|
|
649
|
+
* ```
|
|
650
|
+
*/
|
|
651
|
+
declare function styled(text: string, ...codes: string[]): string;
|
|
652
|
+
|
|
653
|
+
/**
|
|
654
|
+
* Color Support Detection and Degradation
|
|
655
|
+
*
|
|
656
|
+
* Utilities for detecting terminal color capabilities and
|
|
657
|
+
* gracefully degrading colors for limited terminals.
|
|
658
|
+
*
|
|
659
|
+
* @module
|
|
660
|
+
*/
|
|
661
|
+
/**
|
|
662
|
+
* Level of color support in the terminal.
|
|
663
|
+
*
|
|
664
|
+
* - `'none'` - No color support (monochrome)
|
|
665
|
+
* - `'16'` - Basic 16 ANSI colors
|
|
666
|
+
* - `'256'` - Extended 256 color palette
|
|
667
|
+
* - `'truecolor'` - Full 24-bit RGB color support
|
|
668
|
+
*/
|
|
669
|
+
type ColorSupport = 'none' | '16' | '256' | 'truecolor';
|
|
670
|
+
/**
|
|
671
|
+
* Detects the terminal's color support level.
|
|
672
|
+
*
|
|
673
|
+
* Checks environment variables in this order:
|
|
674
|
+
* 1. `NO_COLOR` - Forces no color support
|
|
675
|
+
* 2. `FORCE_COLOR` - Forces a specific color level (0-3)
|
|
676
|
+
* 3. `COLORTERM` - Checks for truecolor support
|
|
677
|
+
* 4. `TERM` - Checks terminal type for color hints
|
|
678
|
+
*
|
|
679
|
+
* @returns The detected color support level
|
|
680
|
+
*
|
|
681
|
+
* @example
|
|
682
|
+
* ```tsx
|
|
683
|
+
* const support = detectColorSupport()
|
|
684
|
+
* if (support === 'truecolor') {
|
|
685
|
+
* // Use full RGB colors
|
|
686
|
+
* } else if (support === '256') {
|
|
687
|
+
* // Use 256 color palette
|
|
688
|
+
* }
|
|
689
|
+
* ```
|
|
690
|
+
*/
|
|
691
|
+
declare function detectColorSupport(): ColorSupport;
|
|
692
|
+
/**
|
|
693
|
+
* Degrades an ANSI color to work with limited terminal color support.
|
|
694
|
+
*
|
|
695
|
+
* Automatically converts colors down to simpler formats:
|
|
696
|
+
* - Truecolor to 256 colors
|
|
697
|
+
* - 256 colors to 16 basic colors
|
|
698
|
+
* - Any color to nothing if support is 'none'
|
|
699
|
+
*
|
|
700
|
+
* @param ansi - Original ANSI escape sequence
|
|
701
|
+
* @param support - Target color support level
|
|
702
|
+
* @returns Degraded ANSI escape sequence, or empty string for 'none'
|
|
703
|
+
*
|
|
704
|
+
* @example
|
|
705
|
+
* ```tsx
|
|
706
|
+
* const trueColorBlue = '\x1b[38;2;100;150;200m'
|
|
707
|
+
* const support = detectColorSupport()
|
|
708
|
+
*
|
|
709
|
+
* // Automatically degrade for the current terminal
|
|
710
|
+
* const blue = degradeColor(trueColorBlue, support)
|
|
711
|
+
* ```
|
|
712
|
+
*/
|
|
713
|
+
declare function degradeColor(ansi: string, support: ColorSupport): string;
|
|
714
|
+
/**
|
|
715
|
+
* Adapts a color based on terminal support level.
|
|
716
|
+
*
|
|
717
|
+
* Alias for {@link degradeColor} - use this when the intent is to
|
|
718
|
+
* "adapt" colors for the current terminal rather than "degrade" them.
|
|
719
|
+
*
|
|
720
|
+
* @param color - ANSI color escape sequence
|
|
721
|
+
* @param level - Target color support level
|
|
722
|
+
* @returns Adapted color escape sequence
|
|
723
|
+
*
|
|
724
|
+
* @example
|
|
725
|
+
* ```tsx
|
|
726
|
+
* const support = detectColorSupport()
|
|
727
|
+
* const color = adaptColor(theme.primary, support)
|
|
728
|
+
* ```
|
|
729
|
+
*/
|
|
730
|
+
declare function adaptColor(color: string, level: ColorSupport): string;
|
|
731
|
+
|
|
732
|
+
/**
|
|
733
|
+
* ANSI Stripping Utilities
|
|
734
|
+
*
|
|
735
|
+
* Functions for removing ANSI escape codes from text and
|
|
736
|
+
* calculating visible text length.
|
|
737
|
+
*
|
|
738
|
+
* @module
|
|
739
|
+
*/
|
|
740
|
+
/**
|
|
741
|
+
* Strips all ANSI escape codes from text.
|
|
742
|
+
*
|
|
743
|
+
* Useful for getting the visible content of styled text or
|
|
744
|
+
* calculating accurate string lengths.
|
|
745
|
+
*
|
|
746
|
+
* @param text - Text potentially containing ANSI escape codes
|
|
747
|
+
* @returns Plain text with all ANSI codes removed, or empty string for null/undefined
|
|
748
|
+
*
|
|
749
|
+
* @example
|
|
750
|
+
* ```tsx
|
|
751
|
+
* const styled = bold(fg('cyan', 'Hello'))
|
|
752
|
+
* const plain = stripAnsi(styled) // 'Hello'
|
|
753
|
+
* ```
|
|
754
|
+
*/
|
|
755
|
+
declare function stripAnsi(text: string): string;
|
|
756
|
+
/**
|
|
757
|
+
* Calculates the visible length of text (excluding ANSI codes).
|
|
758
|
+
*
|
|
759
|
+
* Essential for terminal UI layout calculations where you need
|
|
760
|
+
* to know how many characters will actually be displayed.
|
|
761
|
+
*
|
|
762
|
+
* @param text - Text potentially containing ANSI escape codes
|
|
763
|
+
* @returns Number of visible characters
|
|
764
|
+
*
|
|
765
|
+
* @example
|
|
766
|
+
* ```tsx
|
|
767
|
+
* const styled = bold(fg('cyan', 'Hello'))
|
|
768
|
+
* const len = visibleLength(styled) // 5
|
|
769
|
+
* ```
|
|
770
|
+
*/
|
|
771
|
+
declare function visibleLength(text: string): number;
|
|
772
|
+
|
|
773
|
+
/**
|
|
774
|
+
* Box Drawing Characters
|
|
775
|
+
*
|
|
776
|
+
* Unicode box-drawing character sets for terminal UI borders
|
|
777
|
+
* and utility functions for drawing boxes.
|
|
778
|
+
*
|
|
779
|
+
* @module
|
|
780
|
+
*/
|
|
781
|
+
/**
|
|
782
|
+
* Unicode box-drawing character sets for terminal UI borders.
|
|
783
|
+
*
|
|
784
|
+
* Provides three styles:
|
|
785
|
+
* - `single` - Standard single-line borders (┌─┐│└┘)
|
|
786
|
+
* - `double` - Double-line borders (╔═╗║╚╝)
|
|
787
|
+
* - `rounded` - Single-line with rounded corners (╭─╮│╰╯)
|
|
788
|
+
*
|
|
789
|
+
* Each set includes:
|
|
790
|
+
* - Corner characters (topLeft, topRight, bottomLeft, bottomRight)
|
|
791
|
+
* - Line characters (horizontal, vertical)
|
|
792
|
+
* - T-junction characters (teeLeft, teeRight, teeTop, teeBottom)
|
|
793
|
+
* - Cross character (cross)
|
|
794
|
+
*
|
|
795
|
+
* @example
|
|
796
|
+
* ```tsx
|
|
797
|
+
* const chars = boxChars.single
|
|
798
|
+
* const top = chars.topLeft + chars.horizontal.repeat(10) + chars.topRight
|
|
799
|
+
* // Outputs: ┌──────────┐
|
|
800
|
+
* ```
|
|
801
|
+
*/
|
|
802
|
+
declare const boxChars: {
|
|
803
|
+
readonly single: {
|
|
804
|
+
readonly topLeft: "┌";
|
|
805
|
+
readonly topRight: "┐";
|
|
806
|
+
readonly bottomLeft: "└";
|
|
807
|
+
readonly bottomRight: "┘";
|
|
808
|
+
readonly horizontal: "─";
|
|
809
|
+
readonly vertical: "│";
|
|
810
|
+
readonly teeLeft: "├";
|
|
811
|
+
readonly teeRight: "┤";
|
|
812
|
+
readonly teeTop: "┬";
|
|
813
|
+
readonly teeBottom: "┴";
|
|
814
|
+
readonly cross: "┼";
|
|
815
|
+
};
|
|
816
|
+
readonly double: {
|
|
817
|
+
readonly topLeft: "╔";
|
|
818
|
+
readonly topRight: "╗";
|
|
819
|
+
readonly bottomLeft: "╚";
|
|
820
|
+
readonly bottomRight: "╝";
|
|
821
|
+
readonly horizontal: "═";
|
|
822
|
+
readonly vertical: "║";
|
|
823
|
+
readonly teeLeft: "╠";
|
|
824
|
+
readonly teeRight: "╣";
|
|
825
|
+
readonly teeTop: "╦";
|
|
826
|
+
readonly teeBottom: "╩";
|
|
827
|
+
readonly cross: "╬";
|
|
828
|
+
};
|
|
829
|
+
readonly rounded: {
|
|
830
|
+
readonly topLeft: "╭";
|
|
831
|
+
readonly topRight: "╮";
|
|
832
|
+
readonly bottomLeft: "╰";
|
|
833
|
+
readonly bottomRight: "╯";
|
|
834
|
+
readonly horizontal: "─";
|
|
835
|
+
readonly vertical: "│";
|
|
836
|
+
readonly teeLeft: "├";
|
|
837
|
+
readonly teeRight: "┤";
|
|
838
|
+
readonly teeTop: "┬";
|
|
839
|
+
readonly teeBottom: "┴";
|
|
840
|
+
readonly cross: "┼";
|
|
841
|
+
};
|
|
842
|
+
};
|
|
843
|
+
/**
|
|
844
|
+
* Available box drawing styles.
|
|
845
|
+
* - `'single'` - Standard single-line borders
|
|
846
|
+
* - `'double'` - Double-line borders
|
|
847
|
+
* - `'rounded'` - Single-line with rounded corners
|
|
848
|
+
*/
|
|
849
|
+
type BoxStyle = keyof typeof boxChars;
|
|
850
|
+
/**
|
|
851
|
+
* Draws a box with specified style and dimensions.
|
|
852
|
+
*
|
|
853
|
+
* Creates an array of strings representing each line of the box.
|
|
854
|
+
* The box is hollow (empty inside) and can be used as a container
|
|
855
|
+
* for content in terminal UIs.
|
|
856
|
+
*
|
|
857
|
+
* @param width - Total width of the box including borders
|
|
858
|
+
* @param height - Total height of the box including borders
|
|
859
|
+
* @param style - Box style ('single', 'double', or 'rounded')
|
|
860
|
+
* @returns Array of strings, one per line of the box
|
|
861
|
+
*
|
|
862
|
+
* @example
|
|
863
|
+
* ```tsx
|
|
864
|
+
* const box = drawBox(20, 5, 'rounded')
|
|
865
|
+
* box.forEach(line => console.log(line))
|
|
866
|
+
* // ╭──────────────────╮
|
|
867
|
+
* // │ │
|
|
868
|
+
* // │ │
|
|
869
|
+
* // │ │
|
|
870
|
+
* // ╰──────────────────╯
|
|
871
|
+
* ```
|
|
872
|
+
*/
|
|
873
|
+
declare function drawBox(width: number, height: number, style?: BoxStyle): string[];
|
|
874
|
+
|
|
875
|
+
/**
|
|
876
|
+
* Zod Schemas for Runtime Validation
|
|
877
|
+
*
|
|
878
|
+
* Provides Zod schemas for validating public API inputs at runtime.
|
|
879
|
+
* These schemas ensure type safety beyond TypeScript's compile-time checks.
|
|
880
|
+
*
|
|
881
|
+
* @module
|
|
882
|
+
*/
|
|
883
|
+
|
|
884
|
+
/**
|
|
885
|
+
* Schema for hex color strings.
|
|
886
|
+
*
|
|
887
|
+
* Accepts:
|
|
888
|
+
* - 3-character hex: #RGB or RGB
|
|
889
|
+
* - 6-character hex: #RRGGBB or RRGGBB
|
|
890
|
+
*
|
|
891
|
+
* @example
|
|
892
|
+
* ```tsx
|
|
893
|
+
* HexColorSchema.parse('#ff0000') // Valid
|
|
894
|
+
* HexColorSchema.parse('ff0000') // Valid
|
|
895
|
+
* HexColorSchema.parse('#f00') // Valid
|
|
896
|
+
* HexColorSchema.parse('invalid') // Throws ZodError
|
|
897
|
+
* ```
|
|
898
|
+
*/
|
|
899
|
+
declare const HexColorSchema: z.ZodString;
|
|
900
|
+
/**
|
|
901
|
+
* Schema for RGB component values (0-255).
|
|
902
|
+
*/
|
|
903
|
+
declare const RgbComponentSchema: z.ZodNumber;
|
|
904
|
+
/**
|
|
905
|
+
* Schema for RGB color object.
|
|
906
|
+
*/
|
|
907
|
+
declare const RgbColorSchema: z.ZodObject<{
|
|
908
|
+
r: z.ZodNumber;
|
|
909
|
+
g: z.ZodNumber;
|
|
910
|
+
b: z.ZodNumber;
|
|
911
|
+
}, "strip", z.ZodTypeAny, {
|
|
912
|
+
b: number;
|
|
913
|
+
g: number;
|
|
914
|
+
r: number;
|
|
915
|
+
}, {
|
|
916
|
+
b: number;
|
|
917
|
+
g: number;
|
|
918
|
+
r: number;
|
|
919
|
+
}>;
|
|
920
|
+
/**
|
|
921
|
+
* Schema for ANSI 256 color codes (0-255).
|
|
922
|
+
*/
|
|
923
|
+
declare const Ansi256CodeSchema: z.ZodNumber;
|
|
924
|
+
/**
|
|
925
|
+
* Schema for ANSI escape sequence strings.
|
|
926
|
+
* Validates that a string is a valid ANSI escape sequence.
|
|
927
|
+
*
|
|
928
|
+
* Accepts:
|
|
929
|
+
* - Empty string (valid for 'no color')
|
|
930
|
+
* - ANSI escape sequences like \x1b[38;5;33m
|
|
931
|
+
*/
|
|
932
|
+
declare const AnsiEscapeSchema: z.ZodEffects<z.ZodString, string, string>;
|
|
933
|
+
/**
|
|
934
|
+
* Schema for theme color mode.
|
|
935
|
+
*/
|
|
936
|
+
declare const ThemeModeSchema: z.ZodEnum<["dark", "light"]>;
|
|
937
|
+
/**
|
|
938
|
+
* Schema for terminal theme colors.
|
|
939
|
+
* All values are ANSI escape sequences.
|
|
940
|
+
*/
|
|
941
|
+
declare const TerminalThemeColorsSchema: z.ZodObject<{
|
|
942
|
+
primary: z.ZodEffects<z.ZodString, string, string>;
|
|
943
|
+
secondary: z.ZodEffects<z.ZodString, string, string>;
|
|
944
|
+
accent: z.ZodEffects<z.ZodString, string, string>;
|
|
945
|
+
muted: z.ZodEffects<z.ZodString, string, string>;
|
|
946
|
+
success: z.ZodEffects<z.ZodString, string, string>;
|
|
947
|
+
warning: z.ZodEffects<z.ZodString, string, string>;
|
|
948
|
+
error: z.ZodEffects<z.ZodString, string, string>;
|
|
949
|
+
info: z.ZodEffects<z.ZodString, string, string>;
|
|
950
|
+
border: z.ZodEffects<z.ZodString, string, string>;
|
|
951
|
+
background: z.ZodEffects<z.ZodString, string, string>;
|
|
952
|
+
foreground: z.ZodEffects<z.ZodString, string, string>;
|
|
953
|
+
selection: z.ZodEffects<z.ZodString, string, string>;
|
|
954
|
+
focus: z.ZodEffects<z.ZodString, string, string>;
|
|
955
|
+
}, "strip", z.ZodTypeAny, {
|
|
956
|
+
error: string;
|
|
957
|
+
primary: string;
|
|
958
|
+
secondary: string;
|
|
959
|
+
accent: string;
|
|
960
|
+
muted: string;
|
|
961
|
+
success: string;
|
|
962
|
+
warning: string;
|
|
963
|
+
info: string;
|
|
964
|
+
border: string;
|
|
965
|
+
background: string;
|
|
966
|
+
foreground: string;
|
|
967
|
+
selection: string;
|
|
968
|
+
focus: string;
|
|
969
|
+
}, {
|
|
970
|
+
error: string;
|
|
971
|
+
primary: string;
|
|
972
|
+
secondary: string;
|
|
973
|
+
accent: string;
|
|
974
|
+
muted: string;
|
|
975
|
+
success: string;
|
|
976
|
+
warning: string;
|
|
977
|
+
info: string;
|
|
978
|
+
border: string;
|
|
979
|
+
background: string;
|
|
980
|
+
foreground: string;
|
|
981
|
+
selection: string;
|
|
982
|
+
focus: string;
|
|
983
|
+
}>;
|
|
984
|
+
/**
|
|
985
|
+
* Schema for CreateTerminalThemeOptions.
|
|
986
|
+
*/
|
|
987
|
+
declare const CreateTerminalThemeOptionsSchema: z.ZodObject<{
|
|
988
|
+
mode: z.ZodOptional<z.ZodEnum<["dark", "light"]>>;
|
|
989
|
+
colors: z.ZodOptional<z.ZodObject<{
|
|
990
|
+
primary: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
991
|
+
secondary: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
992
|
+
accent: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
993
|
+
muted: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
994
|
+
success: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
995
|
+
warning: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
996
|
+
error: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
997
|
+
info: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
998
|
+
border: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
999
|
+
background: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
1000
|
+
foreground: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
1001
|
+
selection: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
1002
|
+
focus: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
1003
|
+
}, "strip", z.ZodTypeAny, {
|
|
1004
|
+
error?: string | undefined;
|
|
1005
|
+
primary?: string | undefined;
|
|
1006
|
+
secondary?: string | undefined;
|
|
1007
|
+
accent?: string | undefined;
|
|
1008
|
+
muted?: string | undefined;
|
|
1009
|
+
success?: string | undefined;
|
|
1010
|
+
warning?: string | undefined;
|
|
1011
|
+
info?: string | undefined;
|
|
1012
|
+
border?: string | undefined;
|
|
1013
|
+
background?: string | undefined;
|
|
1014
|
+
foreground?: string | undefined;
|
|
1015
|
+
selection?: string | undefined;
|
|
1016
|
+
focus?: string | undefined;
|
|
1017
|
+
}, {
|
|
1018
|
+
error?: string | undefined;
|
|
1019
|
+
primary?: string | undefined;
|
|
1020
|
+
secondary?: string | undefined;
|
|
1021
|
+
accent?: string | undefined;
|
|
1022
|
+
muted?: string | undefined;
|
|
1023
|
+
success?: string | undefined;
|
|
1024
|
+
warning?: string | undefined;
|
|
1025
|
+
info?: string | undefined;
|
|
1026
|
+
border?: string | undefined;
|
|
1027
|
+
background?: string | undefined;
|
|
1028
|
+
foreground?: string | undefined;
|
|
1029
|
+
selection?: string | undefined;
|
|
1030
|
+
focus?: string | undefined;
|
|
1031
|
+
}>>;
|
|
1032
|
+
}, "strip", z.ZodTypeAny, {
|
|
1033
|
+
mode?: "light" | "dark" | undefined;
|
|
1034
|
+
colors?: {
|
|
1035
|
+
error?: string | undefined;
|
|
1036
|
+
primary?: string | undefined;
|
|
1037
|
+
secondary?: string | undefined;
|
|
1038
|
+
accent?: string | undefined;
|
|
1039
|
+
muted?: string | undefined;
|
|
1040
|
+
success?: string | undefined;
|
|
1041
|
+
warning?: string | undefined;
|
|
1042
|
+
info?: string | undefined;
|
|
1043
|
+
border?: string | undefined;
|
|
1044
|
+
background?: string | undefined;
|
|
1045
|
+
foreground?: string | undefined;
|
|
1046
|
+
selection?: string | undefined;
|
|
1047
|
+
focus?: string | undefined;
|
|
1048
|
+
} | undefined;
|
|
1049
|
+
}, {
|
|
1050
|
+
mode?: "light" | "dark" | undefined;
|
|
1051
|
+
colors?: {
|
|
1052
|
+
error?: string | undefined;
|
|
1053
|
+
primary?: string | undefined;
|
|
1054
|
+
secondary?: string | undefined;
|
|
1055
|
+
accent?: string | undefined;
|
|
1056
|
+
muted?: string | undefined;
|
|
1057
|
+
success?: string | undefined;
|
|
1058
|
+
warning?: string | undefined;
|
|
1059
|
+
info?: string | undefined;
|
|
1060
|
+
border?: string | undefined;
|
|
1061
|
+
background?: string | undefined;
|
|
1062
|
+
foreground?: string | undefined;
|
|
1063
|
+
selection?: string | undefined;
|
|
1064
|
+
focus?: string | undefined;
|
|
1065
|
+
} | undefined;
|
|
1066
|
+
}>;
|
|
1067
|
+
/**
|
|
1068
|
+
* Schema for legacy terminal theme.
|
|
1069
|
+
*/
|
|
1070
|
+
declare const LegacyTerminalThemeSchema: z.ZodObject<{
|
|
1071
|
+
primary: z.ZodEffects<z.ZodString, string, string>;
|
|
1072
|
+
secondary: z.ZodEffects<z.ZodString, string, string>;
|
|
1073
|
+
accent: z.ZodEffects<z.ZodString, string, string>;
|
|
1074
|
+
muted: z.ZodEffects<z.ZodString, string, string>;
|
|
1075
|
+
success: z.ZodEffects<z.ZodString, string, string>;
|
|
1076
|
+
warning: z.ZodEffects<z.ZodString, string, string>;
|
|
1077
|
+
error: z.ZodEffects<z.ZodString, string, string>;
|
|
1078
|
+
info: z.ZodEffects<z.ZodString, string, string>;
|
|
1079
|
+
border: z.ZodEffects<z.ZodString, string, string>;
|
|
1080
|
+
background: z.ZodEffects<z.ZodString, string, string>;
|
|
1081
|
+
foreground: z.ZodEffects<z.ZodString, string, string>;
|
|
1082
|
+
selection: z.ZodEffects<z.ZodString, string, string>;
|
|
1083
|
+
focus: z.ZodEffects<z.ZodString, string, string>;
|
|
1084
|
+
}, "strip", z.ZodTypeAny, {
|
|
1085
|
+
error: string;
|
|
1086
|
+
primary: string;
|
|
1087
|
+
secondary: string;
|
|
1088
|
+
accent: string;
|
|
1089
|
+
muted: string;
|
|
1090
|
+
success: string;
|
|
1091
|
+
warning: string;
|
|
1092
|
+
info: string;
|
|
1093
|
+
border: string;
|
|
1094
|
+
background: string;
|
|
1095
|
+
foreground: string;
|
|
1096
|
+
selection: string;
|
|
1097
|
+
focus: string;
|
|
1098
|
+
}, {
|
|
1099
|
+
error: string;
|
|
1100
|
+
primary: string;
|
|
1101
|
+
secondary: string;
|
|
1102
|
+
accent: string;
|
|
1103
|
+
muted: string;
|
|
1104
|
+
success: string;
|
|
1105
|
+
warning: string;
|
|
1106
|
+
info: string;
|
|
1107
|
+
border: string;
|
|
1108
|
+
background: string;
|
|
1109
|
+
foreground: string;
|
|
1110
|
+
selection: string;
|
|
1111
|
+
focus: string;
|
|
1112
|
+
}>;
|
|
1113
|
+
/**
|
|
1114
|
+
* Schema for legacy terminal theme with extras.
|
|
1115
|
+
*/
|
|
1116
|
+
declare const LegacyTerminalThemeWithExtrasSchema: z.ZodObject<{
|
|
1117
|
+
primary: z.ZodEffects<z.ZodString, string, string>;
|
|
1118
|
+
secondary: z.ZodEffects<z.ZodString, string, string>;
|
|
1119
|
+
accent: z.ZodEffects<z.ZodString, string, string>;
|
|
1120
|
+
muted: z.ZodEffects<z.ZodString, string, string>;
|
|
1121
|
+
success: z.ZodEffects<z.ZodString, string, string>;
|
|
1122
|
+
warning: z.ZodEffects<z.ZodString, string, string>;
|
|
1123
|
+
error: z.ZodEffects<z.ZodString, string, string>;
|
|
1124
|
+
info: z.ZodEffects<z.ZodString, string, string>;
|
|
1125
|
+
border: z.ZodEffects<z.ZodString, string, string>;
|
|
1126
|
+
background: z.ZodEffects<z.ZodString, string, string>;
|
|
1127
|
+
foreground: z.ZodEffects<z.ZodString, string, string>;
|
|
1128
|
+
selection: z.ZodEffects<z.ZodString, string, string>;
|
|
1129
|
+
focus: z.ZodEffects<z.ZodString, string, string>;
|
|
1130
|
+
} & {
|
|
1131
|
+
typography: z.ZodOptional<z.ZodObject<{
|
|
1132
|
+
headingWeight: z.ZodString;
|
|
1133
|
+
bodyWeight: z.ZodString;
|
|
1134
|
+
codeFont: z.ZodString;
|
|
1135
|
+
}, "strip", z.ZodTypeAny, {
|
|
1136
|
+
headingWeight: string;
|
|
1137
|
+
bodyWeight: string;
|
|
1138
|
+
codeFont: string;
|
|
1139
|
+
}, {
|
|
1140
|
+
headingWeight: string;
|
|
1141
|
+
bodyWeight: string;
|
|
1142
|
+
codeFont: string;
|
|
1143
|
+
}>>;
|
|
1144
|
+
spacing: z.ZodOptional<z.ZodObject<{
|
|
1145
|
+
xs: z.ZodNumber;
|
|
1146
|
+
sm: z.ZodNumber;
|
|
1147
|
+
md: z.ZodNumber;
|
|
1148
|
+
lg: z.ZodNumber;
|
|
1149
|
+
xl: z.ZodNumber;
|
|
1150
|
+
}, "strip", z.ZodTypeAny, {
|
|
1151
|
+
xs: number;
|
|
1152
|
+
sm: number;
|
|
1153
|
+
md: number;
|
|
1154
|
+
lg: number;
|
|
1155
|
+
xl: number;
|
|
1156
|
+
}, {
|
|
1157
|
+
xs: number;
|
|
1158
|
+
sm: number;
|
|
1159
|
+
md: number;
|
|
1160
|
+
lg: number;
|
|
1161
|
+
xl: number;
|
|
1162
|
+
}>>;
|
|
1163
|
+
}, "strip", z.ZodTypeAny, {
|
|
1164
|
+
error: string;
|
|
1165
|
+
primary: string;
|
|
1166
|
+
secondary: string;
|
|
1167
|
+
accent: string;
|
|
1168
|
+
muted: string;
|
|
1169
|
+
success: string;
|
|
1170
|
+
warning: string;
|
|
1171
|
+
info: string;
|
|
1172
|
+
border: string;
|
|
1173
|
+
background: string;
|
|
1174
|
+
foreground: string;
|
|
1175
|
+
selection: string;
|
|
1176
|
+
focus: string;
|
|
1177
|
+
typography?: {
|
|
1178
|
+
headingWeight: string;
|
|
1179
|
+
bodyWeight: string;
|
|
1180
|
+
codeFont: string;
|
|
1181
|
+
} | undefined;
|
|
1182
|
+
spacing?: {
|
|
1183
|
+
xs: number;
|
|
1184
|
+
sm: number;
|
|
1185
|
+
md: number;
|
|
1186
|
+
lg: number;
|
|
1187
|
+
xl: number;
|
|
1188
|
+
} | undefined;
|
|
1189
|
+
}, {
|
|
1190
|
+
error: string;
|
|
1191
|
+
primary: string;
|
|
1192
|
+
secondary: string;
|
|
1193
|
+
accent: string;
|
|
1194
|
+
muted: string;
|
|
1195
|
+
success: string;
|
|
1196
|
+
warning: string;
|
|
1197
|
+
info: string;
|
|
1198
|
+
border: string;
|
|
1199
|
+
background: string;
|
|
1200
|
+
foreground: string;
|
|
1201
|
+
selection: string;
|
|
1202
|
+
focus: string;
|
|
1203
|
+
typography?: {
|
|
1204
|
+
headingWeight: string;
|
|
1205
|
+
bodyWeight: string;
|
|
1206
|
+
codeFont: string;
|
|
1207
|
+
} | undefined;
|
|
1208
|
+
spacing?: {
|
|
1209
|
+
xs: number;
|
|
1210
|
+
sm: number;
|
|
1211
|
+
md: number;
|
|
1212
|
+
lg: number;
|
|
1213
|
+
xl: number;
|
|
1214
|
+
} | undefined;
|
|
1215
|
+
}>;
|
|
1216
|
+
/**
|
|
1217
|
+
* Schema for createTheme() function input (partial legacy theme).
|
|
1218
|
+
*/
|
|
1219
|
+
declare const CreateThemeInputSchema: z.ZodObject<{
|
|
1220
|
+
primary: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
1221
|
+
secondary: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
1222
|
+
accent: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
1223
|
+
muted: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
1224
|
+
success: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
1225
|
+
warning: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
1226
|
+
error: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
1227
|
+
info: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
1228
|
+
border: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
1229
|
+
background: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
1230
|
+
foreground: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
1231
|
+
selection: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
1232
|
+
focus: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
1233
|
+
typography: z.ZodOptional<z.ZodOptional<z.ZodObject<{
|
|
1234
|
+
headingWeight: z.ZodString;
|
|
1235
|
+
bodyWeight: z.ZodString;
|
|
1236
|
+
codeFont: z.ZodString;
|
|
1237
|
+
}, "strip", z.ZodTypeAny, {
|
|
1238
|
+
headingWeight: string;
|
|
1239
|
+
bodyWeight: string;
|
|
1240
|
+
codeFont: string;
|
|
1241
|
+
}, {
|
|
1242
|
+
headingWeight: string;
|
|
1243
|
+
bodyWeight: string;
|
|
1244
|
+
codeFont: string;
|
|
1245
|
+
}>>>;
|
|
1246
|
+
spacing: z.ZodOptional<z.ZodOptional<z.ZodObject<{
|
|
1247
|
+
xs: z.ZodNumber;
|
|
1248
|
+
sm: z.ZodNumber;
|
|
1249
|
+
md: z.ZodNumber;
|
|
1250
|
+
lg: z.ZodNumber;
|
|
1251
|
+
xl: z.ZodNumber;
|
|
1252
|
+
}, "strip", z.ZodTypeAny, {
|
|
1253
|
+
xs: number;
|
|
1254
|
+
sm: number;
|
|
1255
|
+
md: number;
|
|
1256
|
+
lg: number;
|
|
1257
|
+
xl: number;
|
|
1258
|
+
}, {
|
|
1259
|
+
xs: number;
|
|
1260
|
+
sm: number;
|
|
1261
|
+
md: number;
|
|
1262
|
+
lg: number;
|
|
1263
|
+
xl: number;
|
|
1264
|
+
}>>>;
|
|
1265
|
+
}, "strip", z.ZodTypeAny, {
|
|
1266
|
+
error?: string | undefined;
|
|
1267
|
+
primary?: string | undefined;
|
|
1268
|
+
secondary?: string | undefined;
|
|
1269
|
+
accent?: string | undefined;
|
|
1270
|
+
muted?: string | undefined;
|
|
1271
|
+
success?: string | undefined;
|
|
1272
|
+
warning?: string | undefined;
|
|
1273
|
+
info?: string | undefined;
|
|
1274
|
+
border?: string | undefined;
|
|
1275
|
+
background?: string | undefined;
|
|
1276
|
+
foreground?: string | undefined;
|
|
1277
|
+
selection?: string | undefined;
|
|
1278
|
+
focus?: string | undefined;
|
|
1279
|
+
typography?: {
|
|
1280
|
+
headingWeight: string;
|
|
1281
|
+
bodyWeight: string;
|
|
1282
|
+
codeFont: string;
|
|
1283
|
+
} | undefined;
|
|
1284
|
+
spacing?: {
|
|
1285
|
+
xs: number;
|
|
1286
|
+
sm: number;
|
|
1287
|
+
md: number;
|
|
1288
|
+
lg: number;
|
|
1289
|
+
xl: number;
|
|
1290
|
+
} | undefined;
|
|
1291
|
+
}, {
|
|
1292
|
+
error?: string | undefined;
|
|
1293
|
+
primary?: string | undefined;
|
|
1294
|
+
secondary?: string | undefined;
|
|
1295
|
+
accent?: string | undefined;
|
|
1296
|
+
muted?: string | undefined;
|
|
1297
|
+
success?: string | undefined;
|
|
1298
|
+
warning?: string | undefined;
|
|
1299
|
+
info?: string | undefined;
|
|
1300
|
+
border?: string | undefined;
|
|
1301
|
+
background?: string | undefined;
|
|
1302
|
+
foreground?: string | undefined;
|
|
1303
|
+
selection?: string | undefined;
|
|
1304
|
+
focus?: string | undefined;
|
|
1305
|
+
typography?: {
|
|
1306
|
+
headingWeight: string;
|
|
1307
|
+
bodyWeight: string;
|
|
1308
|
+
codeFont: string;
|
|
1309
|
+
} | undefined;
|
|
1310
|
+
spacing?: {
|
|
1311
|
+
xs: number;
|
|
1312
|
+
sm: number;
|
|
1313
|
+
md: number;
|
|
1314
|
+
lg: number;
|
|
1315
|
+
xl: number;
|
|
1316
|
+
} | undefined;
|
|
1317
|
+
}>;
|
|
1318
|
+
/**
|
|
1319
|
+
* Schema for RGB to ANSI conversion options.
|
|
1320
|
+
*/
|
|
1321
|
+
declare const RgbToAnsiOptionsSchema: z.ZodObject<{
|
|
1322
|
+
background: z.ZodOptional<z.ZodBoolean>;
|
|
1323
|
+
}, "strip", z.ZodTypeAny, {
|
|
1324
|
+
background?: boolean | undefined;
|
|
1325
|
+
}, {
|
|
1326
|
+
background?: boolean | undefined;
|
|
1327
|
+
}>;
|
|
1328
|
+
/**
|
|
1329
|
+
* Schema for color support levels.
|
|
1330
|
+
*/
|
|
1331
|
+
declare const ColorSupportSchema: z.ZodEnum<["none", "16", "256", "truecolor"]>;
|
|
1332
|
+
type HexColor = z.infer<typeof HexColorSchema>;
|
|
1333
|
+
type RgbColor = z.infer<typeof RgbColorSchema>;
|
|
1334
|
+
type Ansi256Code = z.infer<typeof Ansi256CodeSchema>;
|
|
1335
|
+
type ThemeMode = z.infer<typeof ThemeModeSchema>;
|
|
1336
|
+
type CreateTerminalThemeOptionsInput = z.infer<typeof CreateTerminalThemeOptionsSchema>;
|
|
1337
|
+
type CreateThemeInput = z.infer<typeof CreateThemeInputSchema>;
|
|
1338
|
+
|
|
1339
|
+
export { ANSI, type Ansi256Code, Ansi256CodeSchema, AnsiEscapeSchema, type BoxStyle, type ColorSupport, ColorSupportSchema, type CreateTerminalThemeOptions, type CreateTerminalThemeOptionsInput, CreateTerminalThemeOptionsSchema, type CreateThemeInput, CreateThemeInputSchema, type HexColor, HexColorSchema, type LegacyTerminalTheme, LegacyTerminalThemeSchema, type LegacyTerminalThemeWithExtras, LegacyTerminalThemeWithExtrasSchema, type RgbColor, RgbColorSchema, RgbComponentSchema, type RgbToAnsiOptions, RgbToAnsiOptionsSchema, TAILWIND_COLORS, type TerminalTheme, type TerminalThemeColors, TerminalThemeColorsSchema, type ThemeMode, ThemeModeSchema, adaptColor, ansi256, ansi256Bg, applyThemeStyles, bg, bold, boxChars, colors, composeThemes, createTerminalTheme, createTheme, createThemeVariant, cssVarToAnsi, darkTheme, defaultTheme, degradeColor, detectColorScheme, detectColorSupport, dim, drawBox, extendTheme, fg, getThemeColor, hex, hexBg, hexToAnsi, hexToRgb, highContrastTheme, italic, lightTheme, rgb, rgbBg, rgbToAnsi, strikethrough, stripAnsi, style, styled, tailwindToAnsi, tailwindToTerminal, themePresets, themeTokens, underline, visibleLength };
|