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.
Files changed (56) hide show
  1. package/README.md +60 -48
  2. package/dist/core/Logger.d.ts +1 -1
  3. package/dist/core/Logger.js +36 -39
  4. package/dist/features/Chart.js +8 -9
  5. package/dist/features/Diff.js +4 -8
  6. package/dist/features/Encrypt.js +5 -5
  7. package/dist/features/Notify.js +40 -1
  8. package/dist/features/Screenshot.js +0 -3
  9. package/dist/features/Sound.d.ts +1 -0
  10. package/dist/features/Sound.js +37 -39
  11. package/dist/features/Timer.js +3 -7
  12. package/dist/features/Tree.js +5 -8
  13. package/dist/icon/logo.png +0 -0
  14. package/dist/index.d.ts +1 -1
  15. package/dist/index.js +1 -7
  16. package/dist/sounds/error.wav +0 -0
  17. package/dist/sounds/notification.wav +0 -0
  18. package/dist/sounds/success.wav +0 -0
  19. package/dist/sounds/warning.wav +0 -0
  20. package/dist/styles/KaiChroma.d.ts +85 -0
  21. package/dist/styles/KaiChroma.js +407 -0
  22. package/dist/styles/palettes.d.ts +21 -57
  23. package/dist/styles/palettes.js +160 -37
  24. package/dist/transports/ConsoleTransport.js +2 -2
  25. package/dist/utils/json.js +8 -11
  26. package/dist/utils/prettyError.js +16 -18
  27. package/dist/utils/progress.js +5 -7
  28. package/dist/utils/prompt.js +3 -3
  29. package/dist/utils/selection.js +14 -24
  30. package/dist/utils/spinner.d.ts +1 -1
  31. package/dist/utils/spinner.js +9 -13
  32. package/dist/utils/stripAnsi.js +2 -1
  33. package/dist/utils/table.js +4 -7
  34. package/examples/demo.js +134 -0
  35. package/package.json +4 -9
  36. package/scripts/copy-assets.js +37 -0
  37. package/src/core/Logger.ts +148 -31
  38. package/src/features/Chart.ts +25 -5
  39. package/src/features/Diff.ts +2 -2
  40. package/src/features/Encrypt.ts +13 -5
  41. package/src/features/Sound.ts +51 -25
  42. package/src/features/Timer.ts +3 -3
  43. package/src/features/Tree.ts +6 -5
  44. package/src/index.ts +1 -1
  45. package/src/styles/KaiChroma.ts +370 -0
  46. package/src/styles/palettes.ts +190 -38
  47. package/src/transports/ConsoleTransport.ts +2 -2
  48. package/src/utils/json.ts +14 -6
  49. package/src/utils/prettyError.ts +26 -13
  50. package/src/utils/progress.ts +19 -5
  51. package/src/utils/prompt.ts +6 -2
  52. package/src/utils/selection.ts +40 -17
  53. package/src/utils/spinner.ts +11 -7
  54. package/src/utils/stripAnsi.ts +4 -1
  55. package/src/utils/table.ts +10 -3
  56. package/src/styles/gradients.ts +0 -22
@@ -34,20 +34,44 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.KaiSound = void 0;
37
- const path = __importStar(require("path"));
38
37
  const fs = __importStar(require("fs"));
