@mks2508/better-logger 0.0.2-alpha.2 → 0.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 (326) hide show
  1. package/.claude/settings.local.json +18 -2
  2. package/.github/workflows/ci-quality.yml +357 -0
  3. package/.github/workflows/docs-demo.yml +119 -0
  4. package/.github/workflows/releases-core.yml +512 -0
  5. package/.github/workflows/releases-full.yml +582 -0
  6. package/.github/{workflows → workflows-backup}/ci.yml +12 -110
  7. package/.github/workflows-backup/nightly.yml +196 -0
  8. package/.github/workflows-backup/release-optimized.yml +373 -0
  9. package/.release-notes-0.2.0.md +129 -0
  10. package/.yamllint +28 -0
  11. package/CHANGELOG.json +783 -0
  12. package/CLAUDE.md +92 -1
  13. package/README.md +198 -490
  14. package/bun.lock +323 -0
  15. package/demo.html +9 -2
  16. package/dist/.tsbuildinfo +1 -0
  17. package/dist/Logger.d.ts +272 -0
  18. package/dist/Logger.d.ts.map +1 -0
  19. package/dist/Logger.js +680 -0
  20. package/dist/ScopedLogger.d.ts +126 -0
  21. package/dist/ScopedLogger.d.ts.map +1 -0
  22. package/dist/ScopedLogger.js +234 -0
  23. package/dist/chunks/Logger-BpeuYIxR.js +2 -0
  24. package/dist/chunks/Logger-BpeuYIxR.js.map +1 -0
  25. package/dist/chunks/Logger-Didxtr23.js +3275 -0
  26. package/dist/chunks/Logger-Didxtr23.js.map +1 -0
  27. package/dist/chunks/RemoteLogHandler-CjWpWZGl.js +33 -0
  28. package/dist/chunks/RemoteLogHandler-CjWpWZGl.js.map +1 -0
  29. package/dist/chunks/RemoteLogHandler-ymkQ97xl.js +2 -0
  30. package/dist/chunks/RemoteLogHandler-ymkQ97xl.js.map +1 -0
  31. package/dist/chunks/environment-Bxbnw4pd.js +544 -0
  32. package/dist/chunks/environment-Bxbnw4pd.js.map +1 -0
  33. package/dist/chunks/environment-Dm66zOML.js +4 -0
  34. package/dist/chunks/environment-Dm66zOML.js.map +1 -0
  35. package/dist/chunks/formatting-C0riPC5_.js +95 -0
  36. package/dist/chunks/formatting-C0riPC5_.js.map +1 -0
  37. package/dist/chunks/formatting-DNCAV66-.js +2 -0
  38. package/dist/chunks/formatting-DNCAV66-.js.map +1 -0
  39. package/dist/cli/CommandProcessor.d.ts +103 -0
  40. package/dist/cli/CommandProcessor.d.ts.map +1 -0
  41. package/dist/cli/CommandProcessor.js +184 -0
  42. package/dist/cli/commands/ConfigCommand.d.ts +17 -0
  43. package/dist/cli/commands/ConfigCommand.d.ts.map +1 -0
  44. package/dist/cli/commands/ConfigCommand.js +88 -0
  45. package/dist/cli/commands/ExportCommand.d.ts +51 -0
  46. package/dist/cli/commands/ExportCommand.d.ts.map +1 -0
  47. package/dist/cli/commands/ExportCommand.js +243 -0
  48. package/dist/cli/commands/HistoryCommand.d.ts +50 -0
  49. package/dist/cli/commands/HistoryCommand.d.ts.map +1 -0
  50. package/dist/cli/commands/HistoryCommand.js +96 -0
  51. package/dist/cli/commands/StatusCommand.d.ts +33 -0
  52. package/dist/cli/commands/StatusCommand.d.ts.map +1 -0
  53. package/dist/cli/commands/StatusCommand.js +93 -0
  54. package/dist/cli/commands/ThemeCommand.d.ts +33 -0
  55. package/dist/cli/commands/ThemeCommand.d.ts.map +1 -0
  56. package/dist/cli/commands/ThemeCommand.js +79 -0
  57. package/dist/cli/help.d.ts +15 -0
  58. package/dist/cli/help.d.ts.map +1 -0
  59. package/dist/cli/help.js +118 -0
  60. package/dist/cli/index.d.ts +15 -0
  61. package/dist/cli/index.d.ts.map +1 -0
  62. package/dist/cli/index.js +46 -0
  63. package/dist/constants.d.ts +122 -0
  64. package/dist/constants.d.ts.map +1 -0
  65. package/dist/constants.js +159 -0
  66. package/dist/core.cjs +1 -1
  67. package/dist/core.cjs.map +1 -1
  68. package/dist/core.d.ts +134 -0
  69. package/dist/core.d.ts.map +1 -0
  70. package/dist/core.js +315 -242
  71. package/dist/core.js.map +1 -1
  72. package/dist/example.d.ts +18 -0
  73. package/dist/example.d.ts.map +1 -0
  74. package/dist/example.js +154 -0
  75. package/dist/exports-module.d.ts +203 -0
  76. package/dist/exports-module.d.ts.map +1 -0
  77. package/dist/exports-module.js +260 -0
  78. package/dist/exports.cjs +1 -1
  79. package/dist/exports.cjs.map +1 -1
  80. package/dist/exports.js +5 -4
  81. package/dist/exports.js.map +1 -1
  82. package/dist/handlers/AnalyticsLogHandler.d.ts +11 -0
  83. package/dist/handlers/AnalyticsLogHandler.d.ts.map +1 -0
  84. package/dist/handlers/AnalyticsLogHandler.js +19 -0
  85. package/dist/handlers/ExportLogHandler.d.ts +103 -0
  86. package/dist/handlers/ExportLogHandler.d.ts.map +1 -0
  87. package/dist/handlers/ExportLogHandler.js +516 -0
  88. package/dist/handlers/FileLogHandler.d.ts +36 -0
  89. package/dist/handlers/FileLogHandler.d.ts.map +1 -0
  90. package/dist/handlers/FileLogHandler.js +156 -0
  91. package/dist/handlers/RemoteLogHandler.d.ts +14 -0
  92. package/dist/handlers/RemoteLogHandler.d.ts.map +1 -0
  93. package/dist/handlers/RemoteLogHandler.js +37 -0
  94. package/dist/handlers/index.d.ts +8 -0
  95. package/dist/handlers/index.d.ts.map +1 -0
  96. package/dist/handlers/index.js +7 -0
  97. package/dist/index.cjs +1 -1
  98. package/dist/index.cjs.map +1 -1
  99. package/dist/index.d.ts +86 -0
  100. package/dist/index.d.ts.map +1 -0
  101. package/dist/index.js +89 -103
  102. package/dist/index.js.map +1 -1
  103. package/dist/main.d.ts +2 -0
  104. package/dist/main.d.ts.map +1 -0
  105. package/dist/main.js +139 -0
  106. package/dist/styling/LogStyleBuilder.d.ts +149 -0
  107. package/dist/styling/LogStyleBuilder.d.ts.map +1 -0
  108. package/dist/styling/LogStyleBuilder.js +289 -0
  109. package/dist/styling/SemanticStyles.d.ts +181 -0
  110. package/dist/styling/SemanticStyles.d.ts.map +1 -0
  111. package/dist/styling/SemanticStyles.js +339 -0
  112. package/dist/styling/SmartPresets.d.ts +25 -0
  113. package/dist/styling/SmartPresets.d.ts.map +1 -0
  114. package/dist/styling/SmartPresets.js +276 -0
  115. package/dist/styling/StyleBuilder.d.ts +140 -0
  116. package/dist/styling/StyleBuilder.d.ts.map +1 -0
  117. package/dist/styling/StyleBuilder.js +280 -0
  118. package/dist/styling/banners.d.ts +45 -0
  119. package/dist/styling/banners.d.ts.map +1 -0
  120. package/dist/styling/banners.js +155 -0
  121. package/dist/styling/index.d.ts +10 -0
  122. package/dist/styling/index.d.ts.map +1 -0
  123. package/dist/styling/index.js +9 -0
  124. package/dist/styling/themes.d.ts +10 -0
  125. package/dist/styling/themes.d.ts.map +1 -0
  126. package/dist/styling/themes.js +231 -0
  127. package/dist/styling-module.d.ts +185 -0
  128. package/dist/styling-module.d.ts.map +1 -0
  129. package/dist/styling-module.js +199 -0
  130. package/dist/styling.cjs +1 -1
  131. package/dist/styling.cjs.map +1 -1
  132. package/dist/styling.js +6 -6
  133. package/dist/styling.js.map +1 -1
  134. package/dist/types/Logger.d.ts +268 -0
  135. package/dist/types/Logger.d.ts.map +1 -0
  136. package/dist/types/ScopedLogger.d.ts +123 -0
  137. package/dist/types/ScopedLogger.d.ts.map +1 -0
  138. package/dist/types/cli/CommandProcessor.d.ts +100 -0
  139. package/dist/types/cli/CommandProcessor.d.ts.map +1 -0
  140. package/dist/types/cli/commands/ConfigCommand.d.ts +14 -0
  141. package/dist/types/cli/commands/ConfigCommand.d.ts.map +1 -0
  142. package/dist/types/cli/commands/ExportCommand.d.ts +48 -0
  143. package/dist/types/cli/commands/ExportCommand.d.ts.map +1 -0
  144. package/dist/types/cli/commands/HistoryCommand.d.ts +47 -0
  145. package/dist/types/cli/commands/HistoryCommand.d.ts.map +1 -0
  146. package/dist/types/cli/commands/StatusCommand.d.ts +30 -0
  147. package/dist/types/cli/commands/StatusCommand.d.ts.map +1 -0
  148. package/dist/types/cli/commands/ThemeCommand.d.ts +30 -0
  149. package/dist/types/cli/commands/ThemeCommand.d.ts.map +1 -0
  150. package/dist/types/cli/help.d.ts +12 -0
  151. package/dist/types/cli/help.d.ts.map +1 -0
  152. package/dist/types/cli/index.d.ts +15 -0
  153. package/dist/types/cli/index.d.ts.map +1 -0
  154. package/dist/types/constants.d.ts +119 -0
  155. package/dist/types/constants.d.ts.map +1 -0
  156. package/dist/types/core.d.ts +125 -211
  157. package/dist/types/core.d.ts.map +1 -0
  158. package/dist/types/core.js +13 -0
  159. package/dist/types/example.d.ts +18 -0
  160. package/dist/types/example.d.ts.map +1 -0
  161. package/dist/types/exports-module.d.ts +196 -0
  162. package/dist/types/exports-module.d.ts.map +1 -0
  163. package/dist/types/handlers/AnalyticsLogHandler.d.ts +8 -0
  164. package/dist/types/handlers/AnalyticsLogHandler.d.ts.map +1 -0
  165. package/dist/types/handlers/ExportLogHandler.d.ts +100 -0
  166. package/dist/types/handlers/ExportLogHandler.d.ts.map +1 -0
  167. package/dist/types/handlers/FileLogHandler.d.ts +33 -0
  168. package/dist/types/handlers/FileLogHandler.d.ts.map +1 -0
  169. package/dist/types/handlers/RemoteLogHandler.d.ts +11 -0
  170. package/dist/types/handlers/RemoteLogHandler.d.ts.map +1 -0
  171. package/dist/types/handlers/index.d.ts +8 -0
  172. package/dist/types/handlers/index.d.ts.map +1 -0
  173. package/dist/types/handlers.d.ts +88 -0
  174. package/dist/types/handlers.d.ts.map +1 -0
  175. package/dist/types/handlers.js +4 -0
  176. package/dist/types/index.d.ts +7 -675
  177. package/dist/types/index.d.ts.map +1 -0
  178. package/dist/types/index.js +4 -0
  179. package/dist/types/main.d.ts +2 -0
  180. package/dist/types/main.d.ts.map +1 -0
  181. package/dist/types/styling/LogStyleBuilder.d.ts +146 -0
  182. package/dist/types/styling/LogStyleBuilder.d.ts.map +1 -0
  183. package/dist/types/styling/SemanticStyles.d.ts +178 -0
  184. package/dist/types/styling/SemanticStyles.d.ts.map +1 -0
  185. package/dist/types/styling/SmartPresets.d.ts +22 -0
  186. package/dist/types/styling/SmartPresets.d.ts.map +1 -0
  187. package/dist/types/styling/StyleBuilder.d.ts +140 -0
  188. package/dist/types/styling/StyleBuilder.d.ts.map +1 -0
  189. package/dist/types/styling/banners.d.ts +42 -0
  190. package/dist/types/styling/banners.d.ts.map +1 -0
  191. package/dist/types/styling/index.d.ts +10 -0
  192. package/dist/types/styling/index.d.ts.map +1 -0
  193. package/dist/types/styling/themes.d.ts +7 -0
  194. package/dist/types/styling/themes.d.ts.map +1 -0
  195. package/dist/types/styling-module.d.ts +178 -0
  196. package/dist/types/styling-module.d.ts.map +1 -0
  197. package/dist/types/types/core.d.ts +125 -0
  198. package/dist/types/types/core.d.ts.map +1 -0
  199. package/dist/types/types/handlers.d.ts +85 -0
  200. package/dist/types/types/handlers.d.ts.map +1 -0
  201. package/dist/types/types/index.d.ts +7 -0
  202. package/dist/types/types/index.d.ts.map +1 -0
  203. package/dist/types/utils/environment.d.ts +47 -0
  204. package/dist/types/utils/environment.d.ts.map +1 -0
  205. package/dist/types/utils/formatting.d.ts +37 -0
  206. package/dist/types/utils/formatting.d.ts.map +1 -0
  207. package/dist/types/utils/index.d.ts +7 -0
  208. package/dist/types/utils/index.d.ts.map +1 -0
  209. package/dist/types/utils/opentui-detection.d.ts +34 -0
  210. package/dist/types/utils/opentui-detection.d.ts.map +1 -0
  211. package/dist/types/utils/output.d.ts +41 -0
  212. package/dist/types/utils/output.d.ts.map +1 -0
  213. package/dist/types/utils/stackTrace.d.ts +6 -0
  214. package/dist/types/utils/stackTrace.d.ts.map +1 -0
  215. package/dist/types/utils/timestamps.d.ts +20 -0
  216. package/dist/types/utils/timestamps.d.ts.map +1 -0
  217. package/dist/utils/environment.d.ts +47 -0
  218. package/dist/utils/environment.d.ts.map +1 -0
  219. package/dist/utils/environment.js +85 -0
  220. package/dist/utils/formatting.d.ts +40 -0
  221. package/dist/utils/formatting.d.ts.map +1 -0
  222. package/dist/utils/formatting.js +117 -0
  223. package/dist/utils/index.d.ts +7 -0
  224. package/dist/utils/index.d.ts.map +1 -0
  225. package/dist/utils/index.js +6 -0
  226. package/dist/utils/opentui-detection.d.ts +34 -0
  227. package/dist/utils/opentui-detection.d.ts.map +1 -0
  228. package/dist/utils/opentui-detection.js +116 -0
  229. package/dist/utils/output.d.ts +44 -0
  230. package/dist/utils/output.d.ts.map +1 -0
  231. package/dist/utils/output.js +150 -0
  232. package/dist/utils/stackTrace.d.ts +9 -0
  233. package/dist/utils/stackTrace.d.ts.map +1 -0
  234. package/dist/utils/stackTrace.js +81 -0
  235. package/dist/utils/timestamps.d.ts +20 -0
  236. package/dist/utils/timestamps.d.ts.map +1 -0
  237. package/dist/utils/timestamps.js +71 -0
  238. package/docs/API.md +691 -0
  239. package/docs/CORE.md +10 -10
  240. package/docs/DEVELOPMENT.md +731 -0
  241. package/docs/PACKAGES.md +244 -0
  242. package/docs/_config.yml +36 -0
  243. package/docs/index.md +179 -0
  244. package/examples/README.md +208 -0
  245. package/examples/basic-logging.js +75 -0
  246. package/examples/data-export.js +234 -0
  247. package/examples/package.json +16 -0
  248. package/examples/performance-timing.js +170 -0
  249. package/examples/simplified-api.js +124 -0
  250. package/examples/styling-themes.js +207 -0
  251. package/package.json +37 -21
  252. package/packages/core/package.json +57 -0
  253. package/packages/exports/package.json +41 -0
  254. package/packages/nodejs-opentui/README.md +232 -0
  255. package/packages/nodejs-opentui/package.json +72 -0
  256. package/packages/nodejs-opentui/src/LogRenderer.ts +171 -0
  257. package/packages/nodejs-opentui/src/OpenTUILogHandler.ts +178 -0
  258. package/packages/nodejs-opentui/src/components/LogBadge.tsx +131 -0
  259. package/packages/nodejs-opentui/src/index.ts +133 -0
  260. package/packages/nodejs-opentui/src/types.ts +158 -0
  261. package/packages/nodejs-opentui/tsconfig.json +20 -0
  262. package/packages/styling/package.json +41 -0
  263. package/project-utils/README.md +172 -0
  264. package/project-utils/auto-release-gemini.ts +1193 -0
  265. package/project-utils/auto-release-ui.ts +1329 -0
  266. package/project-utils/commit-generator.ts +1385 -0
  267. package/project-utils/commit-ui.ts +264 -0
  268. package/project-utils/git-utils.ts +199 -0
  269. package/project-utils/github-release-manager.ts +466 -0
  270. package/project-utils/project-config.ts +260 -0
  271. package/project-utils/prompt-templates.js +345 -0
  272. package/project-utils/prompt-templates.ts +422 -0
  273. package/project-utils/version-manager.ts +1078 -0
  274. package/src/Logger.ts +251 -16
  275. package/src/ScopedLogger.ts +262 -0
  276. package/src/cli/CommandProcessor.ts +173 -2
  277. package/src/cli/commands/HistoryCommand.ts +117 -0
  278. package/src/cli/index.ts +12 -0
  279. package/src/constants.ts +84 -2
  280. package/src/core.ts +119 -46
  281. package/src/example.ts +4 -4
  282. package/src/exports-module.ts +1 -1
  283. package/src/handlers/ExportLogHandler.ts +141 -0
  284. package/src/handlers/FileLogHandler.ts +144 -5
  285. package/src/index.ts +1 -1
  286. package/src/main.ts +3 -3
  287. package/src/styling/LogStyleBuilder.ts +355 -0
  288. package/src/styling/SemanticStyles.ts +380 -0
  289. package/src/styling/SmartPresets.ts +288 -0
  290. package/src/styling/StyleBuilder.ts +14 -0
  291. package/src/styling/index.ts +16 -1
  292. package/src/styling-module.ts +1 -1
  293. package/src/types/core.ts +60 -0
  294. package/src/types/index.ts +6 -0
  295. package/src/utils/environment.ts +94 -0
  296. package/src/utils/formatting.ts +142 -0
  297. package/src/utils/index.ts +3 -0
  298. package/src/utils/opentui-detection.ts +138 -0
  299. package/src/utils/output.ts +66 -8
  300. package/test-core-browser.html +237 -0
  301. package/test-core-node.js +63 -0
  302. package/tests/test-conflict-resolution.ts +391 -0
  303. package/tests/validate-workflows.sh +131 -0
  304. package/tests/yaml-autofix.sh +146 -0
  305. package/vite.config.ts +189 -50
  306. package/.npmrc.bak +0 -1
  307. package/dist/chunks/Logger-BQhMKy_T.js +0 -2
  308. package/dist/chunks/Logger-BQhMKy_T.js.map +0 -1
  309. package/dist/chunks/Logger-BrFKFZcD.js +0 -978
  310. package/dist/chunks/Logger-BrFKFZcD.js.map +0 -1
  311. package/dist/chunks/core-2opW4Pi3.js +0 -194
  312. package/dist/chunks/core-2opW4Pi3.js.map +0 -1
  313. package/dist/chunks/core-DyugwSYZ.js +0 -4
  314. package/dist/chunks/core-DyugwSYZ.js.map +0 -1
  315. package/dist/chunks/exports-BNP3R7dp.js +0 -421
  316. package/dist/chunks/exports-BNP3R7dp.js.map +0 -1
  317. package/dist/chunks/exports-U1xLBXrY.js +0 -2
  318. package/dist/chunks/exports-U1xLBXrY.js.map +0 -1
  319. package/dist/chunks/styling-DhUDzwlE.js +0 -654
  320. package/dist/chunks/styling-DhUDzwlE.js.map +0 -1
  321. package/dist/chunks/styling-tmRDI28D.js +0 -2
  322. package/dist/chunks/styling-tmRDI28D.js.map +0 -1
  323. package/dist/types/exports.d.ts +0 -600
  324. package/dist/types/styling.d.ts +0 -751
  325. package/src/Logger.ts.backup +0 -1684
  326. /package/.github/{workflows → workflows-backup}/release.yml +0 -0
