@mks2508/better-logger 5.0.0 → 5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (190) hide show
  1. package/CHANGELOG.json +45 -1
  2. package/package.json +1 -1
  3. package/packages/core/package.json +1 -1
  4. package/packages/exports/package.json +2 -2
  5. package/packages/styling/package.json +2 -2
  6. package/src/terminal/formatter.ts +16 -10
  7. package/bun.lock +0 -333
  8. package/dist/Logger.d.ts +0 -976
  9. package/dist/Logger.d.ts.map +0 -1
  10. package/dist/ScopedLogger.d.ts +0 -74
  11. package/dist/ScopedLogger.d.ts.map +0 -1
  12. package/dist/chunks/Logger-BZ7B7OXE.js +0 -4511
  13. package/dist/chunks/Logger-BZ7B7OXE.js.map +0 -1
  14. package/dist/chunks/Logger-Cbi1f10o.js +0 -2
  15. package/dist/chunks/Logger-Cbi1f10o.js.map +0 -1
  16. package/dist/chunks/RemoteLogHandler-CjWpWZGl.js +0 -33
  17. package/dist/chunks/RemoteLogHandler-CjWpWZGl.js.map +0 -1
  18. package/dist/chunks/RemoteLogHandler-ymkQ97xl.js +0 -2
  19. package/dist/chunks/RemoteLogHandler-ymkQ97xl.js.map +0 -1
  20. package/dist/chunks/cli-module-CadqgZ1Z.js +0 -2
  21. package/dist/chunks/cli-module-CadqgZ1Z.js.map +0 -1
  22. package/dist/chunks/cli-module-ClIJmaT8.js +0 -383
  23. package/dist/chunks/cli-module-ClIJmaT8.js.map +0 -1
  24. package/dist/chunks/color-converter-CCSQRztd.js +0 -2
  25. package/dist/chunks/color-converter-CCSQRztd.js.map +0 -1
  26. package/dist/chunks/color-converter-_Xdmsy7E.js +0 -462
  27. package/dist/chunks/color-converter-_Xdmsy7E.js.map +0 -1
  28. package/dist/chunks/environment-C1xxvc8l.js +0 -1127
  29. package/dist/chunks/environment-C1xxvc8l.js.map +0 -1
  30. package/dist/chunks/environment-Cprkw3g9.js +0 -4
  31. package/dist/chunks/environment-Cprkw3g9.js.map +0 -1
  32. package/dist/chunks/formatting-DMJxYq9o.js +0 -380
  33. package/dist/chunks/formatting-DMJxYq9o.js.map +0 -1
  34. package/dist/chunks/formatting-DpKxCsXq.js +0 -2
  35. package/dist/chunks/formatting-DpKxCsXq.js.map +0 -1
  36. package/dist/cli/CommandProcessor.d.ts +0 -100
  37. package/dist/cli/CommandProcessor.d.ts.map +0 -1
  38. package/dist/cli/commands/ConfigCommand.d.ts +0 -14
  39. package/dist/cli/commands/ConfigCommand.d.ts.map +0 -1
  40. package/dist/cli/commands/ExportCommand.d.ts +0 -48
  41. package/dist/cli/commands/ExportCommand.d.ts.map +0 -1
  42. package/dist/cli/commands/HistoryCommand.d.ts +0 -47
  43. package/dist/cli/commands/HistoryCommand.d.ts.map +0 -1
  44. package/dist/cli/commands/StatusCommand.d.ts +0 -30
  45. package/dist/cli/commands/StatusCommand.d.ts.map +0 -1
  46. package/dist/cli/commands/ThemeCommand.d.ts +0 -30
  47. package/dist/cli/commands/ThemeCommand.d.ts.map +0 -1
  48. package/dist/cli/help.d.ts +0 -12
  49. package/dist/cli/help.d.ts.map +0 -1
  50. package/dist/cli/index.d.ts +0 -15
  51. package/dist/cli/index.d.ts.map +0 -1
  52. package/dist/cli-module.d.ts +0 -15
  53. package/dist/cli-module.d.ts.map +0 -1
  54. package/dist/cli-primitives/box.d.ts +0 -11
  55. package/dist/cli-primitives/box.d.ts.map +0 -1
  56. package/dist/cli-primitives/cli-table.d.ts +0 -11
  57. package/dist/cli-primitives/cli-table.d.ts.map +0 -1
  58. package/dist/cli-primitives/divider.d.ts +0 -11
  59. package/dist/cli-primitives/divider.d.ts.map +0 -1
  60. package/dist/cli-primitives/header.d.ts +0 -12
  61. package/dist/cli-primitives/header.d.ts.map +0 -1
  62. package/dist/cli-primitives/index.d.ts +0 -13
  63. package/dist/cli-primitives/index.d.ts.map +0 -1
  64. package/dist/cli-primitives/server-fallback.d.ts +0 -25
  65. package/dist/cli-primitives/server-fallback.d.ts.map +0 -1
  66. package/dist/cli-primitives/spinner.d.ts +0 -47
  67. package/dist/cli-primitives/spinner.d.ts.map +0 -1
  68. package/dist/cli-primitives/step.d.ts +0 -11
  69. package/dist/cli-primitives/step.d.ts.map +0 -1
  70. package/dist/cli.cjs +0 -2
  71. package/dist/cli.cjs.map +0 -1
  72. package/dist/cli.js +0 -12
  73. package/dist/cli.js.map +0 -1
  74. package/dist/constants.d.ts +0 -235
  75. package/dist/constants.d.ts.map +0 -1
  76. package/dist/core.cjs +0 -2
  77. package/dist/core.cjs.map +0 -1
  78. package/dist/core.d.ts +0 -127
  79. package/dist/core.d.ts.map +0 -1
  80. package/dist/core.js +0 -291
  81. package/dist/core.js.map +0 -1
  82. package/dist/example.d.ts +0 -18
  83. package/dist/example.d.ts.map +0 -1
  84. package/dist/exports-module.d.ts +0 -196
  85. package/dist/exports-module.d.ts.map +0 -1
  86. package/dist/exports.cjs +0 -2
  87. package/dist/exports.cjs.map +0 -1
  88. package/dist/exports.js +0 -238
  89. package/dist/exports.js.map +0 -1
  90. package/dist/handlers/AnalyticsLogHandler.d.ts +0 -8
  91. package/dist/handlers/AnalyticsLogHandler.d.ts.map +0 -1
  92. package/dist/handlers/ExportLogHandler.d.ts +0 -100
  93. package/dist/handlers/ExportLogHandler.d.ts.map +0 -1
  94. package/dist/handlers/FileLogHandler.d.ts +0 -33
  95. package/dist/handlers/FileLogHandler.d.ts.map +0 -1
  96. package/dist/handlers/RemoteLogHandler.d.ts +0 -11
  97. package/dist/handlers/RemoteLogHandler.d.ts.map +0 -1
  98. package/dist/handlers/index.d.ts +0 -8
  99. package/dist/handlers/index.d.ts.map +0 -1
  100. package/dist/hooks/HookManager.d.ts +0 -21
  101. package/dist/hooks/HookManager.d.ts.map +0 -1
  102. package/dist/hooks/index.d.ts +0 -2
  103. package/dist/hooks/index.d.ts.map +0 -1
  104. package/dist/index.cjs +0 -2
  105. package/dist/index.cjs.map +0 -1
  106. package/dist/index.d.ts +0 -161
  107. package/dist/index.d.ts.map +0 -1
  108. package/dist/index.js +0 -627
  109. package/dist/index.js.map +0 -1
  110. package/dist/main.d.ts +0 -2
  111. package/dist/main.d.ts.map +0 -1
  112. package/dist/serializers/SerializerRegistry.d.ts +0 -16
  113. package/dist/serializers/SerializerRegistry.d.ts.map +0 -1
  114. package/dist/serializers/index.d.ts +0 -2
  115. package/dist/serializers/index.d.ts.map +0 -1
  116. package/dist/styling/LogStyleBuilder.d.ts +0 -146
  117. package/dist/styling/LogStyleBuilder.d.ts.map +0 -1
  118. package/dist/styling/SemanticStyles.d.ts +0 -178
  119. package/dist/styling/SemanticStyles.d.ts.map +0 -1
  120. package/dist/styling/SmartPresets.d.ts +0 -22
  121. package/dist/styling/SmartPresets.d.ts.map +0 -1
  122. package/dist/styling/StyleBuilder.d.ts +0 -140
  123. package/dist/styling/StyleBuilder.d.ts.map +0 -1
  124. package/dist/styling/StyleCache.d.ts +0 -42
  125. package/dist/styling/StyleCache.d.ts.map +0 -1
  126. package/dist/styling/banners.d.ts +0 -42
  127. package/dist/styling/banners.d.ts.map +0 -1
  128. package/dist/styling/index.d.ts +0 -10
  129. package/dist/styling/index.d.ts.map +0 -1
  130. package/dist/styling/themes.d.ts +0 -7
  131. package/dist/styling/themes.d.ts.map +0 -1
  132. package/dist/styling-module.d.ts +0 -178
  133. package/dist/styling-module.d.ts.map +0 -1
  134. package/dist/styling.cjs +0 -2
  135. package/dist/styling.cjs.map +0 -1
  136. package/dist/styling.js +0 -146
  137. package/dist/styling.js.map +0 -1
  138. package/dist/terminal/color-converter.d.ts +0 -73
  139. package/dist/terminal/color-converter.d.ts.map +0 -1
  140. package/dist/terminal/formatter.d.ts +0 -20
  141. package/dist/terminal/formatter.d.ts.map +0 -1
  142. package/dist/terminal/terminal-renderer.d.ts +0 -77
  143. package/dist/terminal/terminal-renderer.d.ts.map +0 -1
  144. package/dist/transports/ConsoleTransport.d.ts +0 -9
  145. package/dist/transports/ConsoleTransport.d.ts.map +0 -1
  146. package/dist/transports/FileTransport.d.ts +0 -15
  147. package/dist/transports/FileTransport.d.ts.map +0 -1
  148. package/dist/transports/HttpTransport.d.ts +0 -16
  149. package/dist/transports/HttpTransport.d.ts.map +0 -1
  150. package/dist/transports/TransportManager.d.ts +0 -14
  151. package/dist/transports/TransportManager.d.ts.map +0 -1
  152. package/dist/transports/index.d.ts +0 -5
  153. package/dist/transports/index.d.ts.map +0 -1
  154. package/dist/types/core.d.ts +0 -380
  155. package/dist/types/core.d.ts.map +0 -1
  156. package/dist/types/handlers.d.ts +0 -85
  157. package/dist/types/handlers.d.ts.map +0 -1
  158. package/dist/types/hooks.d.ts +0 -36
  159. package/dist/types/hooks.d.ts.map +0 -1
  160. package/dist/types/index.d.ts +0 -11
  161. package/dist/types/index.d.ts.map +0 -1
  162. package/dist/types/serializers.d.ts +0 -25
  163. package/dist/types/serializers.d.ts.map +0 -1
  164. package/dist/types/transports.d.ts +0 -47
  165. package/dist/types/transports.d.ts.map +0 -1
  166. package/dist/utils/adapter.d.ts +0 -48
  167. package/dist/utils/adapter.d.ts.map +0 -1
  168. package/dist/utils/ansi-colors.d.ts +0 -156
  169. package/dist/utils/ansi-colors.d.ts.map +0 -1
  170. package/dist/utils/environment-detector.d.ts +0 -45
  171. package/dist/utils/environment-detector.d.ts.map +0 -1
  172. package/dist/utils/environment.d.ts +0 -47
  173. package/dist/utils/environment.d.ts.map +0 -1
  174. package/dist/utils/formatting.d.ts +0 -58
  175. package/dist/utils/formatting.d.ts.map +0 -1
  176. package/dist/utils/index.d.ts +0 -8
  177. package/dist/utils/index.d.ts.map +0 -1
  178. package/dist/utils/opentui-detection.d.ts +0 -34
  179. package/dist/utils/opentui-detection.d.ts.map +0 -1
  180. package/dist/utils/output.d.ts +0 -46
  181. package/dist/utils/output.d.ts.map +0 -1
  182. package/dist/utils/stackTrace.d.ts +0 -6
  183. package/dist/utils/stackTrace.d.ts.map +0 -1
  184. package/dist/utils/timestamps.d.ts +0 -20
  185. package/dist/utils/timestamps.d.ts.map +0 -1
  186. package/dist/vite.svg +0 -1
  187. package/dist/writers/BufferWriter.d.ts +0 -96
  188. package/dist/writers/BufferWriter.d.ts.map +0 -1
  189. package/dist/writers/index.d.ts +0 -6
  190. package/dist/writers/index.d.ts.map +0 -1
@@ -1,1127 +0,0 @@
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