kailogger 1.0.1-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 +60 -48
- package/dist/core/Logger.d.ts +1 -1
- package/dist/core/Logger.js +36 -39
- package/dist/features/Chart.js +8 -9
- package/dist/features/Diff.js +4 -8
- package/dist/features/Encrypt.js +5 -5
- package/dist/features/Notify.js +40 -1
- package/dist/features/Screenshot.js +0 -3
- package/dist/features/Sound.d.ts +1 -0
- package/dist/features/Sound.js +37 -39
- package/dist/features/Timer.js +3 -7
- package/dist/features/Tree.js +5 -8
- package/dist/icon/logo.png +0 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -7
- 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/palettes.d.ts +21 -57
- package/dist/styles/palettes.js +160 -37
- package/dist/transports/ConsoleTransport.js +2 -2
- package/dist/utils/json.js +8 -11
- package/dist/utils/prettyError.js +16 -18
- package/dist/utils/progress.js +5 -7
- package/dist/utils/prompt.js +3 -3
- package/dist/utils/selection.js +14 -24
- package/dist/utils/spinner.d.ts +1 -1
- package/dist/utils/spinner.js +9 -13
- package/dist/utils/stripAnsi.js +2 -1
- package/dist/utils/table.js +4 -7
- package/examples/demo.js +134 -0
- package/package.json +4 -9
- package/scripts/copy-assets.js +37 -0
- package/src/core/Logger.ts +148 -31
- package/src/features/Chart.ts +25 -5
- package/src/features/Diff.ts +2 -2
- package/src/features/Encrypt.ts +13 -5
- package/src/features/Sound.ts +51 -25
- package/src/features/Timer.ts +3 -3
- package/src/features/Tree.ts +6 -5
- package/src/index.ts +1 -1
- package/src/styles/KaiChroma.ts +370 -0
- package/src/styles/palettes.ts +190 -38
- package/src/transports/ConsoleTransport.ts +2 -2
- package/src/utils/json.ts +14 -6
- package/src/utils/prettyError.ts +26 -13
- package/src/utils/progress.ts +19 -5
- package/src/utils/prompt.ts +6 -2
- package/src/utils/selection.ts +40 -17
- package/src/utils/spinner.ts +11 -7
- package/src/utils/stripAnsi.ts +4 -1
- package/src/utils/table.ts +10 -3
- package/src/styles/gradients.ts +0 -22
package/README.md
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
# KaiLogger
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
> The Ultimate Logger for Node.js — Beautiful, powerful, and designed for developers who care about aesthetics.
|
|
4
4
|
|
|
5
5
|
<p align="center">
|
|
6
6
|
<img src="https://files.catbox.moe/et33ah.png" alt="KaiLogger Logo" width="600" />
|
|
7
7
|
</p>
|
|
8
8
|
|
|
9
|
-

|
|
10
10
|

