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,47 @@
|
|
|
1
|
+
|
|
2
|
+
import CryptoJS from 'crypto-js';
|
|
3
|
+
import { KaiChroma } from '../styles/KaiChroma';
|
|
4
|
+
|
|
5
|
+
export class KaiEncrypt {
|
|
6
|
+
private static defaultKey: string = 'kailogger-secret-key';
|
|
7
|
+
|
|
8
|
+
static setDefaultKey(key: string): void {
|
|
9
|
+
this.defaultKey = key;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
static encrypt(message: string, key?: string): string {
|
|
13
|
+
const secretKey = key || this.defaultKey;
|
|
14
|
+
return CryptoJS.AES.encrypt(message, secretKey).toString();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
static decrypt(encrypted: string, key?: string): string {
|
|
18
|
+
const secretKey = key || this.defaultKey;
|
|
19
|
+
const bytes = CryptoJS.AES.decrypt(encrypted, secretKey);
|
|
20
|
+
return bytes.toString(CryptoJS.enc.Utf8);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
static printEncrypted(message: string, key?: string): void {
|
|
24
|
+
const encrypted = this.encrypt(message, key);
|
|
25
|
+
console.log(KaiChroma.hex('#FF00FF', '🔐 [ENCRYPTED] ') + KaiChroma.dim(encrypted));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
static printDecrypted(encrypted: string, key?: string): void {
|
|
29
|
+
try {
|
|
30
|
+
const decrypted = this.decrypt(encrypted, key);
|
|
31
|
+
console.log(KaiChroma.hex('#00FF00', '🔓 [DECRYPTED] ') + decrypted);
|
|
32
|
+
} catch (e) {
|
|
33
|
+
console.log(KaiChroma.hex('#FF0000', '❌ [DECRYPT FAILED] Invalid key or corrupted data'));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
static mask(message: string, showLast: number = 4): string {
|
|
38
|
+
if (message.length <= showLast) return '*'.repeat(message.length);
|
|
39
|
+
const masked = '*'.repeat(message.length - showLast);
|
|
40
|
+
const visible = message.slice(-showLast);
|
|
41
|
+
return masked + visible;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
static printMasked(label: string, value: string, showLast: number = 4): void {
|
|
45
|
+
console.log(KaiChroma.hex('#FFFF00', `🔒 ${label}: `) + KaiChroma.dim(this.mask(value, showLast)));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import notifier from 'node-notifier';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
|
|
4
|
+
export interface NotificationOptions {
|
|
5
|
+
title?: string;
|
|
6
|
+
message: string;
|
|
7
|
+
icon?: string;
|
|
8
|
+
sound?: boolean;
|
|
9
|
+
wait?: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export class KaiNotify {
|
|
13
|
+
static send(options: NotificationOptions): void {
|
|
14
|
+
const defaultIcon = path.join(__dirname, '../../src/icon/logo.png');
|
|
15
|
+
let iconPath = options.icon || defaultIcon;
|
|
16
|
+
if (__filename.includes('dist')) {
|
|
17
|
+
iconPath = options.icon || path.join(__dirname, '../icon/logo.png');
|
|
18
|
+
}
|
|
19
|
+
notifier.notify({
|
|
20
|
+
title: options.title || 'KaiLogger',
|
|
21
|
+
message: options.message,
|
|
22
|
+
icon: iconPath,
|
|
23
|
+
sound: options.sound !== false,
|
|
24
|
+
wait: options.wait || false
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
static success(message: string): void {
|
|
28
|
+
this.send({ title: '✅ Success', message, sound: true });
|
|
29
|
+
}
|
|
30
|
+
static error(message: string): void {
|
|
31
|
+
this.send({ title: '❌ Error', message, sound: true });
|
|
32
|
+
}
|
|
33
|
+
static warning(message: string): void {
|
|
34
|
+
this.send({ title: '⚠️ Warning', message, sound: true });
|
|
35
|
+
}
|
|
36
|
+
static info(message: string): void {
|
|
37
|
+
this.send({ title: 'ℹ️ Info', message, sound: false });
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import { stripAnsi } from '../utils/stripAnsi';
|
|
4
|
+
|
|
5
|
+
export class KaiScreenshot {
|
|
6
|
+
private static buffer: string[] = [];
|
|
7
|
+
private static isRecording: boolean = false;
|
|
8
|
+
static startCapture(): void {
|
|
9
|
+
this.buffer = [];
|
|
10
|
+
this.isRecording = true;
|
|
11
|
+
const originalLog = console.log;
|
|
12
|
+
console.log = (...args: any[]) => {
|
|
13
|
+
if (this.isRecording) {
|
|
14
|
+
const line = args.map(a => typeof a === 'object' ? JSON.stringify(a) : String(a)).join(' ');
|
|
15
|
+
this.buffer.push(line);
|
|
16
|
+
}
|
|
17
|
+
originalLog.apply(console, args);
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
static stopCapture(): string[] {
|
|
21
|
+
this.isRecording = false;
|
|
22
|
+
return [...this.buffer];
|
|
23
|
+
}
|
|
24
|
+
static save(filename: string): void {
|
|
25
|
+
const dir = path.dirname(filename);
|
|
26
|
+
if (dir && !fs.existsSync(dir)) {
|
|
27
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
28
|
+
}
|
|
29
|
+
const cleanLines = this.buffer.map(line => stripAnsi(line));
|
|
30
|
+
const content = cleanLines.join('\n');
|
|
31
|
+
fs.writeFileSync(filename, content);
|
|
32
|
+
}
|
|
33
|
+
static saveHtml(filename: string): void {
|
|
34
|
+
const dir = path.dirname(filename);
|
|
35
|
+
if (dir && !fs.existsSync(dir)) {
|
|
36
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
37
|
+
}
|
|
38
|
+
const htmlContent = `<!DOCTYPE html>
|
|
39
|
+
<html>
|
|
40
|
+
<head>
|
|
41
|
+
<meta charset="UTF-8">
|
|
42
|
+
<title>KaiLogger Screenshot</title>
|
|
43
|
+
<style>
|
|
44
|
+
body {
|
|
45
|
+
background: #1a1a2e;
|
|
46
|
+
color: #eee;
|
|
47
|
+
font-family: 'Consolas', 'Monaco', monospace;
|
|
48
|
+
padding: 20px;
|
|
49
|
+
font-size: 14px;
|
|
50
|
+
line-height: 1.5;
|
|
51
|
+
}
|
|
52
|
+
pre {
|
|
53
|
+
white-space: pre-wrap;
|
|
54
|
+
word-wrap: break-word;
|
|
55
|
+
}
|
|
56
|
+
</style>
|
|
57
|
+
</head>
|
|
58
|
+
<body>
|
|
59
|
+
<pre>${this.buffer.map(line => stripAnsi(line)).join('\n')}</pre>
|
|
60
|
+
</body>
|
|
61
|
+
</html>`;
|
|
62
|
+
fs.writeFileSync(filename, htmlContent);
|
|
63
|
+
}
|
|
64
|
+
static getBuffer(): string[] {
|
|
65
|
+
return [...this.buffer];
|
|
66
|
+
}
|
|
67
|
+
static clear(): void {
|
|
68
|
+
this.buffer = [];
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
|
|
2
|
+
import * as fs from 'fs';
|
|
3
|
+
import * as path from 'path';
|
|
4
|
+
|
|
5
|
+
export class KaiSound {
|
|
6
|
+
private static soundsDir: string | null = null;
|
|
7
|
+
|
|
8
|
+
static setSoundsDir(dir: string): void {
|
|
9
|
+
this.soundsDir = dir;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
private static getSoundPath(filename: string): string | null {
|
|
13
|
+
// 1. Explicitly set directory
|
|
14
|
+
if (this.soundsDir) {
|
|
15
|
+
const p = path.join(this.soundsDir, filename);
|
|
16
|
+
if (fs.existsSync(p)) return p;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// 2. Local src/sounds (Development)
|
|
20
|
+
const srcPath = path.join(__dirname, '../../src/sounds', filename);
|
|
21
|
+
if (fs.existsSync(srcPath)) return srcPath;
|
|
22
|
+
|
|
23
|
+
// 3. Dist sounds (Production/Installed)
|
|
24
|
+
// __dirname is .../dist/features
|
|
25
|
+
const distPath = path.join(__dirname, '../sounds', filename);
|
|
26
|
+
if (fs.existsSync(distPath)) return distPath;
|
|
27
|
+
|
|
28
|
+
// 4. Node modules fallback (if imported deeply)
|
|
29
|
+
try {
|
|
30
|
+
const pkgPath = require.resolve('kailogger/package.json');
|
|
31
|
+
const pkgDir = path.dirname(pkgPath);
|
|
32
|
+
const enrolledPath = path.join(pkgDir, 'dist/sounds', filename);
|
|
33
|
+
if(fs.existsSync(enrolledPath)) return enrolledPath;
|
|
34
|
+
} catch (e) {
|
|
35
|
+
// ignore
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
private static async playFile(filename: string): Promise<void> {
|
|
42
|
+
const filepath = this.getSoundPath(filename);
|
|
43
|
+
|
|
44
|
+
if (!filepath) {
|
|
45
|
+
this.beep();
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const { exec } = await import('child_process');
|
|
50
|
+
const platform = process.platform;
|
|
51
|
+
|
|
52
|
+
return new Promise((resolve) => {
|
|
53
|
+
let command: string;
|
|
54
|
+
|
|
55
|
+
if (platform === 'win32') {
|
|
56
|
+
command = `powershell -c "(New-Object Media.SoundPlayer '${filepath}').PlaySync()"`;
|
|
57
|
+
} else if (platform === 'darwin') {
|
|
58
|
+
command = `afplay "${filepath}"`;
|
|
59
|
+
} else {
|
|
60
|
+
command = `aplay "${filepath}" 2>/dev/null || paplay "${filepath}" 2>/dev/null`;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
exec(command, (error) => {
|
|
64
|
+
resolve();
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
static beep(): void {
|
|
70
|
+
process.stdout.write('\x07');
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
static async success(): Promise<void> {
|
|
74
|
+
await this.playFile('success.wav');
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
static async error(): Promise<void> {
|
|
78
|
+
await this.playFile('error.wav');
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
static async warning(): Promise<void> {
|
|
82
|
+
await this.playFile('warning.wav');
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
static async notification(): Promise<void> {
|
|
86
|
+
await this.playFile('notification.wav');
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
static async play(filename: string): Promise<void> {
|
|
90
|
+
await this.playFile(filename);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
|
|
2
|
+
import { paint } from '../styles/palettes';
|
|
3
|
+
|
|
4
|
+
export class KaiTimer {
|
|
5
|
+
private timers: Map<string, number> = new Map();
|
|
6
|
+
time(label: string): void {
|
|
7
|
+
this.timers.set(label, performance.now());
|
|
8
|
+
}
|
|
9
|
+
timeEnd(label: string, theme: any): number | null {
|
|
10
|
+
const start = this.timers.get(label);
|
|
11
|
+
if (!start) {
|
|
12
|
+
console.log(paint.apply(`⚠ Timer "${label}" does not exist`, theme.warning));
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
const duration = performance.now() - start;
|
|
16
|
+
this.timers.delete(label);
|
|
17
|
+
const ms = duration.toFixed(2);
|
|
18
|
+
let color = theme.success;
|
|
19
|
+
let emoji = '⚡';
|
|
20
|
+
|
|
21
|
+
if (duration > 1000) {
|
|
22
|
+
color = theme.warning;
|
|
23
|
+
emoji = '🐢';
|
|
24
|
+
}
|
|
25
|
+
if (duration > 5000) {
|
|
26
|
+
color = theme.error;
|
|
27
|
+
emoji = '🔥';
|
|
28
|
+
}
|
|
29
|
+
console.log(paint.apply(` ⏱ ${label}: ${ms}ms ${emoji} `, color));
|
|
30
|
+
return duration;
|
|
31
|
+
}
|
|
32
|
+
clear(): void {
|
|
33
|
+
this.timers.clear();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
|
|
2
|
+
import { KaiChroma } from '../styles/KaiChroma';
|
|
3
|
+
import { paint } from '../styles/palettes';
|
|
4
|
+
|
|
5
|
+
interface TreeNode {
|
|
6
|
+
[key: string]: TreeNode | null;
|
|
7
|
+
}
|
|
8
|
+
export class KaiTree {
|
|
9
|
+
static print(obj: TreeNode, theme: any, prefix: string = '', isLast: boolean = true): void {
|
|
10
|
+
const keys = Object.keys(obj);
|
|
11
|
+
keys.forEach((key, index) => {
|
|
12
|
+
const isLastItem = index === keys.length - 1;
|
|
13
|
+
const connector = isLastItem ? '└── ' : '├── ';
|
|
14
|
+
const value = obj[key];
|
|
15
|
+
const line = prefix + connector; // connector + key part
|
|
16
|
+
if (value === null) {
|
|
17
|
+
console.log(KaiChroma.hex(theme.dim, prefix + connector) + paint.apply(key, theme.info));
|
|
18
|
+
} else {
|
|
19
|
+
console.log(KaiChroma.hex(theme.dim, prefix + connector) + paint.apply(key + '/', theme.success));
|
|
20
|
+
const newPrefix = prefix + (isLastItem ? ' ' : '│ ');
|
|
21
|
+
KaiTree.print(value, theme, newPrefix, isLastItem);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
Binary file
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
1
|
export * from './core/Logger';
|
|
2
|
+
export * from './core/Config';
|
|
3
|
+
export * from './core/Scope';
|
|
2
4
|
export * from './styles/palettes';
|
|
3
|
-
export * from './styles/
|
|
5
|
+
export * from './styles/KaiChroma';
|
|
6
|
+
export * from './types';
|
|
7
|
+
export * from './transports';
|
|
8
|
+
export * from './features';
|
|
9
|
+
export { KaiSpinner } from './utils/spinner';
|
|
10
|
+
export { KaiProgress } from './utils/progress';
|
|
11
|
+
export { KaiTable } from './utils/table';
|
|
12
|
+
export { KaiJson } from './utils/json';
|
|
13
|
+
export { KaiPrompt } from './utils/prompt';
|
|
14
|
+
export { KaiSelection } from './utils/selection';
|
|
15
|
+
export { PrettyError } from './utils/prettyError';
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|