traceperf 0.2.1 → 1.3.0

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 (268) hide show
  1. package/README.md +608 -253
  2. package/dist/__tests__/helpers/console.d.ts +9 -0
  3. package/dist/__tests__/helpers/console.js +25 -0
  4. package/dist/__tests__/helpers/console.js.map +1 -0
  5. package/dist/auto.d.ts +30 -0
  6. package/dist/auto.js +91 -0
  7. package/dist/auto.js.map +1 -0
  8. package/dist/browser.d.ts +52 -144
  9. package/dist/browser.js +112 -439
  10. package/dist/browser.js.map +1 -1
  11. package/dist/cli.d.ts +68 -0
  12. package/dist/cli.js +528 -0
  13. package/dist/cli.js.map +1 -0
  14. package/dist/core/allocations.d.ts +38 -0
  15. package/dist/core/allocations.js +85 -0
  16. package/dist/core/allocations.js.map +1 -0
  17. package/dist/core/cpu-profile.d.ts +84 -0
  18. package/dist/core/cpu-profile.js +181 -0
  19. package/dist/core/cpu-profile.js.map +1 -0
  20. package/dist/core/env.d.ts +10 -0
  21. package/dist/core/env.js +40 -0
  22. package/dist/core/env.js.map +1 -0
  23. package/dist/core/event-loop.d.ts +30 -0
  24. package/dist/core/event-loop.js +43 -0
  25. package/dist/core/event-loop.js.map +1 -0
  26. package/dist/core/explain.d.ts +48 -0
  27. package/dist/core/explain.js +236 -0
  28. package/dist/core/explain.js.map +1 -0
  29. package/dist/core/exporters.d.ts +111 -0
  30. package/dist/core/exporters.js +236 -0
  31. package/dist/core/exporters.js.map +1 -0
  32. package/dist/core/index.d.ts +9 -3
  33. package/dist/core/index.js +9 -3
  34. package/dist/core/index.js.map +1 -1
  35. package/dist/core/optimized-performance-monitor.d.ts +180 -26
  36. package/dist/core/optimized-performance-monitor.js +687 -175
  37. package/dist/core/optimized-performance-monitor.js.map +1 -1
  38. package/dist/core/prometheus.d.ts +36 -0
  39. package/dist/core/prometheus.js +93 -0
  40. package/dist/core/prometheus.js.map +1 -0
  41. package/dist/core/records.d.ts +97 -0
  42. package/dist/core/records.js +87 -0
  43. package/dist/core/records.js.map +1 -0
  44. package/dist/core/stats.d.ts +45 -0
  45. package/dist/core/stats.js +136 -0
  46. package/dist/core/stats.js.map +1 -0
  47. package/dist/core/timeline.d.ts +28 -0
  48. package/dist/core/timeline.js +65 -0
  49. package/dist/core/timeline.js.map +1 -0
  50. package/dist/drivers.d.ts +51 -0
  51. package/dist/drivers.js +205 -0
  52. package/dist/drivers.js.map +1 -0
  53. package/dist/esm/auto.d.ts +30 -0
  54. package/dist/esm/auto.js +87 -0
  55. package/dist/esm/auto.js.map +1 -0
  56. package/dist/esm/browser.d.ts +52 -144
  57. package/dist/esm/browser.js +101 -445
  58. package/dist/esm/browser.js.map +1 -1
  59. package/dist/esm/cli.d.ts +68 -0
  60. package/dist/esm/cli.js +520 -0
  61. package/dist/esm/cli.js.map +1 -0
  62. package/dist/esm/core/allocations.d.ts +38 -0
  63. package/dist/esm/core/allocations.js +82 -0
  64. package/dist/esm/core/allocations.js.map +1 -0
  65. package/dist/esm/core/cpu-profile.d.ts +84 -0
  66. package/dist/esm/core/cpu-profile.js +176 -0
  67. package/dist/esm/core/cpu-profile.js.map +1 -0
  68. package/dist/esm/core/env.d.ts +10 -0
  69. package/dist/esm/core/env.js +35 -0
  70. package/dist/esm/core/env.js.map +1 -0
  71. package/dist/esm/core/event-loop.d.ts +30 -0
  72. package/dist/esm/core/event-loop.js +40 -0
  73. package/dist/esm/core/event-loop.js.map +1 -0
  74. package/dist/esm/core/explain.d.ts +48 -0
  75. package/dist/esm/core/explain.js +232 -0
  76. package/dist/esm/core/explain.js.map +1 -0
  77. package/dist/esm/core/exporters.d.ts +111 -0
  78. package/dist/esm/core/exporters.js +229 -0
  79. package/dist/esm/core/exporters.js.map +1 -0
  80. package/dist/esm/core/index.d.ts +10 -4
  81. package/dist/esm/core/index.js +10 -4
  82. package/dist/esm/core/index.js.map +1 -1
  83. package/dist/esm/core/optimized-performance-monitor.d.ts +180 -26
  84. package/dist/esm/core/optimized-performance-monitor.js +685 -173
  85. package/dist/esm/core/optimized-performance-monitor.js.map +1 -1
  86. package/dist/esm/core/prometheus.d.ts +36 -0
  87. package/dist/esm/core/prometheus.js +89 -0
  88. package/dist/esm/core/prometheus.js.map +1 -0
  89. package/dist/esm/core/records.d.ts +97 -0
  90. package/dist/esm/core/records.js +82 -0
  91. package/dist/esm/core/records.js.map +1 -0
  92. package/dist/esm/core/stats.d.ts +45 -0
  93. package/dist/esm/core/stats.js +131 -0
  94. package/dist/esm/core/stats.js.map +1 -0
  95. package/dist/esm/core/timeline.d.ts +28 -0
  96. package/dist/esm/core/timeline.js +62 -0
  97. package/dist/esm/core/timeline.js.map +1 -0
  98. package/dist/esm/drivers.d.ts +51 -0
  99. package/dist/esm/drivers.js +197 -0
  100. package/dist/esm/drivers.js.map +1 -0
  101. package/dist/esm/index.d.ts +13 -5
  102. package/dist/esm/index.js +21 -17
  103. package/dist/esm/index.js.map +1 -1
  104. package/dist/esm/instrument.d.ts +88 -0
  105. package/dist/esm/instrument.js +274 -0
  106. package/dist/esm/instrument.js.map +1 -0
  107. package/dist/esm/integrations.d.ts +70 -0
  108. package/dist/esm/integrations.js +197 -0
  109. package/dist/esm/integrations.js.map +1 -0
  110. package/dist/esm/node-builtins.d.ts +1 -0
  111. package/dist/esm/node-builtins.js +32 -0
  112. package/dist/esm/node-builtins.js.map +1 -0
  113. package/dist/esm/package.json +3 -0
  114. package/dist/esm/register.d.ts +20 -0
  115. package/dist/esm/register.js +98 -0
  116. package/dist/esm/register.js.map +1 -0
  117. package/dist/esm/report-html.d.ts +11 -0
  118. package/dist/esm/report-html.js +106 -0
  119. package/dist/esm/report-html.js.map +1 -0
  120. package/dist/esm/types/index.d.ts +4 -80
  121. package/dist/esm/types/index.js +1 -2
  122. package/dist/esm/types/index.js.map +1 -1
  123. package/dist/esm/types/options.d.ts +72 -0
  124. package/dist/esm/types/options.js +2 -0
  125. package/dist/esm/types/options.js.map +1 -0
  126. package/dist/esm/watch.d.ts +17 -0
  127. package/dist/esm/watch.js +87 -0
  128. package/dist/esm/watch.js.map +1 -0
  129. package/dist/index.d.ts +10 -2
  130. package/dist/index.js +26 -29
  131. package/dist/index.js.map +1 -1
  132. package/dist/instrument.d.ts +88 -0
  133. package/dist/instrument.js +282 -0
  134. package/dist/instrument.js.map +1 -0
  135. package/dist/integrations.d.ts +70 -0
  136. package/dist/integrations.js +205 -0
  137. package/dist/integrations.js.map +1 -0
  138. package/dist/node-builtins.d.ts +1 -0
  139. package/dist/node-builtins.js +67 -0
  140. package/dist/node-builtins.js.map +1 -0
  141. package/dist/register.d.ts +20 -0
  142. package/dist/register.js +103 -0
  143. package/dist/register.js.map +1 -0
  144. package/dist/report-html.d.ts +11 -0
  145. package/dist/report-html.js +109 -0
  146. package/dist/report-html.js.map +1 -0
  147. package/dist/traceperf.browser.js +1910 -0
  148. package/dist/traceperf.browser.min.js +6 -0
  149. package/dist/types/index.d.ts +4 -80
  150. package/dist/types/index.js +1 -2
  151. package/dist/types/index.js.map +1 -1
  152. package/dist/types/options.d.ts +72 -0
  153. package/dist/types/{config.js → options.js} +1 -1
  154. package/dist/types/options.js.map +1 -0
  155. package/dist/watch.d.ts +17 -0
  156. package/dist/watch.js +90 -0
  157. package/dist/watch.js.map +1 -0
  158. package/package.json +99 -19
  159. package/dist/core/config.d.ts +0 -77
  160. package/dist/core/config.js +0 -116
  161. package/dist/core/config.js.map +0 -1
  162. package/dist/core/constants.d.ts +0 -78
  163. package/dist/core/constants.js +0 -109
  164. package/dist/core/constants.js.map +0 -1
  165. package/dist/core/logger.d.ts +0 -97
  166. package/dist/core/logger.js +0 -186
  167. package/dist/core/logger.js.map +0 -1
  168. package/dist/esm/core/config.d.ts +0 -77
  169. package/dist/esm/core/config.js +0 -112
  170. package/dist/esm/core/config.js.map +0 -1
  171. package/dist/esm/core/constants.d.ts +0 -78
  172. package/dist/esm/core/constants.js +0 -106
  173. package/dist/esm/core/constants.js.map +0 -1
  174. package/dist/esm/core/logger.d.ts +0 -97
  175. package/dist/esm/core/logger.js +0 -182
  176. package/dist/esm/core/logger.js.map +0 -1
  177. package/dist/esm/formatters/ascii.d.ts +0 -52
  178. package/dist/esm/formatters/ascii.js +0 -100
  179. package/dist/esm/formatters/ascii.js.map +0 -1
  180. package/dist/esm/formatters/cli.d.ts +0 -50
  181. package/dist/esm/formatters/cli.js +0 -96
  182. package/dist/esm/formatters/cli.js.map +0 -1
  183. package/dist/esm/formatters/index.d.ts +0 -3
  184. package/dist/esm/formatters/index.js +0 -4
  185. package/dist/esm/formatters/index.js.map +0 -1
  186. package/dist/esm/formatters/json.d.ts +0 -45
  187. package/dist/esm/formatters/json.js +0 -85
  188. package/dist/esm/formatters/json.js.map +0 -1
  189. package/dist/esm/trackers/execution.d.ts +0 -101
  190. package/dist/esm/trackers/execution.js +0 -226
  191. package/dist/esm/trackers/execution.js.map +0 -1
  192. package/dist/esm/trackers/index.d.ts +0 -2
  193. package/dist/esm/trackers/index.js +0 -3
  194. package/dist/esm/trackers/index.js.map +0 -1
  195. package/dist/esm/trackers/performance.d.ts +0 -68
  196. package/dist/esm/trackers/performance.js +0 -112
  197. package/dist/esm/trackers/performance.js.map +0 -1
  198. package/dist/esm/types/config.d.ts +0 -142
  199. package/dist/esm/types/config.js +0 -2
  200. package/dist/esm/types/config.js.map +0 -1
  201. package/dist/esm/types/logger.d.ts +0 -147
  202. package/dist/esm/types/logger.js +0 -2
  203. package/dist/esm/types/logger.js.map +0 -1
  204. package/dist/esm/utils/colors.d.ts +0 -87
  205. package/dist/esm/utils/colors.js +0 -146
  206. package/dist/esm/utils/colors.js.map +0 -1
  207. package/dist/esm/utils/index.d.ts +0 -3
  208. package/dist/esm/utils/index.js +0 -4
  209. package/dist/esm/utils/index.js.map +0 -1
  210. package/dist/esm/utils/proxy-tracker.d.ts +0 -68
  211. package/dist/esm/utils/proxy-tracker.js +0 -127
  212. package/dist/esm/utils/proxy-tracker.js.map +0 -1
  213. package/dist/esm/utils/stack.d.ts +0 -63
  214. package/dist/esm/utils/stack.js +0 -110
  215. package/dist/esm/utils/stack.js.map +0 -1
  216. package/dist/esm/utils/string.d.ts +0 -29
  217. package/dist/esm/utils/string.js +0 -45
  218. package/dist/esm/utils/string.js.map +0 -1
  219. package/dist/esm/utils/timing.d.ts +0 -65
  220. package/dist/esm/utils/timing.js +0 -99
  221. package/dist/esm/utils/timing.js.map +0 -1
  222. package/dist/formatters/ascii.d.ts +0 -52
  223. package/dist/formatters/ascii.js +0 -104
  224. package/dist/formatters/ascii.js.map +0 -1
  225. package/dist/formatters/cli.d.ts +0 -50
  226. package/dist/formatters/cli.js +0 -100
  227. package/dist/formatters/cli.js.map +0 -1
  228. package/dist/formatters/index.d.ts +0 -3
  229. package/dist/formatters/index.js +0 -20
  230. package/dist/formatters/index.js.map +0 -1
  231. package/dist/formatters/json.d.ts +0 -45
  232. package/dist/formatters/json.js +0 -89
  233. package/dist/formatters/json.js.map +0 -1
  234. package/dist/trackers/execution.d.ts +0 -101
  235. package/dist/trackers/execution.js +0 -230
  236. package/dist/trackers/execution.js.map +0 -1
  237. package/dist/trackers/index.d.ts +0 -2
  238. package/dist/trackers/index.js +0 -19
  239. package/dist/trackers/index.js.map +0 -1
  240. package/dist/trackers/performance.d.ts +0 -68
  241. package/dist/trackers/performance.js +0 -116
  242. package/dist/trackers/performance.js.map +0 -1
  243. package/dist/types/config.d.ts +0 -142
  244. package/dist/types/config.js.map +0 -1
  245. package/dist/types/logger.d.ts +0 -147
  246. package/dist/types/logger.js +0 -3
  247. package/dist/types/logger.js.map +0 -1
  248. package/dist/types.d.ts +0 -65
  249. package/dist/types.js +0 -6
  250. package/dist/types.js.map +0 -1
  251. package/dist/utils/colors.d.ts +0 -87
  252. package/dist/utils/colors.js +0 -160
  253. package/dist/utils/colors.js.map +0 -1
  254. package/dist/utils/index.d.ts +0 -3
  255. package/dist/utils/index.js +0 -20
  256. package/dist/utils/index.js.map +0 -1
  257. package/dist/utils/proxy-tracker.d.ts +0 -68
  258. package/dist/utils/proxy-tracker.js +0 -131
  259. package/dist/utils/proxy-tracker.js.map +0 -1
  260. package/dist/utils/stack.d.ts +0 -63
  261. package/dist/utils/stack.js +0 -116
  262. package/dist/utils/stack.js.map +0 -1
  263. package/dist/utils/string.d.ts +0 -29
  264. package/dist/utils/string.js +0 -50
  265. package/dist/utils/string.js.map +0 -1
  266. package/dist/utils/timing.d.ts +0 -65
  267. package/dist/utils/timing.js +0 -106
  268. package/dist/utils/timing.js.map +0 -1
