@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
@@ -0,0 +1,1127 @@
1
+ import { b as getANSIBackground, g as getANSIForeground, A as ANSI, k as getColorCapability, i as getEnvironment, s as supportsANSI } from "./color-converter-_Xdmsy7E.js";
2
+ function isMinifiedFile(filename) {
3
+ const minifiedPatterns = [
4
+ /\.min\.js$/,
5
+ /\.bundle\.js$/,
6
+ /\.chunk\.js$/,
7
+ /-[\w\d]{8,}\.js$/,
8
+ // Hash-based filenames
9
+ /Logger-[A-Za-z0-9]+\.js$/,
10
+ // Logger bundle files
11
+ /node_modules/,
12
+ /dist\//,
13
+ /build\//,
14
+ /\.mjs$/
15
+ ];
16
+ return minifiedPatterns.some((pattern) => pattern.test(filename));
17
+ }
18
+ function extractCleanFilename(fullPath) {
19
+ const filename = fullPath.split(/[/\\]/).pop() || fullPath;
20
+ return filename.replace(/\.min\.js$/, ".js").replace(/\.bundle\.js$/, ".js").replace(/\.chunk\.js$/, ".js").replace(/-[\w\d]{8,}\.js$/, ".js").replace(/Logger-[A-Za-z0-9]+\.js$/, "logger.ts");
21
+ }
22
+ function parseStackTrace() {
23
+ try {
24
+ const stack = new Error().stack;
25
+ if (!stack) {
26
+ return null;
27
+ }
28
+ const lines = stack.split("\n").filter((line) => line.trim());
29
+ for (let i = 1; i < lines.length; i++) {
30
+ const line = lines[i];
31
+ if (!line) {
32
+ continue;
33
+ }
34
+ if (line.includes("parseStackTrace") || line.includes("Logger.") || line.includes(".log(") || line.includes("createStyledOutput")) {
35
+ continue;
36
+ }
37
+ let match;
38
+ const chromeMatch = line.match(/at\s+(?:(.+?)\s+\()?(.+?):(\d+):(\d+)\)?$/);
39
+ if (chromeMatch) {
40
+ const filename = chromeMatch[2];
41
+ if (filename && isMinifiedFile(filename)) {
42
+ continue;
43
+ }
44
+ match = chromeMatch;
45
+ } else {
46
+ const firefoxMatch = line.match(/(.+?)@(.+?):(\d+):(\d+)$/);
47
+ if (firefoxMatch) {
48
+ const filename = firefoxMatch[2];
49
+ if (filename && isMinifiedFile(filename)) {
50
+ continue;
51
+ }
52
+ match = firefoxMatch;
53
+ } else {
54
+ const safariMatch = line.match(/(\S+)?@(.+?):(\d+):(\d+)$/);
55
+ if (safariMatch) {
56
+ const filename = safariMatch[2];
57
+ if (filename && isMinifiedFile(filename)) {
58
+ continue;
59
+ }
60
+ match = safariMatch;
61
+ }
62
+ }
63
+ }
64
+ if (!match) {
65
+ continue;
66
+ }
67
+ const [, functionName, file, lineStr, columnStr] = match;
68
+ if (!file) {
69
+ continue;
70
+ }
71
+ const cleanFileName = extractCleanFilename(file).split("?")[0];
72
+ if (!cleanFileName) {
73
+ continue;
74
+ }
75
+ const lineNum = lineStr ? parseInt(lineStr, 10) : 0;
76
+ const columnNum = columnStr ? parseInt(columnStr, 10) : 0;
77
+ const cleanFunction = functionName && functionName.trim() ? functionName.trim() : void 0;
78
+ return {
79
+ file: cleanFileName ? cleanFileName : "unknown",
80
+ line: lineNum,
81
+ column: columnNum,
82
+ function: cleanFunction
83
+ };
84
+ }
85
+ return null;
86
+ } catch {
87
+ return null;
88
+ }
89
+ }
90
+ const DEFAULT_CONFIG = {
91
+ verbosity: "info",
92
+ enableColors: true,
93
+ enableTimestamps: true,
94
+ enableStackTrace: true,
95
+ theme: "default",
96
+ bannerType: "simple",
97
+ bufferSize: 1e3,
98
+ autoDetectTheme: true,
99
+ outputFormat: "auto"
100
+ };
101
+ const LEVEL_STYLES = {
102
+ debug: {
103
+ emoji: "🔍",
104
+ label: "DEBUG",
105
+ background: "linear-gradient(90deg, #6c757d, #495057)",
106
+ color: "#ffffff",
107
+ border: "1px solid #6c757d",
108
+ shadow: "0 2px 4px rgba(108, 117, 125, 0.3)"
109
+ },
110
+ info: {
111
+ emoji: "ℹ️",
112
+ label: "INFO",
113
+ background: "linear-gradient(90deg, #007bff, #0056b3)",
114
+ color: "#ffffff",
115
+ border: "1px solid #007bff",
116
+ shadow: "0 2px 4px rgba(0, 123, 255, 0.3)"
117
+ },
118
+ warn: {
119
+ emoji: "⚠️",
120
+ label: "WARN",
121
+ background: "linear-gradient(90deg, #ffc107, #e0a800)",
122
+ color: "#000000",
123
+ border: "1px solid #ffc107",
124
+ shadow: "0 2px 4px rgba(255, 193, 7, 0.3)"
125
+ },
126
+ error: {
127
+ emoji: "❌",
128
+ label: "ERROR",
129
+ background: "linear-gradient(90deg, #dc3545, #c82333)",
130
+ color: "#ffffff",
131
+ border: "1px solid #dc3545",
132
+ shadow: "0 2px 4px rgba(220, 53, 69, 0.3)"
133
+ },
134
+ critical: {
135
+ emoji: "🚨",
136
+ label: "CRITICAL",
137
+ background: "linear-gradient(90deg, #8B0000, #FF0000)",
138
+ color: "#ffffff",
139
+ border: "2px solid #FF0000",
140
+ shadow: "0 4px 8px rgba(255, 0, 0, 0.4)"
141
+ },
142
+ success: {
143
+ emoji: "✅",
144
+ label: "SUCCESS",
145
+ background: "linear-gradient(90deg, #28a745, #1e7e34)",
146
+ color: "#ffffff",
147
+ border: "1px solid #28a745",
148
+ shadow: "0 2px 4px rgba(40, 167, 69, 0.3)"
149
+ }
150
+ };
151
+ const BUFFER_LIMITS = {
152
+ MIN_SIZE: 50,
153
+ DEFAULT_SIZE: 1e3,
154
+ MAX_SIZE: 1e4
155
+ };
156
+ const EXPORT_FORMATS = {
157
+ json: { extension: ".json", mimeType: "application/json" },
158
+ csv: { extension: ".csv", mimeType: "text/csv" },
159
+ markdown: { extension: ".md", mimeType: "text/markdown" },
160
+ plain: { extension: ".txt", mimeType: "text/plain" },
161
+ html: { extension: ".html", mimeType: "text/html" }
162
+ };
163
+ const TIME_UNITS = {
164
+ ms: 1,
165
+ s: 1e3,
166
+ m: 60 * 1e3,
167
+ h: 60 * 60 * 1e3,
168
+ d: 24 * 60 * 60 * 1e3
169
+ };
170
+ const ADAPTIVE_COLORS = {
171
+ timestamp: {
172
+ light: "#666666",
173
+ dark: "#a0a0a0"
174
+ },
175
+ messageText: {
176
+ light: "#2d3748",
177
+ dark: "#f7fafc"
178
+ },
179
+ prefix: {
180
+ light: "#2d3748",
181
+ dark: "#e2e8f0"
182
+ },
183
+ prefixBackground: {
184
+ light: "#2d3748",
185
+ dark: "#4a5568"
186
+ },
187
+ location: {
188
+ light: "#718096",
189
+ dark: "#a0aec0"
190
+ }
191
+ };
192
+ const BUILD_PRESETS = {
193
+ /**
194
+ * Configuración optimizada para Next.js builds
195
+ */
196
+ nextjs: {
197
+ verbosity: "info",
198
+ enableColors: true,
199
+ enableTimestamps: false,
200
+ enableStackTrace: false,
201
+ autoDetectTheme: false,
202
+ outputFormat: "build"
203
+ },
204
+ /**
205
+ * Configuración para Webpack builds
206
+ */
207
+ webpack: {
208
+ verbosity: "info",
209
+ enableColors: true,
210
+ enableTimestamps: true,
211
+ enableStackTrace: false,
212
+ autoDetectTheme: false,
213
+ outputFormat: "build"
214
+ },
215
+ /**
216
+ * Configuración para CI/CD environments
217
+ */
218
+ ci: {
219
+ verbosity: "info",
220
+ enableColors: false,
221
+ enableTimestamps: true,
222
+ enableStackTrace: true,
223
+ autoDetectTheme: false,
224
+ outputFormat: "ci"
225
+ },
226
+ /**
227
+ * Configuración para desarrollo terminal
228
+ */
229
+ terminal: {
230
+ verbosity: "debug",
231
+ enableColors: true,
232
+ enableTimestamps: true,
233
+ enableStackTrace: true,
234
+ autoDetectTheme: false,
235
+ outputFormat: "ansi"
236
+ }
237
+ };
238
+ const ENVIRONMENT_DETECTION = {
239
+ // Next.js detection
240
+ isNextJS: typeof process !== "undefined" && (process.env.NEXT_RUNTIME || process.env.NEXT_PUBLIC_VERCEL_ENV || process.argv && process.argv.some((arg) => arg.includes("next"))),
241
+ // Webpack detection
242
+ isWebpack: typeof process !== "undefined" && (process.env.WEBPACK_ENV || process.env.WEBPACK_BUILD || process.argv && process.argv.some((arg) => arg.includes("webpack"))),
243
+ // CI/CD detection
244
+ isCI: typeof process !== "undefined" && (process.env.CI || process.env.GITHUB_ACTIONS || process.env.JENKINS_URL || process.env.GITLAB_CI || process.env.TRAVIS || process.env.CIRCLECI),
245
+ // Build detection
246
+ isBuild: typeof process !== "undefined" && true,
247
+ // Terminal with ANSI support
248
+ isTerminal: typeof process !== "undefined" && (process.stdout?.isTTY === true && process.env.TERM !== "dumb")
249
+ };
250
+ function detectEnvironmentPreset() {
251
+ if (ENVIRONMENT_DETECTION.isCI) {
252
+ return "ci";
253
+ }
254
+ if (ENVIRONMENT_DETECTION.isNextJS) {
255
+ return "nextjs";
256
+ }
257
+ if (ENVIRONMENT_DETECTION.isWebpack) {
258
+ return "webpack";
259
+ }
260
+ if (ENVIRONMENT_DETECTION.isTerminal) {
261
+ return "terminal";
262
+ }
263
+ return "terminal";
264
+ }
265
+ function getOptimalConfig() {
266
+ const preset = detectEnvironmentPreset();
267
+ return {
268
+ ...DEFAULT_CONFIG,
269
+ ...BUILD_PRESETS[preset]
270
+ };
271
+ }
272
+ const CLI_LEVEL_MAP = {
273
+ silent: { verbosity: "silent", showPrimitives: false },
274
+ quiet: { verbosity: "error", showPrimitives: false },
275
+ normal: { verbosity: "info", showPrimitives: true },
276
+ verbose: { verbosity: "debug", showPrimitives: true },
277
+ debug: { verbosity: "debug", showPrimitives: true }
278
+ };
279
+ function formatTimestamp() {
280
+ try {
281
+ const now = /* @__PURE__ */ new Date();
282
+ return now.toISOString();
283
+ } catch {
284
+ return (/* @__PURE__ */ new Date()).toISOString();
285
+ }
286
+ }
287
+ function parseRelativeTime(timeStr) {
288
+ const match = timeStr.match(/^(\d+)(ms|s|m|h|d)$/);
289
+ if (!match) {
290
+ throw new Error(`Invalid time format: ${timeStr}. Use format like "2h", "30m", "1d"`);
291
+ }
292
+ const [, amount, unit] = match;
293
+ const multiplier = TIME_UNITS[unit];
294
+ return parseInt(amount || "0", 10) * multiplier;
295
+ }
296
+ function parseTimeInput(input) {
297
+ if (input instanceof Date) {
298
+ return input;
299
+ }
300
+ if (typeof input === "number") {
301
+ return new Date(Date.now() - input * TIME_UNITS.h);
302
+ }
303
+ if (typeof input === "string") {
304
+ const isoDate = new Date(input);
305
+ if (!isNaN(isoDate.getTime())) {
306
+ return isoDate;
307
+ }
308
+ try {
309
+ const ms = parseRelativeTime(input);
310
+ return new Date(Date.now() - ms);
311
+ } catch {
312
+ throw new Error(`Invalid time format: ${input}`);
313
+ }
314
+ }
315
+ throw new Error(`Unsupported time input type: ${typeof input}`);
316
+ }
317
+ function formatDisplayTime(date, format = "short") {
318
+ switch (format) {
319
+ case "time-only":
320
+ return date.toTimeString().slice(0, 8);
321
+ // HH:MM:SS
322
+ case "full":
323
+ return date.toISOString();
324
+ case "short":
325
+ default:
326
+ return date.toISOString().slice(11, 23);
327
+ }
328
+ }
329
+ class StyleBuilder {
330
+ styles = [];
331
+ constructor(baseStyle = "") {
332
+ if (baseStyle) this.styles.push(baseStyle);
333
+ }
334
+ /**
335
+ * Add background color or gradient
336
+ */
337
+ bg(background) {
338
+ this.styles.push(`background: ${background}`);
339
+ return this;
340
+ }
341
+ /**
342
+ * Add text color
343
+ */
344
+ color(color) {
345
+ this.styles.push(`color: ${color}`);
346
+ return this;
347
+ }
348
+ /**
349
+ * Add border styling
350
+ */
351
+ border(border) {
352
+ this.styles.push(`border: ${border}`);
353
+ return this;
354
+ }
355
+ /**
356
+ * Add box shadow
357
+ */
358
+ shadow(shadow) {
359
+ this.styles.push(`box-shadow: ${shadow}`);
360
+ return this;
361
+ }
362
+ /**
363
+ * Add padding
364
+ */
365
+ padding(padding) {
366
+ this.styles.push(`padding: ${padding}`);
367
+ return this;
368
+ }
369
+ /**
370
+ * Add margin
371
+ */
372
+ margin(margin) {
373
+ this.styles.push(`margin: ${margin}`);
374
+ return this;
375
+ }
376
+ /**
377
+ * Add border radius
378
+ */
379
+ rounded(radius = "4px") {
380
+ this.styles.push(`border-radius: ${radius}`);
381
+ return this;
382
+ }
383
+ /**
384
+ * Add font weight
385
+ */
386
+ bold() {
387
+ this.styles.push("font-weight: bold");
388
+ return this;
389
+ }
390
+ /**
391
+ * Add font styling
392
+ */
393
+ font(font) {
394
+ this.styles.push(`font-family: ${font}`);
395
+ return this;
396
+ }
397
+ /**
398
+ * Set monospace font family (alias for common monospace fonts)
399
+ */
400
+ mono() {
401
+ return this.font('Monaco, Consolas, "Courier New", monospace');
402
+ }
403
+ /**
404
+ * Set system font family (alias for system fonts)
405
+ */
406
+ system() {
407
+ return this.font('system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif');
408
+ }
409
+ /**
410
+ * Add font size
411
+ */
412
+ size(size) {
413
+ this.styles.push(`font-size: ${size}`);
414
+ return this;
415
+ }
416
+ /**
417
+ * Add line height
418
+ */
419
+ lineHeight(height) {
420
+ this.styles.push(`line-height: ${height}`);
421
+ return this;
422
+ }
423
+ /**
424
+ * Add text decoration
425
+ */
426
+ underline() {
427
+ this.styles.push("text-decoration: underline");
428
+ return this;
429
+ }
430
+ /**
431
+ * Add text transform
432
+ */
433
+ uppercase() {
434
+ this.styles.push("text-transform: uppercase");
435
+ return this;
436
+ }
437
+ /**
438
+ * Add opacity
439
+ */
440
+ opacity(value) {
441
+ this.styles.push(`opacity: ${value}`);
442
+ return this;
443
+ }
444
+ /**
445
+ * Add display property
446
+ */
447
+ display(value) {
448
+ this.styles.push(`display: ${value}`);
449
+ return this;
450
+ }
451
+ /**
452
+ * Add position property
453
+ */
454
+ position(value) {
455
+ this.styles.push(`position: ${value}`);
456
+ return this;
457
+ }
458
+ /**
459
+ * Add transform property
460
+ */
461
+ transform(value) {
462
+ this.styles.push(`transform: ${value}`);
463
+ return this;
464
+ }
465
+ /**
466
+ * Add animation property
467
+ */
468
+ animation(value) {
469
+ this.styles.push(`animation: ${value}`);
470
+ return this;
471
+ }
472
+ /**
473
+ * Add transition property
474
+ */
475
+ transition(value) {
476
+ this.styles.push(`transition: ${value}`);
477
+ return this;
478
+ }
479
+ /**
480
+ * Add cursor property
481
+ */
482
+ cursor(value) {
483
+ this.styles.push(`cursor: ${value}`);
484
+ return this;
485
+ }
486
+ /**
487
+ * Add any custom CSS property
488
+ */
489
+ custom(property, value) {
490
+ this.styles.push(`${property}: ${value}`);
491
+ return this;
492
+ }
493
+ /**
494
+ * Add any CSS property (alias for custom)
495
+ */
496
+ css(property, value) {
497
+ return this.custom(property, value);
498
+ }
499
+ /**
500
+ * Build the final CSS string
501
+ */
502
+ build() {
503
+ return this.styles.join("; ");
504
+ }
505
+ /**
506
+ * Clear all styles and start fresh
507
+ */
508
+ clear() {
509
+ this.styles = [];
510
+ return this;
511
+ }
512
+ /**
513
+ * Clone this StyleBuilder with the same styles
514
+ */
515
+ clone() {
516
+ const cloned = new StyleBuilder();
517
+ cloned.styles = [...this.styles];
518
+ return cloned;
519
+ }
520
+ /**
521
+ * Merge another StyleBuilder's styles into this one
522
+ */
523
+ merge(other) {
524
+ this.styles.push(...other.styles);
525
+ return this;
526
+ }
527
+ }
528
+ function createStyler() {
529
+ const builder = new StyleBuilder();
530
+ return new Proxy(builder, {
531
+ get(target, prop) {
532
+ if (prop in target) {
533
+ const method = target[prop];
534
+ if (typeof method === "function") {
535
+ return method.bind(target);
536
+ }
537
+ return method;
538
+ }
539
+ return void 0;
540
+ }
541
+ });
542
+ }
543
+ createStyler();
544
+ const StylePresets = {
545
+ success: () => new StyleBuilder().bg("linear-gradient(135deg, #00b894 0%, #00a085 100%)").color("#ffffff").padding("4px 8px").rounded("4px").bold(),
546
+ error: () => new StyleBuilder().bg("linear-gradient(135deg, #e84393 0%, #d63031 100%)").color("#ffffff").padding("4px 8px").rounded("4px").bold(),
547
+ warning: () => new StyleBuilder().bg("linear-gradient(135deg, #fdcb6e 0%, #e17055 100%)").color("#2d3436").padding("4px 8px").rounded("4px").bold(),
548
+ info: () => new StyleBuilder().bg("linear-gradient(135deg, #74b9ff 0%, #0984e3 100%)").color("#ffffff").padding("4px 8px").rounded("4px").bold(),
549
+ debug: () => new StyleBuilder().bg("linear-gradient(135deg, #667eea 0%, #764ba2 100%)").color("#ffffff").padding("4px 8px").rounded("4px").bold(),
550
+ muted: () => new StyleBuilder().color("#6c757d").font("Monaco, Consolas, monospace").size("12px"),
551
+ accent: () => new StyleBuilder().bg("#f8f9fa").color("#495057").padding("2px 6px").rounded("3px").border("1px solid #dee2e6"),
552
+ neon: () => new StyleBuilder().bg("linear-gradient(135deg, #0f3460 0%, #e94560 100%)").color("#00ffff").padding("4px 8px").rounded("4px").bold().shadow("0 0 10px rgba(0, 255, 255, 0.5)")
553
+ };
554
+ class TerminalRenderer {
555
+ colorCapability;
556
+ constructor(colorCapability = "full") {
557
+ this.colorCapability = colorCapability;
558
+ }
559
+ /**
560
+ * Get ANSI color codes - now supports truecolor/256-color
561
+ */
562
+ getColorCode(color, background = false) {
563
+ return background ? getANSIBackground(color, this.colorCapability) : getANSIForeground(color, this.colorCapability);
564
+ }
565
+ /**
566
+ * Get ANSI style codes
567
+ */
568
+ getStyleCode(styles) {
569
+ const styleCodes = {
570
+ "bold": "1",
571
+ "dim": "2",
572
+ "italic": "3",
573
+ "underline": "4",
574
+ "reset": "0"
575
+ };
576
+ const codes = styles.map((style) => styleCodes[style] || "0").join(";");
577
+ return codes ? `\x1B[${codes}m` : "";
578
+ }
579
+ /**
580
+ * Convert log styles to ANSI formatting
581
+ */
582
+ renderTerminal(level, message, timestamp, prefix, location, styles) {
583
+ const reset = "\x1B[0m";
584
+ const result = { text: "", reset };
585
+ if (styles) {
586
+ result.timestamp = this.styleTimestamp(timestamp, styles.timestamp);
587
+ result.level = this.styleLevel(level, styles.level);
588
+ result.prefix = this.stylePrefix(prefix, styles.prefix);
589
+ result.message = this.styleMessage(message, styles.message);
590
+ result.location = this.styleLocation(location, styles.location);
591
+ } else {
592
+ result.timestamp = this.styleTimestamp(timestamp);
593
+ result.level = this.styleLevel(level);
594
+ result.prefix = this.stylePrefix(prefix);
595
+ result.message = this.styleMessage(message);
596
+ result.location = this.styleLocation(location);
597
+ }
598
+ const parts = [];
599
+ if (result.timestamp) parts.push(result.timestamp);
600
+ if (result.level) parts.push(result.level);
601
+ if (result.prefix) parts.push(result.prefix);
602
+ if (result.message) parts.push(result.message);
603
+ if (result.location) parts.push(result.location);
604
+ result.text = parts.join(" ") + reset;
605
+ return result;
606
+ }
607
+ /**
608
+ * Style timestamp based on preset or defaults
609
+ */
610
+ styleTimestamp(timestamp, style) {
611
+ if (!timestamp || !style?.show) return "";
612
+ if (this.colorCapability === "none") {
613
+ return timestamp;
614
+ }
615
+ const dimStyle = this.getStyleCode(["dim"]);
616
+ return `${dimStyle}${timestamp}${"\x1B[0m"}`;
617
+ }
618
+ /**
619
+ * Style level with appropriate colors and formatting
620
+ */
621
+ styleLevel(level, style) {
622
+ if (!style?.show) return "";
623
+ const levelText = this.getLevelText(level);
624
+ const levelColors = {
625
+ "debug": "magenta",
626
+ "info": "blue",
627
+ "warn": "yellow",
628
+ "error": "red",
629
+ "critical": "red"
630
+ };
631
+ if (this.colorCapability === "none") {
632
+ return `[${levelText}]`;
633
+ }
634
+ const color = levelColors[level] || "white";
635
+ const colorCode = this.getColorCode(color);
636
+ const boldStyle = this.getStyleCode(["bold"]);
637
+ if (style?.style === "compact") {
638
+ return `${colorCode}[${levelText}]${"\x1B[0m"}`;
639
+ } else {
640
+ return `${colorCode}${boldStyle}[${levelText}]${"\x1B[0m"}`;
641
+ }
642
+ }
643
+ /**
644
+ * Style prefix based on preset - now as a badge
645
+ */
646
+ stylePrefix(prefix, style) {
647
+ if (!prefix || !style?.show) return "";
648
+ if (this.colorCapability === "none") {
649
+ return `[${prefix}]`;
650
+ }
651
+ const colorCode = this.getColorCode("cyan");
652
+ const bgBlack = "\x1B[40m";
653
+ return `${bgBlack}${colorCode}[${prefix.toUpperCase()}]${"\x1B[0m"}`;
654
+ }
655
+ /**
656
+ * Style message based on preset
657
+ */
658
+ styleMessage(message, style) {
659
+ if (!style?.show) return message;
660
+ return message;
661
+ }
662
+ /**
663
+ * Style location (file:line) information
664
+ */
665
+ styleLocation(location, style) {
666
+ if (!location || !style?.show) return "";
667
+ if (this.colorCapability === "none") {
668
+ return `(${location})`;
669
+ }
670
+ const dimStyle = this.getStyleCode(["dim"]);
671
+ if (style?.style === "clickable") {
672
+ const underlineStyle = this.getStyleCode(["dim", "underline"]);
673
+ return `${underlineStyle}(${location})${"\x1B[0m"}`;
674
+ }
675
+ return `${dimStyle}(${location})${"\x1B[0m"}`;
676
+ }
677
+ /**
678
+ * Get text representation of log level
679
+ */
680
+ getLevelText(level) {
681
+ const levelMap = {
682
+ "debug": "DEBUG",
683
+ "info": "INFO",
684
+ "warn": "WARN",
685
+ "error": "ERROR",
686
+ "critical": "CRITICAL"
687
+ };
688
+ return levelMap[level] || String(level).toUpperCase();
689
+ }
690
+ /**
691
+ * Create cyberpunk-style ANSI rendering with truecolor support
692
+ */
693
+ renderCyberpunk(level, message, timestamp, prefix, location) {
694
+ const reset = ANSI.reset;
695
+ const cyberpunkColors = {
696
+ "debug": "#ff00ff",
697
+ // Neon magenta
698
+ "info": "#00ffff",
699
+ // Neon cyan
700
+ "warn": "#ffff00",
701
+ // Neon yellow
702
+ "error": "#ff0040",
703
+ // Neon red-pink
704
+ "critical": "#ff0000"
705
+ // Pure red
706
+ };
707
+ const parts = [];
708
+ if (timestamp) {
709
+ parts.push(`${ANSI.dim}${timestamp}${reset}`);
710
+ }
711
+ const levelColor = this.getColorCode(cyberpunkColors[level] || "#ffffff");
712
+ const bgBlack = ANSI.bg.black;
713
+ const bold = level === "critical" ? ANSI.bold : "";
714
+ parts.push(`${bgBlack}${levelColor}${bold} ${this.getLevelText(level)} ${reset}`);
715
+ if (prefix) {
716
+ const cyanColor = this.getColorCode("#00ffff");
717
+ parts.push(`${bgBlack}${cyanColor}[${prefix.toUpperCase()}]${reset}`);
718
+ }
719
+ parts.push(message);
720
+ if (location) {
721
+ parts.push(`${ANSI.dim}(${location})${reset}`);
722
+ }
723
+ return {
724
+ text: parts.join(" "),
725
+ reset
726
+ };
727
+ }
728
+ /**
729
+ * Create minimal ANSI rendering with truecolor support
730
+ */
731
+ renderMinimal(level, message, timestamp, prefix) {
732
+ const reset = ANSI.reset;
733
+ const minimalColors = {
734
+ "debug": "#c678dd",
735
+ // Soft purple
736
+ "info": "#61afef",
737
+ // Soft blue
738
+ "warn": "#e5c07b",
739
+ // Soft yellow
740
+ "error": "#e06c75",
741
+ // Soft red
742
+ "critical": "#be5046"
743
+ // Dark red
744
+ };
745
+ const parts = [];
746
+ if (timestamp) {
747
+ parts.push(`${ANSI.dim}${timestamp}${reset}`);
748
+ }
749
+ const levelColor = this.getColorCode(minimalColors[level] || "#abb2bf");
750
+ const bold = level === "critical" ? ANSI.bold : "";
751
+ parts.push(`${levelColor}${bold}${this.getLevelText(level)}:${reset}`);
752
+ if (prefix) {
753
+ const cyanColor = this.getColorCode("#56b6c2");
754
+ parts.push(`${cyanColor}[${prefix.toUpperCase()}]${reset}`);
755
+ }
756
+ parts.push(message);
757
+ return {
758
+ text: parts.join(" "),
759
+ reset
760
+ };
761
+ }
762
+ /**
763
+ * Get chalk-like interface for log level with truecolor support
764
+ */
765
+ getChalkForLevel(level) {
766
+ const levelColors = {
767
+ "debug": "#c678dd",
768
+ "info": "#61afef",
769
+ "warn": "#e5c07b",
770
+ "error": "#e06c75",
771
+ "critical": "#be5046"
772
+ };
773
+ const reset = ANSI.reset;
774
+ return {
775
+ color: (text) => {
776
+ const color = levelColors[level] || "#abb2bf";
777
+ const colorCode = this.getColorCode(color);
778
+ return `${colorCode}${text}${reset}`;
779
+ },
780
+ bold: (text) => `${ANSI.bold}${text}${reset}`,
781
+ dim: (text) => `${ANSI.dim}${text}${reset}`,
782
+ bgGray: (text) => `${ANSI.bg.gray}${text}${reset}`,
783
+ bgBlue: (text) => `${this.getColorCode("#1e3a5f", true)}${text}${reset}`,
784
+ reset: (text) => text,
785
+ cyan: {
786
+ bold: (text) => {
787
+ const cyan = this.getColorCode("#00ffff");
788
+ return `${cyan}${ANSI.bold}${text}${reset}`;
789
+ },
790
+ dim: (text) => {
791
+ const cyan = this.getColorCode("#00ffff");
792
+ return `${cyan}${ANSI.dim}${text}${reset}`;
793
+ },
794
+ bg: (text) => {
795
+ const cyan = this.getColorCode("#00ffff");
796
+ return `${ANSI.bg.black}${cyan}[${text.toUpperCase()}]${reset}`;
797
+ }
798
+ }
799
+ };
800
+ }
801
+ }
802
+ class CSS2ANSIAdapter {
803
+ renderer;
804
+ constructor() {
805
+ const colorCapability = getColorCapability();
806
+ this.renderer = new TerminalRenderer(colorCapability);
807
+ }
808
+ /**
809
+ * Convert LogStyles to ANSIStyle for terminal rendering
810
+ */
811
+ adaptStyles(level, message, timestamp, prefix, location, styles, presetName) {
812
+ if (presetName) {
813
+ switch (presetName) {
814
+ case "cyberpunk":
815
+ return this.renderer.renderCyberpunk(level, message, timestamp, prefix, location);
816
+ case "minimal":
817
+ return this.renderer.renderMinimal(level, message, timestamp, prefix);
818
+ case "production":
819
+ return this.adaptProductionStyles(level, message, timestamp, prefix, location, styles);
820
+ case "debug":
821
+ return this.adaptDebugStyles(level, message, timestamp, prefix, location, styles);
822
+ case "glassmorphism":
823
+ return this.adaptGlassmorphismStyles(level, message, timestamp, prefix, location, styles);
824
+ }
825
+ }
826
+ return this.renderer.renderTerminal(level, message, timestamp, prefix, location, styles);
827
+ }
828
+ /**
829
+ * Adapt production preset for terminal
830
+ */
831
+ adaptProductionStyles(level, message, timestamp, prefix, location, styles) {
832
+ const reset = "\x1B[0m";
833
+ const levelChalk = this.renderer.getChalkForLevel(level);
834
+ const parts = [];
835
+ if (timestamp && styles?.timestamp?.show) {
836
+ parts.push(levelChalk.dim(timestamp));
837
+ }
838
+ if (styles?.level?.show) {
839
+ parts.push(levelChalk.color(`[${this.renderer["getLevelText"](level)}]`));
840
+ }
841
+ if (prefix && styles?.prefix?.show) {
842
+ parts.push(levelChalk.dim(`[${prefix}]`));
843
+ }
844
+ if (message && styles?.message?.show) {
845
+ parts.push(levelChalk.reset(message));
846
+ }
847
+ if (location && styles?.location?.show) {
848
+ parts.push(levelChalk.dim(`(${location})`));
849
+ }
850
+ return {
851
+ text: parts.join(" ") + reset,
852
+ reset
853
+ };
854
+ }
855
+ /**
856
+ * Adapt debug preset for terminal
857
+ */
858
+ adaptDebugStyles(level, message, timestamp, prefix, location, styles) {
859
+ const reset = "\x1B[0m";
860
+ const levelChalk = this.renderer.getChalkForLevel(level);
861
+ const parts = [];
862
+ if (timestamp && styles?.timestamp?.show) {
863
+ parts.push(levelChalk.dim(timestamp));
864
+ }
865
+ if (styles?.level?.show) {
866
+ if (styles?.level?.style === "compact") {
867
+ parts.push(levelChalk.color(`[${this.renderer["getLevelText"](level)}]`));
868
+ } else {
869
+ parts.push(levelChalk.bold(`[${this.renderer["getLevelText"](level)}]`));
870
+ }
871
+ }
872
+ if (prefix && styles?.prefix?.show) {
873
+ if (styles?.prefix?.style === "compact") {
874
+ parts.push(levelChalk.cyan.dim(`[${prefix}]`));
875
+ } else {
876
+ parts.push(levelChalk.cyan.bold(`[${prefix}]`));
877
+ }
878
+ }
879
+ if (message && styles?.message?.show) {
880
+ parts.push(levelChalk.reset(message));
881
+ }
882
+ if (location && styles?.location?.show) {
883
+ if (styles?.location?.style === "clickable") {
884
+ parts.push(levelChalk.dim(`${location} (clickable)`));
885
+ } else {
886
+ parts.push(levelChalk.dim(`(${location})`));
887
+ }
888
+ }
889
+ return {
890
+ text: parts.join(" ") + reset,
891
+ reset
892
+ };
893
+ }
894
+ /**
895
+ * Adapt glassmorphism preset for terminal
896
+ */
897
+ adaptGlassmorphismStyles(level, message, timestamp, prefix, location, styles) {
898
+ const reset = "\x1B[0m";
899
+ const levelChalk = this.renderer.getChalkForLevel(level);
900
+ const parts = [];
901
+ if (timestamp && styles?.timestamp?.show) {
902
+ parts.push(levelChalk.dim(timestamp));
903
+ }
904
+ if (styles?.level?.show) {
905
+ parts.push(levelChalk.bgGray(` ${this.renderer["getLevelText"](level)} `));
906
+ }
907
+ if (prefix && styles?.prefix?.show) {
908
+ parts.push(levelChalk.bgBlue(`[${prefix}]`));
909
+ }
910
+ if (message && styles?.message?.show) {
911
+ parts.push(levelChalk.reset(message));
912
+ }
913
+ if (location && styles?.location?.show) {
914
+ parts.push(levelChalk.dim(`(${location})`));
915
+ }
916
+ return {
917
+ text: parts.join(" ") + reset,
918
+ reset
919
+ };
920
+ }
921
+ /**
922
+ * Convert CSS color values to ANSI-friendly colors
923
+ */
924
+ adaptColor(cssColor) {
925
+ if (cssColor.startsWith("#")) {
926
+ return cssColor;
927
+ }
928
+ if (cssColor.startsWith("rgb(")) {
929
+ return cssColor;
930
+ }
931
+ if (cssColor.includes("gradient")) {
932
+ return this.extractColorFromGradient(cssColor);
933
+ }
934
+ return this.cssNameToANSI(cssColor);
935
+ }
936
+ /**
937
+ * Extract primary color from CSS gradient
938
+ */
939
+ extractColorFromGradient(gradient) {
940
+ const match = gradient.match(/#[0-9a-fA-F]{6}|rgb\([^)]+\)/);
941
+ return match ? match[0] : "#ffffff";
942
+ }
943
+ /**
944
+ * Convert CSS color names to ANSI-compatible names
945
+ */
946
+ cssNameToANSI(cssColor) {
947
+ const colorMap = {
948
+ "black": "black",
949
+ "white": "white",
950
+ "red": "red",
951
+ "green": "green",
952
+ "blue": "blue",
953
+ "yellow": "yellow",
954
+ "cyan": "cyan",
955
+ "magenta": "magenta",
956
+ "gray": "gray",
957
+ "grey": "gray",
958
+ "orange": "yellow",
959
+ "purple": "magenta",
960
+ "pink": "red",
961
+ "brown": "yellow",
962
+ "lightblue": "cyan",
963
+ "lightgreen": "green",
964
+ "lightgray": "gray",
965
+ "lightgrey": "gray"
966
+ };
967
+ return colorMap[cssColor.toLowerCase()] || "white";
968
+ }
969
+ /**
970
+ * Check if a style should be rendered in terminal
971
+ */
972
+ shouldRenderStyle(styleType, styles) {
973
+ if (!styles) return true;
974
+ const styleConfig = styles[styleType];
975
+ return styleConfig?.show !== false;
976
+ }
977
+ /**
978
+ * Get renderer instance for advanced usage
979
+ */
980
+ getRenderer() {
981
+ return this.renderer;
982
+ }
983
+ }
984
+ const css2ansiAdapter = new CSS2ANSIAdapter();
985
+ function adaptToTerminal(level, message, timestamp, prefix, location, styles, presetName) {
986
+ return css2ansiAdapter.adaptStyles(level, message, timestamp, prefix, location, styles, presetName);
987
+ }
988
+ function detectDevToolsTheme() {
989
+ try {
990
+ if (typeof window === "undefined" || !window.matchMedia) {
991
+ return "light";
992
+ }
993
+ const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
994
+ return mediaQuery.matches ? "dark" : "light";
995
+ } catch (error) {
996
+ console.warn("Failed to detect DevTools theme:", error);
997
+ return "light";
998
+ }
999
+ }
1000
+ function getAdaptiveColor(colors, theme) {
1001
+ const currentTheme = theme ?? detectDevToolsTheme();
1002
+ return colors[currentTheme];
1003
+ }
1004
+ function setupThemeChangeListener(callback) {
1005
+ try {
1006
+ if (typeof window === "undefined" || !window.matchMedia) {
1007
+ return null;
1008
+ }
1009
+ const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
1010
+ const handler = (e) => {
1011
+ callback(e.matches ? "dark" : "light");
1012
+ };
1013
+ if (mediaQuery.addEventListener) {
1014
+ mediaQuery.addEventListener("change", handler);
1015
+ return () => mediaQuery.removeEventListener("change", handler);
1016
+ } else if (mediaQuery.addListener) {
1017
+ mediaQuery.addListener(handler);
1018
+ return () => mediaQuery.removeListener?.(handler);
1019
+ }
1020
+ return null;
1021
+ } catch (error) {
1022
+ console.warn("Failed to set up theme change listener:", error);
1023
+ return null;
1024
+ }
1025
+ }
1026
+ function createStyledOutput(level, levelStyles, prefix, message, stackInfo, autoDetectTheme = true, presetStyles, presetName) {
1027
+ const levelConfig = levelStyles[level];
1028
+ const timestamp = formatTimestamp();
1029
+ const environment = getEnvironment();
1030
+ if (environment !== "browser" && supportsANSI()) {
1031
+ return createTerminalOutput(level, message, timestamp, prefix, stackInfo, presetStyles, presetName);
1032
+ }
1033
+ const currentTheme = autoDetectTheme ? detectDevToolsTheme() : "light";
1034
+ const timestampStyle = new StyleBuilder().color(getAdaptiveColor(ADAPTIVE_COLORS.timestamp, currentTheme)).size("11px").font("Monaco, Consolas, monospace").build();
1035
+ const levelStyle = new StyleBuilder().bg(levelConfig.background).color(levelConfig.color).border(levelConfig.border).shadow(levelConfig.shadow).padding("2px 8px").rounded("4px").bold().font("Monaco, Consolas, monospace").size("12px").build();
1036
+ const prefixStyle = new StyleBuilder().bg(getAdaptiveColor(ADAPTIVE_COLORS.prefixBackground, currentTheme)).color(getAdaptiveColor(ADAPTIVE_COLORS.prefix, currentTheme)).padding("2px 6px").rounded("3px").bold().font("Monaco, Consolas, monospace").size("11px").build();
1037
+ const messageStyle = new StyleBuilder().color(getAdaptiveColor(ADAPTIVE_COLORS.messageText, currentTheme)).font("system-ui, -apple-system, sans-serif").size("14px").build();
1038
+ const locationStyle = new StyleBuilder().color(getAdaptiveColor(ADAPTIVE_COLORS.location, currentTheme)).size("11px").font("Monaco, Consolas, monospace").build();
1039
+ let format = `%c${timestamp.slice(11, 23)} %c${levelConfig.emoji} ${levelConfig.label}`;
1040
+ const styles = [timestampStyle, levelStyle];
1041
+ if (prefix) {
1042
+ format += ` %c${prefix}`;
1043
+ styles.push(prefixStyle);
1044
+ }
1045
+ format += ` %c${message}`;
1046
+ styles.push(messageStyle);
1047
+ if (stackInfo) {
1048
+ format += ` %c(${stackInfo.file}:${stackInfo.line}:${stackInfo.column})`;
1049
+ styles.push(locationStyle);
1050
+ }
1051
+ return [format, ...styles];
1052
+ }
1053
+ function generateLogId() {
1054
+ return `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
1055
+ }
1056
+ function escapeHtml(text) {
1057
+ const div = document.createElement("div");
1058
+ div.textContent = text;
1059
+ return div.innerHTML;
1060
+ }
1061
+ function safeStringify(obj, _maxDepth = 3) {
1062
+ try {
1063
+ return JSON.stringify(obj, (_key, value) => {
1064
+ if (typeof value === "function") return "[Function]";
1065
+ if (value instanceof Error) return `[Error: ${value.message}]`;
1066
+ if (value instanceof Date) return value.toISOString();
1067
+ if (typeof value === "undefined") return "[undefined]";
1068
+ return value;
1069
+ }, 2);
1070
+ } catch (error) {
1071
+ return String(obj);
1072
+ }
1073
+ }
1074
+ function createTerminalOutput(level, message, timestamp, prefix, stackInfo, presetStyles, presetName) {
1075
+ const location = stackInfo ? `${stackInfo.file}:${stackInfo.line}:${stackInfo.column}` : void 0;
1076
+ const ansiStyle = adaptToTerminal(
1077
+ level,
1078
+ message,
1079
+ timestamp,
1080
+ prefix,
1081
+ location,
1082
+ presetStyles,
1083
+ presetName
1084
+ );
1085
+ return [ansiStyle.text];
1086
+ }
1087
+ const isNode = typeof process !== "undefined" && process.versions && process.versions.node;
1088
+ const isBrowser = typeof window !== "undefined" && typeof document !== "undefined";
1089
+ function supportsCSSColors() {
1090
+ return isBrowser;
1091
+ }
1092
+ function supportsANSIColors() {
1093
+ if (isNode) {
1094
+ return process.stdout?.isTTY === true || process.env.FORCE_COLOR === "1" || process.env.FORCE_COLOR === "true";
1095
+ }
1096
+ return false;
1097
+ }
1098
+ export {
1099
+ ADAPTIVE_COLORS as A,
1100
+ BUILD_PRESETS as B,
1101
+ CLI_LEVEL_MAP as C,
1102
+ DEFAULT_CONFIG as D,
1103
+ ENVIRONMENT_DETECTION as E,
1104
+ LEVEL_STYLES as L,
1105
+ StylePresets as S,
1106
+ TerminalRenderer as T,
1107
+ isNode as a,
1108
+ StyleBuilder as b,
1109
+ createStyledOutput as c,
1110
+ supportsANSIColors as d,
1111
+ detectEnvironmentPreset as e,
1112
+ formatTimestamp as f,
1113
+ getOptimalConfig as g,
1114
+ getAdaptiveColor as h,
1115
+ isBrowser as i,
1116
+ BUFFER_LIMITS as j,
1117
+ generateLogId as k,
1118
+ parseTimeInput as l,
1119
+ formatDisplayTime as m,
1120
+ safeStringify as n,
1121
+ escapeHtml as o,
1122
+ parseStackTrace as p,
1123
+ EXPORT_FORMATS as q,
1124
+ setupThemeChangeListener as r,
1125
+ supportsCSSColors as s
1126
+ };
1127
+ //# sourceMappingURL=environment-C1xxvc8l.js.map