@mks2508/better-logger 1.2.0 → 2.0.0

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