@mks2508/better-logger 5.0.1 → 5.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (310) hide show
  1. package/dist/Logger.d.ts +976 -0
  2. package/dist/Logger.d.ts.map +1 -0
  3. package/dist/ScopedLogger.d.ts +74 -0
  4. package/dist/ScopedLogger.d.ts.map +1 -0
  5. package/dist/chunks/Logger-CKqzXDh3.js +2 -0
  6. package/dist/chunks/Logger-CKqzXDh3.js.map +1 -0
  7. package/dist/chunks/Logger-D_vuKP4l.js +4511 -0
  8. package/dist/chunks/Logger-D_vuKP4l.js.map +1 -0
  9. package/dist/chunks/RemoteLogHandler-CjWpWZGl.js +33 -0
  10. package/dist/chunks/RemoteLogHandler-CjWpWZGl.js.map +1 -0
  11. package/dist/chunks/RemoteLogHandler-ymkQ97xl.js +2 -0
  12. package/dist/chunks/RemoteLogHandler-ymkQ97xl.js.map +1 -0
  13. package/dist/chunks/cli-module-B-njrTWb.js +2 -0
  14. package/dist/chunks/cli-module-B-njrTWb.js.map +1 -0
  15. package/dist/chunks/cli-module-Cx7qotPY.js +390 -0
  16. package/dist/chunks/cli-module-Cx7qotPY.js.map +1 -0
  17. package/dist/chunks/color-converter-CCSQRztd.js +2 -0
  18. package/dist/chunks/color-converter-CCSQRztd.js.map +1 -0
  19. package/dist/chunks/color-converter-_Xdmsy7E.js +462 -0
  20. package/dist/chunks/color-converter-_Xdmsy7E.js.map +1 -0
  21. package/dist/chunks/environment-C1xxvc8l.js +1127 -0
  22. package/dist/chunks/environment-C1xxvc8l.js.map +1 -0
  23. package/dist/chunks/environment-Cprkw3g9.js +4 -0
  24. package/dist/chunks/environment-Cprkw3g9.js.map +1 -0
  25. package/dist/chunks/formatting-DMJxYq9o.js +380 -0
  26. package/dist/chunks/formatting-DMJxYq9o.js.map +1 -0
  27. package/dist/chunks/formatting-DpKxCsXq.js +2 -0
  28. package/dist/chunks/formatting-DpKxCsXq.js.map +1 -0
  29. package/dist/cli/CommandProcessor.d.ts +100 -0
  30. package/dist/cli/CommandProcessor.d.ts.map +1 -0
  31. package/dist/cli/commands/ConfigCommand.d.ts +14 -0
  32. package/dist/cli/commands/ConfigCommand.d.ts.map +1 -0
  33. package/dist/cli/commands/ExportCommand.d.ts +48 -0
  34. package/dist/cli/commands/ExportCommand.d.ts.map +1 -0
  35. package/dist/cli/commands/HistoryCommand.d.ts +47 -0
  36. package/dist/cli/commands/HistoryCommand.d.ts.map +1 -0
  37. package/dist/cli/commands/StatusCommand.d.ts +30 -0
  38. package/dist/cli/commands/StatusCommand.d.ts.map +1 -0
  39. package/dist/cli/commands/ThemeCommand.d.ts +30 -0
  40. package/dist/cli/commands/ThemeCommand.d.ts.map +1 -0
  41. package/dist/cli/help.d.ts +12 -0
  42. package/dist/cli/help.d.ts.map +1 -0
  43. package/dist/cli/index.d.ts +15 -0
  44. package/dist/cli/index.d.ts.map +1 -0
  45. package/{src/cli-module.ts → dist/cli-module.d.ts} +2 -8
  46. package/dist/cli-module.d.ts.map +1 -0
  47. package/dist/cli-primitives/box.d.ts +11 -0
  48. package/dist/cli-primitives/box.d.ts.map +1 -0
  49. package/dist/cli-primitives/cli-table.d.ts +11 -0
  50. package/dist/cli-primitives/cli-table.d.ts.map +1 -0
  51. package/dist/cli-primitives/divider.d.ts +11 -0
  52. package/dist/cli-primitives/divider.d.ts.map +1 -0
  53. package/dist/cli-primitives/header.d.ts +12 -0
  54. package/dist/cli-primitives/header.d.ts.map +1 -0
  55. package/{src/cli-primitives/index.ts → dist/cli-primitives/index.d.ts} +1 -1
  56. package/dist/cli-primitives/index.d.ts.map +1 -0
  57. package/dist/cli-primitives/server-fallback.d.ts +25 -0
  58. package/dist/cli-primitives/server-fallback.d.ts.map +1 -0
  59. package/dist/cli-primitives/spinner.d.ts +47 -0
  60. package/dist/cli-primitives/spinner.d.ts.map +1 -0
  61. package/dist/cli-primitives/step.d.ts +11 -0
  62. package/dist/cli-primitives/step.d.ts.map +1 -0
  63. package/dist/cli.cjs +2 -0
  64. package/dist/cli.cjs.map +1 -0
  65. package/dist/cli.js +12 -0
  66. package/dist/cli.js.map +1 -0
  67. package/dist/constants.d.ts +235 -0
  68. package/dist/constants.d.ts.map +1 -0
  69. package/dist/core.cjs +2 -0
  70. package/dist/core.cjs.map +1 -0
  71. package/dist/core.d.ts +127 -0
  72. package/dist/core.d.ts.map +1 -0
  73. package/dist/core.js +291 -0
  74. package/dist/core.js.map +1 -0
  75. package/dist/example.d.ts +18 -0
  76. package/dist/example.d.ts.map +1 -0
  77. package/dist/exports-module.d.ts +196 -0
  78. package/dist/exports-module.d.ts.map +1 -0
  79. package/dist/exports.cjs +2 -0
  80. package/dist/exports.cjs.map +1 -0
  81. package/dist/exports.js +238 -0
  82. package/dist/exports.js.map +1 -0
  83. package/dist/handlers/AnalyticsLogHandler.d.ts +8 -0
  84. package/dist/handlers/AnalyticsLogHandler.d.ts.map +1 -0
  85. package/dist/handlers/ExportLogHandler.d.ts +100 -0
  86. package/dist/handlers/ExportLogHandler.d.ts.map +1 -0
  87. package/dist/handlers/FileLogHandler.d.ts +33 -0
  88. package/dist/handlers/FileLogHandler.d.ts.map +1 -0
  89. package/dist/handlers/RemoteLogHandler.d.ts +11 -0
  90. package/dist/handlers/RemoteLogHandler.d.ts.map +1 -0
  91. package/{src/handlers/index.ts → dist/handlers/index.d.ts} +2 -2
  92. package/dist/handlers/index.d.ts.map +1 -0
  93. package/dist/hooks/HookManager.d.ts +21 -0
  94. package/dist/hooks/HookManager.d.ts.map +1 -0
  95. package/{src/hooks/index.ts → dist/hooks/index.d.ts} +1 -0
  96. package/dist/hooks/index.d.ts.map +1 -0
  97. package/dist/index.cjs +2 -0
  98. package/dist/index.cjs.map +1 -0
  99. package/dist/index.d.ts +161 -0
  100. package/dist/index.d.ts.map +1 -0
  101. package/dist/index.js +627 -0
  102. package/dist/index.js.map +1 -0
  103. package/dist/main.d.ts +2 -0
  104. package/dist/main.d.ts.map +1 -0
  105. package/dist/serializers/SerializerRegistry.d.ts +16 -0
  106. package/dist/serializers/SerializerRegistry.d.ts.map +1 -0
  107. package/{src/serializers/index.ts → dist/serializers/index.d.ts} +1 -0
  108. package/dist/serializers/index.d.ts.map +1 -0
  109. package/dist/styling/LogStyleBuilder.d.ts +146 -0
  110. package/dist/styling/LogStyleBuilder.d.ts.map +1 -0
  111. package/dist/styling/SemanticStyles.d.ts +178 -0
  112. package/dist/styling/SemanticStyles.d.ts.map +1 -0
  113. package/dist/styling/SmartPresets.d.ts +22 -0
  114. package/dist/styling/SmartPresets.d.ts.map +1 -0
  115. package/dist/styling/StyleBuilder.d.ts +140 -0
  116. package/dist/styling/StyleBuilder.d.ts.map +1 -0
  117. package/dist/styling/StyleCache.d.ts +42 -0
  118. package/dist/styling/StyleCache.d.ts.map +1 -0
  119. package/dist/styling/banners.d.ts +42 -0
  120. package/dist/styling/banners.d.ts.map +1 -0
  121. package/dist/styling/index.d.ts +10 -0
  122. package/dist/styling/index.d.ts.map +1 -0
  123. package/dist/styling/themes.d.ts +7 -0
  124. package/dist/styling/themes.d.ts.map +1 -0
  125. package/dist/styling-module.d.ts +178 -0
  126. package/dist/styling-module.d.ts.map +1 -0
  127. package/dist/styling.cjs +2 -0
  128. package/dist/styling.cjs.map +1 -0
  129. package/dist/styling.js +146 -0
  130. package/dist/styling.js.map +1 -0
  131. package/dist/terminal/color-converter.d.ts +73 -0
  132. package/dist/terminal/color-converter.d.ts.map +1 -0
  133. package/dist/terminal/formatter.d.ts +20 -0
  134. package/dist/terminal/formatter.d.ts.map +1 -0
  135. package/dist/terminal/terminal-renderer.d.ts +77 -0
  136. package/dist/terminal/terminal-renderer.d.ts.map +1 -0
  137. package/dist/transports/ConsoleTransport.d.ts +9 -0
  138. package/dist/transports/ConsoleTransport.d.ts.map +1 -0
  139. package/dist/transports/FileTransport.d.ts +15 -0
  140. package/dist/transports/FileTransport.d.ts.map +1 -0
  141. package/dist/transports/HttpTransport.d.ts +16 -0
  142. package/dist/transports/HttpTransport.d.ts.map +1 -0
  143. package/dist/transports/TransportManager.d.ts +14 -0
  144. package/dist/transports/TransportManager.d.ts.map +1 -0
  145. package/{src/transports/index.ts → dist/transports/index.d.ts} +1 -0
  146. package/dist/transports/index.d.ts.map +1 -0
  147. package/{src/types/core.ts → dist/types/core.d.ts} +25 -62
  148. package/dist/types/core.d.ts.map +1 -0
  149. package/{src/types/handlers.ts → dist/types/handlers.d.ts} +5 -15
  150. package/dist/types/handlers.d.ts.map +1 -0
  151. package/{src/types/hooks.ts → dist/types/hooks.d.ts} +3 -12
  152. package/dist/types/hooks.d.ts.map +1 -0
  153. package/dist/types/index.d.ts +11 -0
  154. package/dist/types/index.d.ts.map +1 -0
  155. package/{src/types/serializers.ts → dist/types/serializers.d.ts} +1 -6
  156. package/dist/types/serializers.d.ts.map +1 -0
  157. package/{src/types/transports.ts → dist/types/transports.d.ts} +2 -7
  158. package/dist/types/transports.d.ts.map +1 -0
  159. package/dist/utils/adapter.d.ts +48 -0
  160. package/dist/utils/adapter.d.ts.map +1 -0
  161. package/dist/utils/ansi-colors.d.ts +156 -0
  162. package/dist/utils/ansi-colors.d.ts.map +1 -0
  163. package/dist/utils/environment-detector.d.ts +45 -0
  164. package/dist/utils/environment-detector.d.ts.map +1 -0
  165. package/dist/utils/environment.d.ts +47 -0
  166. package/dist/utils/environment.d.ts.map +1 -0
  167. package/dist/utils/formatting.d.ts +58 -0
  168. package/dist/utils/formatting.d.ts.map +1 -0
  169. package/dist/utils/index.d.ts +8 -0
  170. package/dist/utils/index.d.ts.map +1 -0
  171. package/dist/utils/opentui-detection.d.ts +34 -0
  172. package/dist/utils/opentui-detection.d.ts.map +1 -0
  173. package/dist/utils/output.d.ts +46 -0
  174. package/dist/utils/output.d.ts.map +1 -0
  175. package/dist/utils/stackTrace.d.ts +6 -0
  176. package/dist/utils/stackTrace.d.ts.map +1 -0
  177. package/dist/utils/timestamps.d.ts +20 -0
  178. package/dist/utils/timestamps.d.ts.map +1 -0
  179. package/{src/writers/BufferWriter.ts → dist/writers/BufferWriter.d.ts} +16 -77
  180. package/dist/writers/BufferWriter.d.ts.map +1 -0
  181. package/{src/writers/index.ts → dist/writers/index.d.ts} +1 -1
  182. package/dist/writers/index.d.ts.map +1 -0
  183. package/package.json +5 -1
  184. package/.claude/settings.local.json +0 -48
  185. package/.github/workflows/ci-quality.yml +0 -357
  186. package/.github/workflows/docs-demo.yml +0 -119
  187. package/.github/workflows/releases-core.yml +0 -512
  188. package/.github/workflows/releases-full.yml +0 -582
  189. package/.github/workflows-backup/ci.yml +0 -221
  190. package/.github/workflows-backup/nightly.yml +0 -196
  191. package/.github/workflows-backup/release-optimized.yml +0 -373
  192. package/.github/workflows-backup/release.yml +0 -269
  193. package/.release-notes-0.2.0.md +0 -129
  194. package/.yamllint +0 -28
  195. package/CHANGELOG.json +0 -1120
  196. package/CHANGELOG.md +0 -209
  197. package/CLAUDE.md +0 -217
  198. package/demo.html +0 -847
  199. package/docs/API.md +0 -918
  200. package/docs/CORE.md +0 -264
  201. package/docs/DEVELOPMENT.md +0 -731
  202. package/docs/EXPORTS.md +0 -467
  203. package/docs/PACKAGES.md +0 -244
  204. package/docs/STYLING.md +0 -405
  205. package/docs/_config.yml +0 -36
  206. package/docs/index.md +0 -179
  207. package/examples/README.md +0 -208
  208. package/examples/basic-logging.js +0 -75
  209. package/examples/data-export.js +0 -234
  210. package/examples/package.json +0 -16
  211. package/examples/performance-timing.js +0 -170
  212. package/examples/simplified-api.js +0 -124
  213. package/examples/styling-themes.js +0 -207
  214. package/index.html +0 -358
  215. package/packages/core/package.json +0 -57
  216. package/packages/exports/package.json +0 -41
  217. package/packages/nodejs-opentui/README.md +0 -232
  218. package/packages/nodejs-opentui/package.json +0 -72
  219. package/packages/nodejs-opentui/src/LogRenderer.ts +0 -171
  220. package/packages/nodejs-opentui/src/OpenTUILogHandler.ts +0 -178
  221. package/packages/nodejs-opentui/src/components/LogBadge.tsx +0 -131
  222. package/packages/nodejs-opentui/src/index.ts +0 -133
  223. package/packages/nodejs-opentui/src/types.ts +0 -158
  224. package/packages/nodejs-opentui/tsconfig.json +0 -20
  225. package/packages/styling/package.json +0 -41
  226. package/playground/demo-all.ts +0 -95
  227. package/playground/demo-box.ts +0 -85
  228. package/playground/demo-levels.ts +0 -56
  229. package/playground/demo-real-world.ts +0 -98
  230. package/playground/demo-spinner.ts +0 -77
  231. package/playground/demo-steps.ts +0 -72
  232. package/playground/demo-table.ts +0 -83
  233. package/project-utils/README.md +0 -172
  234. package/project-utils/auto-release-gemini.ts +0 -1193
  235. package/project-utils/auto-release-ui.ts +0 -1329
  236. package/project-utils/commit-generator.ts +0 -1385
  237. package/project-utils/commit-ui.ts +0 -264
  238. package/project-utils/git-utils.ts +0 -199
  239. package/project-utils/github-release-manager.ts +0 -466
  240. package/project-utils/project-config.ts +0 -260
  241. package/project-utils/prompt-templates.js +0 -345
  242. package/project-utils/prompt-templates.ts +0 -422
  243. package/project-utils/version-manager.ts +0 -1078
  244. package/src/Logger.ts +0 -1858
  245. package/src/ScopedLogger.ts +0 -256
  246. package/src/cli/CommandProcessor.ts +0 -248
  247. package/src/cli/commands/ConfigCommand.ts +0 -93
  248. package/src/cli/commands/ExportCommand.ts +0 -276
  249. package/src/cli/commands/HistoryCommand.ts +0 -117
  250. package/src/cli/commands/StatusCommand.ts +0 -112
  251. package/src/cli/commands/ThemeCommand.ts +0 -88
  252. package/src/cli/help.ts +0 -127
  253. package/src/cli/index.ts +0 -71
  254. package/src/cli-primitives/box.ts +0 -86
  255. package/src/cli-primitives/cli-table.ts +0 -62
  256. package/src/cli-primitives/divider.ts +0 -17
  257. package/src/cli-primitives/header.ts +0 -18
  258. package/src/cli-primitives/server-fallback.ts +0 -54
  259. package/src/cli-primitives/spinner.ts +0 -133
  260. package/src/cli-primitives/step.ts +0 -22
  261. package/src/constants.ts +0 -313
  262. package/src/core.ts +0 -397
  263. package/src/example.ts +0 -210
  264. package/src/exports-module.ts +0 -311
  265. package/src/handlers/AnalyticsLogHandler.ts +0 -22
  266. package/src/handlers/ExportLogHandler.ts +0 -610
  267. package/src/handlers/FileLogHandler.ts +0 -169
  268. package/src/handlers/RemoteLogHandler.ts +0 -42
  269. package/src/hooks/HookManager.ts +0 -177
  270. package/src/index.ts +0 -395
  271. package/src/main.ts +0 -196
  272. package/src/serializers/SerializerRegistry.ts +0 -173
  273. package/src/style.css +0 -96
  274. package/src/styling/LogStyleBuilder.ts +0 -355
  275. package/src/styling/SemanticStyles.ts +0 -380
  276. package/src/styling/SmartPresets.ts +0 -288
  277. package/src/styling/StyleBuilder.ts +0 -319
  278. package/src/styling/StyleCache.ts +0 -131
  279. package/src/styling/banners.ts +0 -168
  280. package/src/styling/index.ts +0 -27
  281. package/src/styling/themes.ts +0 -235
  282. package/src/styling-module.ts +0 -244
  283. package/src/terminal/color-converter.ts +0 -315
  284. package/src/terminal/formatter.ts +0 -242
  285. package/src/terminal/terminal-renderer.ts +0 -342
  286. package/src/transports/ConsoleTransport.ts +0 -28
  287. package/src/transports/FileTransport.ts +0 -53
  288. package/src/transports/HttpTransport.ts +0 -56
  289. package/src/transports/TransportManager.ts +0 -130
  290. package/src/types/index.ts +0 -83
  291. package/src/typescript.svg +0 -1
  292. package/src/utils/adapter.ts +0 -291
  293. package/src/utils/ansi-colors.ts +0 -333
  294. package/src/utils/environment-detector.ts +0 -170
  295. package/src/utils/environment.ts +0 -94
  296. package/src/utils/formatting.ts +0 -332
  297. package/src/utils/index.ts +0 -33
  298. package/src/utils/opentui-detection.ts +0 -138
  299. package/src/utils/output.ts +0 -227
  300. package/src/utils/stackTrace.ts +0 -144
  301. package/src/utils/timestamps.ts +0 -80
  302. package/src/vite-env.d.ts +0 -1
  303. package/test-core-browser.html +0 -237
  304. package/test-core-node.js +0 -63
  305. package/tests/test-conflict-resolution.ts +0 -391
  306. package/tests/validate-workflows.sh +0 -131
  307. package/tests/yaml-autofix.sh +0 -146
  308. package/tsconfig.json +0 -50
  309. package/vite.config.ts +0 -256
  310. /package/{public → dist}/vite.svg +0 -0