@@ -0,0 +1,47 @@
1
+ /**
2
+ * @fileoverview Environment detection utilities for Universal Logger
3
+ */
4
+ /**
5
+ * Checks if running in Node.js environment
6
+ */
7
+ export declare const isNode: string | false;
8
+ /**
9
+ * Checks if running in browser environment
10
+ */
11
+ export declare const isBrowser: boolean;
12
+ /**
13
+ * Checks if running in web worker environment
14
+ */
15
+ export declare const isWebWorker: boolean;
16
+ /**
17
+ * Checks if running in Deno environment
18
+ */
19
+ export declare const isDeno: boolean;
20
+ /**
21
+ * Gets the current runtime environment
22
+ */
23
+ export declare function getRuntimeEnvironment(): 'node' | 'browser' | 'webworker' | 'deno' | 'unknown';
24
+ /**
25
+ * Checks if colors/styling should be supported in current environment
26
+ */
27
+ export declare function supportsColors(): boolean;
28
+ /**
29
+ * Checks if CSS styling is supported (browser-only feature)
30
+ */
31
+ export declare function supportsCSSColors(): boolean;
32
+ /**
33
+ * Checks if ANSI colors are supported (terminal environments)
34
+ */
35
+ export declare function supportsANSIColors(): boolean;
36
+ /**
37
+ * Gets environment-specific information
38
+ */
39
+ export declare function getEnvironmentInfo(): {
40
+ runtime: "unknown" | "node" | "browser" | "webworker" | "deno";
41
+ supportsColors: boolean;
42
+ supportsCSSColors: boolean;
43
+ supportsANSIColors: boolean;
44
+ isProduction: boolean;
45
+ version: string;
46
+ };
47
+ //# sourceMappingURL=environment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../../src/utils/environment.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,eAAO,MAAM,MAAM,gBAEwB,CAAC;AAE5C;;GAEG;AACH,eAAO,MAAM,SAAS,SACmC,CAAC;AAE1D;;GAEG;AACH,eAAO,MAAM,WAAW,SACqD,CAAC;AAE9E;;GAEG;AACH,eAAO,MAAM,MAAM,SACuB,CAAC;AAE3C;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,GAAG,SAAS,GAAG,WAAW,GAAG,MAAM,GAAG,SAAS,CAM7F;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,OAAO,CAcxC;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAE3C;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,OAAO,CAQ5C;AAED;;GAEG;AACH,wBAAgB,kBAAkB;;;;;;;EAWjC"}
@@ -0,0 +1,85 @@
1
+ /**
2
+ * @fileoverview Environment detection utilities for Universal Logger
3
+ */
4
+ /**
5
+ * Checks if running in Node.js environment
6
+ */
7
+ export const isNode = typeof process !== 'undefined' &&
8
+ process.versions &&
9
+ process.versions.node;
10
+ /**
11
+ * Checks if running in browser environment
12
+ */
13
+ export const isBrowser = typeof window !== 'undefined' &&
14
+ typeof document !== 'undefined';
15
+ /**
16
+ * Checks if running in web worker environment
17
+ */
18
+ export const isWebWorker = typeof self !== 'undefined' &&
19
+ typeof self.importScripts === 'function';
20
+ /**
21
+ * Checks if running in Deno environment
22
+ */
23
+ export const isDeno = typeof globalThis !== 'undefined' &&
24
+ 'Deno' in globalThis;
25
+ /**
26
+ * Gets the current runtime environment
27
+ */
28
+ export function getRuntimeEnvironment() {
29
+ if (isNode)
30
+ return 'node';
31
+ if (isBrowser)
32
+ return 'browser';
33
+ if (isWebWorker)
34
+ return 'webworker';
35
+ if (isDeno)
36
+ return 'deno';
37
+ return 'unknown';
38
+ }
39
+ /**
40
+ * Checks if colors/styling should be supported in current environment
41
+ */
42
+ export function supportsColors() {
43
+ if (isBrowser) {
44
+ // Browser always supports CSS colors
45
+ return true;
46
+ }
47
+ if (isNode) {
48
+ // Check if Node.js supports colors
49
+ return process.stdout?.isTTY === true ||
50
+ process.env.FORCE_COLOR === '1' ||
51
+ process.env.FORCE_COLOR === 'true';
52
+ }
53
+ return false;
54
+ }
55
+ /**
56
+ * Checks if CSS styling is supported (browser-only feature)
57
+ */
58
+ export function supportsCSSColors() {
59
+ return isBrowser;
60
+ }
61
+ /**
62
+ * Checks if ANSI colors are supported (terminal environments)
63
+ */
64
+ export function supportsANSIColors() {
65
+ if (isNode) {
66
+ return process.stdout?.isTTY === true ||
67
+ process.env.FORCE_COLOR === '1' ||
68
+ process.env.FORCE_COLOR === 'true';
69
+ }
70
+ return false;
71
+ }
72
+ /**
73
+ * Gets environment-specific information
74
+ */
75
+ export function getEnvironmentInfo() {
76
+ const env = getRuntimeEnvironment();
77
+ return {
78
+ runtime: env,
79
+ supportsColors: supportsColors(),
80
+ supportsCSSColors: supportsCSSColors(),
81
+ supportsANSIColors: supportsANSIColors(),
82
+ isProduction: isNode ? process.env.NODE_ENV === 'production' : false,
83
+ version: isNode ? process.versions.node : (isBrowser ? navigator.userAgent : 'unknown')
84
+ };
85
+ }
@@ -0,0 +1,40 @@
1
+ /**
2
+ * @fileoverview Formatting utilities for Universal Logger
3
+ */
4
+ import type { LogLevel, StackInfo } from '../types/index.js';
5
+ /**
6
+ * Creates plain text output for any environment
7
+ * No colors, no styling - maximum compatibility
8
+ */
9
+ export declare function createPlainOutput(level: LogLevel, message: string, prefix?: string, stackInfo?: StackInfo | null): string;
10
+ /**
11
+ * Gets the appropriate log method for the level
12
+ * Uses different console methods for better semantics
13
+ */
14
+ export declare function getConsoleMethod(level: LogLevel): 'log' | 'info' | 'warn' | 'error';
15
+ /**
16
+ * Create a simple log entry object for handlers
17
+ */
18
+ export declare function createLogEntry(level: LogLevel, message: string, args: any[], prefix?: string, stackInfo?: StackInfo | null): {
19
+ timestamp: string;
20
+ level: string;
21
+ prefix: string | undefined;
22
+ message: string;
23
+ args: any[];
24
+ location: {
25
+ file: string;
26
+ line: number;
27
+ column: number;
28
+ function: string | undefined;
29
+ } | undefined;
30
+ raw: any[];
31
+ };
32
+ /**
33
+ * Format data for table display in plain text
34
+ */
35
+ export declare function formatTablePlain(data: any, columns?: string[]): string;
36
+ /**
37
+ * Safe object serialization for logging
38
+ */
39
+ export declare function safeSerialize(obj: any, maxDepth?: number, currentDepth?: number): any;
40
+ //# sourceMappingURL=formatting.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatting.d.ts","sourceRoot":"","sources":["../../src/utils/formatting.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAG7D;;;GAGG;AACH,wBAAgB,iBAAiB,CAC7B,KAAK,EAAE,QAAQ,EACf,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,MAAM,EACf,SAAS,CAAC,EAAE,SAAS,GAAG,IAAI,GAC7B,MAAM,CAiBR;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,QAAQ,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAcnF;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC1B,KAAK,EAAE,QAAQ,EACf,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,GAAG,EAAE,EACX,MAAM,CAAC,EAAE,MAAM,EACf,SAAS,CAAC,EAAE,SAAS,GAAG,IAAI;;;;;;;;;;;;;EAgB/B;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CA+BtE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,GAAE,MAAU,EAAE,YAAY,GAAE,MAAU,GAAG,GAAG,CAqB3F"}
@@ -0,0 +1,117 @@
1
+ /**
2
+ * @fileoverview Formatting utilities for Universal Logger
3
+ */
4
+ import { formatTimestamp } from './timestamps.js';
5
+ /**
6
+ * Creates plain text output for any environment
7
+ * No colors, no styling - maximum compatibility
8
+ */
9
+ export function createPlainOutput(level, message, prefix, stackInfo) {
10
+ const timestamp = formatTimestamp();
11
+ const timeStr = timestamp.slice(11, 23); // HH:MM:SS.mmm
12
+ let output = `[${timeStr}] [${level.toUpperCase()}]`;
13
+ if (prefix) {
14
+ output += ` [${prefix}]`;
15
+ }
16
+ output += ` ${message}`;
17
+ if (stackInfo) {
18
+ output += ` (${stackInfo.file}:${stackInfo.line}:${stackInfo.column})`;
19
+ }
20
+ return output;
21
+ }
22
+ /**
23
+ * Gets the appropriate log method for the level
24
+ * Uses different console methods for better semantics
25
+ */
26
+ export function getConsoleMethod(level) {
27
+ switch (level) {
28
+ case 'debug':
29
+ return 'log';
30
+ case 'info':
31
+ return 'info';
32
+ case 'warn':
33
+ return 'warn';
34
+ case 'error':
35
+ case 'critical':
36
+ return 'error';
37
+ default:
38
+ return 'log';
39
+ }
40
+ }
41
+ /**
42
+ * Create a simple log entry object for handlers
43
+ */
44
+ export function createLogEntry(level, message, args, prefix, stackInfo) {
45
+ return {
46
+ timestamp: formatTimestamp(),
47
+ level: level.toUpperCase(),
48
+ prefix,
49
+ message,
50
+ args: args.slice(1), // Exclude the first message argument
51
+ location: stackInfo ? {
52
+ file: stackInfo.file,
53
+ line: stackInfo.line,
54
+ column: stackInfo.column,
55
+ function: stackInfo.function
56
+ } : undefined,
57
+ raw: args
58
+ };
59
+ }
60
+ /**
61
+ * Format data for table display in plain text
62
+ */
63
+ export function formatTablePlain(data, columns) {
64
+ try {
65
+ if (Array.isArray(data)) {
66
+ if (data.length === 0)
67
+ return '[Empty Array]';
68
+ // Simple array formatting
69
+ if (typeof data[0] !== 'object') {
70
+ return data.map((item, i) => `${i}: ${item}`).join('\n');
71
+ }
72
+ // Object array formatting
73
+ const keys = columns || Object.keys(data[0] || {});
74
+ const header = keys.join('\t');
75
+ const rows = data.map(item => keys.map(key => String(item[key] || '')).join('\t'));
76
+ return [header, ...rows].join('\n');
77
+ }
78
+ if (typeof data === 'object' && data !== null) {
79
+ // Simple object formatting
80
+ return Object.entries(data)
81
+ .map(([key, value]) => `${key}: ${value}`)
82
+ .join('\n');
83
+ }
84
+ return String(data);
85
+ }
86
+ catch (error) {
87
+ return `[Error formatting table: ${error}]`;
88
+ }
89
+ }
90
+ /**
91
+ * Safe object serialization for logging
92
+ */
93
+ export function safeSerialize(obj, maxDepth = 3, currentDepth = 0) {
94
+ if (currentDepth >= maxDepth) {
95
+ return '[Max Depth Reached]';
96
+ }
97
+ if (obj === null)
98
+ return null;
99
+ if (obj === undefined)
100
+ return '[undefined]';
101
+ if (typeof obj === 'function')
102
+ return '[Function]';
103
+ if (obj instanceof Error)
104
+ return `[Error: ${obj.message}]`;
105
+ if (obj instanceof Date)
106
+ return obj.toISOString();
107
+ if (typeof obj !== 'object')
108
+ return obj;
109
+ if (Array.isArray(obj)) {
110
+ return obj.map(item => safeSerialize(item, maxDepth, currentDepth + 1));
111
+ }
112
+ const result = {};
113
+ for (const [key, value] of Object.entries(obj)) {
114
+ result[key] = safeSerialize(value, maxDepth, currentDepth + 1);
115
+ }
116
+ return result;
117
+ }
@@ -0,0 +1,7 @@
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, detectDevToolsTheme, getAdaptiveColor, setupThemeChangeListener, type LevelStyleConfig } from './output.js';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EACH,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EACpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACH,kBAAkB,EAClB,aAAa,EACb,UAAU,EACV,aAAa,EACb,mBAAmB,EACnB,gBAAgB,EAChB,wBAAwB,EACxB,KAAK,gBAAgB,EACxB,MAAM,aAAa,CAAC"}
@@ -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, detectDevToolsTheme, getAdaptiveColor, setupThemeChangeListener } from './output.js';
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @fileoverview OpenTUI detection and enhancement utilities for core logger
3
+ */
4
+ /**
5
+ * Check if OpenTUI packages are available
6
+ */
7
+ export declare function hasOpenTUI(): Promise<boolean>;
8
+ /**
9
+ * Check if OpenTUI enhancement package is available
10
+ */
11
+ export declare function hasOpenTUILogHandler(): Promise<boolean>;
12
+ /**
13
+ * Dynamically enhance logger with OpenTUI if available
14
+ */
15
+ export declare function tryEnhanceWithOpenTUI(logger: any): Promise<boolean>;
16
+ /**
17
+ * Get OpenTUI environment information
18
+ */
19
+ export declare function getOpenTUIInfo(): Promise<{
20
+ available: boolean;
21
+ coreAvailable: boolean;
22
+ handlerAvailable: boolean;
23
+ nodeVersion: string | null;
24
+ terminalSupport: boolean;
25
+ }>;
26
+ /**
27
+ * Auto-enhance logger with best available rendering
28
+ */
29
+ export declare function autoEnhanceLogger(logger: any): Promise<{
30
+ enhanced: boolean;
31
+ method: 'opentui' | 'ansi' | 'plain';
32
+ info?: any;
33
+ }>;
34
+ //# sourceMappingURL=opentui-detection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opentui-detection.d.ts","sourceRoot":"","sources":["../../src/utils/opentui-detection.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;GAEG;AACH,wBAAsB,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC,CAanD;AAED;;GAEG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,OAAO,CAAC,CAY7D;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,CAkCzE;AAED;;GAEG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC;IAC5C,SAAS,EAAE,OAAO,CAAC;IACnB,aAAa,EAAE,OAAO,CAAC;IACvB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,eAAe,EAAE,OAAO,CAAC;CAC5B,CAAC,CAaD;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC;IAC1D,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC;IACrC,IAAI,CAAC,EAAE,GAAG,CAAC;CACd,CAAC,CA0BD"}
@@ -0,0 +1,116 @@
1
+ /**
2
+ * @fileoverview OpenTUI detection and enhancement utilities for core logger
3
+ */
4
+ import { isNode } from './environment.js';
5
+ /**
6
+ * Check if OpenTUI packages are available
7
+ */
8
+ export async function hasOpenTUI() {
9
+ if (!isNode) {
10
+ return false; // OpenTUI is Node.js only
11
+ }
12
+ try {
13
+ // Try to dynamically import OpenTUI core
14
+ // @ts-expect-error - Optional dependency, may not be installed
15
+ await import('@opentui/core');
16
+ return true;
17
+ }
18
+ catch (error) {
19
+ return false;
20
+ }
21
+ }
22
+ /**
23
+ * Check if OpenTUI enhancement package is available
24
+ */
25
+ export async function hasOpenTUILogHandler() {
26
+ if (!isNode) {
27
+ return false;
28
+ }
29
+ try {
30
+ // @ts-expect-error - Optional dependency, may not be installed
31
+ await import('@mks2508/better-logger-nodejs-opentui');
32
+ return true;
33
+ }
34
+ catch (error) {
35
+ return false;
36
+ }
37
+ }
38
+ /**
39
+ * Dynamically enhance logger with OpenTUI if available
40
+ */
41
+ export async function tryEnhanceWithOpenTUI(logger) {
42
+ try {
43
+ // Check if both OpenTUI and our enhancement package are available
44
+ const [hasCore, hasEnhancer] = await Promise.all([
45
+ hasOpenTUI(),
46
+ hasOpenTUILogHandler()
47
+ ]);
48
+ if (!hasCore || !hasEnhancer) {
49
+ return false;
50
+ }
51
+ // Dynamically import and apply enhancement
52
+ // @ts-expect-error - Optional dependency, may not be installed
53
+ const { enhanceLoggerWithOpenTUI } = await import('@mks2508/better-logger-nodejs-opentui');
54
+ const enhanced = await enhanceLoggerWithOpenTUI(logger, {
55
+ renderer: {
56
+ animated: true,
57
+ theme: 'auto',
58
+ components: {
59
+ badges: true,
60
+ progressBars: false,
61
+ tables: false,
62
+ charts: false
63
+ }
64
+ }
65
+ });
66
+ return enhanced;
67
+ }
68
+ catch (error) {
69
+ console.warn('Failed to enhance logger with OpenTUI:', error);
70
+ return false;
71
+ }
72
+ }
73
+ /**
74
+ * Get OpenTUI environment information
75
+ */
76
+ export async function getOpenTUIInfo() {
77
+ const [coreAvailable, handlerAvailable] = await Promise.all([
78
+ hasOpenTUI(),
79
+ hasOpenTUILogHandler()
80
+ ]);
81
+ return {
82
+ available: coreAvailable && handlerAvailable,
83
+ coreAvailable,
84
+ handlerAvailable,
85
+ nodeVersion: isNode ? process.version : null,
86
+ terminalSupport: isNode ? process.stdout?.isTTY === true : false
87
+ };
88
+ }
89
+ /**
90
+ * Auto-enhance logger with best available rendering
91
+ */
92
+ export async function autoEnhanceLogger(logger) {
93
+ // Try OpenTUI first
94
+ const openTUIEnhanced = await tryEnhanceWithOpenTUI(logger);
95
+ if (openTUIEnhanced) {
96
+ return {
97
+ enhanced: true,
98
+ method: 'opentui',
99
+ info: await getOpenTUIInfo()
100
+ };
101
+ }
102
+ // Fallback to ANSI colors if in Node.js
103
+ if (isNode && process.stdout?.isTTY) {
104
+ return {
105
+ enhanced: false,
106
+ method: 'ansi',
107
+ info: { reason: 'OpenTUI not available, using ANSI colors' }
108
+ };
109
+ }
110
+ // Plain text fallback
111
+ return {
112
+ enhanced: false,
113
+ method: 'plain',
114
+ info: { reason: 'No enhanced rendering available' }
115
+ };
116
+ }
@@ -0,0 +1,44 @@
1
+ /**
2
+ * @fileoverview Styled output creation utilities for Advanced Logger
3
+ */
4
+ import type { LogLevel, StackInfo, DevToolsTheme, AdaptiveColors } 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
+ * Detects the current DevTools theme preference
18
+ */
19
+ export declare function detectDevToolsTheme(): DevToolsTheme;
20
+ /**
21
+ * Gets adaptive color based on current DevTools theme
22
+ */
23
+ export declare function getAdaptiveColor(colors: AdaptiveColors, theme?: DevToolsTheme): string;
24
+ /**
25
+ * Sets up theme change listener for dynamic updates
26
+ */
27
+ export declare function setupThemeChangeListener(callback: (theme: DevToolsTheme) => void): (() => void) | null;
28
+ /**
29
+ * Creates styled console output with multiple %c formatters
30
+ */
31
+ export declare function createStyledOutput(level: LogLevel, levelStyles: Record<LogLevel | 'success', LevelStyleConfig>, prefix: string | undefined, message: string, stackInfo: StackInfo | null, autoDetectTheme?: boolean): [string, ...string[]];
32
+ /**
33
+ * Create a unique ID for log entries
34
+ */
35
+ export declare function generateLogId(): string;
36
+ /**
37
+ * Escape HTML entities for safe HTML output
38
+ */
39
+ export declare function escapeHtml(text: string): string;
40
+ /**
41
+ * Convert objects to safe string representation for logging
42
+ */
43
+ export declare function safeStringify(obj: any, _maxDepth?: number): string;
44
+ //# 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,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAK5F;;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;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,aAAa,CAYnD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,cAAc,EAAE,KAAK,CAAC,EAAE,aAAa,GAAG,MAAM,CAGtF;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,CAyBtG;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,EAC3B,eAAe,GAAE,OAAc,GAChC,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,CAgEvB;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,150 @@
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
+ import { ADAPTIVE_COLORS } from '../constants.js';
7
+ /**
8
+ * Detects the current DevTools theme preference
9
+ */
10
+ export function detectDevToolsTheme() {
11
+ try {
12
+ if (typeof window === 'undefined' || !window.matchMedia) {
13
+ return 'light'; // Safe fallback for SSR or older browsers
14
+ }
15
+ const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
16
+ return mediaQuery.matches ? 'dark' : 'light';
17
+ }
18
+ catch (error) {
19
+ console.warn('Failed to detect DevTools theme:', error);
20
+ return 'light'; // Fallback to light theme
21
+ }
22
+ }
23
+ /**
24
+ * Gets adaptive color based on current DevTools theme
25
+ */
26
+ export function getAdaptiveColor(colors, theme) {
27
+ const currentTheme = theme ?? detectDevToolsTheme();
28
+ return colors[currentTheme];
29
+ }
30
+ /**
31
+ * Sets up theme change listener for dynamic updates
32
+ */
33
+ export function setupThemeChangeListener(callback) {
34
+ try {
35
+ if (typeof window === 'undefined' || !window.matchMedia) {
36
+ return null;
37
+ }
38
+ const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
39
+ const handler = (e) => {
40
+ callback(e.matches ? 'dark' : 'light');
41
+ };
42
+ // Use newer addEventListener if available, fallback to addListener
43
+ if (mediaQuery.addEventListener) {
44
+ mediaQuery.addEventListener('change', handler);
45
+ return () => mediaQuery.removeEventListener('change', handler);
46
+ }
47
+ else if (mediaQuery.addListener) {
48
+ mediaQuery.addListener(handler);
49
+ return () => mediaQuery.removeListener?.(handler);
50
+ }
51
+ return null;
52
+ }
53
+ catch (error) {
54
+ console.warn('Failed to set up theme change listener:', error);
55
+ return null;
56
+ }
57
+ }
58
+ /**
59
+ * Creates styled console output with multiple %c formatters
60
+ */
61
+ export function createStyledOutput(level, levelStyles, prefix, message, stackInfo, autoDetectTheme = true) {
62
+ const levelConfig = levelStyles[level];
63
+ const timestamp = formatTimestamp();
64
+ const currentTheme = autoDetectTheme ? detectDevToolsTheme() : 'light';
65
+ // Base styles with adaptive colors
66
+ const timestampStyle = new StyleBuilder()
67
+ .color(getAdaptiveColor(ADAPTIVE_COLORS.timestamp, currentTheme))
68
+ .size('11px')
69
+ .font('Monaco, Consolas, monospace')
70
+ .build();
71
+ const levelStyle = new StyleBuilder()
72
+ .bg(levelConfig.background)
73
+ .color(levelConfig.color)
74
+ .border(levelConfig.border)
75
+ .shadow(levelConfig.shadow)
76
+ .padding('2px 8px')
77
+ .rounded('4px')
78
+ .bold()
79
+ .font('Monaco, Consolas, monospace')
80
+ .size('12px')
81
+ .build();
82
+ const prefixStyle = new StyleBuilder()
83
+ .bg(getAdaptiveColor(ADAPTIVE_COLORS.prefixBackground, currentTheme))
84
+ .color(getAdaptiveColor(ADAPTIVE_COLORS.prefix, currentTheme))
85
+ .padding('2px 6px')
86
+ .rounded('3px')
87
+ .bold()
88
+ .font('Monaco, Consolas, monospace')
89
+ .size('11px')
90
+ .build();
91
+ const messageStyle = new StyleBuilder()
92
+ .color(getAdaptiveColor(ADAPTIVE_COLORS.messageText, currentTheme))
93
+ .font('system-ui, -apple-system, sans-serif')
94
+ .size('14px')
95
+ .build();
96
+ const locationStyle = new StyleBuilder()
97
+ .color(getAdaptiveColor(ADAPTIVE_COLORS.location, currentTheme))
98
+ .size('11px')
99
+ .font('Monaco, Consolas, monospace')
100
+ .build();
101
+ // Build format string and styles
102
+ let format = `%c${timestamp.slice(11, 23)} %c${levelConfig.emoji} ${levelConfig.label}`;
103
+ const styles = [timestampStyle, levelStyle];
104
+ if (prefix) {
105
+ format += ` %c${prefix}`;
106
+ styles.push(prefixStyle);
107
+ }
108
+ format += ` %c${message}`;
109
+ styles.push(messageStyle);
110
+ if (stackInfo) {
111
+ format += ` %c(${stackInfo.file}:${stackInfo.line}:${stackInfo.column})`;
112
+ styles.push(locationStyle);
113
+ }
114
+ return [format, ...styles];
115
+ }
116
+ /**
117
+ * Create a unique ID for log entries
118
+ */
119
+ export function generateLogId() {
120
+ return `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
121
+ }
122
+ /**
123
+ * Escape HTML entities for safe HTML output
124
+ */
125
+ export function escapeHtml(text) {
126
+ const div = document.createElement('div');
127
+ div.textContent = text;
128
+ return div.innerHTML;
129
+ }
130
+ /**
131
+ * Convert objects to safe string representation for logging
132
+ */
133
+ export function safeStringify(obj, _maxDepth = 3) {
134
+ try {
135
+ return JSON.stringify(obj, (_key, value) => {
136
+ if (typeof value === 'function')
137
+ return '[Function]';
138
+ if (value instanceof Error)
139
+ return `[Error: ${value.message}]`;
140
+ if (value instanceof Date)
141
+ return value.toISOString();
142
+ if (typeof value === 'undefined')
143
+ return '[undefined]';
144
+ return value;
145
+ }, 2);
146
+ }
147
+ catch (error) {
148
+ return String(obj);
149
+ }
150
+ }
@@ -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