39
- // For cross-platform sound, we'll use different approaches
40
- // Windows: PowerShell
41
- // Mac: afplay
42
- // Linux: aplay or paplay
38
+ const path = __importStar(require("path"));
43
39
  class KaiSound {
44
40
  static setSoundsDir(dir) {
45
41
  this.soundsDir = dir;
46
42
  }
43
+ static getSoundPath(filename) {
44
+ // 1. Explicitly set directory
45
+ if (this.soundsDir) {
46
+ const p = path.join(this.soundsDir, filename);
47
+ if (fs.existsSync(p))
48
+ return p;
49
+ }
50
+ // 2. Local src/sounds (Development)
51
+ const srcPath = path.join(__dirname, '../../src/sounds', filename);
52
+ if (fs.existsSync(srcPath))
53
+ return srcPath;
54
+ // 3. Dist sounds (Production/Installed)
55
+ // __dirname is .../dist/features
56
+ const distPath = path.join(__dirname, '../sounds', filename);
57
+ if (fs.existsSync(distPath))
58
+ return distPath;
59
+ // 4. Node modules fallback (if imported deeply)
60
+ try {
61
+ const pkgPath = require.resolve('kailogger/package.json');
62
+ const pkgDir = path.dirname(pkgPath);
63
+ const enrolledPath = path.join(pkgDir, 'dist/sounds', filename);
64
+ if (fs.existsSync(enrolledPath))
65
+ return enrolledPath;
66
+ }
67
+ catch (e) {
68
+ // ignore
69
+ }
70
+ return null;
71
+ }
47
72
  static async playFile(filename) {
48
- const filepath = this.soundsDir ? path.join(this.soundsDir, filename) : filename;
49
- if (!fs.existsSync(filepath)) {
50
- // Fallback to system beep
73
+ const filepath = this.getSoundPath(filename);
74
+ if (!filepath) {
51
75
  this.beep();
52
76
  return;
53
77
  }
@@ -56,15 +80,12 @@ class KaiSound {
56
80
  return new Promise((resolve) => {
57
81
  let command;
58
82
  if (platform === 'win32') {
59
- // Windows - use PowerShell
60
83
  command = `powershell -c "(New-Object Media.SoundPlayer '${filepath}').PlaySync()"`;
61
84
  }
62
85
  else if (platform === 'darwin') {
63
- // macOS
64
86
  command = `afplay "${filepath}"`;
65
87
  }
66
88
  else {
67
- // Linux
68
89
  command = `aplay "${filepath}" 2>/dev/null || paplay "${filepath}" 2>/dev/null`;
69
90
  }
70
91
  exec(command, (error) => {
@@ -73,46 +94,23 @@ class KaiSound {
73
94
  });
74
95
  }
75
96
  static beep() {
76
- // Universal beep using stdout
77
97
  process.stdout.write('\x07');
78
98
  }
79
99
  static async success() {
80
- if (this.soundsDir && fs.existsSync(path.join(this.soundsDir, 'success.wav'))) {
81
- await this.playFile('success.wav');
82
- }
83
- else {
84
- this.beep();
85
- }
100
+ await this.playFile('success.wav');
86
101
  }
87
102
  static async error() {
88
- if (this.soundsDir && fs.existsSync(path.join(this.soundsDir, 'error.wav'))) {
89
- await this.playFile('error.wav');
90
- }
91
- else {
92
- // Double beep for error
93
- this.beep();
94
- setTimeout(() => this.beep(), 200);
95
- }
103
+ await this.playFile('error.wav');
96
104
  }
97
105
  static async warning() {
98
- if (this.soundsDir && fs.existsSync(path.join(this.soundsDir, 'warning.wav'))) {
99
- await this.playFile('warning.wav');
100
- }
101
- else {
102
- this.beep();
103
- }
106
+ await this.playFile('warning.wav');
104
107
  }
105
108
  static async notification() {
106
- if (this.soundsDir && fs.existsSync(path.join(this.soundsDir, 'notification.wav'))) {
107
- await this.playFile('notification.wav');
108
- }
109
- else {
110
- this.beep();
111
- }
109
+ await this.playFile('notification.wav');
112
110
  }
113
111
  static async play(filename) {
114
112
  await this.playFile(filename);
115
113
  }
116
114
  }
117
115
  exports.KaiSound = KaiSound;
118
- KaiSound.soundsDir = '';
116
+ KaiSound.soundsDir = null;
@@ -1,11 +1,7 @@
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.KaiTimer = void 0;
7
- const chalk_1 = __importDefault(require("chalk"));
8
- const gradients_1 = require("../styles/gradients");
4
+ const palettes_1 = require("../styles/palettes");
9
5
  class KaiTimer {
10
6
  constructor() {
11
7
  this.timers = new Map();
@@ -16,7 +12,7 @@ class KaiTimer {
16
12
  timeEnd(label, theme) {
17
13
  const start = this.timers.get(label);
18
14
  if (!start) {
19
- console.log(chalk_1.default.yellow(`⚠ Timer "${label}" does not exist`));
15
+ console.log(palettes_1.paint.apply(`⚠ Timer "${label}" does not exist`, theme.warning));
20
16
  return null;
21
17
  }
22
18
  const duration = performance.now() - start;
@@ -32,7 +28,7 @@ class KaiTimer {
32
28
  color = theme.error;
33
29
  emoji = '🔥';
34
30
  }
35
- console.log(gradients_1.paint.apply(` ⏱ ${label}: ${ms}ms ${emoji} `, color));
31
+ console.log(palettes_1.paint.apply(` ⏱ ${label}: ${ms}ms ${emoji} `, color));
36
32
  return duration;
37
33
  }
38
34
  clear() {
@@ -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.KaiTree = void 0;
7
- const chalk_1 = __importDefault(require("chalk"));
8
- const gradients_1 = require("../styles/gradients");
4
+ const KaiChroma_1 = require("../styles/KaiChroma");
5
+ const palettes_1 = require("../styles/palettes");
9
6
  class KaiTree {
10
7
  static print(obj, theme, prefix = '', isLast = true) {
11
8
  const keys = Object.keys(obj);
@@ -13,12 +10,12 @@ class KaiTree {
13
10
  const isLastItem = index === keys.length - 1;
14
11
  const connector = isLastItem ? '└── ' : '├── ';
15
12
  const value = obj[key];
16
- const line = prefix + connector + key;
13
+ const line = prefix + connector; // connector + key part
17
14
  if (value === null) {
18
- console.log(chalk_1.default.gray(prefix + connector) + gradients_1.paint.apply(key, theme.info));
15
+ console.log(KaiChroma_1.KaiChroma.hex(theme.dim, prefix + connector) + palettes_1.paint.apply(key, theme.info));
19
16
  }
20
17
  else {
21
- console.log(chalk_1.default.gray(prefix + connector) + gradients_1.paint.apply(key + '/', theme.success));
18
+ console.log(KaiChroma_1.KaiChroma.hex(theme.dim, prefix + connector) + palettes_1.paint.apply(key + '/', theme.success));
22
19
  const newPrefix = prefix + (isLastItem ? ' ' : '│ ');
23
20
  KaiTree.print(value, theme, newPrefix, isLastItem);
24
21
  }
Binary file
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ export * from './core/Logger';
2
2
  export * from './core/Config';
3
3
  export * from './core/Scope';
4
4
  export * from './styles/palettes';
5
- export * from './styles/gradients';
5
+ export * from './styles/KaiChroma';
6
6
  export * from './types';
7
7
  export * from './transports';
8
8
  export * from './features';
package/dist/index.js CHANGED
@@ -15,20 +15,14 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.PrettyError = exports.KaiSelection = exports.KaiPrompt = exports.KaiJson = exports.KaiTable = exports.KaiProgress = exports.KaiSpinner = void 0;
18
- // Core
19
18
  __exportStar(require("./core/Logger"), exports);
20
19
  __exportStar(require("./core/Config"), exports);
21
20
  __exportStar(require("./core/Scope"), exports);
22
- // Styles
23
21
  __exportStar(require("./styles/palettes"), exports);
24
- __exportStar(require("./styles/gradients"), exports);
25
- // Types
22
+ __exportStar(require("./styles/KaiChroma"), exports);
26
23
  __exportStar(require("./types"), exports);
27
- // Transports
28
24
  __exportStar(require("./transports"), exports);
29
- // Features
30
25
  __exportStar(require("./features"), exports);
31
- // Utils (selective exports)
32
26
  var spinner_1 = require("./utils/spinner");
33
27
  Object.defineProperty(exports, "KaiSpinner", { enumerable: true, get: function () { return spinner_1.KaiSpinner; } });
34
28
  var progress_1 = require("./utils/progress");
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,85 @@
1
+ export type Color = [number, number, number];
2
+ export type HexColor = string;
3
+ export type RgbColor = {
4
+ r: number;
5
+ g: number;
6
+ b: number;
7
+ };
8
+ export type HslColor = {
9
+ h: number;
10
+ s: number;
11
+ l: number;
12
+ };
13
+ export type ColorStop = {
14
+ color: string;
15
+ position: number;
16
+ };
17
+ export type GradientOptions = {
18
+ interpolation?: 'linear' | 'ease' | 'bezier' | 'smooth';
19
+ direction?: 'horizontal' | 'vertical' | 'diagonal';
20
+ stops?: ColorStop[];
21
+ };
22
+ export type StyleOptions = {
23
+ bold?: boolean;
24
+ dim?: boolean;
25
+ italic?: boolean;
26
+ underline?: boolean;
27
+ inverse?: boolean;
28
+ strikethrough?: boolean;
29
+ blink?: boolean;
30
+ hidden?: boolean;
31
+ };
32
+ export declare class KaiChroma {
33
+ private static cache;
34
+ private static readonly MAX_CACHE_SIZE;
35
+ private static hexToRgb;
36
+ private static rgbToHex;
37
+ private static rgbToHsl;
38
+ private static hslToRgb;
39
+ private static rgbToAnsi256;
40
+ private static interpolateLinear;
41
+ private static interpolateEase;
42
+ private static interpolateBezier;
43
+ private static interpolateSmooth;
44
+ static hex(hex: string, text: string): string;
45
+ static rgb(r: number, g: number, b: number, text: string): string;
46
+ static hsl(h: number, s: number, l: number, text: string): string;
47
+ static bgHex(hex: string, text: string): string;
48
+ static bgRgb(r: number, g: number, b: number, text: string): string;
49
+ static bold(text: string): string;
50
+ static dim(text: string): string;
51
+ static italic(text: string): string;
52
+ static underline(text: string): string;
53
+ static inverse(text: string): string;
54
+ static hidden(text: string): string;
55
+ static strikethrough(text: string): string;
56
+ static blink(text: string): string;
57
+ static style(text: string, options: StyleOptions): string;
58
+ static gradient(colors: string[], text: string, options?: GradientOptions): string;
59
+ static rainbowGradient(text: string): string;
60
+ static sunsetGradient(text: string): string;
61
+ static oceanGradient(text: string): string;
62
+ static fireGradient(text: string): string;
63
+ static matrixGradient(text: string): string;
64
+ static lighten(hex: string, amount: number): string;
65
+ static darken(hex: string, amount: number): string;
66
+ static saturate(hex: string, amount: number): string;
67
+ static desaturate(hex: string, amount: number): string;
68
+ static rotate(hex: string, degrees: number): string;
69
+ static mix(hex1: string, hex2: string, weight?: number): string;
70
+ static analogous(hex: string, count?: number): string[];
71
+ static complementary(hex: string): string[];
72
+ static triadic(hex: string): string[];
73
+ static tetradic(hex: string): string[];
74
+ static monochromatic(hex: string, count?: number): string[];
75
+ static strip(text: string): string;
76
+ static getSupport(): number;
77
+ static getSupportName(): string;
78
+ static isSupported(): boolean;
79
+ static textLength(text: string): number;
80
+ static box(text: string, color?: string, padding?: number): string;
81
+ static wave(text: string, colors: string[]): string;
82
+ static pulse(text: string, color: string, frames?: number): string[];
83
+ private static clearCacheIfNeeded;
84
+ }
85
+ export default KaiChroma;