|
|
11
11
|
|
|
12
|
-
Turn your boring console logs into a cyber-aesthetic experience. KaiLogger
|
|
12
|
+
Turn your boring console logs into a cyber-aesthetic experience. KaiLogger is a complete CLI toolkit featuring a custom high-performance color engine (KaiChroma) with TrueColor support, gradients, and 14 built-in themes.
|
|
13
13
|
|
|
14
14
|
---
|
|
15
15
|
|
|
16
16
|
## Features
|
|
17
17
|
|
|
18
|
-
| Category | Features
|
|
19
|
-
| --------------- |
|
|
20
|
-
| **Logging** | Log levels, scoped loggers, custom badges, silent mode
|
|
21
|
-
| **Styling** |
|
|
22
|
-
| **Interactive** | Spinners, progress bars, select menus, prompts
|
|
23
|
-
| **Debug** | Pretty errors, JSON highlighting, diff view, tree view
|
|
24
|
-
| **Visuals** | **Charts** (Bar, Sparkline, Gauge), **Screenshots**
|
|
25
|
-
| **System** | **Desktop Notifications**, **Encryption**, **Sound Alerts**
|
|
26
|
-
| **Transports** | Console, File (with rotation), Webhooks
|
|
18
|
+
| Category | Features |
|
|
19
|
+
| --------------- | -------------------------------------------------------------- |
|
|
20
|
+
| **Logging** | Log levels, scoped loggers, custom badges, silent mode |
|
|
21
|
+
| **Styling** | **14 Themes**, custom gradients, KaiChroma engine (TrueColor) |
|
|
22
|
+
| **Interactive** | Spinners, progress bars, select menus, prompts |
|
|
23
|
+
| **Debug** | Pretty errors, JSON highlighting, diff view, tree view |
|
|
24
|
+
| **Visuals** | **Charts** (Bar, Sparkline, Gauge), **Screenshots** (TXT/HTML) |
|
|
25
|
+
| **System** | **Desktop Notifications**, **Encryption**, **Sound Alerts** |
|
|
26
|
+
| **Transports** | Console, File (with rotation), Webhooks |
|
|
27
27
|
|
|
28
28
|
---
|
|
29
29
|
|
|
@@ -45,15 +45,45 @@ kai.error("Something went wrong");
|
|
|
45
45
|
kai.warning("Careful there");
|
|
46
46
|
kai.info("Just FYI");
|
|
47
47
|
kai.debug("For your eyes only");
|
|
48
|
+
|
|
49
|
+
// Enable sound
|
|
50
|
+
kai.beep();
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## Themes
|
|
56
|
+
|
|
57
|
+
Switch between 14 stunning themes powered by our custom KaiChroma engine.
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
kai.setTheme("cyberpunk");
|
|
48
61
|
```
|
|
49
62
|
|
|
63
|
+
**Available Themes:**
|
|
64
|
+
|
|
65
|
+
- `zen` (Minimalist)
|
|
66
|
+
- `neon` (Bright cyber)
|
|
67
|
+
- `pastel` (Soft colors)
|
|
68
|
+
- `hacker` (Matrix style)
|
|
69
|
+
- `sunset` (Warm gradients)
|
|
70
|
+
- `ocean` (Blue/Green tones)
|
|
71
|
+
- `cyberpunk` (Blue/Pink/Yellow)
|
|
72
|
+
- `dracula` (Dark mode favorite)
|
|
73
|
+
- `monokai` (Classic code style)
|
|
74
|
+
- `vaporwave` (Aesthetic purple/cyan)
|
|
75
|
+
- `midnight` (Deep blues)
|
|
76
|
+
- `forest` (Nature tones)
|
|
77
|
+
- `volcano` (Fiery reds/oranges)
|
|
78
|
+
- `gold` (Luxury)
|
|
79
|
+
|
|
50
80
|
---
|
|
51
81
|
|
|
52
|
-
## Charts
|
|
82
|
+
## Charts
|
|
53
83
|
|
|
54
84
|
Visualize data directly in your terminal.
|
|
55
85
|
|
|
56
|
-
|
|
86
|
+
**Bar Chart**
|
|
57
87
|
|
|
58
88
|
```typescript
|
|
59
89
|
kai.chart([
|
|
@@ -63,14 +93,14 @@ kai.chart([
|
|
|
63
93
|
]);
|
|
64
94
|
```
|
|
65
95
|
|
|
66
|
-
|
|
96
|
+
**Sparkline**
|
|
67
97
|
|
|
68
98
|
```typescript
|
|
69
99
|
kai.sparkline([10, 25, 40, 35, 60, 90, 45, 20]);
|
|
70
100
|
// Output: ▂▃▄▃▅▇▄▂
|
|
71
101
|
```
|
|
72
102
|
|
|
73
|
-
|
|
103
|
+
**Gauge**
|
|
74
104
|
|
|
75
105
|
```typescript
|
|
76
106
|
kai.gauge(75, 100, "CPU");
|
|
@@ -79,39 +109,37 @@ kai.gauge(75, 100, "CPU");
|
|
|
79
109
|
|
|
80
110
|
---
|
|
81
111
|
|
|
82
|
-
## Notifications & Sounds
|
|
83
|
-
|
|
84
|
-
### Desktop Notifications
|
|
112
|
+
## Notifications & Sounds
|
|
85
113
|
|
|
114
|
+
**Desktop Notifications**
|
|
86
115
|
Send native system notifications.
|
|
87
116
|
|
|
88
117
|
```typescript
|
|
89
|
-
kai.notify("Build complete!", "
|
|
118
|
+
kai.notify("Build complete!", "Success");
|
|
90
119
|
```
|
|
91
120
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
Play sounds for events. (Requires `src/sounds` folder or system sounds)
|
|
121
|
+
**Sound Alerts**
|
|
122
|
+
Play sounds for events (Success, Error, Warning, Notification).
|
|
95
123
|
|
|
96
124
|
```typescript
|
|
97
|
-
//
|
|
125
|
+
// Optional: Set custom sounds directory
|
|
98
126
|
kai.setSoundsDir("./src/sounds");
|
|
99
127
|
|
|
100
128
|
await kai.soundSuccess();
|
|
101
129
|
await kai.soundError();
|
|
102
|
-
kai.
|
|
130
|
+
kai.playSound("custom.wav");
|
|
103
131
|
```
|
|
104
132
|
|
|
105
133
|
---
|
|
106
134
|
|
|
107
|
-
## Encryption
|
|
135
|
+
## Encryption
|
|
108
136
|
|
|
109
137
|
Handle sensitive data securely.
|
|
110
138
|
|
|
111
139
|
```typescript
|
|
112
140
|
// Mask sensitive info in logs
|
|
113
141
|
kai.masked("API Key", "sk-1234567890abcdef", 4);
|
|
114
|
-
//
|
|
142
|
+
// API Key: ************cdef
|
|
115
143
|
|
|
116
144
|
// Encrypt/Decrypt helpers
|
|
117
145
|
const secret = kai.encrypted("My Secret Data", "my-key");
|
|
@@ -120,7 +148,7 @@ kai.decrypted(secret, "my-key");
|
|
|
120
148
|
|
|
121
149
|
---
|
|
122
150
|
|
|
123
|
-
## Screen Capture
|
|
151
|
+
## Screen Capture
|
|
124
152
|
|
|
125
153
|
Capture terminal output to file.
|
|
126
154
|
|
|
@@ -136,15 +164,6 @@ kai.saveScreenshotHtml("logs/session.html"); // Saves as styled HTML!
|
|
|
136
164
|
|
|
137
165
|
---
|
|
138
166
|
|
|
139
|
-
## Themes
|
|
140
|
-
|
|
141
|
-
```typescript
|
|
142
|
-
kai.setTheme("neon");
|
|
143
|
-
// Options: 'zen', 'neon', 'pastel', 'hacker', 'sunset', 'ocean'
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
---
|
|
147
|
-
|
|
148
167
|
## Log Levels & Scopes
|
|
149
168
|
|
|
150
169
|
```typescript
|
|
@@ -158,17 +177,6 @@ db.info("Connected"); // [Database] Connected
|
|
|
158
177
|
|
|
159
178
|
---
|
|
160
179
|
|
|
161
|
-
## Performance Timer
|
|
162
|
-
|
|
163
|
-
```typescript
|
|
164
|
-
kai.time("query");
|
|
165
|
-
await db.query();
|
|
166
|
-
kai.timeEnd("query");
|
|
167
|
-
// ⏱ query: 145.32ms ⚡
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
---
|
|
171
|
-
|
|
172
180
|
## Tree & Diff View
|
|
173
181
|
|
|
174
182
|
```typescript
|
|
@@ -188,6 +196,10 @@ kai.diff({ status: "idle" }, { status: "active" });
|
|
|
188
196
|
```typescript
|
|
189
197
|
const name = await kai.ask("Name?");
|
|
190
198
|
const framework = await kai.select("Framework", ["React", "Vue", "Svelte"]);
|
|
199
|
+
|
|
200
|
+
// Progress Bar
|
|
201
|
+
const bar = kai.createProgress(100);
|
|
202
|
+
bar.update(50);
|
|
191
203
|
```
|
|
192
204
|
|
|
193
205
|
---
|
package/dist/core/Logger.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { KaiProgress } from '../utils/progress';
|
|
2
1
|
import { ThemeName } from '../styles/palettes';
|
|
2
|
+
import { KaiProgress } from '../utils/progress';
|
|
3
3
|
import { ScopedLogger } from './Scope';
|
|
4
4
|
import { LogLevel } from '../types';
|
|
5
5
|
import { FileTransportOptions } from '../transports/FileTransport';
|
package/dist/core/Logger.js
CHANGED
|
@@ -32,14 +32,11 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
36
|
exports.kai = exports.KaiLogger = void 0;
|
|
40
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
41
37
|
const fs = __importStar(require("fs"));
|
|
42
|
-
const
|
|
38
|
+
const palettes_1 = require("../styles/palettes");
|
|
39
|
+
const KaiChroma_1 = require("../styles/KaiChroma");
|
|
43
40
|
const spinner_1 = require("../utils/spinner");
|
|
44
41
|
const progress_1 = require("../utils/progress");
|
|
45
42
|
const table_1 = require("../utils/table");
|
|
@@ -48,7 +45,6 @@ const selection_1 = require("../utils/selection");
|
|
|
48
45
|
const json_1 = require("../utils/json");
|
|
49
46
|
const prettyError_1 = require("../utils/prettyError");
|
|
50
47
|
const stripAnsi_1 = require("../utils/stripAnsi");
|
|
51
|
-
const palettes_1 = require("../styles/palettes");
|
|
52
48
|
const Config_1 = require("./Config");
|
|
53
49
|
const Scope_1 = require("./Scope");
|
|
54
50
|
const Timer_1 = require("../features/Timer");
|
|
@@ -81,7 +77,7 @@ class KaiLogger {
|
|
|
81
77
|
this.silent = options.silent || false;
|
|
82
78
|
this.timestampFormat = options.timestamp || 'locale';
|
|
83
79
|
}
|
|
84
|
-
|
|
80
|
+
palettes_1.paint.setTheme(this.theme);
|
|
85
81
|
}
|
|
86
82
|
// ========== CONFIGURATION ==========
|
|
87
83
|
configure(options) {
|
|
@@ -98,7 +94,7 @@ class KaiLogger {
|
|
|
98
94
|
}
|
|
99
95
|
setTheme(theme) {
|
|
100
96
|
this.theme = theme;
|
|
101
|
-
|
|
97
|
+
palettes_1.paint.setTheme(theme);
|
|
102
98
|
}
|
|
103
99
|
setLevel(level) {
|
|
104
100
|
this.level = level;
|
|
@@ -150,7 +146,6 @@ class KaiLogger {
|
|
|
150
146
|
const logLine = `${this.getTime()} [${level.toUpperCase()}] ${cleanMsg}\n`;
|
|
151
147
|
fs.appendFileSync(this.logFilePath, logLine);
|
|
152
148
|
}
|
|
153
|
-
// Also log to configured transports
|
|
154
149
|
const transports = Config_1.config.get('transports') || [];
|
|
155
150
|
transports.forEach(t => t.log(level, message));
|
|
156
151
|
}
|
|
@@ -170,9 +165,10 @@ class KaiLogger {
|
|
|
170
165
|
return;
|
|
171
166
|
}
|
|
172
167
|
this.stopSpinner();
|
|
173
|
-
|
|
174
|
-
const
|
|
175
|
-
const
|
|
168
|
+
// Accedemos safe a paint.colors[level]
|
|
169
|
+
const colors = palettes_1.paint.colors[level];
|
|
170
|
+
const time = this.timestampFormat !== 'none' ? KaiChroma_1.KaiChroma.hex('#666666', this.getTime()) + ' ' : '';
|
|
171
|
+
const badge = palettes_1.paint.apply(` ${label.padEnd(7)} `, colors);
|
|
176
172
|
const output = `${time}${badge} ${message}`;
|
|
177
173
|
console.log(output, ...args);
|
|
178
174
|
const fileMsg = [message, ...args.map(a => typeof a === 'object' ? JSON.stringify(a) : a)].join(' ');
|
|
@@ -187,7 +183,7 @@ class KaiLogger {
|
|
|
187
183
|
return;
|
|
188
184
|
if (message instanceof Error) {
|
|
189
185
|
this.stopSpinner();
|
|
190
|
-
prettyError_1.PrettyError.handle(message, palettes_1.
|
|
186
|
+
prettyError_1.PrettyError.handle(message, palettes_1.paint.colors);
|
|
191
187
|
this.logToFile('error', message.toString());
|
|
192
188
|
this.addToBuffer('error', message.toString());
|
|
193
189
|
}
|
|
@@ -208,7 +204,7 @@ class KaiLogger {
|
|
|
208
204
|
if (this.silent)
|
|
209
205
|
return;
|
|
210
206
|
this.stopSpinner();
|
|
211
|
-
const time = this.timestampFormat !== 'none' ?
|
|
207
|
+
const time = this.timestampFormat !== 'none' ? KaiChroma_1.KaiChroma.hex('#666666', this.getTime()) + ' ' : '';
|
|
212
208
|
console.log(`${time}${message}`);
|
|
213
209
|
this.logToFile('log', message);
|
|
214
210
|
}
|
|
@@ -217,8 +213,8 @@ class KaiLogger {
|
|
|
217
213
|
if (this.silent)
|
|
218
214
|
return;
|
|
219
215
|
this.stopSpinner();
|
|
220
|
-
const time = this.timestampFormat !== 'none' ?
|
|
221
|
-
const styledBadge =
|
|
216
|
+
const time = this.timestampFormat !== 'none' ? KaiChroma_1.KaiChroma.hex('#666666', this.getTime()) + ' ' : '';
|
|
217
|
+
const styledBadge = KaiChroma_1.KaiChroma.bgHex(color, ` ${badge.toUpperCase().padEnd(7)} `);
|
|
222
218
|
console.log(`${time}${styledBadge} ${message}`, ...args);
|
|
223
219
|
this.logToFile(badge, message);
|
|
224
220
|
}
|
|
@@ -228,15 +224,15 @@ class KaiLogger {
|
|
|
228
224
|
return;
|
|
229
225
|
this.stopSpinner();
|
|
230
226
|
const width = Math.max(message.length, title.length) + 4;
|
|
231
|
-
const border =
|
|
232
|
-
const topLeft =
|
|
233
|
-
const topRight =
|
|
234
|
-
const bottomLeft =
|
|
235
|
-
const bottomRight =
|
|
236
|
-
const side =
|
|
227
|
+
const border = palettes_1.paint.apply('─'.repeat(width), palettes_1.paint.colors.info);
|
|
228
|
+
const topLeft = palettes_1.paint.apply('╭', palettes_1.paint.colors.info);
|
|
229
|
+
const topRight = palettes_1.paint.apply('╮', palettes_1.paint.colors.info);
|
|
230
|
+
const bottomLeft = palettes_1.paint.apply('╰', palettes_1.paint.colors.info);
|
|
231
|
+
const bottomRight = palettes_1.paint.apply('╯', palettes_1.paint.colors.info);
|
|
232
|
+
const side = palettes_1.paint.apply('│', palettes_1.paint.colors.info);
|
|
237
233
|
console.log(`${topLeft}${border}${topRight}`);
|
|
238
|
-
console.log(`${side} ${
|
|
239
|
-
console.log(`${side}${
|
|
234
|
+
console.log(`${side} ${palettes_1.paint.apply(title.padEnd(width - 2), palettes_1.paint.colors.success)} ${side}`);
|
|
235
|
+
console.log(`${side}${palettes_1.paint.apply('─'.repeat(width), palettes_1.paint.colors.debug)}${side}`);
|
|
240
236
|
console.log(`${side} ${message.padEnd(width - 2)} ${side}`);
|
|
241
237
|
console.log(`${bottomLeft}${border}${bottomRight}`);
|
|
242
238
|
this.logToFile('box', `${title}: ${message}`);
|
|
@@ -245,15 +241,15 @@ class KaiLogger {
|
|
|
245
241
|
await(message) {
|
|
246
242
|
if (this.silent)
|
|
247
243
|
return;
|
|
248
|
-
this.spinner.start(message,
|
|
244
|
+
this.spinner.start(message, palettes_1.paint.colors.info[0]);
|
|
249
245
|
}
|
|
250
246
|
stop(message) {
|
|
251
|
-
this.spinner.stop('✔', message,
|
|
247
|
+
this.spinner.stop('✔', message, palettes_1.paint.colors.success[1]);
|
|
252
248
|
if (message)
|
|
253
249
|
this.logToFile('stop', message);
|
|
254
250
|
}
|
|
255
251
|
stopSpinner() {
|
|
256
|
-
|
|
252
|
+
this.spinner.stop();
|
|
257
253
|
}
|
|
258
254
|
// ========== PROGRESS ==========
|
|
259
255
|
createProgress(total, width) {
|
|
@@ -264,7 +260,7 @@ class KaiLogger {
|
|
|
264
260
|
if (this.silent)
|
|
265
261
|
return;
|
|
266
262
|
this.stopSpinner();
|
|
267
|
-
table_1.KaiTable.print(data, palettes_1.
|
|
263
|
+
table_1.KaiTable.print(data, palettes_1.paint.colors);
|
|
268
264
|
this.logToFile('table', JSON.stringify(data));
|
|
269
265
|
}
|
|
270
266
|
// ========== JSON ==========
|
|
@@ -272,7 +268,7 @@ class KaiLogger {
|
|
|
272
268
|
if (this.silent)
|
|
273
269
|
return;
|
|
274
270
|
this.stopSpinner();
|
|
275
|
-
json_1.KaiJson.print(data, palettes_1.
|
|
271
|
+
json_1.KaiJson.print(data, palettes_1.paint.colors);
|
|
276
272
|
this.logToFile('json', JSON.stringify(data));
|
|
277
273
|
}
|
|
278
274
|
// ========== TREE ==========
|
|
@@ -280,7 +276,7 @@ class KaiLogger {
|
|
|
280
276
|
if (this.silent)
|
|
281
277
|
return;
|
|
282
278
|
this.stopSpinner();
|
|
283
|
-
Tree_1.KaiTree.print(data, palettes_1.
|
|
279
|
+
Tree_1.KaiTree.print(data, palettes_1.paint.colors);
|
|
284
280
|
this.logToFile('tree', JSON.stringify(data));
|
|
285
281
|
}
|
|
286
282
|
// ========== DIFF ==========
|
|
@@ -288,7 +284,7 @@ class KaiLogger {
|
|
|
288
284
|
if (this.silent)
|
|
289
285
|
return;
|
|
290
286
|
this.stopSpinner();
|
|
291
|
-
Diff_1.KaiDiff.print(before, after, palettes_1.
|
|
287
|
+
Diff_1.KaiDiff.print(before, after, palettes_1.paint.colors);
|
|
292
288
|
this.logToFile('diff', JSON.stringify({ before, after }));
|
|
293
289
|
}
|
|
294
290
|
// ========== TIMER ==========
|
|
@@ -298,30 +294,31 @@ class KaiLogger {
|
|
|
298
294
|
timeEnd(label) {
|
|
299
295
|
if (this.silent)
|
|
300
296
|
return null;
|
|
301
|
-
return this.timer.timeEnd(label, palettes_1.
|
|
297
|
+
return this.timer.timeEnd(label, palettes_1.paint.colors);
|
|
302
298
|
}
|
|
303
299
|
// ========== PROMPTS ==========
|
|
304
300
|
async ask(question) {
|
|
305
301
|
this.stopSpinner();
|
|
306
|
-
|
|
302
|
+
// Pasamos theme.info colors, asumimos que prompt maneja esto
|
|
303
|
+
const answer = await prompt_1.KaiPrompt.ask(question, palettes_1.paint.colors);
|
|
307
304
|
this.logToFile('ask', `${question} -> ${answer}`);
|
|
308
305
|
return answer;
|
|
309
306
|
}
|
|
310
307
|
async confirm(question) {
|
|
311
308
|
this.stopSpinner();
|
|
312
|
-
const answer = await prompt_1.KaiPrompt.confirm(question, palettes_1.
|
|
309
|
+
const answer = await prompt_1.KaiPrompt.confirm(question, palettes_1.paint.colors);
|
|
313
310
|
this.logToFile('confirm', `${question} -> ${answer}`);
|
|
314
311
|
return answer;
|
|
315
312
|
}
|
|
316
313
|
async select(question, options) {
|
|
317
314
|
this.stopSpinner();
|
|
318
|
-
const answer = await selection_1.KaiSelection.select(question, options, palettes_1.
|
|
315
|
+
const answer = await selection_1.KaiSelection.select(question, options, palettes_1.paint.colors);
|
|
319
316
|
this.logToFile('select', `${question} -> ${answer}`);
|
|
320
317
|
return answer;
|
|
321
318
|
}
|
|
322
319
|
async multiselect(question, options) {
|
|
323
320
|
this.stopSpinner();
|
|
324
|
-
const answer = await selection_1.KaiSelection.multiselect(question, options, palettes_1.
|
|
321
|
+
const answer = await selection_1.KaiSelection.multiselect(question, options, palettes_1.paint.colors);
|
|
325
322
|
this.logToFile('multiselect', `${question} -> ${answer.join(', ')}`);
|
|
326
323
|
return answer;
|
|
327
324
|
}
|
|
@@ -330,19 +327,19 @@ class KaiLogger {
|
|
|
330
327
|
if (this.silent)
|
|
331
328
|
return;
|
|
332
329
|
this.stopSpinner();
|
|
333
|
-
Chart_1.KaiChart.bar(data, palettes_1.
|
|
330
|
+
Chart_1.KaiChart.bar(data, palettes_1.paint.colors, options);
|
|
334
331
|
}
|
|
335
332
|
sparkline(values) {
|
|
336
333
|
if (this.silent)
|
|
337
334
|
return;
|
|
338
335
|
this.stopSpinner();
|
|
339
|
-
Chart_1.KaiChart.sparkline(values, palettes_1.
|
|
336
|
+
Chart_1.KaiChart.sparkline(values, palettes_1.paint.colors);
|
|
340
337
|
}
|
|
341
338
|
gauge(value, max, label) {
|
|
342
339
|
if (this.silent)
|
|
343
340
|
return;
|
|
344
341
|
this.stopSpinner();
|
|
345
|
-
Chart_1.KaiChart.gauge(value, max, palettes_1.
|
|
342
|
+
Chart_1.KaiChart.gauge(value, max, palettes_1.paint.colors, label);
|
|
346
343
|
}
|
|
347
344
|
// ========== NOTIFICATIONS ==========
|
|
348
345
|
notify(message, title) {
|
package/dist/features/Chart.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.KaiChart = void 0;
|
|
7
|
-
const
|
|
8
|
-
const
|
|
4
|
+
const KaiChroma_1 = require("../styles/KaiChroma");
|
|
5
|
+
const palettes_1 = require("../styles/palettes");
|
|
9
6
|
class KaiChart {
|
|
10
7
|
static bar(data, theme, options) {
|
|
11
8
|
const width = options?.width || 30;
|
|
@@ -22,11 +19,13 @@ class KaiChart {
|
|
|
22
19
|
// Cycle through theme colors
|
|
23
20
|
const colorKeys = ['success', 'info', 'warning', 'error', 'debug'];
|
|
24
21
|
const colorKey = colorKeys[index % colorKeys.length];
|
|
22
|
+
// @ts-ignore
|
|
25
23
|
const colors = theme[colorKey];
|
|
26
24
|
const label = item.label.padEnd(maxLabelLength);
|
|
27
|
-
|
|
25
|
+
// Usamos PaletteEngine apply (que usa KaiChroma)
|
|
26
|
+
const bar = palettes_1.paint.apply(filled, colors) + KaiChroma_1.KaiChroma.hex('#666666', empty);
|
|
28
27
|
const value = showValues ? ` ${item.value}` : '';
|
|
29
|
-
console.log(`${
|
|
28
|
+
console.log(`${KaiChroma_1.KaiChroma.bold(label)} ${bar}${KaiChroma_1.KaiChroma.dim(value)}`);
|
|
30
29
|
});
|
|
31
30
|
console.log('');
|
|
32
31
|
}
|
|
@@ -42,7 +41,7 @@ class KaiChart {
|
|
|
42
41
|
const index = Math.floor(((v - min) / range) * (chars.length - 1));
|
|
43
42
|
return chars[index];
|
|
44
43
|
}).join('');
|
|
45
|
-
console.log(
|
|
44
|
+
console.log(palettes_1.paint.apply(line, theme.info));
|
|
46
45
|
}
|
|
47
46
|
static gauge(value, max, theme, label) {
|
|
48
47
|
const percentage = Math.min(1, value / max);
|
|
@@ -56,7 +55,7 @@ class KaiChart {
|
|
|
56
55
|
colors = theme.warning;
|
|
57
56
|
if (percentage > 0.9)
|
|
58
57
|
colors = theme.error;
|
|
59
|
-
const bar =
|
|
58
|
+
const bar = palettes_1.paint.apply(filled, colors) + KaiChroma_1.KaiChroma.hex('#666666', empty);
|
|
60
59
|
const percentText = Math.round(percentage * 100) + '%';
|
|
61
60
|
const labelText = label ? `${label}: ` : '';
|
|
62
61
|
console.log(`${labelText}[${bar}] ${percentText}`);
|
package/dist/features/Diff.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.KaiDiff = void 0;
|
|
4
|
-
const
|
|
4
|
+
const palettes_1 = require("../styles/palettes");
|
|
5
5
|
class KaiDiff {
|
|
6
6
|
static print(before, after, theme, path = '') {
|
|
7
7
|
const allKeys = new Set([
|
|
@@ -13,20 +13,16 @@ class KaiDiff {
|
|
|
13
13
|
const oldVal = before?.[key];
|
|
14
14
|
const newVal = after?.[key];
|
|
15
15
|
if (oldVal === undefined && newVal !== undefined) {
|
|
16
|
-
|
|
17
|
-
console.log(gradients_1.paint.apply(`+ ${fullPath}: ${JSON.stringify(newVal)}`, theme.success));
|
|
16
|
+
console.log(palettes_1.paint.apply(`+ ${fullPath}: ${JSON.stringify(newVal)}`, theme.success));
|
|
18
17
|
}
|
|
19
18
|
else if (oldVal !== undefined && newVal === undefined) {
|
|
20
|
-
|
|
21
|
-
console.log(gradients_1.paint.apply(`- ${fullPath}: ${JSON.stringify(oldVal)}`, theme.error));
|
|
19
|
+
console.log(palettes_1.paint.apply(`- ${fullPath}: ${JSON.stringify(oldVal)}`, theme.error));
|
|
22
20
|
}
|
|
23
21
|
else if (typeof oldVal === 'object' && typeof newVal === 'object' && oldVal !== null && newVal !== null) {
|
|
24
|
-
// Recurse into nested objects
|
|
25
22
|
KaiDiff.print(oldVal, newVal, theme, fullPath);
|
|
26
23
|
}
|
|
27
24
|
else if (oldVal !== newVal) {
|
|
28
|
-
|
|
29
|
-
console.log(gradients_1.paint.apply(`~ ${fullPath}: ${JSON.stringify(oldVal)} → ${JSON.stringify(newVal)}`, theme.warning));
|
|
25
|
+
console.log(palettes_1.paint.apply(`~ ${fullPath}: ${JSON.stringify(oldVal)} → ${JSON.stringify(newVal)}`, theme.warning));
|
|
30
26
|
}
|
|
31
27
|
});
|
|
32
28
|
}
|
package/dist/features/Encrypt.js
CHANGED
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.KaiEncrypt = void 0;
|
|
7
7
|
const crypto_js_1 = __importDefault(require("crypto-js"));
|
|
8
|
-
const
|
|
8
|
+
const KaiChroma_1 = require("../styles/KaiChroma");
|
|
9
9
|
class KaiEncrypt {
|
|
10
10
|
static setDefaultKey(key) {
|
|
11
11
|
this.defaultKey = key;
|
|
@@ -21,15 +21,15 @@ class KaiEncrypt {
|
|
|
21
21
|
}
|
|
22
22
|
static printEncrypted(message, key) {
|
|
23
23
|
const encrypted = this.encrypt(message, key);
|
|
24
|
-
console.log(
|
|
24
|
+
console.log(KaiChroma_1.KaiChroma.hex('#FF00FF', '🔐 [ENCRYPTED] ') + KaiChroma_1.KaiChroma.dim(encrypted));
|
|
25
25
|
}
|
|
26
26
|
static printDecrypted(encrypted, key) {
|
|
27
27
|
try {
|
|
28
28
|
const decrypted = this.decrypt(encrypted, key);
|
|
29
|
-
console.log(
|
|
29
|
+
console.log(KaiChroma_1.KaiChroma.hex('#00FF00', '🔓 [DECRYPTED] ') + decrypted);
|
|
30
30
|
}
|
|
31
31
|
catch (e) {
|
|
32
|
-
console.log(
|
|
32
|
+
console.log(KaiChroma_1.KaiChroma.hex('#FF0000', '❌ [DECRYPT FAILED] Invalid key or corrupted data'));
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
static mask(message, showLast = 4) {
|
|
@@ -40,7 +40,7 @@ class KaiEncrypt {
|
|
|
40
40
|
return masked + visible;
|
|
41
41
|
}
|
|
42
42
|
static printMasked(label, value, showLast = 4) {
|
|
43
|
-
console.log(
|
|
43
|
+
console.log(KaiChroma_1.KaiChroma.hex('#FFFF00', `🔒 ${label}: `) + KaiChroma_1.KaiChroma.dim(this.mask(value, showLast)));
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
exports.KaiEncrypt = KaiEncrypt;
|
package/dist/features/Notify.js
CHANGED
|
@@ -1,16 +1,55 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
37
|
};
|
|
5
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
39
|
exports.KaiNotify = void 0;
|
|
7
40
|
const node_notifier_1 = __importDefault(require("node-notifier"));
|
|
41
|
+
const path = __importStar(require("path"));
|
|
8
42
|
class KaiNotify {
|
|
9
43
|
static send(options) {
|
|
44
|
+
const defaultIcon = path.join(__dirname, '../../src/icon/logo.png');
|
|
45
|
+
let iconPath = options.icon || defaultIcon;
|
|
46
|
+
if (__filename.includes('dist')) {
|
|
47
|
+
iconPath = options.icon || path.join(__dirname, '../icon/logo.png');
|
|
48
|
+
}
|
|
10
49
|
node_notifier_1.default.notify({
|
|
11
50
|
title: options.title || 'KaiLogger',
|
|
12
51
|
message: options.message,
|
|
13
|
-
icon:
|
|
52
|
+
icon: iconPath,
|
|
14
53
|
sound: options.sound !== false,
|
|
15
54
|
wait: options.wait || false
|
|
16
55
|
});
|
|
@@ -41,7 +41,6 @@ class KaiScreenshot {
|
|
|
41
41
|
static startCapture() {
|
|
42
42
|
this.buffer = [];
|
|
43
43
|
this.isRecording = true;
|
|
44
|
-
// Override console.log to capture output
|
|
45
44
|
const originalLog = console.log;
|
|
46
45
|
console.log = (...args) => {
|
|
47
46
|
if (this.isRecording) {
|
|
@@ -60,7 +59,6 @@ class KaiScreenshot {
|
|
|
60
59
|
if (dir && !fs.existsSync(dir)) {
|
|
61
60
|
fs.mkdirSync(dir, { recursive: true });
|
|
62
61
|
}
|
|
63
|
-
// Clean ANSI codes and save as text
|
|
64
62
|
const cleanLines = this.buffer.map(line => (0, stripAnsi_1.stripAnsi)(line));
|
|
65
63
|
const content = cleanLines.join('\n');
|
|
66
64
|
fs.writeFileSync(filename, content);
|
|
@@ -70,7 +68,6 @@ class KaiScreenshot {
|
|
|
70
68
|
if (dir && !fs.existsSync(dir)) {
|
|
71
69
|
fs.mkdirSync(dir, { recursive: true });
|
|
72
70
|
}
|
|
73
|
-
// Convert ANSI to HTML (basic conversion)
|
|
74
71
|
const htmlContent = `<!DOCTYPE html>
|
|
75
72
|
<html>
|
|
76
73
|
<head>
|