@@ -1,291 +0,0 @@
1
- /**
2
- * CSS to ANSI Adapter - Converts CSS-based styles to ANSI terminal styles
3
- * Bridges the gap between browser styling and terminal rendering
4
- */
5
-
6
- import type { LogStyles } from '../types/index.js';
7
- import type { ANSIStyle } from '../terminal/terminal-renderer.js';
8
- import { TerminalRenderer } from '../terminal/terminal-renderer.js';
9
- import type { LogLevel } from '../types/index.js';
10
- import { getColorCapability } from './environment-detector.js';
11
-
12
- export class CSS2ANSIAdapter {
13
- private renderer: TerminalRenderer;
14
-
15
- constructor() {
16
- const colorCapability = getColorCapability();
17
- this.renderer = new TerminalRenderer(colorCapability);
18
- }
19
-
20
- /**
21
- * Convert LogStyles to ANSIStyle for terminal rendering
22
- */
23
- adaptStyles(
24
- level: LogLevel,
25
- message: string,
26
- timestamp?: string,
27
- prefix?: string,
28
- location?: string,
29
- styles?: LogStyles,
30
- presetName?: string
31
- ): ANSIStyle {
32
- // Special handling for specific presets that need unique terminal representations
33
- if (presetName) {
34
- switch (presetName) {
35
- case 'cyberpunk':
36
- return this.renderer.renderCyberpunk(level, message, timestamp, prefix, location);
37
- case 'minimal':
38
- return this.renderer.renderMinimal(level, message, timestamp, prefix);
39
- case 'production':
40
- return this.adaptProductionStyles(level, message, timestamp, prefix, location, styles);
41
- case 'debug':
42
- return this.adaptDebugStyles(level, message, timestamp, prefix, location, styles);
43
- case 'glassmorphism':
44
- return this.adaptGlassmorphismStyles(level, message, timestamp, prefix, location, styles);
45
- }
46
- }
47
-
48
- // Default adaptation using the renderer
49
- return this.renderer.renderTerminal(level, message, timestamp, prefix, location, styles);
50
- }
51
-
52
- /**
53
- * Adapt production preset for terminal
54
- */
55
- private adaptProductionStyles(
56
- level: LogLevel,
57
- message: string,
58
- timestamp?: string,
59
- prefix?: string,
60
- location?: string,
61
- styles?: LogStyles
62
- ): ANSIStyle {
63
- const reset = '\x1b[0m';
64
- const levelChalk = this.renderer.getChalkForLevel(level);
65
-
66
- const parts: string[] = [];
67
-
68
- // Production: clean, essential info only
69
- if (timestamp && styles?.timestamp?.show) {
70
- parts.push(levelChalk.dim(timestamp));
71
- }
72
-
73
- if (styles?.level?.show) {
74
- parts.push(levelChalk.color(`[${this.renderer['getLevelText'](level)}]`));
75
- }
76
-
77
- // Skip prefix in production (as per preset config)
78
- if (prefix && styles?.prefix?.show) {
79
- parts.push(levelChalk.dim(`[${prefix}]`));
80
- }
81
-
82
- if (message && styles?.message?.show) {
83
- parts.push(levelChalk.reset(message));
84
- }
85
-
86
- // Skip location in production (as per preset config)
87
- if (location && styles?.location?.show) {
88
- parts.push(levelChalk.dim(`(${location})`));
89
- }
90
-
91
- return {
92
- text: parts.join(' ') + reset,
93
- reset
94
- };
95
- }
96
-
97
- /**
98
- * Adapt debug preset for terminal
99
- */
100
- private adaptDebugStyles(
101
- level: LogLevel,
102
- message: string,
103
- timestamp?: string,
104
- prefix?: string,
105
- location?: string,
106
- styles?: LogStyles
107
- ): ANSIStyle {
108
- const reset = '\x1b[0m';
109
- const levelChalk = this.renderer.getChalkForLevel(level);
110
-
111
- const parts: string[] = [];
112
-
113
- // Debug: monospace fonts, detailed info, compact layout
114
- if (timestamp && styles?.timestamp?.show) {
115
- parts.push(levelChalk.dim(timestamp));
116
- }
117
-
118
- if (styles?.level?.show) {
119
- if (styles?.level?.style === 'compact') {
120
- parts.push(levelChalk.color(`[${this.renderer['getLevelText'](level)}]`));
121
- } else {
122
- parts.push(levelChalk.bold(`[${this.renderer['getLevelText'](level)}]`));
123
- }
124
- }
125
-
126
- if (prefix && styles?.prefix?.show) {
127
- if (styles?.prefix?.style === 'compact') {
128
- parts.push(levelChalk.cyan.dim(`[${prefix}]`));
129
- } else {
130
- parts.push(levelChalk.cyan.bold(`[${prefix}]`));
131
- }
132
- }
133
-
134
- if (message && styles?.message?.show) {
135
- parts.push(levelChalk.reset(message));
136
- }
137
-
138
- // Debug usually shows location
139
- if (location && styles?.location?.show) {
140
- if (styles?.location?.style === 'clickable') {
141
- parts.push(levelChalk.dim(`${location} (clickable)`));
142
- } else {
143
- parts.push(levelChalk.dim(`(${location})`));
144
- }
145
- }
146
-
147
- return {
148
- text: parts.join(' ') + reset,
149
- reset
150
- };
151
- }
152
-
153
- /**
154
- * Adapt glassmorphism preset for terminal
155
- */
156
- private adaptGlassmorphismStyles(
157
- level: LogLevel,
158
- message: string,
159
- timestamp?: string,
160
- prefix?: string,
161
- location?: string,
162
- styles?: LogStyles
163
- ): ANSIStyle {
164
- const reset = '\x1b[0m';
165
- const levelChalk = this.renderer.getChalkForLevel(level);
166
-
167
- const parts: string[] = [];
168
-
169
- // Glassmorphism: subtle, transparent effects
170
- if (timestamp && styles?.timestamp?.show) {
171
- parts.push(levelChalk.dim(timestamp));
172
- }
173
-
174
- if (styles?.level?.show) {
175
- // Subtle level styling with dim background effect
176
- parts.push(levelChalk.bgGray(` ${this.renderer['getLevelText'](level)} `));
177
- }
178
-
179
- if (prefix && styles?.prefix?.show) {
180
- parts.push(levelChalk.bgBlue(`[${prefix}]`));
181
- }
182
-
183
- if (message && styles?.message?.show) {
184
- parts.push(levelChalk.reset(message));
185
- }
186
-
187
- if (location && styles?.location?.show) {
188
- parts.push(levelChalk.dim(`(${location})`));
189
- }
190
-
191
- return {
192
- text: parts.join(' ') + reset,
193
- reset
194
- };
195
- }
196
-
197
- /**
198
- * Convert CSS color values to ANSI-friendly colors
199
- */
200
- adaptColor(cssColor: string): string {
201
- // Handle hex colors
202
- if (cssColor.startsWith('#')) {
203
- return cssColor; // TerminalRenderer will handle this
204
- }
205
-
206
- // Handle RGB colors
207
- if (cssColor.startsWith('rgb(')) {
208
- return cssColor; // TerminalRenderer will handle this
209
- }
210
-
211
- // Handle CSS gradients - extract primary color
212
- if (cssColor.includes('gradient')) {
213
- return this.extractColorFromGradient(cssColor);
214
- }
215
-
216
- // Handle CSS color names
217
- return this.cssNameToANSI(cssColor);
218
- }
219
-
220
- /**
221
- * Extract primary color from CSS gradient
222
- */
223
- private extractColorFromGradient(gradient: string): string {
224
- // Extract first color from linear-gradient
225
- const match = gradient.match(/#[0-9a-fA-F]{6}|rgb\([^)]+\)/);
226
- return match ? match[0] : '#ffffff';
227
- }
228
-
229
- /**
230
- * Convert CSS color names to ANSI-compatible names
231
- */
232
- private cssNameToANSI(cssColor: string): string {
233
- const colorMap: Record<string, string> = {
234
- 'black': 'black',
235
- 'white': 'white',
236
- 'red': 'red',
237
- 'green': 'green',
238
- 'blue': 'blue',
239
- 'yellow': 'yellow',
240
- 'cyan': 'cyan',
241
- 'magenta': 'magenta',
242
- 'gray': 'gray',
243
- 'grey': 'gray',
244
- 'orange': 'yellow',
245
- 'purple': 'magenta',
246
- 'pink': 'red',
247
- 'brown': 'yellow',
248
- 'lightblue': 'cyan',
249
- 'lightgreen': 'green',
250
- 'lightgray': 'gray',
251
- 'lightgrey': 'gray'
252
- };
253
-
254
- return colorMap[cssColor.toLowerCase()] || 'white';
255
- }
256
-
257
- /**
258
- * Check if a style should be rendered in terminal
259
- */
260
- shouldRenderStyle(styleType: string, styles?: LogStyles): boolean {
261
- if (!styles) return true;
262
-
263
- const styleConfig = (styles as any)[styleType];
264
- return styleConfig?.show !== false;
265
- }
266
-
267
- /**
268
- * Get renderer instance for advanced usage
269
- */
270
- getRenderer(): TerminalRenderer {
271
- return this.renderer;
272
- }
273
- }
274
-
275
- // Singleton instance for consistent styling
276
- export const css2ansiAdapter = new CSS2ANSIAdapter();
277
-
278
- /**
279
- * Convenience function for quick style adaptation
280
- */
281
- export function adaptToTerminal(
282
- level: LogLevel,
283
- message: string,
284
- timestamp?: string,
285
- prefix?: string,
286
- location?: string,
287
- styles?: LogStyles,
288
- presetName?: string
289
- ): ANSIStyle {
290
- return css2ansiAdapter.adaptStyles(level, message, timestamp, prefix, location, styles, presetName);
291
- }
@@ -1,333 +0,0 @@
1
- /**
2
- * @fileoverview ANSI color utilities for terminal environments
3
- * @since 1.0.0
4
- */
5
-
6
- import type { LogLevel } from '../types/index.js';
7
- import { supportsANSIColors } from './environment.js';
8
-
9
- /**
10
- * ANSI color codes for terminal styling
11
- */
12
- export const ANSI_CODES = {
13
- // Colors
14
- black: 30,
15
- red: 31,
16
- green: 32,
17
- yellow: 33,
18
- blue: 34,
19
- magenta: 35,
20
- cyan: 36,
21
- white: 37,
22
-
23
- // Bright colors
24
- brightBlack: 90,
25
- brightRed: 91,
26
- brightGreen: 92,
27
- brightYellow: 93,
28
- brightBlue: 94,
29
- brightMagenta: 95,
30
- brightCyan: 96,
31
- brightWhite: 97,
32
-
33
- // Background colors
34
- bgBlack: 40,
35
- bgRed: 41,
36
- bgGreen: 42,
37
- bgYellow: 43,
38
- bgBlue: 44,
39
- bgMagenta: 45,
40
- bgCyan: 46,
41
- bgWhite: 47,
42
-
43
- // Background bright colors
44
- bgBrightBlack: 100,
45
- bgBrightRed: 101,
46
- bgBrightGreen: 102,
47
- bgBrightYellow: 103,
48
- bgBrightBlue: 104,
49
- bgBrightMagenta: 105,
50
- bgBrightCyan: 106,
51
- bgBrightWhite: 107,
52
-
53
- // Styles
54
- reset: 0,
55
- bold: 1,
56
- dim: 2,
57
- italic: 3,
58
- underline: 4,
59
- blink: 5,
60
- inverse: 7,
61
- hidden: 8,
62
- strikethrough: 9,
63
-
64
- // Reset specific
65
- resetBold: 22,
66
- resetDim: 22,
67
- resetItalic: 23,
68
- resetUnderline: 24,
69
- resetBlink: 25,
70
- resetInverse: 27,
71
- resetHidden: 28,
72
- resetStrikethrough: 29
73
- } as const;
74
-
75
- /**
76
- * ANSI color presets for different log levels
77
- */
78
- export const ANSI_LEVEL_STYLES: Record<LogLevel | 'success', {
79
- color: number;
80
- background?: number;
81
- styles: number[];
82
- emoji: string;
83
- }> = {
84
- debug: {
85
- color: ANSI_CODES.brightBlack,
86
- styles: [ANSI_CODES.dim],
87
- emoji: '🔍'
88
- },
89
- info: {
90
- color: ANSI_CODES.blue,
91
- styles: [ANSI_CODES.bold],
92
- emoji: 'ℹ️'
93
- },
94
- warn: {
95
- color: ANSI_CODES.yellow,
96
- background: ANSI_CODES.bgYellow,
97
- styles: [ANSI_CODES.bold, ANSI_CODES.black],
98
- emoji: '⚠️'
99
- },
100
- error: {
101
- color: ANSI_CODES.red,
102
- background: ANSI_CODES.bgRed,
103
- styles: [ANSI_CODES.bold],
104
- emoji: '❌'
105
- },
106
- critical: {
107
- color: ANSI_CODES.white,
108
- background: ANSI_CODES.bgRed,
109
- styles: [ANSI_CODES.bold, ANSI_CODES.blink],
110
- emoji: '🚨'
111
- },
112
- success: {
113
- color: ANSI_CODES.green,
114
- background: ANSI_CODES.bgGreen,
115
- styles: [ANSI_CODES.bold],
116
- emoji: '✅'
117
- }
118
- };
119
-
120
- /**
121
- * Creates an ANSI escape sequence
122
- */
123
- function ansi(code: number | number[]): string {
124
- const codes = Array.isArray(code) ? code : [code];
125
- return `\x1b[${codes.join(';')}m`;
126
- }
127
-
128
- /**
129
- * Applies ANSI styling to text
130
- */
131
- export function ansiStyle(text: string, codes: number[]): string {
132
- if (!supportsANSIColors()) return text;
133
- return `${ansi(codes)}${text}${ansi(ANSI_CODES.reset)}`;
134
- }
135
-
136
- /**
137
- * Applies color to text
138
- */
139
- export function ansiColor(text: string, color: number): string {
140
- return ansiStyle(text, [color]);
141
- }
142
-
143
- /**
144
- * Applies background color to text
145
- */
146
- export function ansiBackground(text: string, bg: number, color?: number): string {
147
- if (color) {
148
- return ansiStyle(text, [color, bg]);
149
- }
150
- return ansiStyle(text, [bg]);
151
- }
152
-
153
- /**
154
- * Makes text bold
155
- */
156
- export function ansiBold(text: string): string {
157
- return ansiStyle(text, [ANSI_CODES.bold]);
158
- }
159
-
160
- /**
161
- * Makes text dim
162
- */
163
- export function ansiDim(text: string): string {
164
- return ansiStyle(text, [ANSI_CODES.dim]);
165
- }
166
-
167
- /**
168
- * Underlines text
169
- */
170
- export function ansiUnderline(text: string): string {
171
- return ansiStyle(text, [ANSI_CODES.underline]);
172
- }
173
-
174
- /**
175
- * Specialized formatters for different contexts
176
- */
177
-
178
- /**
179
- * Format timestamp for terminal
180
- */
181
- export function formatTimestampANSI(timestamp: string): string {
182
- return ansiColor(timestamp, ANSI_CODES.brightBlack);
183
- }
184
-
185
- /**
186
- * Format log level for terminal
187
- */
188
- export function formatLogLevelANSI(level: LogLevel, useEmojis: boolean = true): string {
189
- const style = ANSI_LEVEL_STYLES[level];
190
- const emoji = useEmojis ? style.emoji : '';
191
- const label = level.toUpperCase().padEnd(8);
192
-
193
- if (!supportsANSIColors()) {
194
- return `${emoji} ${label}`;
195
- }
196
-
197
- let codes = [style.color, ...style.styles];
198
- if (style.background) {
199
- codes.push(style.background);
200
- }
201
-
202
- return ansiStyle(`${emoji} ${label}`, codes);
203
- }
204
-
205
- /**
206
- * Format success message for terminal
207
- */
208
- export function formatSuccessANSI(message: string, useEmojis: boolean = true): string {
209
- const style = ANSI_LEVEL_STYLES.success;
210
- const emoji = useEmojis ? style.emoji : '';
211
-
212
- if (!supportsANSIColors()) {
213
- return `${emoji} SUCCESS: ${message}`;
214
- }
215
-
216
- const prefix = ansiStyle(`${emoji} SUCCESS:`, [style.color, ...style.styles]);
217
- return `${prefix} ${message}`;
218
- }
219
-
220
- /**
221
- * Format prefix for terminal
222
- */
223
- export function formatPrefixANSI(prefix: string): string {
224
- if (!supportsANSIColors()) {
225
- return `[${prefix}]`;
226
- }
227
-
228
- return ansiStyle(`[${prefix}]`, [ANSI_CODES.cyan, ANSI_CODES.bold]);
229
- }
230
-
231
- /**
232
- * Format file location for terminal
233
- */
234
- export function formatLocationANSI(location: string): string {
235
- if (!supportsANSIColors()) {
236
- return `(${location})`;
237
- }
238
-
239
- return ansiColor(`(${location})`, ANSI_CODES.brightBlack);
240
- }
241
-
242
- /**
243
- * Format build-specific messages
244
- */
245
- export const BUILD_FORMATTERS = {
246
- /**
247
- * Format compilation step
248
- */
249
- compilation: (step: string, status: 'starting' | 'completed' | 'failed' = 'starting') => {
250
- const stepText = ansiBold(step);
251
-
252
- switch (status) {
253
- case 'starting':
254
- return `${ansiColor('⚙️', ANSI_CODES.blue)} ${stepText}...`;
255
- case 'completed':
256
- return `${ansiColor('✓', ANSI_CODES.green)} ${stepText} ${ansiColor('completed', ANSI_CODES.green)}`;
257
- case 'failed':
258
- return `${ansiColor('✗', ANSI_CODES.red)} ${stepText} ${ansiColor('failed', ANSI_CODES.red)}`;
259
- default:
260
- return stepText;
261
- }
262
- },
263
-
264
- /**
265
- * Format warning message
266
- */
267
- warning: (message: string) => {
268
- return `${ansiColor('⚠', ANSI_CODES.yellow)} ${ansiStyle('Warning:', [ANSI_CODES.yellow, ANSI_CODES.bold])} ${message}`;
269
- },
270
-
271
- /**
272
- * Format error message
273
- */
274
- error: (message: string) => {
275
- return `${ansiColor('✗', ANSI_CODES.red)} ${ansiStyle('Error:', [ANSI_CODES.red, ANSI_CODES.bold])} ${message}`;
276
- },
277
-
278
- /**
279
- * Format success message
280
- */
281
- success: (message: string) => {
282
- return `${ansiColor('✓', ANSI_CODES.green)} ${ansiColor(message, ANSI_CODES.green)}`;
283
- },
284
-
285
- /**
286
- * Format info message
287
- */
288
- info: (message: string) => {
289
- return `${ansiColor('ℹ', ANSI_CODES.blue)} ${message}`;
290
- }
291
- };
292
-
293
- /**
294
- * Terminal-friendly emoji alternatives for environments that don't support them
295
- */
296
- export const EMOJI_ALTERNATIVES = {
297
- '🔍': '[DEBUG]',
298
- 'ℹ️': '[INFO]',
299
- '⚠️': '[WARN]',
300
- '❌': '[ERROR]',
301
- '🚨': '[CRITICAL]',
302
- '✅': '[OK]',
303
- '✓': '[OK]',
304
- '✗': '[FAIL]',
305
- '⚙️': '[BUILD]',
306
- '📦': '[PKG]'
307
- };
308
-
309
- /**
310
- * Replace emojis with text alternatives for non-emoji terminals
311
- */
312
- export function sanitizeEmojis(text: string): string {
313
- // Check if we're in a terminal that likely supports emojis
314
- const isModernTerminal = process.env.TERM &&
315
- (process.env.TERM.includes('xterm') ||
316
- process.env.TERM.includes('screen') ||
317
- process.env.TERM.includes('tmux'));
318
-
319
- const isCI = process.env.CI || process.env.GITHUB_ACTIONS || process.env.JENKINS_URL;
320
-
321
- // Use emojis if we have a modern terminal and not in CI
322
- if (isModernTerminal && !isCI) {
323
- return text;
324
- }
325
-
326
- // Replace emojis with text alternatives
327
- let result = text;
328
- Object.entries(EMOJI_ALTERNATIVES).forEach(([emoji, alt]) => {
329
- result = result.replace(new RegExp(emoji, 'g'), alt);
330
- });
331
-
332
- return result;
333
- }