traceperf 0.1.0 → 0.1.1

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 (71) hide show
  1. package/README.md +31 -0
  2. package/dist/browser.d.ts +9 -3
  3. package/dist/browser.js +28 -8
  4. package/dist/browser.js.map +1 -1
  5. package/dist/esm/browser.d.ts +73 -0
  6. package/dist/esm/browser.js +275 -0
  7. package/dist/esm/browser.js.map +1 -0
  8. package/dist/esm/core/config.d.ts +77 -0
  9. package/dist/esm/core/config.js +112 -0
  10. package/dist/esm/core/config.js.map +1 -0
  11. package/dist/esm/core/constants.d.ts +78 -0
  12. package/dist/esm/core/constants.js +106 -0
  13. package/dist/esm/core/constants.js.map +1 -0
  14. package/dist/esm/core/index.d.ts +3 -0
  15. package/dist/esm/core/index.js +4 -0
  16. package/dist/esm/core/index.js.map +1 -0
  17. package/dist/esm/core/logger.d.ts +84 -0
  18. package/dist/esm/core/logger.js +170 -0
  19. package/dist/esm/core/logger.js.map +1 -0
  20. package/dist/esm/formatters/ascii.d.ts +52 -0
  21. package/dist/esm/formatters/ascii.js +100 -0
  22. package/dist/esm/formatters/ascii.js.map +1 -0
  23. package/dist/esm/formatters/cli.d.ts +50 -0
  24. package/dist/esm/formatters/cli.js +96 -0
  25. package/dist/esm/formatters/cli.js.map +1 -0
  26. package/dist/esm/formatters/index.d.ts +3 -0
  27. package/dist/esm/formatters/index.js +4 -0
  28. package/dist/esm/formatters/index.js.map +1 -0
  29. package/dist/esm/formatters/json.d.ts +45 -0
  30. package/dist/esm/formatters/json.js +85 -0
  31. package/dist/esm/formatters/json.js.map +1 -0
  32. package/dist/esm/index.d.ts +10 -0
  33. package/dist/esm/index.js +29 -0
  34. package/dist/esm/index.js.map +1 -0
  35. package/dist/esm/trackers/execution.d.ts +72 -0
  36. package/dist/esm/trackers/execution.js +143 -0
  37. package/dist/esm/trackers/execution.js.map +1 -0
  38. package/dist/esm/trackers/index.d.ts +2 -0
  39. package/dist/esm/trackers/index.js +3 -0
  40. package/dist/esm/trackers/index.js.map +1 -0
  41. package/dist/esm/trackers/performance.d.ts +82 -0
  42. package/dist/esm/trackers/performance.js +106 -0
  43. package/dist/esm/trackers/performance.js.map +1 -0
  44. package/dist/esm/types/config.d.ts +110 -0
  45. package/dist/esm/types/config.js +2 -0
  46. package/dist/esm/types/config.js.map +1 -0
  47. package/dist/esm/types/index.d.ts +2 -0
  48. package/dist/esm/types/index.js +3 -0
  49. package/dist/esm/types/index.js.map +1 -0
  50. package/dist/esm/types/logger.d.ts +127 -0
  51. package/dist/esm/types/logger.js +2 -0
  52. package/dist/esm/types/logger.js.map +1 -0
  53. package/dist/esm/utils/colors.d.ts +87 -0
  54. package/dist/esm/utils/colors.js +134 -0
  55. package/dist/esm/utils/colors.js.map +1 -0
  56. package/dist/esm/utils/index.d.ts +3 -0
  57. package/dist/esm/utils/index.js +4 -0
  58. package/dist/esm/utils/index.js.map +1 -0
  59. package/dist/esm/utils/stack.d.ts +63 -0
  60. package/dist/esm/utils/stack.js +110 -0
  61. package/dist/esm/utils/stack.js.map +1 -0
  62. package/dist/esm/utils/timing.d.ts +65 -0
  63. package/dist/esm/utils/timing.js +99 -0
  64. package/dist/esm/utils/timing.js.map +1 -0
  65. package/dist/index.js +13 -0
  66. package/dist/index.js.map +1 -1
  67. package/dist/types/config.js +2 -1
  68. package/dist/types/index.js +18 -2
  69. package/dist/types/index.js.map +1 -1
  70. package/dist/types/logger.js +2 -1
  71. package/package.json +16 -2
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution.js","sourceRoot":"","sources":["../../../src/trackers/execution.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EAAiB,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAiBvE;;GAEG;AACH,MAAM,OAA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QACtE,MAAM,cAAc,GAAG,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAEhE,0BAA0B;QAC1B,OAAO,IAAI,CAAC,eAAe,CAAC,iBAAiB,CAAC,cAAc,CAAC,CAAC;IAChE,CAAC;IAED;;OAEG;IACI,KAAK;QACV,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;QAC9B,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;IAC1B,CAAC;IAED;;;;OAIG;IACI,aAAa;QAClB,OAAO,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC;IAC/B,CAAC;IAED;;;;;OAKG;IACK,iBAAiB,CAAC,UAA6B;QACrD,MAAM,MAAM,GAAoB,EAAE,CAAC;QAEnC,kDAAkD;QAClD,MAAM,OAAO,GAAG,CAAC,MAAuB,EAAQ,EAAE;YAChD,MAAM,CAAC,IAAI,CAAC;gBACV,IAAI,EAAE,MAAM,CAAC,IAAI;gBACjB,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,WAAW,EAAE,MAAM,CAAC,WAAW;gBAC/B,KAAK,EAAE,MAAM,CAAC,KAAK;aACpB,CAAC,CAAC;YAEH,mBAAmB;YACnB,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;QACnD,CAAC,CAAC;QAEF,8BAA8B;QAC9B,UAAU,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC;QAEpD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
@@ -0,0 +1,2 @@
1
+ export * from './execution';
2
+ export * from './performance';
@@ -0,0 +1,3 @@
1
+ export * from './execution';
2
+ export * from './performance';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/trackers/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC"}
@@ -0,0 +1,82 @@
1
+ import { IPerformanceMonitor } from '../types';
2
+ /**
3
+ * Performance monitor for tracking execution times and memory usage
4
+ */
5
+ export declare class PerformanceMonitor implements IPerformanceMonitor {
6
+ private _timers;
7
+ private _defaultThreshold;
8
+ /**
9
+ * Create a new PerformanceMonitor instance
10
+ *
11
+ * @param options - Monitor options
12
+ */
13
+ constructor(options?: {
14
+ defaultThreshold?: number;
15
+ });
16
+ /**
17
+ * Start timing an operation
18
+ *
19
+ * @param label - Label for the operation
20
+ * @returns A unique identifier for the timing operation
21
+ */
22
+ startTimer(label: string): string;
23
+ /**
24
+ * End timing an operation
25
+ *
26
+ * @param id - The identifier returned by startTimer
27
+ * @returns The duration in milliseconds
28
+ * @throws Error if the timer doesn't exist
29
+ */
30
+ endTimer(id: string): number;
31
+ /**
32
+ * Check if an operation exceeds the performance threshold
33
+ *
34
+ * @param duration - The duration in milliseconds
35
+ * @param threshold - The threshold to check against
36
+ * @returns Whether the operation is considered slow
37
+ */
38
+ isBottleneck(duration: number, threshold?: number): boolean;
39
+ /**
40
+ * Get memory usage information
41
+ *
42
+ * @returns Memory usage in bytes
43
+ */
44
+ getMemoryUsage(): {
45
+ heapUsed: number;
46
+ heapTotal: number;
47
+ external: number;
48
+ rss: number;
49
+ };
50
+ /**
51
+ * Get memory difference between two points
52
+ *
53
+ * @param before - Memory usage before
54
+ * @param after - Memory usage after
55
+ * @returns Memory difference in bytes
56
+ */
57
+ getMemoryDiff(before: {
58
+ heapUsed: number;
59
+ heapTotal: number;
60
+ external: number;
61
+ rss: number;
62
+ }, after: {
63
+ heapUsed: number;
64
+ heapTotal: number;
65
+ external: number;
66
+ rss: number;
67
+ }): {
68
+ heapUsed: number;
69
+ heapTotal: number;
70
+ external: number;
71
+ rss: number;
72
+ };
73
+ /**
74
+ * Generate a suggestion for a bottleneck
75
+ *
76
+ * @param functionName - The name of the function
77
+ * @param duration - The duration in milliseconds
78
+ * @param memoryUsage - Memory usage in bytes
79
+ * @returns A suggestion for improving performance
80
+ */
81
+ generateSuggestion(functionName: string, duration: number, memoryUsage?: number): string;
82
+ }
@@ -0,0 +1,106 @@
1
+ import { getHighResTime, getDuration } from '../utils/timing';
2
+ import { v4 as uuidv4 } from 'uuid';
3
+ /**
4
+ * Performance monitor for tracking execution times and memory usage
5
+ */
6
+ export class PerformanceMonitor {
7
+ /**
8
+ * Create a new PerformanceMonitor instance
9
+ *
10
+ * @param options - Monitor options
11
+ */
12
+ constructor(options = {}) {
13
+ var _a;
14
+ this._timers = new Map();
15
+ this._defaultThreshold = (_a = options.defaultThreshold) !== null && _a !== void 0 ? _a : 100; // ms
16
+ }
17
+ /**
18
+ * Start timing an operation
19
+ *
20
+ * @param label - Label for the operation
21
+ * @returns A unique identifier for the timing operation
22
+ */
23
+ startTimer(label) {
24
+ const id = `${label}-${uuidv4()}`;
25
+ this._timers.set(id, getHighResTime());
26
+ return id;
27
+ }
28
+ /**
29
+ * End timing an operation
30
+ *
31
+ * @param id - The identifier returned by startTimer
32
+ * @returns The duration in milliseconds
33
+ * @throws Error if the timer doesn't exist
34
+ */
35
+ endTimer(id) {
36
+ const startTime = this._timers.get(id);
37
+ if (!startTime) {
38
+ throw new Error(`Timer with id ${id} not found`);
39
+ }
40
+ const duration = getDuration(startTime);
41
+ this._timers.delete(id);
42
+ return duration;
43
+ }
44
+ /**
45
+ * Check if an operation exceeds the performance threshold
46
+ *
47
+ * @param duration - The duration in milliseconds
48
+ * @param threshold - The threshold to check against
49
+ * @returns Whether the operation is considered slow
50
+ */
51
+ isBottleneck(duration, threshold) {
52
+ const effectiveThreshold = threshold !== null && threshold !== void 0 ? threshold : this._defaultThreshold;
53
+ return duration > effectiveThreshold;
54
+ }
55
+ /**
56
+ * Get memory usage information
57
+ *
58
+ * @returns Memory usage in bytes
59
+ */
60
+ getMemoryUsage() {
61
+ const memoryUsage = process.memoryUsage();
62
+ return {
63
+ heapUsed: memoryUsage.heapUsed,
64
+ heapTotal: memoryUsage.heapTotal,
65
+ external: memoryUsage.external,
66
+ rss: memoryUsage.rss,
67
+ };
68
+ }
69
+ /**
70
+ * Get memory difference between two points
71
+ *
72
+ * @param before - Memory usage before
73
+ * @param after - Memory usage after
74
+ * @returns Memory difference in bytes
75
+ */
76
+ getMemoryDiff(before, after) {
77
+ return {
78
+ heapUsed: after.heapUsed - before.heapUsed,
79
+ heapTotal: after.heapTotal - before.heapTotal,
80
+ external: after.external - before.external,
81
+ rss: after.rss - before.rss,
82
+ };
83
+ }
84
+ /**
85
+ * Generate a suggestion for a bottleneck
86
+ *
87
+ * @param functionName - The name of the function
88
+ * @param duration - The duration in milliseconds
89
+ * @param memoryUsage - Memory usage in bytes
90
+ * @returns A suggestion for improving performance
91
+ */
92
+ generateSuggestion(functionName, duration, memoryUsage) {
93
+ // Simple heuristic-based suggestions
94
+ if (memoryUsage && memoryUsage > 10 * 1024 * 1024) {
95
+ return `🛠 Potential Fix: Check for memory leaks or large object allocations in ${functionName}`;
96
+ }
97
+ if (duration > 1000) {
98
+ return `🛠 Potential Fix: Consider optimizing or adding caching to ${functionName}`;
99
+ }
100
+ if (duration > 500) {
101
+ return `🛠 Potential Fix: Look for blocking operations in ${functionName}`;
102
+ }
103
+ return `🛠 Potential Fix: Review ${functionName} for performance optimizations`;
104
+ }
105
+ }
106
+ //# sourceMappingURL=performance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"performance.js","sourceRoot":"","sources":["../../../src/trackers/performance.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAEpC;;GAEG;AACH,MAAM,OAAO,kBAAkB;IAI7B;;;;OAIG;IACH,Y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ED;;;;;;OAMG;IACI,aAAa,CAClB,MAA8E,EAC9E,KAA6E;QAE7E,OAAO;YACL,QAAQ,EAAE,KAAK,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ;YAC1C,SAAS,EAAE,KAAK,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS;YAC7C,QAAQ,EAAE,KAAK,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ;YAC1C,GAAG,EAAE,KAAK,CAAC,GAAG,GAAG,MAAM,CAAC,GAAG;SAC5B,CAAC;IACJ,CAAC;IAED;;;;;;;OAOG;IACI,kBAAkB,CACvB,YAAoB,EACpB,QAAgB,EAChB,WAAoB;QAEpB,qCAAqC;QACrC,IAAI,WAAW,IAAI,WAAW,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,EAAE,CAAC;YAClD,OAAO,2EAA2E,YAAY,EAAE,CAAC;QACnG,CAAC;QAED,IAAI,QAAQ,GAAG,IAAI,EAAE,CAAC;YACpB,OAAO,8DAA8D,YAAY,EAAE,CAAC;QACtF,CAAC;QAED,IAAI,QAAQ,GAAG,GAAG,EAAE,CAAC;YACnB,OAAO,qDAAqD,YAAY,EAAE,CAAC;QAC7E,CAAC;QAED,OAAO,4BAA4B,YAAY,gCAAgC,CAAC;IAClF,CAAC;CACF"}
@@ -0,0 +1,110 @@
1
+ /**
2
+ * LogLevel - Defines the severity levels for logging
3
+ */
4
+ export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
5
+ /**
6
+ * LogMode - Defines the operational modes for the logger
7
+ */
8
+ export type LogMode = 'dev' | 'staging' | 'prod' | string;
9
+ /**
10
+ * Transport - Interface for log output destinations
11
+ */
12
+ export interface ITransport {
13
+ /**
14
+ * Write a log entry to the destination
15
+ *
16
+ * @param entry - The formatted log entry to write
17
+ */
18
+ write(entry: string): void;
19
+ }
20
+ /**
21
+ * Formatter - Interface for log formatters
22
+ */
23
+ export interface IFormatter {
24
+ /**
25
+ * Format a log entry
26
+ *
27
+ * @param level - The log level
28
+ * @param message - The log message
29
+ * @param args - Additional arguments
30
+ * @param meta - Metadata for the log entry
31
+ * @returns The formatted log entry
32
+ */
33
+ format(level: LogLevel, message: string | object, args: any[], meta: LogMeta): string;
34
+ }
35
+ /**
36
+ * LogMeta - Metadata for log entries
37
+ */
38
+ export interface LogMeta {
39
+ timestamp: Date;
40
+ level: LogLevel;
41
+ indentLevel: number;
42
+ [key: string]: any;
43
+ }
44
+ /**
45
+ * TrackOptions - Options for function execution tracking
46
+ */
47
+ export interface ITrackOptions {
48
+ /**
49
+ * Custom label for the tracked function
50
+ */
51
+ label?: string;
52
+ /**
53
+ * Performance threshold in milliseconds
54
+ * Functions exceeding this threshold will be flagged as bottlenecks
55
+ */
56
+ threshold?: number;
57
+ /**
58
+ * Whether to include memory usage tracking
59
+ */
60
+ includeMemory?: boolean;
61
+ /**
62
+ * Whether to suppress logging for this tracking
63
+ */
64
+ silent?: boolean;
65
+ }
66
+ /**
67
+ * LoggerConfig - Configuration options for the logger
68
+ */
69
+ export interface ILoggerConfig {
70
+ /**
71
+ * Operational mode
72
+ * @default 'dev'
73
+ */
74
+ mode?: LogMode;
75
+ /**
76
+ * Minimum log level to display
77
+ * @default 'debug'
78
+ */
79
+ level?: LogLevel;
80
+ /**
81
+ * Whether to colorize output
82
+ * @default true
83
+ */
84
+ colorize?: boolean;
85
+ /**
86
+ * Whether to include timestamps in logs
87
+ * @default true
88
+ */
89
+ timestamp?: boolean;
90
+ /**
91
+ * Default performance threshold in milliseconds
92
+ * @default 100
93
+ */
94
+ performanceThreshold?: number;
95
+ /**
96
+ * Number of spaces for each indentation level
97
+ * @default 2
98
+ */
99
+ indentSize?: number;
100
+ /**
101
+ * Log output destinations
102
+ * @default [ConsoleTransport]
103
+ */
104
+ transports?: ITransport[];
105
+ /**
106
+ * Log formatters
107
+ * @default [CliFormatter]
108
+ */
109
+ formatters?: IFormatter[];
110
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/types/config.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export * from './config';
2
+ export * from './logger';
@@ -0,0 +1,3 @@
1
+ export * from './config';
2
+ export * from './logger';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC"}
@@ -0,0 +1,127 @@
1
+ import { LogMode, ITrackOptions } from './config';
2
+ /**
3
+ * ILogger - Interface for the main logger functionality
4
+ */
5
+ export interface ILogger {
6
+ /**
7
+ * Log an informational message
8
+ *
9
+ * @param message - The message to log
10
+ * @param args - Additional arguments to include in the log
11
+ */
12
+ info(message: string | object, ...args: any[]): void;
13
+ /**
14
+ * Log a warning message
15
+ *
16
+ * @param message - The message to log
17
+ * @param args - Additional arguments to include in the log
18
+ */
19
+ warn(message: string | object, ...args: any[]): void;
20
+ /**
21
+ * Log an error message
22
+ *
23
+ * @param message - The message to log
24
+ * @param args - Additional arguments to include in the log
25
+ */
26
+ error(message: string | object, ...args: any[]): void;
27
+ /**
28
+ * Log a debug message
29
+ *
30
+ * @param message - The message to log
31
+ * @param args - Additional arguments to include in the log
32
+ */
33
+ debug(message: string | object, ...args: any[]): void;
34
+ /**
35
+ * Start a new log group with the given label
36
+ *
37
+ * @param label - The label for the group
38
+ */
39
+ group(label: string): void;
40
+ /**
41
+ * End the current log group
42
+ */
43
+ groupEnd(): void;
44
+ /**
45
+ * Set the operational mode for the logger
46
+ *
47
+ * @param mode - The mode to set
48
+ */
49
+ setMode(mode: LogMode): void;
50
+ /**
51
+ * Get the current operational mode
52
+ *
53
+ * @returns The current mode
54
+ */
55
+ getMode(): LogMode;
56
+ /**
57
+ * Track the execution of a function and log performance metrics
58
+ *
59
+ * @param fn - The function to track
60
+ * @param options - Options for tracking
61
+ * @returns The return value of the tracked function
62
+ */
63
+ track<T>(fn: () => T, options?: ITrackOptions): T;
64
+ }
65
+ /**
66
+ * IExecutionTracker - Interface for tracking function execution
67
+ */
68
+ export interface IExecutionTracker {
69
+ /**
70
+ * Track the execution of a function
71
+ *
72
+ * @param fn - The function to track
73
+ * @param options - Options for tracking
74
+ * @returns The return value of the tracked function
75
+ */
76
+ track<T>(fn: () => T, options?: ITrackOptions): T;
77
+ /**
78
+ * Get the current call stack
79
+ *
80
+ * @returns The current call stack
81
+ */
82
+ getCallStack(): string[];
83
+ /**
84
+ * Generate a visual representation of the execution flow
85
+ *
86
+ * @returns ASCII flow chart of the execution
87
+ */
88
+ generateFlowChart(): string;
89
+ }
90
+ /**
91
+ * IPerformanceMonitor - Interface for monitoring performance
92
+ */
93
+ export interface IPerformanceMonitor {
94
+ /**
95
+ * Start timing an operation
96
+ *
97
+ * @param label - Label for the operation
98
+ * @returns A unique identifier for the timing operation
99
+ */
100
+ startTimer(label: string): string;
101
+ /**
102
+ * End timing an operation
103
+ *
104
+ * @param id - The identifier returned by startTimer
105
+ * @returns The duration in milliseconds
106
+ */
107
+ endTimer(id: string): number;
108
+ /**
109
+ * Check if an operation exceeds the performance threshold
110
+ *
111
+ * @param duration - The duration in milliseconds
112
+ * @param threshold - The threshold to check against
113
+ * @returns Whether the operation is considered slow
114
+ */
115
+ isBottleneck(duration: number, threshold?: number): boolean;
116
+ /**
117
+ * Get memory usage information
118
+ *
119
+ * @returns Memory usage in bytes
120
+ */
121
+ getMemoryUsage(): {
122
+ heapUsed: number;
123
+ heapTotal: number;
124
+ external: number;
125
+ rss: number;
126
+ };
127
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../src/types/logger.ts"],"names":[],"mappings":""}
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Utilities for working with terminal colors
3
+ */
4
+ /**
5
+ * Apply color to a string
6
+ *
7
+ * @param text - The text to colorize
8
+ * @param color - The color to apply
9
+ * @returns The colorized string
10
+ */
11
+ export declare function colorize(text: string, color: string): string;
12
+ /**
13
+ * Apply bold formatting to a string
14
+ *
15
+ * @param text - The text to make bold
16
+ * @returns The bold string
17
+ */
18
+ export declare function bold(text: string): string;
19
+ /**
20
+ * Apply dim formatting to a string
21
+ *
22
+ * @param text - The text to make dim
23
+ * @returns The dim string
24
+ */
25
+ export declare function dim(text: string): string;
26
+ /**
27
+ * Apply underline formatting to a string
28
+ *
29
+ * @param text - The text to underline
30
+ * @returns The underlined string
31
+ */
32
+ export declare function underline(text: string): string;
33
+ /**
34
+ * Apply red color to a string
35
+ *
36
+ * @param text - The text to colorize
37
+ * @returns The red string
38
+ */
39
+ export declare function red(text: string): string;
40
+ /**
41
+ * Apply green color to a string
42
+ *
43
+ * @param text - The text to colorize
44
+ * @returns The green string
45
+ */
46
+ export declare function green(text: string): string;
47
+ /**
48
+ * Apply yellow color to a string
49
+ *
50
+ * @param text - The text to colorize
51
+ * @returns The yellow string
52
+ */
53
+ export declare function yellow(text: string): string;
54
+ /**
55
+ * Apply blue color to a string
56
+ *
57
+ * @param text - The text to colorize
58
+ * @returns The blue string
59
+ */
60
+ export declare function blue(text: string): string;
61
+ /**
62
+ * Apply magenta color to a string
63
+ *
64
+ * @param text - The text to colorize
65
+ * @returns The magenta string
66
+ */
67
+ export declare function magenta(text: string): string;
68
+ /**
69
+ * Apply cyan color to a string
70
+ *
71
+ * @param text - The text to colorize
72
+ * @returns The cyan string
73
+ */
74
+ export declare function cyan(text: string): string;
75
+ /**
76
+ * Apply gray color to a string
77
+ *
78
+ * @param text - The text to colorize
79
+ * @returns The gray string
80
+ */
81
+ export declare function gray(text: string): string;
82
+ /**
83
+ * Check if terminal supports colors
84
+ *
85
+ * @returns Whether the terminal supports colors
86
+ */
87
+ export declare function supportsColor(): boolean;