@reliverse/relico 1.1.2 → 1.3.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/LICENSE +1 -1
- package/README.md +67 -10
- package/bin/mod.d.ts +70 -359
- package/bin/mod.js +429 -1161
- package/package.json +14 -27
- package/bin/utils.d.ts +0 -4
- package/bin/utils.js +0 -10
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) Nazar Kornienko (blefnk), Bleverse, Reliverse
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -4,22 +4,22 @@
|
|
|
4
4
|
|
|
5
5
|
[sponsor](https://github.com/sponsors/blefnk) — [discord](https://discord.gg/Pb8uKbwpsJ) — [repo](https://github.com/reliverse/relico) — [npm](https://npmjs.com/@reliverse/relico)
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Why Relico?
|
|
8
8
|
|
|
9
|
-
Because terminal styling shouldn
|
|
9
|
+
Because terminal styling shouldn't feel like duct tape. **Relico** brings design-system-level polish to your CLI logs, banners, errors, and output — without battling your runtime, shell, or platform. Terminal styling should be *fun*, not frustrating. Relico makes it feel *right*.
|
|
10
10
|
|
|
11
|
+
- ⚡ **Blazing-fast & lightweight** — type-safe, runtime-safe, build-time aware, zero bloat, zero dependencies, zero configuration
|
|
11
12
|
- 🎨 **80+ built-in colors** — easily customize or override with your own [`HEX`](https://chatgpt.com/share/67fd24cd-e7b0-8008-a815-f33d01f33758) palette
|
|
12
13
|
- 🧩 **Themeable by default** — end-users can configure themes+typography+colors via `relico.config.ts`, developers via `await initUserConfig({ ... })`
|
|
13
14
|
- 🌈 **Smart color detection** — full support for truecolor (16M), 256-color, and fallback modes across environments
|
|
14
15
|
- 🦄 **A modern alternative** to `chalk`, `kleur`, `colorette`, `gradient-string`, and legacy console hacks
|
|
15
16
|
- 🧠 **Typed, chainable, DX-optimized** — with autocompletion, inline docs, and expressive API ergonomics
|
|
16
17
|
- 🌿 **Respects your environment** — including `NO_COLOR`, `FORCE_COLOR`, and terminal capabilities
|
|
17
|
-
- ⚡ **Blazing-fast & lightweight** — zero bloat, runtime-safe, build-time aware, minimal dependencies
|
|
18
18
|
- 🛡️ **Cross-platform & runtime-ready** — works everywhere — even when your users' terminals are weird — in Node.js, Bun, Deno, CI, Windows, macOS, Linux, Docker & more
|
|
19
19
|
- 🎯 **Precision-crafted ANSI output** — every color, reset, and style code is finely tuned for contrast, legibility, and glitch-free rendering — even in flaky terminals (as far as Node.js permits)
|
|
20
|
-
- 🦾 **Relico isn
|
|
20
|
+
- 🦾 **Relico isn't just about color** — it's about communication — make your CLI users' output more than readable — make it feel *intentional*.
|
|
21
21
|
|
|
22
|
-
<img src="example.png" width="50%" alt="Available Relico colors" />
|
|
22
|
+
<img src="./example/example.png" width="50%" alt="Available Relico colors" />
|
|
23
23
|
|
|
24
24
|
## Installation
|
|
25
25
|
|
|
@@ -28,6 +28,64 @@ bun add @reliverse/relico
|
|
|
28
28
|
# bun • pnpm • yarn • npm
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
+
## Performance
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
$ bun bench
|
|
35
|
+
$ bun examples/benchmarks/performance.ts
|
|
36
|
+
|
|
37
|
+
🚀 Relico Performance Benchmarks
|
|
38
|
+
==================================================
|
|
39
|
+
C:/B/R/reliverse/relico/dist-npm/bin/mod.js
|
|
40
|
+
|
|
41
|
+
Basic color access: 107.02ms (934 379 ops/sec)
|
|
42
|
+
Chained colors: 191.49ms (522 227 ops/sec)
|
|
43
|
+
RGB color creation: 73.79ms (1 355 276 ops/sec)
|
|
44
|
+
Hex color creation: 87.73ms (1 139 866 ops/sec)
|
|
45
|
+
HSL color creation: 78.10ms (1 280 444 ops/sec)
|
|
46
|
+
Chain function: 226.13ms (442 219 ops/sec)
|
|
47
|
+
Background colors: 208.55ms (479 492 ops/sec)
|
|
48
|
+
Bright colors: 124.96ms (800 282 ops/sec)
|
|
49
|
+
Pastel colors: 126.03ms (793 446 ops/sec)
|
|
50
|
+
Multiline text (small): 165.08ms (605 769 ops/sec)
|
|
51
|
+
Multiline text (large): 1089.44ms (91 790 ops/sec)
|
|
52
|
+
|
|
53
|
+
Bundle Size Test:
|
|
54
|
+
Core exports imported: 5
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
$ bun size
|
|
59
|
+
$ bun examples/benchmarks/bundle-size.ts
|
|
60
|
+
|
|
61
|
+
📦 Bundle Size Analysis
|
|
62
|
+
==============================
|
|
63
|
+
C:/B/R/reliverse/relico/dist-npm/bin/mod.js
|
|
64
|
+
|
|
65
|
+
Size:
|
|
66
|
+
- File size: 12.9KB
|
|
67
|
+
- Declaration file size: 2.9KB
|
|
68
|
+
- Total bundle size: 15.8KB
|
|
69
|
+
|
|
70
|
+
Breakdown:
|
|
71
|
+
- Color data: 554B (4.2%)
|
|
72
|
+
- Logic: 12.4KB (95.8%)
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## 🔥 Important Notice
|
|
76
|
+
|
|
77
|
+
Relico (v1.3.0+) was recently rewritten from scratch:
|
|
78
|
+
|
|
79
|
+
- To have zero dependencies and zero configuration
|
|
80
|
+
- Include only the really necessary for daily usage features
|
|
81
|
+
- To be as fast as possible
|
|
82
|
+
|
|
83
|
+
Some missing important features may be added back in the coming future.
|
|
84
|
+
|
|
85
|
+
This means everything or most of the things described below in this readme may be different now.
|
|
86
|
+
|
|
87
|
+
The readme will be updated soon.
|
|
88
|
+
|
|
31
89
|
## Configuration
|
|
32
90
|
|
|
33
91
|
**If you're end-user OR developer, create `relico.config.ts` in your root**:
|
|
@@ -62,11 +120,10 @@ console.log(re.info("Custom config loaded!"));
|
|
|
62
120
|
## API Sneak Peek
|
|
63
121
|
|
|
64
122
|
```ts
|
|
65
|
-
import { re,
|
|
123
|
+
import { re, rgb } from "@reliverse/relico";
|
|
66
124
|
|
|
67
125
|
console.log(re.red("Red!"));
|
|
68
126
|
console.log(re.bold(re.green("Bold green")));
|
|
69
|
-
console.log(colorize("magenta", "Hello!"));
|
|
70
127
|
|
|
71
128
|
console.log(rgb(250, 128, 114)("This is salmon"));
|
|
72
129
|
```
|
|
@@ -120,7 +177,7 @@ const brandColors: DefaultColorKeys[] = ["magentaBright", "maroon"];
|
|
|
120
177
|
|
|
121
178
|
## Color Detection
|
|
122
179
|
|
|
123
|
-
Relico detects your terminal
|
|
180
|
+
Relico detects your terminal's capability:
|
|
124
181
|
|
|
125
182
|
```ts
|
|
126
183
|
import { colorSupport } from "@reliverse/relico";
|
|
@@ -275,7 +332,7 @@ bun i
|
|
|
275
332
|
bun dev
|
|
276
333
|
```
|
|
277
334
|
|
|
278
|
-
Check `
|
|
335
|
+
Check `example/e-mod.ts` for all the fun.
|
|
279
336
|
|
|
280
337
|
## Use Cases
|
|
281
338
|
|
|
@@ -294,7 +351,7 @@ Relico draws inspiration from all — and goes beyond them with modern configs,
|
|
|
294
351
|
|
|
295
352
|
## 🛠 Contributing
|
|
296
353
|
|
|
297
|
-
We
|
|
354
|
+
We'd love your help! Bug? Feature? Example? PR it!
|
|
298
355
|
Or hop into [Discord](https://discord.gg/Pb8uKbwpsJ) to discuss CLI theming and terminal art 💜
|
|
299
356
|
|
|
300
357
|
```bash
|
package/bin/mod.d.ts
CHANGED
|
@@ -1,364 +1,75 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export type DefaultColorKeys = (typeof defaultColorKeys)[number];
|
|
7
|
-
/**
|
|
8
|
-
* Format keys that must NOT be overridden by the user.
|
|
9
|
-
* We'll exclude them from IntelliSense and also skip them at runtime.
|
|
10
|
-
*/
|
|
11
|
-
type RestrictedKeys = "reset" | "bold" | "dim" | "italic" | "underline" | "inverse" | "hidden" | "strikethrough";
|
|
12
|
-
/** All the keys user is allowed to override */
|
|
13
|
-
type OverridableColorKeys = Exclude<DefaultColorKeys, RestrictedKeys>;
|
|
14
|
-
/** A map of user-overridable color definitions (no format keys) */
|
|
15
|
-
export type OverridableColorMap = Partial<Record<OverridableColorKeys, ColorDefinition>>;
|
|
16
|
-
/**
|
|
17
|
-
* `relico.config.ts` configuration options.
|
|
18
|
-
* Note: `customColors` is restricted to OverridableColorMap.
|
|
19
|
-
*/
|
|
20
|
-
export type RelicoConfig = {
|
|
21
|
-
/**
|
|
22
|
-
* Determines which ANSI mode is used:
|
|
23
|
-
* - 0: no color
|
|
24
|
-
* - 1: basic ANSI (8 colors)
|
|
25
|
-
* - 2: 256 color palette
|
|
26
|
-
* - 3: 24-bit truecolor (default)
|
|
27
|
-
*/
|
|
28
|
-
colorLevel?: 0 | 1 | 2 | 3;
|
|
29
|
-
/**
|
|
30
|
-
* Theme to use for color definitions.
|
|
31
|
-
* - "primary": primary theme (default)
|
|
32
|
-
* - "secondary": secondary theme
|
|
33
|
-
*/
|
|
34
|
-
theme?: "primary" | "secondary";
|
|
35
|
-
/**
|
|
36
|
-
* Custom color definitions.
|
|
37
|
-
* - Theming: ["primary", "secondary"]
|
|
38
|
-
*/
|
|
39
|
-
customColors?: OverridableColorMap;
|
|
40
|
-
/**
|
|
41
|
-
* Enable auto-detection of terminal color support
|
|
42
|
-
* Default: true
|
|
43
|
-
*/
|
|
44
|
-
autoDetect?: boolean;
|
|
1
|
+
type ColorLevel = 0 | 1 | 2 | 3;
|
|
2
|
+
type Rgb = {
|
|
3
|
+
r: number;
|
|
4
|
+
g: number;
|
|
5
|
+
b: number;
|
|
45
6
|
};
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
bgMagenta(text: string | number): string;
|
|
70
|
-
bgCyan(text: string | number): string;
|
|
71
|
-
bgWhite(text: string | number): string;
|
|
72
|
-
blackBright(text: string | number): string;
|
|
73
|
-
redBright(text: string | number): string;
|
|
74
|
-
greenBright(text: string | number): string;
|
|
75
|
-
yellowBright(text: string | number): string;
|
|
76
|
-
blueBright(text: string | number): string;
|
|
77
|
-
magentaBright(text: string | number): string;
|
|
78
|
-
cyanBright(text: string | number): string;
|
|
79
|
-
whiteBright(text: string | number): string;
|
|
80
|
-
bgBlackBright(text: string | number): string;
|
|
81
|
-
bgRedBright(text: string | number): string;
|
|
82
|
-
bgGreenBright(text: string | number): string;
|
|
83
|
-
bgYellowBright(text: string | number): string;
|
|
84
|
-
bgBlueBright(text: string | number): string;
|
|
85
|
-
bgMagentaBright(text: string | number): string;
|
|
86
|
-
bgCyanBright(text: string | number): string;
|
|
87
|
-
bgWhiteBright(text: string | number): string;
|
|
88
|
-
redPastel(text: string | number): string;
|
|
89
|
-
greenPastel(text: string | number): string;
|
|
90
|
-
yellowPastel(text: string | number): string;
|
|
91
|
-
bluePastel(text: string | number): string;
|
|
92
|
-
magentaPastel(text: string | number): string;
|
|
93
|
-
cyanPastel(text: string | number): string;
|
|
94
|
-
bgRedPastel(text: string | number): string;
|
|
95
|
-
bgGreenPastel(text: string | number): string;
|
|
96
|
-
bgYellowPastel(text: string | number): string;
|
|
97
|
-
bgBluePastel(text: string | number): string;
|
|
98
|
-
bgMagentaPastel(text: string | number): string;
|
|
99
|
-
bgCyanPastel(text: string | number): string;
|
|
100
|
-
orange(text: string | number): string;
|
|
101
|
-
pink(text: string | number): string;
|
|
102
|
-
purple(text: string | number): string;
|
|
103
|
-
teal(text: string | number): string;
|
|
104
|
-
lime(text: string | number): string;
|
|
105
|
-
brown(text: string | number): string;
|
|
106
|
-
navy(text: string | number): string;
|
|
107
|
-
maroon(text: string | number): string;
|
|
108
|
-
olive(text: string | number): string;
|
|
109
|
-
silver(text: string | number): string;
|
|
110
|
-
bgOrange(text: string | number): string;
|
|
111
|
-
bgPink(text: string | number): string;
|
|
112
|
-
bgPurple(text: string | number): string;
|
|
113
|
-
bgTeal(text: string | number): string;
|
|
114
|
-
bgLime(text: string | number): string;
|
|
115
|
-
bgBrown(text: string | number): string;
|
|
116
|
-
bgNavy(text: string | number): string;
|
|
117
|
-
bgMaroon(text: string | number): string;
|
|
118
|
-
bgOlive(text: string | number): string;
|
|
119
|
-
bgSilver(text: string | number): string;
|
|
120
|
-
gray10(text: string | number): string;
|
|
121
|
-
gray20(text: string | number): string;
|
|
122
|
-
gray30(text: string | number): string;
|
|
123
|
-
gray40(text: string | number): string;
|
|
124
|
-
gray50(text: string | number): string;
|
|
125
|
-
gray60(text: string | number): string;
|
|
126
|
-
gray70(text: string | number): string;
|
|
127
|
-
gray80(text: string | number): string;
|
|
128
|
-
gray90(text: string | number): string;
|
|
7
|
+
type SgrOp = {
|
|
8
|
+
kind: "style";
|
|
9
|
+
open: number[];
|
|
10
|
+
} | {
|
|
11
|
+
kind: "fg-basic";
|
|
12
|
+
idx: number;
|
|
13
|
+
bright: boolean;
|
|
14
|
+
} | {
|
|
15
|
+
kind: "bg-basic";
|
|
16
|
+
idx: number;
|
|
17
|
+
bright: boolean;
|
|
18
|
+
} | {
|
|
19
|
+
kind: "fg-256";
|
|
20
|
+
code: number;
|
|
21
|
+
} | {
|
|
22
|
+
kind: "bg-256";
|
|
23
|
+
code: number;
|
|
24
|
+
} | {
|
|
25
|
+
kind: "fg-true";
|
|
26
|
+
rgb: Rgb;
|
|
27
|
+
} | {
|
|
28
|
+
kind: "bg-true";
|
|
29
|
+
rgb: Rgb;
|
|
129
30
|
};
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
* `RelicoConfig`. Invalid fields are ignored.
|
|
134
|
-
*/
|
|
135
|
-
export declare function configure(userInput: unknown): void;
|
|
136
|
-
/**
|
|
137
|
-
* Returns a color function by name (or `reset` or identity if not found).
|
|
138
|
-
* Uses cached functions for better performance.
|
|
139
|
-
*/
|
|
140
|
-
export declare function getColor(name: string): (text: string | number) => string;
|
|
141
|
-
/**
|
|
142
|
-
* Colorizes text with a color function.
|
|
143
|
-
*/
|
|
144
|
-
export declare function colorize(name: string, text: string | number): string;
|
|
145
|
-
/**
|
|
146
|
-
* Sets the color level (0=none, 1=basic, 2=256, 3=truecolor).
|
|
147
|
-
*/
|
|
148
|
-
export declare function setColorLevel(level: 0 | 1 | 2 | 3): void;
|
|
149
|
-
/**
|
|
150
|
-
* Returns a custom "rgb" color function if level is truecolor, otherwise identity.
|
|
151
|
-
* Uses caching for better performance.
|
|
152
|
-
* @param r Red component (0-255)
|
|
153
|
-
* @param g Green component (0-255)
|
|
154
|
-
* @param b Blue component (0-255)
|
|
155
|
-
*/
|
|
156
|
-
export declare function rgb(r: number, g: number, b: number): (text: string | number) => string;
|
|
157
|
-
/**
|
|
158
|
-
* Returns a custom background "bgRgb" color function.
|
|
159
|
-
* Uses caching for better performance.
|
|
160
|
-
* @param r Red component (0-255)
|
|
161
|
-
* @param g Green component (0-255)
|
|
162
|
-
* @param b Blue component (0-255)
|
|
163
|
-
*/
|
|
164
|
-
export declare function bgRgb(r: number, g: number, b: number): (text: string | number) => string;
|
|
165
|
-
/**
|
|
166
|
-
* Creates a color function from a hex string or color name
|
|
167
|
-
* @param color Hex string (e.g., "#ff0000") or color name (e.g., "red")
|
|
168
|
-
*/
|
|
169
|
-
export declare function hex(color: string): (text: string | number) => string;
|
|
170
|
-
/**
|
|
171
|
-
* Creates a background color function from a hex string or color name
|
|
172
|
-
* @param color Hex string (e.g., "#ff0000") or color name (e.g., "red")
|
|
173
|
-
*/
|
|
174
|
-
export declare function bgHex(color: string): (text: string | number) => string;
|
|
175
|
-
/**
|
|
176
|
-
* Creates an HSL color from hue, saturation, and lightness values
|
|
177
|
-
* @param h Hue (0-360)
|
|
178
|
-
* @param s Saturation (0-100)
|
|
179
|
-
* @param l Lightness (0-100)
|
|
180
|
-
*/
|
|
181
|
-
export declare function hsl(h: number, s: number, l: number): (text: string | number) => string;
|
|
182
|
-
/**
|
|
183
|
-
* Creates a background HSL color
|
|
184
|
-
* @param h Hue (0-360)
|
|
185
|
-
* @param s Saturation (0-100)
|
|
186
|
-
* @param l Lightness (0-100)
|
|
187
|
-
*/
|
|
188
|
-
export declare function bgHsl(h: number, s: number, l: number): (text: string | number) => string;
|
|
189
|
-
/**
|
|
190
|
-
* Chain multiple color formatters together
|
|
191
|
-
* @param formatters Array of color formatters to apply in sequence
|
|
192
|
-
*/
|
|
193
|
-
export declare function chain(...formatters: ((text: string | number) => string)[]): (text: string | number) => string;
|
|
194
|
-
/**
|
|
195
|
-
* Creates a rainbow text effect
|
|
196
|
-
* @param text The text to colorize
|
|
197
|
-
* @param saturation Saturation (0-100)
|
|
198
|
-
* @param lightness Lightness (0-100)
|
|
199
|
-
* @param options Additional options
|
|
200
|
-
* @returns The rainbow-colorized text
|
|
201
|
-
*/
|
|
202
|
-
export declare function rainbow(text: string, saturation?: number, lightness?: number, options?: {
|
|
203
|
-
startHue?: number;
|
|
204
|
-
endHue?: number;
|
|
205
|
-
}): string;
|
|
206
|
-
/**
|
|
207
|
-
* Creates a gradient text effect between multiple colors
|
|
208
|
-
* @param text The text to colorize
|
|
209
|
-
* @param colors Array of colors (hex, rgb, hsl, or named colors)
|
|
210
|
-
* @param options Additional options (smoothing, distribution)
|
|
211
|
-
* @returns The gradient-colorized text
|
|
212
|
-
*/
|
|
213
|
-
export declare function multiGradient(text: string, colors: string[], options?: {
|
|
214
|
-
smoothing?: number;
|
|
215
|
-
distribution?: "even" | "weighted";
|
|
216
|
-
}): string;
|
|
217
|
-
/**
|
|
218
|
-
* Creates a gradient text effect between two colors
|
|
219
|
-
* @param text The text to colorize
|
|
220
|
-
* @param startColor Starting color (hex, rgb, hsl, or named color)
|
|
221
|
-
* @param endColor Ending color (hex, rgb, hsl, or named color)
|
|
222
|
-
* @param options Additional options (smoothing)
|
|
223
|
-
* @returns The gradient-colorized text
|
|
224
|
-
*/
|
|
225
|
-
export declare function gradient(text: string, startColor: string, endColor: string, options?: {
|
|
226
|
-
smoothing?: number;
|
|
227
|
-
}): string;
|
|
228
|
-
/**
|
|
229
|
-
* Blend two colors together with a given ratio
|
|
230
|
-
* @param color1 First color
|
|
231
|
-
* @param color2 Second color
|
|
232
|
-
* @param ratio Blend ratio (0-1, 0 = color1, 1 = color2)
|
|
233
|
-
* @returns A formatter function with the blended color
|
|
234
|
-
*/
|
|
235
|
-
export declare function blend(color1: string, color2: string, ratio?: number): (text: string | number) => string;
|
|
236
|
-
/**
|
|
237
|
-
* Checks if a color meets WCAG contrast guidelines against another color
|
|
238
|
-
* @param foreground Foreground color
|
|
239
|
-
* @param background Background color (defaults to white)
|
|
240
|
-
* @returns Object with contrast ratio and pass/fail for AA and AAA levels
|
|
241
|
-
*/
|
|
242
|
-
export declare function checkContrast(foreground: string, background?: string): {
|
|
243
|
-
ratio: number;
|
|
244
|
-
passesAA: boolean;
|
|
245
|
-
passesAAA: boolean;
|
|
246
|
-
passesAALarge: boolean;
|
|
247
|
-
passesAAALarge: boolean;
|
|
31
|
+
type ApplyInput = string | number;
|
|
32
|
+
type FormatCallable = ((input: ApplyInput) => string) & {
|
|
33
|
+
readonly [OP_SYMBOL]: SgrOp[];
|
|
248
34
|
};
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
35
|
+
type BaseColorName = "black" | "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white" | "gray" | "orange" | "pink" | "purple" | "teal" | "lime" | "brown" | "navy" | "maroon" | "olive" | "silver";
|
|
36
|
+
type ColorName = BaseColorName | GrayScaleName | BrightColorName | PastelColorName | BgColorName;
|
|
37
|
+
type GrayScaleName = "gray10" | "gray20" | "gray30" | "gray40" | "gray50" | "gray60" | "gray70" | "gray80" | "gray90";
|
|
38
|
+
type BrightColorName = "blackBright" | "redBright" | "greenBright" | "yellowBright" | "blueBright" | "magentaBright" | "cyanBright" | "whiteBright" | "orangeBright" | "pinkBright" | "purpleBright" | "tealBright" | "limeBright" | "brownBright" | "navyBright" | "maroonBright" | "oliveBright" | "silverBright";
|
|
39
|
+
type PastelColorName = "blackPastel" | "redPastel" | "greenPastel" | "yellowPastel" | "bluePastel" | "magentaPastel" | "cyanPastel" | "whitePastel" | "grayPastel" | "orangePastel" | "pinkPastel" | "purplePastel" | "tealPastel" | "limePastel" | "brownPastel" | "navyPastel" | "maroonPastel" | "olivePastel" | "silverPastel";
|
|
40
|
+
type BgColorName = `bg${Capitalize<BaseColorName>}` | `bg${Capitalize<GrayScaleName>}` | `bg${Capitalize<BrightColorName>}` | `bg${Capitalize<PastelColorName>}`;
|
|
41
|
+
type MkRgbFn = (r: number, g: number, b: number) => Re;
|
|
42
|
+
type MkHexFn = (hex: string) => Re;
|
|
43
|
+
type MkHslFn = (h: number, s: number, l: number) => Re;
|
|
44
|
+
type StyleKeys = "reset" | "bold" | "dim" | "italic" | "underline" | "inverse" | "hidden" | "strikethrough";
|
|
45
|
+
type Re = FormatCallable & {
|
|
46
|
+
readonly [K in StyleKeys]: Re;
|
|
47
|
+
} & {
|
|
48
|
+
readonly [K in ColorName]: Re;
|
|
49
|
+
} & {
|
|
50
|
+
readonly [K in BgColorName]: Re;
|
|
51
|
+
} & {
|
|
52
|
+
readonly rgb: MkRgbFn;
|
|
53
|
+
readonly hex: MkHexFn;
|
|
54
|
+
readonly hsl: MkHslFn;
|
|
55
|
+
readonly bgRgb: MkRgbFn;
|
|
56
|
+
readonly bgHex: MkHexFn;
|
|
57
|
+
readonly bgHsl: MkHslFn;
|
|
263
58
|
};
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
export declare
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
/**
|
|
281
|
-
* Apply background and foreground colors while preventing spillover
|
|
282
|
-
* @param bgColor Background color
|
|
283
|
-
* @param fgColor Foreground color
|
|
284
|
-
* @param text Optional text to colorize immediately
|
|
285
|
-
*/
|
|
286
|
-
export declare function safeColor(bgColor: string, fgColor: string, text?: string | number): ((text: string | number) => string) | string;
|
|
287
|
-
/**
|
|
288
|
-
* Creates a color function that automatically ensures good contrast
|
|
289
|
-
* @param color Base color to use
|
|
290
|
-
* @param background Background color to check contrast against
|
|
291
|
-
* @param targetRatio Minimum contrast ratio to achieve (4.5 = AA, 7 = AAA)
|
|
292
|
-
*/
|
|
293
|
-
export declare function autoContrast(color: string, background?: string, targetRatio?: number): (text: string | number) => string;
|
|
294
|
-
/**
|
|
295
|
-
* Creates a color scheme from a base color
|
|
296
|
-
* @param baseColor The main color to generate a scheme from
|
|
297
|
-
* @returns Object with various related colors
|
|
298
|
-
*/
|
|
299
|
-
export declare function createColorScheme(baseColor: string): {
|
|
300
|
-
base: (text: string | number) => string;
|
|
301
|
-
light: (text: string | number) => string;
|
|
302
|
-
dark: (text: string | number) => string;
|
|
303
|
-
bright: (text: string | number) => string;
|
|
304
|
-
pastel: (text: string | number) => string;
|
|
305
|
-
bg: (text: string | number) => string;
|
|
306
|
-
bgLight: (text: string | number) => string;
|
|
307
|
-
accent: (text: string | number) => string;
|
|
308
|
-
};
|
|
309
|
-
/**
|
|
310
|
-
* Creates a highlighted text with colored background and contrasting text
|
|
311
|
-
* @param text Text to highlight
|
|
312
|
-
* @param bgColor Background color
|
|
313
|
-
* @param options Additional options
|
|
314
|
-
*/
|
|
315
|
-
export declare function highlight(text: string, bgColor: string, options?: {
|
|
316
|
-
padding?: number;
|
|
317
|
-
border?: boolean;
|
|
318
|
-
borderColor?: string;
|
|
319
|
-
}): string;
|
|
320
|
-
/**
|
|
321
|
-
* Creates an ANSI link (works in supported terminals)
|
|
322
|
-
* @param text Link text to display
|
|
323
|
-
* @param url The URL to link to
|
|
324
|
-
* @param color Optional color for the link text
|
|
325
|
-
*/
|
|
326
|
-
export declare function link(text: string, url: string, color?: string): string;
|
|
327
|
-
/**
|
|
328
|
-
* Colorize a JSON object with syntax highlighting
|
|
329
|
-
* @param obj Object to stringify and colorize
|
|
330
|
-
* @param options Options for JSON stringification
|
|
331
|
-
*/
|
|
332
|
-
export declare function colorizeJson(obj: unknown, options?: {
|
|
333
|
-
indent?: number;
|
|
334
|
-
compact?: boolean;
|
|
335
|
-
}): string;
|
|
336
|
-
/**
|
|
337
|
-
* Initialize user configuration with optional programmatic overrides
|
|
338
|
-
* @param programmaticConfig Optional configuration to override default settings
|
|
339
|
-
* @param userSettingsPrecedence If true, user file settings take precedence over programmatic
|
|
340
|
-
*/
|
|
341
|
-
/**
|
|
342
|
-
* Initialize user configuration with optional programmatic overrides
|
|
343
|
-
* @param programmaticConfig Optional configuration to override settings
|
|
344
|
-
* @param userSettingsPrecedence If true, user file settings take precedence over programmatic
|
|
345
|
-
*/
|
|
346
|
-
export declare function initUserConfig(programmaticConfig?: Partial<RelicoConfig>, userSettingsPrecedence?: boolean): Promise<void>;
|
|
347
|
-
/**
|
|
348
|
-
* Provides type safety and IntelliSense for user configuration.
|
|
349
|
-
* Example usage in `relico.config.ts`:
|
|
350
|
-
* ```ts
|
|
351
|
-
* import { defineConfig } from "@reliverse/relico-cfg";
|
|
352
|
-
* export default defineConfig({
|
|
353
|
-
* colorLevel: 3,
|
|
354
|
-
* theme: "secondary",
|
|
355
|
-
* customColors: {
|
|
356
|
-
* red: ["#f00", "#c00"],
|
|
357
|
-
* blue: ["#0af", "#08f"],
|
|
358
|
-
* green: ["#00ff00", "#00cc00"],
|
|
359
|
-
* },
|
|
360
|
-
* });
|
|
361
|
-
* ```
|
|
362
|
-
*/
|
|
363
|
-
export declare function defineConfig(cfg: RelicoConfig): RelicoConfig;
|
|
59
|
+
declare const OP_SYMBOL: unique symbol;
|
|
60
|
+
export declare const setColorLevel: (level: ColorLevel) => void;
|
|
61
|
+
export declare const re: Re;
|
|
62
|
+
export declare const rgb: MkRgbFn;
|
|
63
|
+
export declare const hex: MkHexFn;
|
|
64
|
+
export declare const hsl: MkHslFn;
|
|
65
|
+
export declare const bgRgb: MkRgbFn;
|
|
66
|
+
export declare const bgHex: MkHexFn;
|
|
67
|
+
export declare const bgHsl: MkHslFn;
|
|
68
|
+
export declare const chain: (...parts: FormatCallable[]) => Re;
|
|
69
|
+
export declare const parseRgb: (value: string) => Rgb | null;
|
|
70
|
+
export declare const parseHsl: (value: string) => {
|
|
71
|
+
h: number;
|
|
72
|
+
s: number;
|
|
73
|
+
l: number;
|
|
74
|
+
} | null;
|
|
364
75
|
export {};
|