@mks2508/better-logger 0.0.2-alpha.2 → 0.11.0-alpha.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 (247) hide show
  1. package/.github/workflows/ci-quality.yml +357 -0
  2. package/.github/workflows/docs-demo.yml +119 -0
  3. package/.github/workflows/releases-core.yml +512 -0
  4. package/.github/workflows/releases-full.yml +582 -0
  5. package/.github/{workflows → workflows-backup}/ci.yml +12 -110
  6. package/.github/workflows-backup/nightly.yml +196 -0
  7. package/.github/workflows-backup/release-optimized.yml +373 -0
  8. package/.release-notes-0.2.0.md +129 -0
  9. package/.yamllint +28 -0
  10. package/CHANGELOG.json +749 -0
  11. package/CLAUDE.md +92 -1
  12. package/README.md +142 -498
  13. package/bun.lock +323 -0
  14. package/demo.html +9 -2
  15. package/dist/Logger.d.ts +176 -0
  16. package/dist/Logger.d.ts.map +1 -0
  17. package/dist/Logger.js +498 -0
  18. package/dist/chunks/Logger-C2-cR3No.js +2 -0
  19. package/dist/chunks/Logger-C2-cR3No.js.map +1 -0
  20. package/dist/chunks/Logger-CVwk8cgA.js +2159 -0
  21. package/dist/chunks/Logger-CVwk8cgA.js.map +1 -0
  22. package/dist/chunks/RemoteLogHandler-CjWpWZGl.js +33 -0
  23. package/dist/chunks/RemoteLogHandler-CjWpWZGl.js.map +1 -0
  24. package/dist/chunks/RemoteLogHandler-ymkQ97xl.js +2 -0
  25. package/dist/chunks/RemoteLogHandler-ymkQ97xl.js.map +1 -0
  26. package/dist/chunks/StyleBuilder-BoJTmskd.js +361 -0
  27. package/dist/chunks/StyleBuilder-BoJTmskd.js.map +1 -0
  28. package/dist/chunks/StyleBuilder-LPLzsoHY.js +4 -0
  29. package/dist/chunks/StyleBuilder-LPLzsoHY.js.map +1 -0
  30. package/dist/cli/CommandProcessor.d.ts +103 -0
  31. package/dist/cli/CommandProcessor.d.ts.map +1 -0
  32. package/dist/cli/CommandProcessor.js +184 -0
  33. package/dist/cli/commands/ConfigCommand.d.ts +17 -0
  34. package/dist/cli/commands/ConfigCommand.d.ts.map +1 -0
  35. package/dist/cli/commands/ConfigCommand.js +88 -0
  36. package/dist/cli/commands/ExportCommand.d.ts +51 -0
  37. package/dist/cli/commands/ExportCommand.d.ts.map +1 -0
  38. package/dist/cli/commands/ExportCommand.js +243 -0
  39. package/dist/cli/commands/HistoryCommand.d.ts +50 -0
  40. package/dist/cli/commands/HistoryCommand.d.ts.map +1 -0
  41. package/dist/cli/commands/HistoryCommand.js +96 -0
  42. package/dist/cli/commands/StatusCommand.d.ts +33 -0
  43. package/dist/cli/commands/StatusCommand.d.ts.map +1 -0
  44. package/dist/cli/commands/StatusCommand.js +93 -0
  45. package/dist/cli/commands/ThemeCommand.d.ts +33 -0
  46. package/dist/cli/commands/ThemeCommand.d.ts.map +1 -0
  47. package/dist/cli/commands/ThemeCommand.js +79 -0
  48. package/dist/cli/help.d.ts +15 -0
  49. package/dist/cli/help.d.ts.map +1 -0
  50. package/dist/cli/help.js +118 -0
  51. package/dist/cli/index.d.ts +15 -0
  52. package/dist/cli/index.d.ts.map +1 -0
  53. package/dist/cli/index.js +46 -0
  54. package/dist/constants.d.ts +91 -0
  55. package/dist/constants.d.ts.map +1 -0
  56. package/dist/constants.js +80 -0
  57. package/dist/core.cjs +1 -1
  58. package/dist/core.cjs.map +1 -1
  59. package/dist/core.d.ts +130 -0
  60. package/dist/core.d.ts.map +1 -0
  61. package/dist/core.js +258 -242
  62. package/dist/core.js.map +1 -1
  63. package/dist/example.d.ts +18 -0
  64. package/dist/example.d.ts.map +1 -0
  65. package/dist/example.js +154 -0
  66. package/dist/exports-module.d.ts +203 -0
  67. package/dist/exports-module.d.ts.map +1 -0
  68. package/dist/exports-module.js +260 -0
  69. package/dist/exports.cjs +1 -1
  70. package/dist/exports.cjs.map +1 -1
  71. package/dist/exports.js +2 -2
  72. package/dist/handlers/AnalyticsLogHandler.d.ts +11 -0
  73. package/dist/handlers/AnalyticsLogHandler.d.ts.map +1 -0
  74. package/dist/handlers/AnalyticsLogHandler.js +19 -0
  75. package/dist/handlers/ExportLogHandler.d.ts +103 -0
  76. package/dist/handlers/ExportLogHandler.d.ts.map +1 -0
  77. package/dist/handlers/ExportLogHandler.js +516 -0
  78. package/dist/handlers/FileLogHandler.d.ts +13 -0
  79. package/dist/handlers/FileLogHandler.d.ts.map +1 -0
  80. package/dist/handlers/FileLogHandler.js +24 -0
  81. package/dist/handlers/RemoteLogHandler.d.ts +14 -0
  82. package/dist/handlers/RemoteLogHandler.d.ts.map +1 -0
  83. package/dist/handlers/RemoteLogHandler.js +37 -0
  84. package/dist/handlers/index.d.ts +8 -0
  85. package/dist/handlers/index.d.ts.map +1 -0
  86. package/dist/handlers/index.js +7 -0
  87. package/dist/index.cjs +1 -1
  88. package/dist/index.cjs.map +1 -1
  89. package/dist/index.d.ts +86 -0
  90. package/dist/index.d.ts.map +1 -0
  91. package/dist/index.js +89 -103
  92. package/dist/main.d.ts +2 -0
  93. package/dist/main.d.ts.map +1 -0
  94. package/dist/main.js +139 -0
  95. package/dist/styling/StyleBuilder.d.ts +132 -0
  96. package/dist/styling/StyleBuilder.d.ts.map +1 -0
  97. package/dist/styling/StyleBuilder.js +268 -0
  98. package/dist/styling/banners.d.ts +45 -0
  99. package/dist/styling/banners.d.ts.map +1 -0
  100. package/dist/styling/banners.js +155 -0
  101. package/dist/styling/index.d.ts +7 -0
  102. package/dist/styling/index.d.ts.map +1 -0
  103. package/dist/styling/index.js +6 -0
  104. package/dist/styling/themes.d.ts +10 -0
  105. package/dist/styling/themes.d.ts.map +1 -0
  106. package/dist/styling/themes.js +231 -0
  107. package/dist/styling-module.d.ts +185 -0
  108. package/dist/styling-module.d.ts.map +1 -0
  109. package/dist/styling-module.js +199 -0
  110. package/dist/styling.cjs +1 -1
  111. package/dist/styling.cjs.map +1 -1
  112. package/dist/styling.js +4 -4
  113. package/dist/types/Logger.d.ts +172 -0
  114. package/dist/types/Logger.d.ts.map +1 -0
  115. package/dist/types/cli/CommandProcessor.d.ts +100 -0
  116. package/dist/types/cli/CommandProcessor.d.ts.map +1 -0
  117. package/dist/types/cli/commands/ConfigCommand.d.ts +14 -0
  118. package/dist/types/cli/commands/ConfigCommand.d.ts.map +1 -0
  119. package/dist/types/cli/commands/ExportCommand.d.ts +48 -0
  120. package/dist/types/cli/commands/ExportCommand.d.ts.map +1 -0
  121. package/dist/types/cli/commands/HistoryCommand.d.ts +47 -0
  122. package/dist/types/cli/commands/HistoryCommand.d.ts.map +1 -0
  123. package/dist/types/cli/commands/StatusCommand.d.ts +30 -0
  124. package/dist/types/cli/commands/StatusCommand.d.ts.map +1 -0
  125. package/dist/types/cli/commands/ThemeCommand.d.ts +30 -0
  126. package/dist/types/cli/commands/ThemeCommand.d.ts.map +1 -0
  127. package/dist/types/cli/help.d.ts +12 -0
  128. package/dist/types/cli/help.d.ts.map +1 -0
  129. package/dist/types/cli/index.d.ts +15 -0
  130. package/dist/types/cli/index.d.ts.map +1 -0
  131. package/dist/types/constants.d.ts +88 -0
  132. package/dist/types/constants.d.ts.map +1 -0
  133. package/dist/types/core.d.ts +71 -211
  134. package/dist/types/core.d.ts.map +1 -0
  135. package/dist/types/core.js +13 -0
  136. package/dist/types/example.d.ts +18 -0
  137. package/dist/types/example.d.ts.map +1 -0
  138. package/dist/types/exports-module.d.ts +196 -0
  139. package/dist/types/exports-module.d.ts.map +1 -0
  140. package/dist/types/handlers/AnalyticsLogHandler.d.ts +8 -0
  141. package/dist/types/handlers/AnalyticsLogHandler.d.ts.map +1 -0
  142. package/dist/types/handlers/ExportLogHandler.d.ts +100 -0
  143. package/dist/types/handlers/ExportLogHandler.d.ts.map +1 -0
  144. package/dist/types/handlers/FileLogHandler.d.ts +10 -0
  145. package/dist/types/handlers/FileLogHandler.d.ts.map +1 -0
  146. package/dist/types/handlers/RemoteLogHandler.d.ts +11 -0
  147. package/dist/types/handlers/RemoteLogHandler.d.ts.map +1 -0
  148. package/dist/types/handlers/index.d.ts +8 -0
  149. package/dist/types/handlers/index.d.ts.map +1 -0
  150. package/dist/types/handlers.d.ts +88 -0
  151. package/dist/types/handlers.d.ts.map +1 -0
  152. package/dist/types/handlers.js +4 -0
  153. package/dist/types/index.d.ts +7 -675
  154. package/dist/types/index.d.ts.map +1 -0
  155. package/dist/types/index.js +4 -0
  156. package/dist/types/main.d.ts +2 -0
  157. package/dist/types/main.d.ts.map +1 -0
  158. package/dist/types/styling/StyleBuilder.d.ts +132 -0
  159. package/dist/types/styling/StyleBuilder.d.ts.map +1 -0
  160. package/dist/types/styling/banners.d.ts +42 -0
  161. package/dist/types/styling/banners.d.ts.map +1 -0
  162. package/dist/types/styling/index.d.ts +7 -0
  163. package/dist/types/styling/index.d.ts.map +1 -0
  164. package/dist/types/styling/themes.d.ts +7 -0
  165. package/dist/types/styling/themes.d.ts.map +1 -0
  166. package/dist/types/styling-module.d.ts +178 -0
  167. package/dist/types/styling-module.d.ts.map +1 -0
  168. package/dist/types/types/core.d.ts +71 -0
  169. package/dist/types/types/core.d.ts.map +1 -0
  170. package/dist/types/types/handlers.d.ts +85 -0
  171. package/dist/types/types/handlers.d.ts.map +1 -0
  172. package/dist/types/types/index.d.ts +7 -0
  173. package/dist/types/types/index.d.ts.map +1 -0
  174. package/dist/types/utils/index.d.ts +7 -0
  175. package/dist/types/utils/index.d.ts.map +1 -0
  176. package/dist/types/utils/output.d.ts +29 -0
  177. package/dist/types/utils/output.d.ts.map +1 -0
  178. package/dist/types/utils/stackTrace.d.ts +6 -0
  179. package/dist/types/utils/stackTrace.d.ts.map +1 -0
  180. package/dist/types/utils/timestamps.d.ts +20 -0
  181. package/dist/types/utils/timestamps.d.ts.map +1 -0
  182. package/dist/utils/index.d.ts +7 -0
  183. package/dist/utils/index.d.ts.map +1 -0
  184. package/dist/utils/index.js +6 -0
  185. package/dist/utils/output.d.ts +32 -0
  186. package/dist/utils/output.d.ts.map +1 -0
  187. package/dist/utils/output.js +97 -0
  188. package/dist/utils/stackTrace.d.ts +9 -0
  189. package/dist/utils/stackTrace.d.ts.map +1 -0
  190. package/dist/utils/stackTrace.js +81 -0
  191. package/dist/utils/timestamps.d.ts +20 -0
  192. package/dist/utils/timestamps.d.ts.map +1 -0
  193. package/dist/utils/timestamps.js +71 -0
  194. package/docs/API.md +691 -0
  195. package/docs/DEVELOPMENT.md +731 -0
  196. package/docs/PACKAGES.md +244 -0
  197. package/docs/_config.yml +36 -0
  198. package/docs/index.md +179 -0
  199. package/examples/README.md +208 -0
  200. package/examples/basic-logging.js +75 -0
  201. package/examples/data-export.js +234 -0
  202. package/examples/package.json +16 -0
  203. package/examples/performance-timing.js +170 -0
  204. package/examples/styling-themes.js +207 -0
  205. package/package.json +32 -21
  206. package/packages/core/package.json +35 -0
  207. package/packages/exports/package.json +41 -0
  208. package/packages/styling/package.json +41 -0
  209. package/project-utils/README.md +172 -0
  210. package/project-utils/auto-release-gemini.ts +1193 -0
  211. package/project-utils/commit-generator.ts +1385 -0
  212. package/project-utils/commit-ui.ts +264 -0
  213. package/project-utils/git-utils.ts +199 -0
  214. package/project-utils/github-release-manager.ts +466 -0
  215. package/project-utils/prompt-templates.js +345 -0
  216. package/project-utils/prompt-templates.ts +422 -0
  217. package/project-utils/version-manager.ts +1078 -0
  218. package/src/Logger.ts +2 -1
  219. package/src/cli/CommandProcessor.ts +173 -2
  220. package/src/cli/commands/HistoryCommand.ts +117 -0
  221. package/src/cli/index.ts +12 -0
  222. package/src/handlers/ExportLogHandler.ts +141 -0
  223. package/tests/test-conflict-resolution.ts +391 -0
  224. package/tests/validate-workflows.sh +131 -0
  225. package/tests/yaml-autofix.sh +146 -0
  226. package/vite.config.ts +152 -50
  227. package/.claude/settings.local.json +0 -22
  228. package/.npmrc.bak +0 -1
  229. package/dist/chunks/Logger-BQhMKy_T.js +0 -2
  230. package/dist/chunks/Logger-BQhMKy_T.js.map +0 -1
  231. package/dist/chunks/Logger-BrFKFZcD.js +0 -978
  232. package/dist/chunks/Logger-BrFKFZcD.js.map +0 -1
  233. package/dist/chunks/core-2opW4Pi3.js +0 -194
  234. package/dist/chunks/core-2opW4Pi3.js.map +0 -1
  235. package/dist/chunks/core-DyugwSYZ.js +0 -4
  236. package/dist/chunks/core-DyugwSYZ.js.map +0 -1
  237. package/dist/chunks/exports-BNP3R7dp.js +0 -421
  238. package/dist/chunks/exports-BNP3R7dp.js.map +0 -1
  239. package/dist/chunks/exports-U1xLBXrY.js +0 -2
  240. package/dist/chunks/exports-U1xLBXrY.js.map +0 -1
  241. package/dist/chunks/styling-DhUDzwlE.js +0 -654
  242. package/dist/chunks/styling-DhUDzwlE.js.map +0 -1
  243. package/dist/chunks/styling-tmRDI28D.js +0 -2
  244. package/dist/chunks/styling-tmRDI28D.js.map +0 -1
  245. package/dist/types/exports.d.ts +0 -600
  246. package/dist/types/styling.d.ts +0 -751
  247. /package/.github/{workflows → workflows-backup}/release.yml +0 -0
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @fileoverview Utility functions exports for Advanced Logger
3
+ */
4
+ export { parseStackTrace } from './stackTrace.js';
5
+ export { formatTimestamp, parseRelativeTime, parseTimeInput, formatDisplayTime } from './timestamps.js';
6
+ export { createStyledOutput, generateLogId, escapeHtml, safeStringify } from './output.js';
@@ -0,0 +1,32 @@
1
+ /**
2
+ * @fileoverview Styled output creation utilities for Advanced Logger
3
+ */
4
+ import type { LogLevel, StackInfo } from '../types/index.js';
5
+ /**
6
+ * Style configuration for each log level
7
+ */
8
+ export interface LevelStyleConfig {
9
+ emoji: string;
10
+ label: string;
11
+ background: string;
12
+ color: string;
13
+ border: string;
14
+ shadow: string;
15
+ }
16
+ /**
17
+ * Creates styled console output with multiple %c formatters
18
+ */
19
+ export declare function createStyledOutput(level: LogLevel, levelStyles: Record<LogLevel | 'success', LevelStyleConfig>, prefix: string | undefined, message: string, stackInfo: StackInfo | null): [string, ...string[]];
20
+ /**
21
+ * Create a unique ID for log entries
22
+ */
23
+ export declare function generateLogId(): string;
24
+ /**
25
+ * Escape HTML entities for safe HTML output
26
+ */
27
+ export declare function escapeHtml(text: string): string;
28
+ /**
29
+ * Convert objects to safe string representation for logging
30
+ */
31
+ export declare function safeStringify(obj: any, _maxDepth?: number): string;
32
+ //# sourceMappingURL=output.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/utils/output.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAI7D;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAClB;AAGD;;GAEG;AACH,wBAAgB,kBAAkB,CAC9B,KAAK,EAAE,QAAQ,EACf,WAAW,EAAE,MAAM,CAAC,QAAQ,GAAG,SAAS,EAAE,gBAAgB,CAAC,EAC3D,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,SAAS,GAAG,IAAI,GAC5B,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,CA+DvB;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAI/C;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,SAAI,GAAG,MAAM,CAY7D"}
@@ -0,0 +1,97 @@
1
+ /**
2
+ * @fileoverview Styled output creation utilities for Advanced Logger
3
+ */
4
+ import { formatTimestamp } from './timestamps.js';
5
+ import { StyleBuilder } from '../styling/index.js';
6
+ /**
7
+ * Creates styled console output with multiple %c formatters
8
+ */
9
+ export function createStyledOutput(level, levelStyles, prefix, message, stackInfo) {
10
+ const levelConfig = levelStyles[level];
11
+ const timestamp = formatTimestamp();
12
+ // Base styles
13
+ const timestampStyle = new StyleBuilder()
14
+ .color('#666')
15
+ .size('11px')
16
+ .font('Monaco, Consolas, monospace')
17
+ .build();
18
+ const levelStyle = new StyleBuilder()
19
+ .bg(levelConfig.background)
20
+ .color(levelConfig.color)
21
+ .border(levelConfig.border)
22
+ .shadow(levelConfig.shadow)
23
+ .padding('2px 8px')
24
+ .rounded('4px')
25
+ .bold()
26
+ .font('Monaco, Consolas, monospace')
27
+ .size('12px')
28
+ .build();
29
+ const prefixStyle = new StyleBuilder()
30
+ .bg('#2d3748')
31
+ .color('#e2e8f0')
32
+ .padding('2px 6px')
33
+ .rounded('3px')
34
+ .bold()
35
+ .font('Monaco, Consolas, monospace')
36
+ .size('11px')
37
+ .build();
38
+ const messageStyle = new StyleBuilder()
39
+ .color('#2d3748')
40
+ .font('system-ui, -apple-system, sans-serif')
41
+ .size('14px')
42
+ .build();
43
+ const locationStyle = new StyleBuilder()
44
+ .color('#718096')
45
+ .size('11px')
46
+ .font('Monaco, Consolas, monospace')
47
+ .build();
48
+ // Build format string and styles
49
+ let format = `%c${timestamp.slice(11, 23)} %c${levelConfig.emoji} ${levelConfig.label}`;
50
+ const styles = [timestampStyle, levelStyle];
51
+ if (prefix) {
52
+ format += ` %c${prefix}`;
53
+ styles.push(prefixStyle);
54
+ }
55
+ format += ` %c${message}`;
56
+ styles.push(messageStyle);
57
+ if (stackInfo) {
58
+ format += ` %c(${stackInfo.file}:${stackInfo.line}:${stackInfo.column})`;
59
+ styles.push(locationStyle);
60
+ }
61
+ return [format, ...styles];
62
+ }
63
+ /**
64
+ * Create a unique ID for log entries
65
+ */
66
+ export function generateLogId() {
67
+ return `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
68
+ }
69
+ /**
70
+ * Escape HTML entities for safe HTML output
71
+ */
72
+ export function escapeHtml(text) {
73
+ const div = document.createElement('div');
74
+ div.textContent = text;
75
+ return div.innerHTML;
76
+ }
77
+ /**
78
+ * Convert objects to safe string representation for logging
79
+ */
80
+ export function safeStringify(obj, _maxDepth = 3) {
81
+ try {
82
+ return JSON.stringify(obj, (_key, value) => {
83
+ if (typeof value === 'function')
84
+ return '[Function]';
85
+ if (value instanceof Error)
86
+ return `[Error: ${value.message}]`;
87
+ if (value instanceof Date)
88
+ return value.toISOString();
89
+ if (typeof value === 'undefined')
90
+ return '[undefined]';
91
+ return value;
92
+ }, 2);
93
+ }
94
+ catch (error) {
95
+ return String(obj);
96
+ }
97
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @fileoverview Stack trace parsing utilities for Advanced Logger
3
+ */
4
+ import type { StackInfo } from '../types/index.js';
5
+ /**
6
+ * Parses the current stack trace to extract caller information
7
+ */
8
+ export declare function parseStackTrace(): StackInfo | null;
9
+ //# sourceMappingURL=stackTrace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stackTrace.d.ts","sourceRoot":"","sources":["../../src/utils/stackTrace.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD;;GAEG;AACH,wBAAgB,eAAe,IAAI,SAAS,GAAG,IAAI,CAqFlD"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * @fileoverview Stack trace parsing utilities for Advanced Logger
3
+ */
4
+ /**
5
+ * Parses the current stack trace to extract caller information
6
+ */
7
+ export function parseStackTrace() {
8
+ try {
9
+ const stack = new Error().stack;
10
+ if (!stack) {
11
+ return null;
12
+ }
13
+ const lines = stack.split('\n').filter(line => line.trim());
14
+ // Find the first caller that's not from Logger methods
15
+ for (let i = 1; i < lines.length; i++) {
16
+ const line = lines[i];
17
+ if (!line) {
18
+ continue;
19
+ }
20
+ // Skip if line contains Logger methods or parseStackTrace
21
+ if (line.includes('parseStackTrace') ||
22
+ line.includes('Logger.') ||
23
+ line.includes('.log(') ||
24
+ line.includes('createStyledOutput')) {
25
+ continue;
26
+ }
27
+ // Parse different stack trace formats
28
+ let match;
29
+ // Chrome format: "at functionName (file:line:column)" or "at file:line:column"
30
+ const chromeMatch = line.match(/at\s+(?:(.+?)\s+\()?(.+?):(\d+):(\d+)\)?$/);
31
+ if (chromeMatch) {
32
+ match = chromeMatch;
33
+ }
34
+ else {
35
+ // Firefox format: "functionName@file:line:column"
36
+ const firefoxMatch = line.match(/(.+?)@(.+?):(\d+):(\d+)$/);
37
+ if (firefoxMatch) {
38
+ match = firefoxMatch;
39
+ }
40
+ else {
41
+ // Safari/other formats
42
+ const safariMatch = line.match(/(\S+)?@(.+?):(\d+):(\d+)$/);
43
+ if (safariMatch) {
44
+ match = safariMatch;
45
+ }
46
+ }
47
+ }
48
+ if (!match) {
49
+ continue;
50
+ }
51
+ const [, functionName, file, lineStr, columnStr] = match;
52
+ if (!file) {
53
+ continue;
54
+ }
55
+ // Process file path - remove query params and get filename
56
+ const fileParts = file.split('/');
57
+ const fileName = fileParts[fileParts.length - 1];
58
+ if (!fileName) {
59
+ continue;
60
+ }
61
+ const cleanFileName = fileName.split('?')[0];
62
+ // Parse line and column numbers
63
+ const lineNum = lineStr ? parseInt(lineStr, 10) : 0;
64
+ const columnNum = columnStr ? parseInt(columnStr, 10) : 0;
65
+ // Clean function name
66
+ const cleanFunction = functionName && functionName.trim()
67
+ ? functionName.trim()
68
+ : undefined;
69
+ return {
70
+ file: cleanFileName ? cleanFileName : 'unknown',
71
+ line: lineNum,
72
+ column: columnNum,
73
+ function: cleanFunction
74
+ };
75
+ }
76
+ return null;
77
+ }
78
+ catch {
79
+ return null;
80
+ }
81
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @fileoverview Timestamp utilities for Advanced Logger
3
+ */
4
+ /**
5
+ * Formats the timestamp using modern Date API
6
+ */
7
+ export declare function formatTimestamp(): string;
8
+ /**
9
+ * Parse relative time strings like "2h", "30m", "1d" into milliseconds
10
+ */
11
+ export declare function parseRelativeTime(timeStr: string): number;
12
+ /**
13
+ * Parse time input which can be Date, ISO string, or relative time
14
+ */
15
+ export declare function parseTimeInput(input: Date | string | number): Date;
16
+ /**
17
+ * Format timestamp for display in different contexts
18
+ */
19
+ export declare function formatDisplayTime(date: Date, format?: 'short' | 'full' | 'time-only'): string;
20
+ //# sourceMappingURL=timestamps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timestamps.d.ts","sourceRoot":"","sources":["../../src/utils/timestamps.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;GAEG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAQxC;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAUzD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CA2BlE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,GAAE,OAAO,GAAG,MAAM,GAAG,WAAqB,GAAG,MAAM,CAUtG"}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * @fileoverview Timestamp utilities for Advanced Logger
3
+ */
4
+ import { TIME_UNITS } from '../constants.js';
5
+ /**
6
+ * Formats the timestamp using modern Date API
7
+ */
8
+ export function formatTimestamp() {
9
+ try {
10
+ // Use modern Temporal API if available, fallback to Date
11
+ const now = new Date();
12
+ return now.toISOString();
13
+ }
14
+ catch {
15
+ return new Date().toISOString();
16
+ }
17
+ }
18
+ /**
19
+ * Parse relative time strings like "2h", "30m", "1d" into milliseconds
20
+ */
21
+ export function parseRelativeTime(timeStr) {
22
+ const match = timeStr.match(/^(\d+)(ms|s|m|h|d)$/);
23
+ if (!match) {
24
+ throw new Error(`Invalid time format: ${timeStr}. Use format like "2h", "30m", "1d"`);
25
+ }
26
+ const [, amount, unit] = match;
27
+ const multiplier = TIME_UNITS[unit];
28
+ return parseInt(amount || '0', 10) * multiplier;
29
+ }
30
+ /**
31
+ * Parse time input which can be Date, ISO string, or relative time
32
+ */
33
+ export function parseTimeInput(input) {
34
+ if (input instanceof Date) {
35
+ return input;
36
+ }
37
+ if (typeof input === 'number') {
38
+ // Assume hours ago
39
+ return new Date(Date.now() - input * TIME_UNITS.h);
40
+ }
41
+ if (typeof input === 'string') {
42
+ // Try parsing as ISO date first
43
+ const isoDate = new Date(input);
44
+ if (!isNaN(isoDate.getTime())) {
45
+ return isoDate;
46
+ }
47
+ // Try parsing as relative time
48
+ try {
49
+ const ms = parseRelativeTime(input);
50
+ return new Date(Date.now() - ms);
51
+ }
52
+ catch {
53
+ throw new Error(`Invalid time format: ${input}`);
54
+ }
55
+ }
56
+ throw new Error(`Unsupported time input type: ${typeof input}`);
57
+ }
58
+ /**
59
+ * Format timestamp for display in different contexts
60
+ */
61
+ export function formatDisplayTime(date, format = 'short') {
62
+ switch (format) {
63
+ case 'time-only':
64
+ return date.toTimeString().slice(0, 8); // HH:MM:SS
65
+ case 'full':
66
+ return date.toISOString();
67
+ case 'short':
68
+ default:
69
+ return date.toISOString().slice(11, 23); // HH:MM:SS.mmm
70
+ }
71
+ }