@@ -1,147 +0,0 @@
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
- * Create a trackable version of a function
66
- *
67
- * This is a helper method to create a tracked version of a function
68
- * that can be used for nested function tracking.
69
- *
70
- * @param fn - The function to make trackable
71
- * @param options - Options for tracking
72
- * @returns A tracked version of the function
73
- */
74
- createTrackable<T extends (...args: any[]) => any>(fn: T, options?: any): (...args: Parameters<T>) => ReturnType<T>;
75
- }
76
- /**
77
- * IExecutionTracker - Interface for tracking function execution
78
- */
79
- export interface IExecutionTracker {
80
- /**
81
- * Track the execution of a function
82
- *
83
- * @param fn - The function to track
84
- * @param options - Options for tracking
85
- * @returns The return value of the tracked function
86
- */
87
- track<T>(fn: () => T, options?: ITrackOptions): T;
88
- /**
89
- * Get the current call stack
90
- *
91
- * @returns The current call stack
92
- */
93
- getCallStack(): string[];
94
- /**
95
- * Generate a visual representation of the execution flow
96
- *
97
- * @returns ASCII flow chart of the execution
98
- */
99
- generateFlowChart(): string;
100
- }
101
- /**
102
- * IPerformanceMonitor - Interface for monitoring performance
103
- */
104
- export interface IPerformanceMonitor {
105
- /**
106
- * Start timing an operation
107
- *
108
- * @param label - Label for the operation
109
- * @returns A unique identifier for the timing operation
110
- */
111
- startTimer(label: string): string;
112
- /**
113
- * End timing an operation
114
- *
115
- * @param id - The identifier returned by startTimer
116
- * @returns The duration in milliseconds
117
- */
118
- endTimer(id: string): number;
119
- /**
120
- * Check if an operation exceeds the performance threshold
121
- *
122
- * @param duration - The duration in milliseconds
123
- * @param threshold - The threshold to check against
124
- * @returns Whether the operation is considered slow
125
- */
126
- isBottleneck(duration: number, threshold?: number): boolean;
127
- /**
128
- * Get memory usage information
129
- *
130
- * @returns Memory usage object or undefined if not available
131
- */
132
- getMemoryUsage(): {
133
- heapUsed: number;
134
- heapTotal: number;
135
- external: number;
136
- rss: number;
137
- } | undefined;
138
- /**
139
- * Calculate memory difference between current and start memory
140
- *
141
- * @param start - Starting memory usage snapshot
142
- * @returns Memory difference in bytes
143
- */
144
- getMemoryDiff(start: {
145
- heapUsed: number;
146
- }): number;
147
- }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=logger.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../src/types/logger.ts"],"names":[],"mappings":""}
@@ -1,87 +0,0 @@
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;
@@ -1,146 +0,0 @@
1
- import { COLORS } from '../core/constants';
2
- /**
3
- * Utilities for working with terminal colors
4
- */
5
- /**
6
- * Apply color to a string
7
- *
8
- * @param text - The text to colorize
9
- * @param color - The color to apply
10
- * @returns The colorized string
11
- */
12
- export function colorize(text, color) {
13
- if (typeof supportsColor === 'function' ? !supportsColor() : false) {
14
- return text;
15
- }
16
- return `${color}${text}${COLORS.reset}`;
17
- }
18
- /**
19
- * Apply bold formatting to a string
20
- *
21
- * @param text - The text to make bold
22
- * @returns The bold string
23
- */
24
- export function bold(text) {
25
- if (typeof supportsColor === 'function' ? !supportsColor() : false) {
26
- return text;
27
- }
28
- return `${COLORS.bright}${text}${COLORS.reset}`;
29
- }
30
- /**
31
- * Apply dim formatting to a string
32
- *
33
- * @param text - The text to make dim
34
- * @returns The dim string
35
- */
36
- export function dim(text) {
37
- if (typeof supportsColor === 'function' ? !supportsColor() : false) {
38
- return text;
39
- }
40
- return `${COLORS.dim}${text}${COLORS.reset}`;
41
- }
42
- /**
43
- * Apply underline formatting to a string
44
- *
45
- * @param text - The text to underline
46
- * @returns The underlined string
47
- */
48
- export function underline(text) {
49
- if (typeof supportsColor === 'function' ? !supportsColor() : false) {
50
- return text;
51
- }
52
- return `${COLORS.underscore}${text}${COLORS.reset}`;
53
- }
54
- /**
55
- * Apply red color to a string
56
- *
57
- * @param text - The text to colorize
58
- * @returns The red string
59
- */
60
- export function red(text) {
61
- return colorize(text, COLORS.fg.red);
62
- }
63
- /**
64
- * Apply green color to a string
65
- *
66
- * @param text - The text to colorize
67
- * @returns The green string
68
- */
69
- export function green(text) {
70
- return colorize(text, COLORS.fg.green);
71
- }
72
- /**
73
- * Apply yellow color to a string
74
- *
75
- * @param text - The text to colorize
76
- * @returns The yellow string
77
- */
78
- export function yellow(text) {
79
- return colorize(text, COLORS.fg.yellow);
80
- }
81
- /**
82
- * Apply blue color to a string
83
- *
84
- * @param text - The text to colorize
85
- * @returns The blue string
86
- */
87
- export function blue(text) {
88
- return colorize(text, COLORS.fg.blue);
89
- }
90
- /**
91
- * Apply magenta color to a string
92
- *
93
- * @param text - The text to colorize
94
- * @returns The magenta string
95
- */
96
- export function magenta(text) {
97
- return colorize(text, COLORS.fg.magenta);
98
- }
99
- /**
100
- * Apply cyan color to a string
101
- *
102
- * @param text - The text to colorize
103
- * @returns The cyan string
104
- */
105
- export function cyan(text) {
106
- return colorize(text, COLORS.fg.cyan);
107
- }
108
- /**
109
- * Apply gray color to a string
110
- *
111
- * @param text - The text to colorize
112
- * @returns The gray string
113
- */
114
- export function gray(text) {
115
- return colorize(text, COLORS.fg.gray);
116
- }
117
- /**
118
- * Check if terminal supports colors
119
- *
120
- * @returns Whether the terminal supports colors
121
- */
122
- export function supportsColor() {
123
- if (process.env.FORCE_COLOR === '0') {
124
- return false;
125
- }
126
- if (process.env.FORCE_COLOR) {
127
- return true;
128
- }
129
- if (process.platform === 'win32') {
130
- return true;
131
- }
132
- if ('CI' in process.env) {
133
- return true;
134
- }
135
- if (process.env.COLORTERM) {
136
- return true;
137
- }
138
- if (process.env.TERM === 'dumb') {
139
- return false;
140
- }
141
- if (process.stdout.isTTY) {
142
- return true;
143
- }
144
- return false;
145
- }
146
- //# sourceMappingURL=colors.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"colors.js","sourceRoot":"","sources":["../../../src/utils/colors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C;;GAEG;AAEH;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAY,EAAE,KAAa;IAClD,IAAI,OAAO,aAAa,KAAK,UAAU,CAAC,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;QACnE,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,GAAG,KAAK,GAAG,IAAI,GAAG,MAAM,CAAC,KAAK,EAAE,CAAC;AAC1C,CAAC;AAED;;;;;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I,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -1,3 +0,0 @@
1
- export * from './timing';
2
- export * from './stack';
3
- export * from './colors';
@@ -1,4 +0,0 @@
1
- export * from './timing';
2
- export * from './stack';
3
- export * from './colors';
4
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC"}
@@ -1,68 +0,0 @@
1
- /**
2
- * Proxy-based function tracking utility
3
- *
4
- * This module provides utilities for automatically tracking nested function calls
5
- * using JavaScript Proxies without modifying the original code structure.
6
- */
7
- import { ITrackOptions } from '../types';
8
- /**
9
- * Interface for a function that can track other functions
10
- */
11
- export interface ITrackFunction {
12
- <T>(fn: () => T, options?: ITrackOptions): T;
13
- }
14
- /**
15
- * A tracking context that manages function tracking using proxies
16
- */
17
- export declare class ProxyTracker {
18
- private _trackFn;
19
- private _originalFunctions;
20
- private _trackedFunctions;
21
- private _isEnabled;
22
- /**
23
- * Create a new ProxyTracker
24
- *
25
- * @param trackFn - The function to use for tracking
26
- */
27
- constructor(trackFn: ITrackFunction);
28
- /**
29
- * Enable or disable tracking
30
- *
31
- * @param enabled - Whether tracking is enabled
32
- */
33
- setEnabled(enabled: boolean): void;
34
- /**
35
- * Check if tracking is enabled
36
- *
37
- * @returns Whether tracking is enabled
38
- */
39
- isEnabled(): boolean;
40
- /**
41
- * Make a function trackable
42
- *
43
- * @param fn - The function to make trackable
44
- * @param name - The name to use for tracking
45
- * @returns A tracked version of the function
46
- */
47
- makeTrackable(fn: Function, name?: string): Function;
48
- /**
49
- * Create a proxy for an object to track all its methods
50
- *
51
- * @param obj - The object to proxy
52
- * @param namespace - The namespace to use for tracking
53
- * @returns A proxied version of the object
54
- */
55
- createProxy<T extends object>(obj: T, namespace?: string): T;
56
- /**
57
- * Track a module's exports
58
- *
59
- * @param moduleExports - The module's exports
60
- * @param namespace - The namespace to use for tracking
61
- * @returns A proxied version of the module's exports
62
- */
63
- trackModule<T extends object>(moduleExports: T, namespace: string): T;
64
- /**
65
- * Clear all tracked functions
66
- */
67
- clear(): void;
68
- }
@@ -1,127 +0,0 @@
1
- /**
2
- * Proxy-based function tracking utility
3
- *
4
- * This module provides utilities for automatically tracking nested function calls
5
- * using JavaScript Proxies without modifying the original code structure.
6
- */
7
- /**
8
- * A tracking context that manages function tracking using proxies
9
- */
10
- export class ProxyTracker {
11
- /**
12
- * Create a new ProxyTracker
13
- *
14
- * @param trackFn - The function to use for tracking
15
- */
16
- constructor(trackFn) {
17
- this._originalFunctions = new Map();
18
- this._trackedFunctions = new Map();
19
- this._isEnabled = true;
20
- this._trackFn = trackFn;
21
- }
22
- /**
23
- * Enable or disable tracking
24
- *
25
- * @param enabled - Whether tracking is enabled
26
- */
27
- setEnabled(enabled) {
28
- this._isEnabled = enabled;
29
- }
30
- /**
31
- * Check if tracking is enabled
32
- *
33
- * @returns Whether tracking is enabled
34
- */
35
- isEnabled() {
36
- return this._isEnabled;
37
- }
38
- /**
39
- * Make a function trackable
40
- *
41
- * @param fn - The function to make trackable
42
- * @param name - The name to use for tracking
43
- * @returns A tracked version of the function
44
- */
45
- makeTrackable(fn, name) {
46
- // If tracking is disabled, return the original function
47
- if (!this._isEnabled) {
48
- return fn;
49
- }
50
- // If we've already tracked this function, return the tracked version
51
- if (this._trackedFunctions.has(fn)) {
52
- return this._trackedFunctions.get(fn);
53
- }
54
- // Create a tracked version of the function
55
- const self = this;
56
- const trackedFn = function (...args) {
57
- return self._trackFn(() => fn.apply(this, args), {
58
- label: name || fn.name || 'anonymous'
59
- });
60
- };
61
- // Store the tracked version
62
- this._trackedFunctions.set(fn, trackedFn);
63
- return trackedFn;
64
- }
65
- /**
66
- * Create a proxy for an object to track all its methods
67
- *
68
- * @param obj - The object to proxy
69
- * @param namespace - The namespace to use for tracking
70
- * @returns A proxied version of the object
71
- */
72
- createProxy(obj, namespace = '') {
73
- // If tracking is disabled, return the original object
74
- if (!this._isEnabled) {
75
- return obj;
76
- }
77
- const self = this;
78
- return new Proxy(obj, {
79
- get(target, prop, receiver) {
80
- const value = Reflect.get(target, prop, receiver);
81
- // If the property is a function, make it trackable
82
- if (typeof value === 'function' && prop !== 'constructor') {
83
- const name = namespace
84
- ? `${namespace}.${String(prop)}`
85
- : String(prop);
86
- return self.makeTrackable(value, name);
87
- }
88
- // If the property is an object (but not a built-in), proxy it too
89
- if (value &&
90
- typeof value === 'object' &&
91
- !Array.isArray(value) &&
92
- Object.getPrototypeOf(value) === Object.prototype) {
93
- const nestedNamespace = namespace
94
- ? `${namespace}.${String(prop)}`
95
- : String(prop);
96
- return self.createProxy(value, nestedNamespace);
97
- }
98
- return value;
99
- },
100
- apply(target, thisArg, args) {
101
- // This handles the case when the proxy itself is called as a function
102
- const name = namespace || target.name || 'anonymous';
103
- return self._trackFn(() => Reflect.apply(target, thisArg, args), {
104
- label: name
105
- });
106
- }
107
- });
108
- }
109
- /**
110
- * Track a module's exports
111
- *
112
- * @param moduleExports - The module's exports
113
- * @param namespace - The namespace to use for tracking
114
- * @returns A proxied version of the module's exports
115
- */
116
- trackModule(moduleExports, namespace) {
117
- return this.createProxy(moduleExports, namespace);
118
- }
119
- /**
120
- * Clear all tracked functions
121
- */
122
- clear() {
123
- this._trackedFunctions.clear();
124
- this._originalFunctions.clear();
125
- }
126
- }
127
- //# sourceMappingURL=proxy-tracker.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"proxy-tracker.js","sourceRoot":"","sources":["../../../src/utils/proxy-tracker.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAWH;;GAEG;AACH,MAAM,OAAO,YAAY;IAMvB;;;;OAIG;IACH,YAAY,OAAuB;QAT3B,uBAAkB,GAA4B,IAAI,GAAG,EAAE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AAE;oBAC/D,KAAK,EAAE,IAAI;iBACZ,CAAC,CAAC;YACL,CAAC;SACF,CAAC,CAAC;IACL,CAAC;IAED;;;;;;OAMG;IACI,WAAW,CAAmB,aAAgB,EAAE,SAAiB;QACtE,OAAO,IAAI,CAAC,WAAW,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;IACpD,CAAC;IAED;;OAEG;IACI,KAAK;QACV,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAC;QAC/B,IAAI,CAAC,kBAAkB,CAAC,KAAK,EAAE,CAAC;IAClC,CAAC;CACF"}
@@ -1,63 +0,0 @@
1
- /**
2
- * Utilities for managing call stacks and function tracking
3
- */
4
- /**
5
- * Extract the name of a function
6
- *
7
- * @param fn - The function to extract the name from
8
- * @returns The function name or a placeholder if not available
9
- */
10
- export declare function getFunctionName(fn: Function): string;
11
- /**
12
- * Get the current call stack
13
- *
14
- * @returns An array of function names in the call stack
15
- */
16
- export declare function getCallStack(): string[];
17
- /**
18
- * CallStackManager - Manages a call stack for execution tracking
19
- */
20
- export declare class CallStackManager {
21
- private _stack;
22
- /**
23
- * Push a function name onto the call stack
24
- *
25
- * @param name - The function name
26
- * @returns The current stack depth
27
- */
28
- push(name: string): number;
29
- /**
30
- * Pop a function name from the call stack
31
- *
32
- * @returns The popped function name or undefined if the stack is empty
33
- */
34
- pop(): string | undefined;
35
- /**
36
- * Get the current call stack
37
- *
38
- * @returns A copy of the current call stack
39
- */
40
- getStack(): string[];
41
- /**
42
- * Get the current stack depth
43
- *
44
- * @returns The current stack depth
45
- */
46
- getDepth(): number;
47
- /**
48
- * Clear the call stack
49
- */
50
- clear(): void;
51
- /**
52
- * Get the current function name (top of the stack)
53
- *
54
- * @returns The current function name or undefined if the stack is empty
55
- */
56
- getCurrentFunction(): string | undefined;
57
- /**
58
- * Get the parent function name
59
- *
60
- * @returns The parent function name or undefined if there is no parent
61
- */
62
- getParentFunction(): string | undefined;
63
- }