kailogger 1.0.0-dark.red → 1.0.2
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 +195 -53
- package/dist/core/Config.d.ts +15 -0
- package/dist/core/Config.js +44 -0
- package/dist/core/Logger.d.ts +75 -4
- package/dist/core/Logger.js +375 -47
- package/dist/core/Scope.d.ts +13 -0
- package/dist/core/Scope.js +36 -0
- package/dist/features/Chart.d.ts +15 -0
- package/dist/features/Chart.js +64 -0
- package/dist/features/Diff.d.ts +3 -0
- package/dist/features/Diff.js +30 -0
- package/dist/features/Encrypt.d.ts +10 -0
- package/dist/features/Encrypt.js +47 -0
- package/dist/features/Notify.d.ts +14 -0
- package/dist/features/Notify.js +70 -0
- package/dist/features/Screenshot.d.ts +10 -0
- package/dist/features/Screenshot.js +106 -0
- package/dist/features/Sound.d.ts +12 -0
- package/dist/features/Sound.js +116 -0
- package/dist/features/Timer.d.ts +6 -0
- package/dist/features/Timer.js +38 -0
- package/dist/features/Tree.d.ts +7 -0
- package/dist/features/Tree.js +25 -0
- package/dist/features/index.d.ts +8 -0
- package/dist/features/index.js +24 -0
- package/dist/icon/logo.png +0 -0
- package/dist/index.d.ts +13 -1
- package/dist/index.js +21 -1
- package/dist/sounds/error.wav +0 -0
- package/dist/sounds/notification.wav +0 -0
- package/dist/sounds/success.wav +0 -0
- package/dist/sounds/warning.wav +0 -0
- package/dist/styles/KaiChroma.d.ts +85 -0
- package/dist/styles/KaiChroma.js +407 -0
- package/dist/styles/gradients.d.ts +28 -0
- package/dist/styles/palettes.d.ts +21 -26
- package/dist/styles/palettes.js +167 -13
- package/dist/transports/ConsoleTransport.d.ts +9 -0
- package/dist/transports/ConsoleTransport.js +18 -0
- package/dist/transports/FileTransport.d.ts +16 -0
- package/dist/transports/FileTransport.js +84 -0
- package/dist/transports/WebhookTransport.d.ts +15 -0
- package/dist/transports/WebhookTransport.js +31 -0
- package/dist/transports/index.d.ts +3 -0
- package/dist/transports/index.js +19 -0
- package/dist/types/index.d.ts +16 -0
- package/dist/types/index.js +11 -0
- package/dist/utils/json.d.ts +3 -0
- package/dist/utils/json.js +33 -0
- package/dist/utils/prettyError.d.ts +3 -0
- package/dist/utils/prettyError.js +94 -0
- package/dist/utils/progress.d.ts +11 -0
- package/dist/utils/progress.js +43 -0
- package/dist/utils/prompt.d.ts +4 -0
- package/dist/utils/prompt.js +59 -0
- package/dist/utils/selection.d.ts +4 -0
- package/dist/utils/selection.js +156 -0
- package/dist/utils/spinner.d.ts +1 -1
- package/dist/utils/spinner.js +9 -13
- package/dist/utils/stripAnsi.d.ts +1 -0
- package/dist/utils/stripAnsi.js +7 -0
- package/dist/utils/table.d.ts +3 -0
- package/dist/utils/table.js +35 -0
- package/examples/demo.js +134 -0
- package/examples/demo.ts +88 -25
- package/package.json +20 -6
- package/scripts/copy-assets.js +37 -0
- package/src/core/Config.ts +44 -0
- package/src/core/Logger.ts +427 -51
- package/src/core/Scope.ts +35 -0
- package/src/features/Chart.ts +81 -0
- package/src/features/Diff.ts +25 -0
- package/src/features/Encrypt.ts +47 -0
- package/src/features/Notify.ts +39 -0
- package/src/features/Screenshot.ts +70 -0
- package/src/features/Sound.ts +92 -0
- package/src/features/Timer.ts +35 -0
- package/src/features/Tree.ts +25 -0
- package/src/features/index.ts +8 -0
- package/src/icon/logo.png +0 -0
- package/src/index.ts +13 -1
- package/src/sounds/error.wav +0 -0
- package/src/sounds/notification.wav +0 -0
- package/src/sounds/success.wav +0 -0
- package/src/sounds/warning.wav +0 -0
- package/src/styles/KaiChroma.ts +370 -0
- package/src/styles/palettes.ts +197 -14
- package/src/transports/ConsoleTransport.ts +19 -0
- package/src/transports/FileTransport.ts +55 -0
- package/src/transports/WebhookTransport.ts +37 -0
- package/src/transports/index.ts +3 -0
- package/src/types/cli-highlight.d.ts +3 -0
- package/src/types/index.ts +23 -0
- package/src/utils/json.ts +33 -0
- package/src/utils/prettyError.ts +65 -0
- package/src/utils/progress.ts +56 -0
- package/src/utils/prompt.ts +27 -0
- package/src/utils/selection.ts +136 -0
- package/src/utils/spinner.ts +11 -7
- package/src/utils/stripAnsi.ts +6 -0
- package/src/utils/table.ts +38 -0
- package/src/styles/gradients.ts +0 -22
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.KaiChroma = void 0;
|
|
7
|
+
const os_1 = __importDefault(require("os"));
|
|
8
|
+
const env = process.env;
|
|
9
|
+
const isTTY = process.stdout.isTTY;
|
|
10
|
+
const platform = os_1.default.platform();
|
|
11
|
+
const supportLevel = (() => {
|
|
12
|
+
if (env.CI && !env.FORCE_COLOR)
|
|
13
|
+
return 0;
|
|
14
|
+
if (!isTTY && !env.FORCE_COLOR)
|
|
15
|
+
return 0;
|
|
16
|
+
if (env.FORCE_COLOR === '0')
|
|
17
|
+
return 0;
|
|
18
|
+
if (env.FORCE_COLOR === '1')
|
|
19
|
+
return 1;
|
|
20
|
+
if (env.FORCE_COLOR === '2')
|
|
21
|
+
return 2;
|
|
22
|
+
if (env.FORCE_COLOR === '3')
|
|
23
|
+
return 3;
|
|
24
|
+
if (platform === 'win32') {
|
|
25
|
+
if (env.WT_SESSION || env.ConEmuANSI === 'ON')
|
|
26
|
+
return 3;
|
|
27
|
+
}
|
|
28
|
+
if (env.COLORTERM === 'truecolor' || env.COLORTERM === '24bit')
|
|
29
|
+
return 3;
|
|
30
|
+
if (env.TERM_PROGRAM === 'iTerm.app')
|
|
31
|
+
return 3;
|
|
32
|
+
if (env.TERM_PROGRAM === 'Apple_Terminal')
|
|
33
|
+
return 2;
|
|
34
|
+
if (env.TERM_PROGRAM === 'Hyper')
|
|
35
|
+
return 3;
|
|
36
|
+
if (env.TERM_PROGRAM === 'vscode')
|
|
37
|
+
return 3;
|
|
38
|
+
const term = env.TERM || '';
|
|
39
|
+
if (term.includes('truecolor') || term.includes('24bit'))
|
|
40
|
+
return 3;
|
|
41
|
+
if (term.includes('256color'))
|
|
42
|
+
return 2;
|
|
43
|
+
if (term === 'xterm' || term === 'screen' || term === 'linux')
|
|
44
|
+
return 1;
|
|
45
|
+
return isTTY ? 1 : 0;
|
|
46
|
+
})();
|
|
47
|
+
class KaiChroma {
|
|
48
|
+
static hexToRgb(hex) {
|
|
49
|
+
const cleanHex = hex.replace(/^#/, '');
|
|
50
|
+
const bigint = parseInt(cleanHex, 16);
|
|
51
|
+
return [(bigint >> 16) & 255, (bigint >> 8) & 255, bigint & 255];
|
|
52
|
+
}
|
|
53
|
+
static rgbToHex(r, g, b) {
|
|
54
|
+
return '#' + [r, g, b].map(x => {
|
|
55
|
+
const hex = x.toString(16);
|
|
56
|
+
return hex.length === 1 ? '0' + hex : hex;
|
|
57
|
+
}).join('');
|
|
58
|
+
}
|
|
59
|
+
static rgbToHsl(r, g, b) {
|
|
60
|
+
r /= 255;
|
|
61
|
+
g /= 255;
|
|
62
|
+
b /= 255;
|
|
63
|
+
const max = Math.max(r, g, b), min = Math.min(r, g, b);
|
|
64
|
+
let h = 0, s = 0, l = (max + min) / 2;
|
|
65
|
+
if (max !== min) {
|
|
66
|
+
const d = max - min;
|
|
67
|
+
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
|
68
|
+
switch (max) {
|
|
69
|
+
case r:
|
|
70
|
+
h = ((g - b) / d + (g < b ? 6 : 0)) / 6;
|
|
71
|
+
break;
|
|
72
|
+
case g:
|
|
73
|
+
h = ((b - r) / d + 2) / 6;
|
|
74
|
+
break;
|
|
75
|
+
case b:
|
|
76
|
+
h = ((r - g) / d + 4) / 6;
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return { h: h * 360, s: s * 100, l: l * 100 };
|
|
81
|
+
}
|
|
82
|
+
static hslToRgb(h, s, l) {
|
|
83
|
+
h /= 360;
|
|
84
|
+
s /= 100;
|
|
85
|
+
l /= 100;
|
|
86
|
+
const hue2rgb = (p, q, t) => {
|
|
87
|
+
if (t < 0)
|
|
88
|
+
t += 1;
|
|
89
|
+
if (t > 1)
|
|
90
|
+
t -= 1;
|
|
91
|
+
if (t < 1 / 6)
|
|
92
|
+
return p + (q - p) * 6 * t;
|
|
93
|
+
if (t < 1 / 2)
|
|
94
|
+
return q;
|
|
95
|
+
if (t < 2 / 3)
|
|
96
|
+
return p + (q - p) * (2 / 3 - t) * 6;
|
|
97
|
+
return p;
|
|
98
|
+
};
|
|
99
|
+
if (s === 0) {
|
|
100
|
+
const val = Math.round(l * 255);
|
|
101
|
+
return [val, val, val];
|
|
102
|
+
}
|
|
103
|
+
const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
|
104
|
+
const p = 2 * l - q;
|
|
105
|
+
return [
|
|
106
|
+
Math.round(hue2rgb(p, q, h + 1 / 3) * 255),
|
|
107
|
+
Math.round(hue2rgb(p, q, h) * 255),
|
|
108
|
+
Math.round(hue2rgb(p, q, h - 1 / 3) * 255)
|
|
109
|
+
];
|
|
110
|
+
}
|
|
111
|
+
static rgbToAnsi256(r, g, b) {
|
|
112
|
+
if (r === g && g === b) {
|
|
113
|
+
if (r < 8)
|
|
114
|
+
return 16;
|
|
115
|
+
if (r > 248)
|
|
116
|
+
return 231;
|
|
117
|
+
return Math.round(((r - 8) / 247) * 24) + 232;
|
|
118
|
+
}
|
|
119
|
+
return 16 + (36 * Math.round(r / 255 * 5)) + (6 * Math.round(g / 255 * 5)) + Math.round(b / 255 * 5);
|
|
120
|
+
}
|
|
121
|
+
static interpolateLinear(start, end, t) {
|
|
122
|
+
return [
|
|
123
|
+
Math.round(start[0] + (end[0] - start[0]) * t),
|
|
124
|
+
Math.round(start[1] + (end[1] - start[1]) * t),
|
|
125
|
+
Math.round(start[2] + (end[2] - start[2]) * t)
|
|
126
|
+
];
|
|
127
|
+
}
|
|
128
|
+
static interpolateEase(start, end, t) {
|
|
129
|
+
const eased = t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t;
|
|
130
|
+
return this.interpolateLinear(start, end, eased);
|
|
131
|
+
}
|
|
132
|
+
static interpolateBezier(start, end, t) {
|
|
133
|
+
const bezier = t * t * (3 - 2 * t);
|
|
134
|
+
return this.interpolateLinear(start, end, bezier);
|
|
135
|
+
}
|
|
136
|
+
static interpolateSmooth(start, end, t) {
|
|
137
|
+
const smooth = t * t * t * (t * (t * 6 - 15) + 10);
|
|
138
|
+
return this.interpolateLinear(start, end, smooth);
|
|
139
|
+
}
|
|
140
|
+
static hex(hex, text) {
|
|
141
|
+
if (supportLevel === 0)
|
|
142
|
+
return text;
|
|
143
|
+
const cacheKey = `hex:${hex}:${supportLevel}`;
|
|
144
|
+
const [r, g, b] = this.hexToRgb(hex);
|
|
145
|
+
if (supportLevel === 3) {
|
|
146
|
+
return `\x1b[38;2;${r};${g};${b}m${text}\x1b[39m`;
|
|
147
|
+
}
|
|
148
|
+
else if (supportLevel === 2) {
|
|
149
|
+
return `\x1b[38;5;${this.rgbToAnsi256(r, g, b)}m${text}\x1b[39m`;
|
|
150
|
+
}
|
|
151
|
+
return text;
|
|
152
|
+
}
|
|
153
|
+
static rgb(r, g, b, text) {
|
|
154
|
+
if (supportLevel === 0)
|
|
155
|
+
return text;
|
|
156
|
+
if (supportLevel === 3) {
|
|
157
|
+
return `\x1b[38;2;${r};${g};${b}m${text}\x1b[39m`;
|
|
158
|
+
}
|
|
159
|
+
else if (supportLevel === 2) {
|
|
160
|
+
return `\x1b[38;5;${this.rgbToAnsi256(r, g, b)}m${text}\x1b[39m`;
|
|
161
|
+
}
|
|
162
|
+
return text;
|
|
163
|
+
}
|
|
164
|
+
static hsl(h, s, l, text) {
|
|
165
|
+
const [r, g, b] = this.hslToRgb(h, s, l);
|
|
166
|
+
return this.rgb(r, g, b, text);
|
|
167
|
+
}
|
|
168
|
+
static bgHex(hex, text) {
|
|
169
|
+
if (supportLevel === 0)
|
|
170
|
+
return text;
|
|
171
|
+
const [r, g, b] = this.hexToRgb(hex);
|
|
172
|
+
if (supportLevel === 3) {
|
|
173
|
+
return `\x1b[48;2;${r};${g};${b}m${text}\x1b[49m`;
|
|
174
|
+
}
|
|
175
|
+
else if (supportLevel === 2) {
|
|
176
|
+
return `\x1b[48;5;${this.rgbToAnsi256(r, g, b)}m${text}\x1b[49m`;
|
|
177
|
+
}
|
|
178
|
+
return text;
|
|
179
|
+
}
|
|
180
|
+
static bgRgb(r, g, b, text) {
|
|
181
|
+
if (supportLevel === 0)
|
|
182
|
+
return text;
|
|
183
|
+
if (supportLevel === 3) {
|
|
184
|
+
return `\x1b[48;2;${r};${g};${b}m${text}\x1b[49m`;
|
|
185
|
+
}
|
|
186
|
+
else if (supportLevel === 2) {
|
|
187
|
+
return `\x1b[48;5;${this.rgbToAnsi256(r, g, b)}m${text}\x1b[49m`;
|
|
188
|
+
}
|
|
189
|
+
return text;
|
|
190
|
+
}
|
|
191
|
+
static bold(text) { return `\x1b[1m${text}\x1b[22m`; }
|
|
192
|
+
static dim(text) { return `\x1b[2m${text}\x1b[22m`; }
|
|
193
|
+
static italic(text) { return `\x1b[3m${text}\x1b[23m`; }
|
|
194
|
+
static underline(text) { return `\x1b[4m${text}\x1b[24m`; }
|
|
195
|
+
static inverse(text) { return `\x1b[7m${text}\x1b[27m`; }
|
|
196
|
+
static hidden(text) { return `\x1b[8m${text}\x1b[28m`; }
|
|
197
|
+
static strikethrough(text) { return `\x1b[9m${text}\x1b[29m`; }
|
|
198
|
+
static blink(text) { return `\x1b[5m${text}\x1b[25m`; }
|
|
199
|
+
static style(text, options) {
|
|
200
|
+
let result = text;
|
|
201
|
+
if (options.bold)
|
|
202
|
+
result = this.bold(result);
|
|
203
|
+
if (options.dim)
|
|
204
|
+
result = this.dim(result);
|
|
205
|
+
if (options.italic)
|
|
206
|
+
result = this.italic(result);
|
|
207
|
+
if (options.underline)
|
|
208
|
+
result = this.underline(result);
|
|
209
|
+
if (options.inverse)
|
|
210
|
+
result = this.inverse(result);
|
|
211
|
+
if (options.strikethrough)
|
|
212
|
+
result = this.strikethrough(result);
|
|
213
|
+
if (options.blink)
|
|
214
|
+
result = this.blink(result);
|
|
215
|
+
if (options.hidden)
|
|
216
|
+
result = this.hidden(result);
|
|
217
|
+
return result;
|
|
218
|
+
}
|
|
219
|
+
static gradient(colors, text, options = {}) {
|
|
220
|
+
if (supportLevel === 0)
|
|
221
|
+
return text;
|
|
222
|
+
if (colors.length < 2)
|
|
223
|
+
return this.hex(colors[0] || '#ffffff', text);
|
|
224
|
+
const interpolation = options.interpolation || 'linear';
|
|
225
|
+
const rgbColors = colors.map(c => this.hexToRgb(c));
|
|
226
|
+
const chars = [...text];
|
|
227
|
+
const steps = chars.length;
|
|
228
|
+
let output = '';
|
|
229
|
+
const interpolate = (start, end, t) => {
|
|
230
|
+
switch (interpolation) {
|
|
231
|
+
case 'ease': return this.interpolateEase(start, end, t);
|
|
232
|
+
case 'bezier': return this.interpolateBezier(start, end, t);
|
|
233
|
+
case 'smooth': return this.interpolateSmooth(start, end, t);
|
|
234
|
+
default: return this.interpolateLinear(start, end, t);
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
chars.forEach((char, i) => {
|
|
238
|
+
const t = steps <= 1 ? 0 : i / (steps - 1);
|
|
239
|
+
const segmentLength = 1 / (rgbColors.length - 1);
|
|
240
|
+
const segmentIndex = Math.min(Math.floor(t / segmentLength), rgbColors.length - 2);
|
|
241
|
+
const segmentT = (t - (segmentIndex * segmentLength)) / segmentLength;
|
|
242
|
+
const [r, g, b] = interpolate(rgbColors[segmentIndex], rgbColors[segmentIndex + 1], segmentT);
|
|
243
|
+
if (supportLevel === 3) {
|
|
244
|
+
output += `\x1b[38;2;${r};${g};${b}m${char}`;
|
|
245
|
+
}
|
|
246
|
+
else if (supportLevel === 2) {
|
|
247
|
+
output += `\x1b[38;5;${this.rgbToAnsi256(r, g, b)}m${char}`;
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
output += char;
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
return output + '\x1b[39m';
|
|
254
|
+
}
|
|
255
|
+
static rainbowGradient(text) {
|
|
256
|
+
return this.gradient(['#FF0000', '#FF7F00', '#FFFF00', '#00FF00', '#0000FF', '#4B0082', '#9400D3'], text, { interpolation: 'smooth' });
|
|
257
|
+
}
|
|
258
|
+
static sunsetGradient(text) {
|
|
259
|
+
return this.gradient(['#FF512F', '#F09819', '#FFD89B'], text, { interpolation: 'ease' });
|
|
260
|
+
}
|
|
261
|
+
static oceanGradient(text) {
|
|
262
|
+
return this.gradient(['#667eea', '#764ba2', '#f093fb'], text, { interpolation: 'bezier' });
|
|
263
|
+
}
|
|
264
|
+
static fireGradient(text) {
|
|
265
|
+
return this.gradient(['#ff0000', '#ff4500', '#ffa500', '#ffff00'], text, { interpolation: 'smooth' });
|
|
266
|
+
}
|
|
267
|
+
static matrixGradient(text) {
|
|
268
|
+
return this.gradient(['#00ff00', '#00cc00', '#009900'], text, { interpolation: 'linear' });
|
|
269
|
+
}
|
|
270
|
+
static lighten(hex, amount) {
|
|
271
|
+
const [r, g, b] = this.hexToRgb(hex);
|
|
272
|
+
const hsl = this.rgbToHsl(r, g, b);
|
|
273
|
+
hsl.l = Math.min(100, hsl.l + amount);
|
|
274
|
+
const [nr, ng, nb] = this.hslToRgb(hsl.h, hsl.s, hsl.l);
|
|
275
|
+
return this.rgbToHex(nr, ng, nb);
|
|
276
|
+
}
|
|
277
|
+
static darken(hex, amount) {
|
|
278
|
+
return this.lighten(hex, -amount);
|
|
279
|
+
}
|
|
280
|
+
static saturate(hex, amount) {
|
|
281
|
+
const [r, g, b] = this.hexToRgb(hex);
|
|
282
|
+
const hsl = this.rgbToHsl(r, g, b);
|
|
283
|
+
hsl.s = Math.min(100, hsl.s + amount);
|
|
284
|
+
const [nr, ng, nb] = this.hslToRgb(hsl.h, hsl.s, hsl.l);
|
|
285
|
+
return this.rgbToHex(nr, ng, nb);
|
|
286
|
+
}
|
|
287
|
+
static desaturate(hex, amount) {
|
|
288
|
+
return this.saturate(hex, -amount);
|
|
289
|
+
}
|
|
290
|
+
static rotate(hex, degrees) {
|
|
291
|
+
const [r, g, b] = this.hexToRgb(hex);
|
|
292
|
+
const hsl = this.rgbToHsl(r, g, b);
|
|
293
|
+
hsl.h = (hsl.h + degrees) % 360;
|
|
294
|
+
if (hsl.h < 0)
|
|
295
|
+
hsl.h += 360;
|
|
296
|
+
const [nr, ng, nb] = this.hslToRgb(hsl.h, hsl.s, hsl.l);
|
|
297
|
+
return this.rgbToHex(nr, ng, nb);
|
|
298
|
+
}
|
|
299
|
+
static mix(hex1, hex2, weight = 0.5) {
|
|
300
|
+
const [r1, g1, b1] = this.hexToRgb(hex1);
|
|
301
|
+
const [r2, g2, b2] = this.hexToRgb(hex2);
|
|
302
|
+
const [r, g, b] = this.interpolateLinear([r1, g1, b1], [r2, g2, b2], weight);
|
|
303
|
+
return this.rgbToHex(r, g, b);
|
|
304
|
+
}
|
|
305
|
+
static analogous(hex, count = 3) {
|
|
306
|
+
const palette = [hex];
|
|
307
|
+
const step = 30;
|
|
308
|
+
for (let i = 1; i < count; i++) {
|
|
309
|
+
palette.push(this.rotate(hex, step * i));
|
|
310
|
+
}
|
|
311
|
+
return palette;
|
|
312
|
+
}
|
|
313
|
+
static complementary(hex) {
|
|
314
|
+
return [hex, this.rotate(hex, 180)];
|
|
315
|
+
}
|
|
316
|
+
static triadic(hex) {
|
|
317
|
+
return [hex, this.rotate(hex, 120), this.rotate(hex, 240)];
|
|
318
|
+
}
|
|
319
|
+
static tetradic(hex) {
|
|
320
|
+
return [hex, this.rotate(hex, 90), this.rotate(hex, 180), this.rotate(hex, 270)];
|
|
321
|
+
}
|
|
322
|
+
static monochromatic(hex, count = 5) {
|
|
323
|
+
const palette = [];
|
|
324
|
+
const step = 100 / (count - 1);
|
|
325
|
+
for (let i = 0; i < count; i++) {
|
|
326
|
+
palette.push(this.lighten(hex, -50 + step * i));
|
|
327
|
+
}
|
|
328
|
+
return palette;
|
|
329
|
+
}
|
|
330
|
+
static strip(text) {
|
|
331
|
+
return text.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, '');
|
|
332
|
+
}
|
|
333
|
+
static getSupport() {
|
|
334
|
+
return supportLevel;
|
|
335
|
+
}
|
|
336
|
+
static getSupportName() {
|
|
337
|
+
const names = ['none', 'basic', '256', 'truecolor'];
|
|
338
|
+
return names[supportLevel];
|
|
339
|
+
}
|
|
340
|
+
static isSupported() {
|
|
341
|
+
return supportLevel > 0;
|
|
342
|
+
}
|
|
343
|
+
static textLength(text) {
|
|
344
|
+
return this.strip(text).length;
|
|
345
|
+
}
|
|
346
|
+
static box(text, color = '#ffffff', padding = 1) {
|
|
347
|
+
const lines = text.split('\n');
|
|
348
|
+
const maxLen = Math.max(...lines.map(l => this.textLength(l)));
|
|
349
|
+
const pad = ' '.repeat(padding);
|
|
350
|
+
const width = maxLen + padding * 2;
|
|
351
|
+
const top = this.hex(color, '┌' + '─'.repeat(width) + '┐');
|
|
352
|
+
const bottom = this.hex(color, '└' + '─'.repeat(width) + '┘');
|
|
353
|
+
const content = lines.map(line => {
|
|
354
|
+
const spaces = ' '.repeat(maxLen - this.textLength(line));
|
|
355
|
+
return this.hex(color, '│') + pad + line + spaces + pad + this.hex(color, '│');
|
|
356
|
+
}).join('\n');
|
|
357
|
+
return `${top}\n${content}\n${bottom}`;
|
|
358
|
+
}
|
|
359
|
+
static wave(text, colors) {
|
|
360
|
+
if (supportLevel === 0)
|
|
361
|
+
return text;
|
|
362
|
+
const chars = [...text];
|
|
363
|
+
const rgbColors = colors.map(c => this.hexToRgb(c));
|
|
364
|
+
let output = '';
|
|
365
|
+
chars.forEach((char, i) => {
|
|
366
|
+
const colorIndex = Math.floor((Math.sin(i * 0.5) + 1) * (rgbColors.length - 1) / 2);
|
|
367
|
+
const [r, g, b] = rgbColors[colorIndex];
|
|
368
|
+
if (supportLevel === 3) {
|
|
369
|
+
output += `\x1b[38;2;${r};${g};${b}m${char}`;
|
|
370
|
+
}
|
|
371
|
+
else if (supportLevel === 2) {
|
|
372
|
+
output += `\x1b[38;5;${this.rgbToAnsi256(r, g, b)}m${char}`;
|
|
373
|
+
}
|
|
374
|
+
else {
|
|
375
|
+
output += char;
|
|
376
|
+
}
|
|
377
|
+
});
|
|
378
|
+
return output + '\x1b[39m';
|
|
379
|
+
}
|
|
380
|
+
static pulse(text, color, frames = 10) {
|
|
381
|
+
const result = [];
|
|
382
|
+
const [r, g, b] = this.hexToRgb(color);
|
|
383
|
+
for (let i = 0; i < frames; i++) {
|
|
384
|
+
const brightness = (Math.sin((i / frames) * Math.PI * 2) + 1) / 2;
|
|
385
|
+
const adjustedR = Math.round(r * brightness);
|
|
386
|
+
const adjustedG = Math.round(g * brightness);
|
|
387
|
+
const adjustedB = Math.round(b * brightness);
|
|
388
|
+
result.push(this.rgb(adjustedR, adjustedG, adjustedB, text));
|
|
389
|
+
}
|
|
390
|
+
return result;
|
|
391
|
+
}
|
|
392
|
+
static clearCacheIfNeeded() {
|
|
393
|
+
if (this.cache.size > this.MAX_CACHE_SIZE) {
|
|
394
|
+
const entriesToDelete = this.cache.size - this.MAX_CACHE_SIZE / 2;
|
|
395
|
+
const iterator = this.cache.keys();
|
|
396
|
+
for (let i = 0; i < entriesToDelete; i++) {
|
|
397
|
+
const key = iterator.next().value;
|
|
398
|
+
if (key)
|
|
399
|
+
this.cache.delete(key);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
exports.KaiChroma = KaiChroma;
|
|
405
|
+
KaiChroma.cache = new Map();
|
|
406
|
+
KaiChroma.MAX_CACHE_SIZE = 1000;
|
|
407
|
+
exports.default = KaiChroma;
|
|
@@ -16,12 +16,40 @@ export declare class GradientEngine {
|
|
|
16
16
|
warning: string[];
|
|
17
17
|
info: string[];
|
|
18
18
|
debug: string[];
|
|
19
|
+
light: string;
|
|
20
|
+
dim: string;
|
|
21
|
+
} | {
|
|
22
|
+
success: string[];
|
|
23
|
+
error: string[];
|
|
24
|
+
warning: string[];
|
|
25
|
+
info: string[];
|
|
26
|
+
debug: string[];
|
|
27
|
+
light: string;
|
|
28
|
+
dim: string;
|
|
29
|
+
} | {
|
|
30
|
+
success: string[];
|
|
31
|
+
error: string[];
|
|
32
|
+
warning: string[];
|
|
33
|
+
info: string[];
|
|
34
|
+
debug: string[];
|
|
35
|
+
light: string;
|
|
36
|
+
dim: string;
|
|
37
|
+
} | {
|
|
38
|
+
success: string[];
|
|
39
|
+
error: string[];
|
|
40
|
+
warning: string[];
|
|
41
|
+
info: string[];
|
|
42
|
+
debug: string[];
|
|
43
|
+
light: string;
|
|
44
|
+
dim: string;
|
|
19
45
|
} | {
|
|
20
46
|
success: string[];
|
|
21
47
|
error: string[];
|
|
22
48
|
warning: string[];
|
|
23
49
|
info: string[];
|
|
24
50
|
debug: string[];
|
|
51
|
+
light: string;
|
|
52
|
+
dim: string;
|
|
25
53
|
};
|
|
26
54
|
apply(text: string, colors: string[]): string;
|
|
27
55
|
multiline(text: string, colors: string[]): string;
|
|
@@ -1,26 +1,21 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
info: string[];
|
|
23
|
-
debug: string[];
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
export type ThemeName = keyof typeof palettes;
|
|
1
|
+
export type ThemeName = 'zen' | 'neon' | 'pastel' | 'hacker' | 'sunset' | 'ocean' | 'cyberpunk' | 'dracula' | 'monokai' | 'vaporwave' | 'midnight' | 'forest' | 'volcano' | 'gold';
|
|
2
|
+
export interface Theme {
|
|
3
|
+
success: string[];
|
|
4
|
+
error: string[];
|
|
5
|
+
warning: string[];
|
|
6
|
+
info: string[];
|
|
7
|
+
debug: string[];
|
|
8
|
+
text: string;
|
|
9
|
+
dim: string;
|
|
10
|
+
accent: string;
|
|
11
|
+
bg?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const palettes: Record<ThemeName, Theme>;
|
|
14
|
+
export declare class PaletteEngine {
|
|
15
|
+
private currentTheme;
|
|
16
|
+
private theme;
|
|
17
|
+
setTheme(name: ThemeName): void;
|
|
18
|
+
get colors(): Theme;
|
|
19
|
+
apply(text: string, colors: string[]): string;
|
|
20
|
+
}
|
|
21
|
+
export declare const paint: PaletteEngine;
|
package/dist/styles/palettes.js
CHANGED
|
@@ -1,28 +1,182 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.palettes = void 0;
|
|
3
|
+
exports.paint = exports.PaletteEngine = exports.palettes = void 0;
|
|
4
|
+
const KaiChroma_1 = require("./KaiChroma");
|
|
4
5
|
exports.palettes = {
|
|
6
|
+
// 1. Zen (Minimalist, calming)
|
|
5
7
|
zen: {
|
|
6
8
|
success: ['#00b09b', '#96c93d'],
|
|
7
9
|
error: ['#ff416c', '#ff4b2b'],
|
|
8
10
|
warning: ['#f7971e', '#ffd200'],
|
|
9
11
|
info: ['#2193b0', '#6dd5ed'],
|
|
10
12
|
debug: ['#8e2de2', '#4a00e0'],
|
|
11
|
-
|
|
12
|
-
dim: '#888888'
|
|
13
|
+
text: '#ffffff',
|
|
14
|
+
dim: '#888888',
|
|
15
|
+
accent: '#00b09b'
|
|
13
16
|
},
|
|
17
|
+
// 2. Neon (Bright, cyber)
|
|
14
18
|
neon: {
|
|
15
|
-
success: ['#
|
|
16
|
-
error: ['#
|
|
17
|
-
warning: ['#
|
|
18
|
-
info: ['#
|
|
19
|
-
debug: ['#
|
|
19
|
+
success: ['#39ff14', '#00ffef'],
|
|
20
|
+
error: ['#ff0055', '#ff0099'],
|
|
21
|
+
warning: ['#ffff00', '#ffae00'],
|
|
22
|
+
info: ['#00ffff', '#0099ff'],
|
|
23
|
+
debug: ['#b300ff', '#8800ff'],
|
|
24
|
+
text: '#f0f0f0',
|
|
25
|
+
dim: '#666666',
|
|
26
|
+
accent: '#39ff14'
|
|
20
27
|
},
|
|
28
|
+
// 3. Cyberpunk 2077
|
|
29
|
+
cyberpunk: {
|
|
30
|
+
success: ['#00ff9f', '#00b8ff'], // Cyan to Blue
|
|
31
|
+
error: ['#ff003c', '#ff3cac'], // Cyber Red
|
|
32
|
+
warning: ['#fcee0a', '#ffae00'], // Cyber Yellow
|
|
33
|
+
info: ['#0abdc6', '#ea00d9'], // Blue to Pink
|
|
34
|
+
debug: ['#711c91', '#ea00d9'], // Purple
|
|
35
|
+
text: '#fcee0a', // Yellow text
|
|
36
|
+
dim: '#5e4e69',
|
|
37
|
+
accent: '#0abdc6'
|
|
38
|
+
},
|
|
39
|
+
// 4. Dracula (Dark mode favorite)
|
|
40
|
+
dracula: {
|
|
41
|
+
success: ['#50fa7b', '#8be9fd'],
|
|
42
|
+
error: ['#ff5555', '#ffb86c'],
|
|
43
|
+
warning: ['#ffb86c', '#f1fa8c'],
|
|
44
|
+
info: ['#bd93f9', '#ff79c6'],
|
|
45
|
+
debug: ['#6272a4', '#8be9fd'],
|
|
46
|
+
text: '#f8f8f2',
|
|
47
|
+
dim: '#6272a4',
|
|
48
|
+
accent: '#bd93f9'
|
|
49
|
+
},
|
|
50
|
+
// 5. Monokai
|
|
51
|
+
monokai: {
|
|
52
|
+
success: ['#a6e22e', '#a6e22e'],
|
|
53
|
+
error: ['#f92672', '#f92672'],
|
|
54
|
+
warning: ['#fd971f', '#e6db74'],
|
|
55
|
+
info: ['#66d9ef', '#ae81ff'],
|
|
56
|
+
debug: ['#ae81ff', '#fd971f'],
|
|
57
|
+
text: '#f8f8f2',
|
|
58
|
+
dim: '#75715e',
|
|
59
|
+
accent: '#a6e22e'
|
|
60
|
+
},
|
|
61
|
+
// 6. Vaporwave
|
|
62
|
+
vaporwave: {
|
|
63
|
+
success: ['#00f0ff', '#ff00aa'],
|
|
64
|
+
error: ['#ff2a00', '#ff0066'],
|
|
65
|
+
warning: ['#ffcc00', '#ff9900'],
|
|
66
|
+
info: ['#ff77ff', '#9933ff'],
|
|
67
|
+
debug: ['#9900ff', '#5500aa'],
|
|
68
|
+
text: '#ff99ff',
|
|
69
|
+
dim: '#554477',
|
|
70
|
+
accent: '#00f0ff'
|
|
71
|
+
},
|
|
72
|
+
// 7. Midnight (Deep blues)
|
|
73
|
+
midnight: {
|
|
74
|
+
success: ['#34e89e', '#0f3443'],
|
|
75
|
+
error: ['#cb2d3e', '#ef473a'],
|
|
76
|
+
warning: ['#ffc371', '#ff5f6d'],
|
|
77
|
+
info: ['#56ccf2', '#2f80ed'],
|
|
78
|
+
debug: ['#642b73', '#c6426e'],
|
|
79
|
+
text: '#d1d1d1',
|
|
80
|
+
dim: '#4b5563',
|
|
81
|
+
accent: '#56ccf2'
|
|
82
|
+
},
|
|
83
|
+
// 8. Sunset (Warm)
|
|
84
|
+
sunset: {
|
|
85
|
+
success: ['#11998e', '#38ef7d'],
|
|
86
|
+
error: ['#ee0979', '#ff6a00'],
|
|
87
|
+
warning: ['#ff9966', '#ff5e62'],
|
|
88
|
+
info: ['#00c6ff', '#0072ff'],
|
|
89
|
+
debug: ['#8360c3', '#2ebf91'],
|
|
90
|
+
text: '#ffedd5',
|
|
91
|
+
dim: '#7c2d12',
|
|
92
|
+
accent: '#ff9966'
|
|
93
|
+
},
|
|
94
|
+
// 9. Ocean (Blues/Greens)
|
|
95
|
+
ocean: {
|
|
96
|
+
success: ['#4cb8c4', '#3cd3ad'],
|
|
97
|
+
error: ['#ff416c', '#ff4b2b'],
|
|
98
|
+
warning: ['#f09819', '#edde5d'],
|
|
99
|
+
info: ['#2b5876', '#4e4376'],
|
|
100
|
+
debug: ['#1c92d2', '#f2fcfe'],
|
|
101
|
+
text: '#e0f2fe',
|
|
102
|
+
dim: '#1e3a8a',
|
|
103
|
+
accent: '#4cb8c4'
|
|
104
|
+
},
|
|
105
|
+
// 10. Pastel (Soft)
|
|
21
106
|
pastel: {
|
|
22
|
-
success: ['#
|
|
23
|
-
error: ['#
|
|
24
|
-
warning: ['#
|
|
25
|
-
info: ['#
|
|
26
|
-
debug: ['#
|
|
107
|
+
success: ['#B2F7EF', '#7BDFF2'],
|
|
108
|
+
error: ['#FFB7B2', '#FF9AA2'],
|
|
109
|
+
warning: ['#FFE29A', '#FFDAC1'],
|
|
110
|
+
info: ['#A0E7E5', '#B4F8C8'],
|
|
111
|
+
debug: ['#FBE7C6', '#C3B1E1'],
|
|
112
|
+
text: '#ffffff',
|
|
113
|
+
dim: '#a0a0a0',
|
|
114
|
+
accent: '#B2F7EF'
|
|
115
|
+
},
|
|
116
|
+
// 11. Hacker
|
|
117
|
+
hacker: {
|
|
118
|
+
success: ['#00ff00', '#003300'],
|
|
119
|
+
error: ['#ff0000', '#330000'],
|
|
120
|
+
warning: ['#ffff00', '#333300'],
|
|
121
|
+
info: ['#0000ff', '#000033'],
|
|
122
|
+
debug: ['#ff00ff', '#330033'],
|
|
123
|
+
text: '#00ff00',
|
|
124
|
+
dim: '#004400',
|
|
125
|
+
accent: '#00ff00'
|
|
126
|
+
},
|
|
127
|
+
// 12. Volcano
|
|
128
|
+
volcano: {
|
|
129
|
+
success: ['#FF8008', '#FFC837'],
|
|
130
|
+
error: ['#FF0000', '#950000'],
|
|
131
|
+
warning: ['#FF4B1F', '#1FDDFF'],
|
|
132
|
+
info: ['#ED4264', '#FFEDBC'],
|
|
133
|
+
debug: ['#2C3E50', '#FD746C'],
|
|
134
|
+
text: '#FFD700',
|
|
135
|
+
dim: '#500000',
|
|
136
|
+
accent: '#FF4B1F'
|
|
137
|
+
},
|
|
138
|
+
// 13. Forest
|
|
139
|
+
forest: {
|
|
140
|
+
success: ['#134E5E', '#71B280'],
|
|
141
|
+
error: ['#603813', '#b29f94'],
|
|
142
|
+
warning: ['#eacda3', '#d6ae7b'],
|
|
143
|
+
info: ['#5D4157', '#A8CABA'],
|
|
144
|
+
debug: ['#4DA0B0', '#D39D38'],
|
|
145
|
+
text: '#D4FFD6',
|
|
146
|
+
dim: '#2b3d2b',
|
|
147
|
+
accent: '#71B280'
|
|
148
|
+
},
|
|
149
|
+
// 14. Gold (Luxury)
|
|
150
|
+
gold: {
|
|
151
|
+
success: ['#F2994A', '#F2C94C'],
|
|
152
|
+
error: ['#8e2de2', '#4a00e0'],
|
|
153
|
+
warning: ['#CAC531', '#F3F9A7'],
|
|
154
|
+
info: ['#7F7FD5', '#86A8E7'],
|
|
155
|
+
debug: ['#E0EAFC', '#CFDEF3'],
|
|
156
|
+
text: '#FFD700',
|
|
157
|
+
dim: '#706015',
|
|
158
|
+
accent: '#F2C94C'
|
|
27
159
|
}
|
|
28
160
|
};
|
|
161
|
+
class PaletteEngine {
|
|
162
|
+
constructor() {
|
|
163
|
+
this.currentTheme = 'zen';
|
|
164
|
+
this.theme = exports.palettes.zen;
|
|
165
|
+
}
|
|
166
|
+
setTheme(name) {
|
|
167
|
+
if (exports.palettes[name]) {
|
|
168
|
+
this.currentTheme = name;
|
|
169
|
+
this.theme = exports.palettes[name];
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
get colors() {
|
|
173
|
+
return this.theme;
|
|
174
|
+
}
|
|
175
|
+
apply(text, colors) {
|
|
176
|
+
if (colors.length === 1)
|
|
177
|
+
return KaiChroma_1.KaiChroma.hex(colors[0], text);
|
|
178
|
+
return KaiChroma_1.KaiChroma.gradient(colors, text);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
exports.PaletteEngine = PaletteEngine;
|
|
182
|
+
exports.paint = new PaletteEngine();
|