@mks2508/better-logger 5.0.0 → 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.
- package/dist/chunks/{Logger-Cbi1f10o.js → Logger-CKqzXDh3.js} +2 -2
- package/dist/chunks/{Logger-Cbi1f10o.js.map → Logger-CKqzXDh3.js.map} +1 -1
- package/dist/chunks/{Logger-BZ7B7OXE.js → Logger-D_vuKP4l.js} +2 -2
- package/dist/chunks/{Logger-BZ7B7OXE.js.map → Logger-D_vuKP4l.js.map} +1 -1
- package/dist/chunks/cli-module-B-njrTWb.js +2 -0
- package/dist/chunks/cli-module-B-njrTWb.js.map +1 -0
- package/dist/chunks/{cli-module-ClIJmaT8.js → cli-module-Cx7qotPY.js} +16 -9
- package/dist/chunks/cli-module-Cx7qotPY.js.map +1 -0
- package/dist/cli.cjs +1 -1
- package/dist/cli.js +1 -1
- package/dist/exports.cjs +1 -1
- package/dist/exports.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +3 -3
- package/dist/styling.cjs +1 -1
- package/dist/styling.js +2 -2
- package/dist/terminal/formatter.d.ts.map +1 -1
- package/package.json +5 -1
- package/.claude/settings.local.json +0 -48
- package/.github/workflows/ci-quality.yml +0 -357
- package/.github/workflows/docs-demo.yml +0 -119
- package/.github/workflows/releases-core.yml +0 -512
- package/.github/workflows/releases-full.yml +0 -582
- package/.github/workflows-backup/ci.yml +0 -221
- package/.github/workflows-backup/nightly.yml +0 -196
- package/.github/workflows-backup/release-optimized.yml +0 -373
- package/.github/workflows-backup/release.yml +0 -269
- package/.release-notes-0.2.0.md +0 -129
- package/.yamllint +0 -28
- package/CHANGELOG.json +0 -1076
- package/CHANGELOG.md +0 -209
- package/CLAUDE.md +0 -217
- package/bun.lock +0 -333
- package/demo.html +0 -847
- package/dist/chunks/cli-module-CadqgZ1Z.js +0 -2
- package/dist/chunks/cli-module-CadqgZ1Z.js.map +0 -1
- package/dist/chunks/cli-module-ClIJmaT8.js.map +0 -1
- package/docs/API.md +0 -918
- package/docs/CORE.md +0 -264
- package/docs/DEVELOPMENT.md +0 -731
- package/docs/EXPORTS.md +0 -467
- package/docs/PACKAGES.md +0 -244
- package/docs/STYLING.md +0 -405
- package/docs/_config.yml +0 -36
- package/docs/index.md +0 -179
- package/examples/README.md +0 -208
- package/examples/basic-logging.js +0 -75
- package/examples/data-export.js +0 -234
- package/examples/package.json +0 -16
- package/examples/performance-timing.js +0 -170
- package/examples/simplified-api.js +0 -124
- package/examples/styling-themes.js +0 -207
- package/index.html +0 -358
- package/packages/core/package.json +0 -57
- package/packages/exports/package.json +0 -41
- package/packages/nodejs-opentui/README.md +0 -232
- package/packages/nodejs-opentui/package.json +0 -72
- package/packages/nodejs-opentui/src/LogRenderer.ts +0 -171
- package/packages/nodejs-opentui/src/OpenTUILogHandler.ts +0 -178
- package/packages/nodejs-opentui/src/components/LogBadge.tsx +0 -131
- package/packages/nodejs-opentui/src/index.ts +0 -133
- package/packages/nodejs-opentui/src/types.ts +0 -158
- package/packages/nodejs-opentui/tsconfig.json +0 -20
- package/packages/styling/package.json +0 -41
- package/playground/demo-all.ts +0 -95
- package/playground/demo-box.ts +0 -85
- package/playground/demo-levels.ts +0 -56
- package/playground/demo-real-world.ts +0 -98
- package/playground/demo-spinner.ts +0 -77
- package/playground/demo-steps.ts +0 -72
- package/playground/demo-table.ts +0 -83
- package/project-utils/README.md +0 -172
- package/project-utils/auto-release-gemini.ts +0 -1193
- package/project-utils/auto-release-ui.ts +0 -1329
- package/project-utils/commit-generator.ts +0 -1385
- package/project-utils/commit-ui.ts +0 -264
- package/project-utils/git-utils.ts +0 -199
- package/project-utils/github-release-manager.ts +0 -466
- package/project-utils/project-config.ts +0 -260
- package/project-utils/prompt-templates.js +0 -345
- package/project-utils/prompt-templates.ts +0 -422
- package/project-utils/version-manager.ts +0 -1078
- package/public/vite.svg +0 -1
- package/src/Logger.ts +0 -1858
- package/src/ScopedLogger.ts +0 -256
- package/src/cli/CommandProcessor.ts +0 -248
- package/src/cli/commands/ConfigCommand.ts +0 -93
- package/src/cli/commands/ExportCommand.ts +0 -276
- package/src/cli/commands/HistoryCommand.ts +0 -117
- package/src/cli/commands/StatusCommand.ts +0 -112
- package/src/cli/commands/ThemeCommand.ts +0 -88
- package/src/cli/help.ts +0 -127
- package/src/cli/index.ts +0 -71
- package/src/cli-module.ts +0 -21
- package/src/cli-primitives/box.ts +0 -86
- package/src/cli-primitives/cli-table.ts +0 -62
- package/src/cli-primitives/divider.ts +0 -17
- package/src/cli-primitives/header.ts +0 -18
- package/src/cli-primitives/index.ts +0 -13
- package/src/cli-primitives/server-fallback.ts +0 -54
- package/src/cli-primitives/spinner.ts +0 -133
- package/src/cli-primitives/step.ts +0 -22
- package/src/constants.ts +0 -313
- package/src/core.ts +0 -397
- package/src/example.ts +0 -210
- package/src/exports-module.ts +0 -311
- package/src/handlers/AnalyticsLogHandler.ts +0 -22
- package/src/handlers/ExportLogHandler.ts +0 -610
- package/src/handlers/FileLogHandler.ts +0 -169
- package/src/handlers/RemoteLogHandler.ts +0 -42
- package/src/handlers/index.ts +0 -8
- package/src/hooks/HookManager.ts +0 -177
- package/src/hooks/index.ts +0 -1
- package/src/index.ts +0 -395
- package/src/main.ts +0 -196
- package/src/serializers/SerializerRegistry.ts +0 -173
- package/src/serializers/index.ts +0 -1
- package/src/style.css +0 -96
- package/src/styling/LogStyleBuilder.ts +0 -355
- package/src/styling/SemanticStyles.ts +0 -380
- package/src/styling/SmartPresets.ts +0 -288
- package/src/styling/StyleBuilder.ts +0 -319
- package/src/styling/StyleCache.ts +0 -131
- package/src/styling/banners.ts +0 -168
- package/src/styling/index.ts +0 -27
- package/src/styling/themes.ts +0 -235
- package/src/styling-module.ts +0 -244
- package/src/terminal/color-converter.ts +0 -315
- package/src/terminal/formatter.ts +0 -236
- package/src/terminal/terminal-renderer.ts +0 -342
- package/src/transports/ConsoleTransport.ts +0 -28
- package/src/transports/FileTransport.ts +0 -53
- package/src/transports/HttpTransport.ts +0 -56
- package/src/transports/TransportManager.ts +0 -130
- package/src/transports/index.ts +0 -4
- package/src/types/core.ts +0 -417
- package/src/types/handlers.ts +0 -95
- package/src/types/hooks.ts +0 -45
- package/src/types/index.ts +0 -83
- package/src/types/serializers.ts +0 -30
- package/src/types/transports.ts +0 -52
- package/src/typescript.svg +0 -1
- package/src/utils/adapter.ts +0 -291
- package/src/utils/ansi-colors.ts +0 -333
- package/src/utils/environment-detector.ts +0 -170
- package/src/utils/environment.ts +0 -94
- package/src/utils/formatting.ts +0 -332
- package/src/utils/index.ts +0 -33
- package/src/utils/opentui-detection.ts +0 -138
- package/src/utils/output.ts +0 -227
- package/src/utils/stackTrace.ts +0 -144
- package/src/utils/timestamps.ts +0 -80
- package/src/vite-env.d.ts +0 -1
- package/src/writers/BufferWriter.ts +0 -157
- package/src/writers/index.ts +0 -6
- package/test-core-browser.html +0 -237
- package/test-core-node.js +0 -63
- package/tests/test-conflict-resolution.ts +0 -391
- package/tests/validate-workflows.sh +0 -131
- package/tests/yaml-autofix.sh +0 -146
- package/tsconfig.json +0 -50
- package/vite.config.ts +0 -256
package/src/types/transports.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import type { LogLevel, StackInfo } from './core.js';
|
|
2
|
-
|
|
3
|
-
export interface TransportRecord {
|
|
4
|
-
level: LogLevel;
|
|
5
|
-
levelValue: number;
|
|
6
|
-
time: number;
|
|
7
|
-
msg: string;
|
|
8
|
-
prefix?: string;
|
|
9
|
-
location?: {
|
|
10
|
-
file: string;
|
|
11
|
-
line: number;
|
|
12
|
-
column: number;
|
|
13
|
-
function?: string;
|
|
14
|
-
};
|
|
15
|
-
[key: string]: any;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface TransportOptions {
|
|
19
|
-
level?: LogLevel;
|
|
20
|
-
transform?: (record: TransportRecord) => TransportRecord | null;
|
|
21
|
-
batchSize?: number;
|
|
22
|
-
flushInterval?: number;
|
|
23
|
-
[key: string]: any;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export interface TransportTarget {
|
|
27
|
-
target: string | ITransport;
|
|
28
|
-
options?: TransportOptions;
|
|
29
|
-
level?: LogLevel;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface ITransport {
|
|
33
|
-
readonly name: string;
|
|
34
|
-
write(record: TransportRecord): void | Promise<void>;
|
|
35
|
-
flush?(): void | Promise<void>;
|
|
36
|
-
close?(): void | Promise<void>;
|
|
37
|
-
isReady?(): boolean;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export interface IBufferedTransport extends ITransport {
|
|
41
|
-
readonly bufferSize: number;
|
|
42
|
-
readonly maxBufferSize: number;
|
|
43
|
-
flush(): Promise<void>;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export interface ITransportManager {
|
|
47
|
-
add(target: TransportTarget): string;
|
|
48
|
-
remove(id: string): boolean;
|
|
49
|
-
write(record: TransportRecord): Promise<void>;
|
|
50
|
-
flush(): Promise<void>;
|
|
51
|
-
close(): Promise<void>;
|
|
52
|
-
}
|
package/src/typescript.svg
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="32" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path fill="#007ACC" d="M0 128v128h256V0H0z"></path><path fill="#FFF" d="m56.612 128.85l-.081 10.483h33.32v94.68h23.568v-94.68h33.321v-10.28c0-5.69-.122-10.444-.284-10.566c-.122-.162-20.4-.244-44.983-.203l-44.74.122l-.121 10.443Zm149.955-10.742c6.501 1.625 11.459 4.51 16.01 9.224c2.357 2.52 5.851 7.111 6.136 8.208c.08.325-11.053 7.802-17.798 11.988c-.244.162-1.22-.894-2.317-2.52c-3.291-4.795-6.745-6.867-12.028-7.233c-7.76-.528-12.759 3.535-12.718 10.321c0 1.992.284 3.17 1.097 4.795c1.707 3.536 4.876 5.649 14.832 9.956c18.326 7.883 26.168 13.084 31.045 20.48c5.445 8.249 6.664 21.415 2.966 31.208c-4.063 10.646-14.14 17.879-28.323 20.276c-4.388.772-14.79.65-19.504-.203c-10.28-1.828-20.033-6.908-26.047-13.572c-2.357-2.6-6.949-9.387-6.664-9.874c.122-.163 1.178-.813 2.356-1.504c1.138-.65 5.446-3.129 9.509-5.485l7.355-4.267l1.544 2.276c2.154 3.29 6.867 7.801 9.712 9.305c8.167 4.307 19.383 3.698 24.909-1.26c2.357-2.153 3.332-4.388 3.332-7.68c0-2.966-.366-4.266-1.91-6.501c-1.99-2.845-6.054-5.242-17.595-10.24c-13.206-5.69-18.895-9.224-24.096-14.832c-3.007-3.25-5.852-8.452-7.03-12.8c-.975-3.617-1.22-12.678-.447-16.335c2.723-12.76 12.353-21.659 26.25-24.3c4.51-.853 14.994-.528 19.424.569Z"></path></svg>
|
package/src/utils/adapter.ts
DELETED
|
@@ -1,291 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CSS to ANSI Adapter - Converts CSS-based styles to ANSI terminal styles
|
|
3
|
-
* Bridges the gap between browser styling and terminal rendering
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import type { LogStyles } from '../types/index.js';
|
|
7
|
-
import type { ANSIStyle } from '../terminal/terminal-renderer.js';
|
|
8
|
-
import { TerminalRenderer } from '../terminal/terminal-renderer.js';
|
|
9
|
-
import type { LogLevel } from '../types/index.js';
|
|
10
|
-
import { getColorCapability } from './environment-detector.js';
|
|
11
|
-
|
|
12
|
-
export class CSS2ANSIAdapter {
|
|
13
|
-
private renderer: TerminalRenderer;
|
|
14
|
-
|
|
15
|
-
constructor() {
|
|
16
|
-
const colorCapability = getColorCapability();
|
|
17
|
-
this.renderer = new TerminalRenderer(colorCapability);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Convert LogStyles to ANSIStyle for terminal rendering
|
|
22
|
-
*/
|
|
23
|
-
adaptStyles(
|
|
24
|
-
level: LogLevel,
|
|
25
|
-
message: string,
|
|
26
|
-
timestamp?: string,
|
|
27
|
-
prefix?: string,
|
|
28
|
-
location?: string,
|
|
29
|
-
styles?: LogStyles,
|
|
30
|
-
presetName?: string
|
|
31
|
-
): ANSIStyle {
|
|
32
|
-
// Special handling for specific presets that need unique terminal representations
|
|
33
|
-
if (presetName) {
|
|
34
|
-
switch (presetName) {
|
|
35
|
-
case 'cyberpunk':
|
|
36
|
-
return this.renderer.renderCyberpunk(level, message, timestamp, prefix, location);
|
|
37
|
-
case 'minimal':
|
|
38
|
-
return this.renderer.renderMinimal(level, message, timestamp, prefix);
|
|
39
|
-
case 'production':
|
|
40
|
-
return this.adaptProductionStyles(level, message, timestamp, prefix, location, styles);
|
|
41
|
-
case 'debug':
|
|
42
|
-
return this.adaptDebugStyles(level, message, timestamp, prefix, location, styles);
|
|
43
|
-
case 'glassmorphism':
|
|
44
|
-
return this.adaptGlassmorphismStyles(level, message, timestamp, prefix, location, styles);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// Default adaptation using the renderer
|
|
49
|
-
return this.renderer.renderTerminal(level, message, timestamp, prefix, location, styles);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Adapt production preset for terminal
|
|
54
|
-
*/
|
|
55
|
-
private adaptProductionStyles(
|
|
56
|
-
level: LogLevel,
|
|
57
|
-
message: string,
|
|
58
|
-
timestamp?: string,
|
|
59
|
-
prefix?: string,
|
|
60
|
-
location?: string,
|
|
61
|
-
styles?: LogStyles
|
|
62
|
-
): ANSIStyle {
|
|
63
|
-
const reset = '\x1b[0m';
|
|
64
|
-
const levelChalk = this.renderer.getChalkForLevel(level);
|
|
65
|
-
|
|
66
|
-
const parts: string[] = [];
|
|
67
|
-
|
|
68
|
-
// Production: clean, essential info only
|
|
69
|
-
if (timestamp && styles?.timestamp?.show) {
|
|
70
|
-
parts.push(levelChalk.dim(timestamp));
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (styles?.level?.show) {
|
|
74
|
-
parts.push(levelChalk.color(`[${this.renderer['getLevelText'](level)}]`));
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// Skip prefix in production (as per preset config)
|
|
78
|
-
if (prefix && styles?.prefix?.show) {
|
|
79
|
-
parts.push(levelChalk.dim(`[${prefix}]`));
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (message && styles?.message?.show) {
|
|
83
|
-
parts.push(levelChalk.reset(message));
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// Skip location in production (as per preset config)
|
|
87
|
-
if (location && styles?.location?.show) {
|
|
88
|
-
parts.push(levelChalk.dim(`(${location})`));
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return {
|
|
92
|
-
text: parts.join(' ') + reset,
|
|
93
|
-
reset
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Adapt debug preset for terminal
|
|
99
|
-
*/
|
|
100
|
-
private adaptDebugStyles(
|
|
101
|
-
level: LogLevel,
|
|
102
|
-
message: string,
|
|
103
|
-
timestamp?: string,
|
|
104
|
-
prefix?: string,
|
|
105
|
-
location?: string,
|
|
106
|
-
styles?: LogStyles
|
|
107
|
-
): ANSIStyle {
|
|
108
|
-
const reset = '\x1b[0m';
|
|
109
|
-
const levelChalk = this.renderer.getChalkForLevel(level);
|
|
110
|
-
|
|
111
|
-
const parts: string[] = [];
|
|
112
|
-
|
|
113
|
-
// Debug: monospace fonts, detailed info, compact layout
|
|
114
|
-
if (timestamp && styles?.timestamp?.show) {
|
|
115
|
-
parts.push(levelChalk.dim(timestamp));
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (styles?.level?.show) {
|
|
119
|
-
if (styles?.level?.style === 'compact') {
|
|
120
|
-
parts.push(levelChalk.color(`[${this.renderer['getLevelText'](level)}]`));
|
|
121
|
-
} else {
|
|
122
|
-
parts.push(levelChalk.bold(`[${this.renderer['getLevelText'](level)}]`));
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if (prefix && styles?.prefix?.show) {
|
|
127
|
-
if (styles?.prefix?.style === 'compact') {
|
|
128
|
-
parts.push(levelChalk.cyan.dim(`[${prefix}]`));
|
|
129
|
-
} else {
|
|
130
|
-
parts.push(levelChalk.cyan.bold(`[${prefix}]`));
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
if (message && styles?.message?.show) {
|
|
135
|
-
parts.push(levelChalk.reset(message));
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// Debug usually shows location
|
|
139
|
-
if (location && styles?.location?.show) {
|
|
140
|
-
if (styles?.location?.style === 'clickable') {
|
|
141
|
-
parts.push(levelChalk.dim(`${location} (clickable)`));
|
|
142
|
-
} else {
|
|
143
|
-
parts.push(levelChalk.dim(`(${location})`));
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
return {
|
|
148
|
-
text: parts.join(' ') + reset,
|
|
149
|
-
reset
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Adapt glassmorphism preset for terminal
|
|
155
|
-
*/
|
|
156
|
-
private adaptGlassmorphismStyles(
|
|
157
|
-
level: LogLevel,
|
|
158
|
-
message: string,
|
|
159
|
-
timestamp?: string,
|
|
160
|
-
prefix?: string,
|
|
161
|
-
location?: string,
|
|
162
|
-
styles?: LogStyles
|
|
163
|
-
): ANSIStyle {
|
|
164
|
-
const reset = '\x1b[0m';
|
|
165
|
-
const levelChalk = this.renderer.getChalkForLevel(level);
|
|
166
|
-
|
|
167
|
-
const parts: string[] = [];
|
|
168
|
-
|
|
169
|
-
// Glassmorphism: subtle, transparent effects
|
|
170
|
-
if (timestamp && styles?.timestamp?.show) {
|
|
171
|
-
parts.push(levelChalk.dim(timestamp));
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
if (styles?.level?.show) {
|
|
175
|
-
// Subtle level styling with dim background effect
|
|
176
|
-
parts.push(levelChalk.bgGray(` ${this.renderer['getLevelText'](level)} `));
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
if (prefix && styles?.prefix?.show) {
|
|
180
|
-
parts.push(levelChalk.bgBlue(`[${prefix}]`));
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
if (message && styles?.message?.show) {
|
|
184
|
-
parts.push(levelChalk.reset(message));
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
if (location && styles?.location?.show) {
|
|
188
|
-
parts.push(levelChalk.dim(`(${location})`));
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
return {
|
|
192
|
-
text: parts.join(' ') + reset,
|
|
193
|
-
reset
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* Convert CSS color values to ANSI-friendly colors
|
|
199
|
-
*/
|
|
200
|
-
adaptColor(cssColor: string): string {
|
|
201
|
-
// Handle hex colors
|
|
202
|
-
if (cssColor.startsWith('#')) {
|
|
203
|
-
return cssColor; // TerminalRenderer will handle this
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
// Handle RGB colors
|
|
207
|
-
if (cssColor.startsWith('rgb(')) {
|
|
208
|
-
return cssColor; // TerminalRenderer will handle this
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
// Handle CSS gradients - extract primary color
|
|
212
|
-
if (cssColor.includes('gradient')) {
|
|
213
|
-
return this.extractColorFromGradient(cssColor);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
// Handle CSS color names
|
|
217
|
-
return this.cssNameToANSI(cssColor);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* Extract primary color from CSS gradient
|
|
222
|
-
*/
|
|
223
|
-
private extractColorFromGradient(gradient: string): string {
|
|
224
|
-
// Extract first color from linear-gradient
|
|
225
|
-
const match = gradient.match(/#[0-9a-fA-F]{6}|rgb\([^)]+\)/);
|
|
226
|
-
return match ? match[0] : '#ffffff';
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
/**
|
|
230
|
-
* Convert CSS color names to ANSI-compatible names
|
|
231
|
-
*/
|
|
232
|
-
private cssNameToANSI(cssColor: string): string {
|
|
233
|
-
const colorMap: Record<string, string> = {
|
|
234
|
-
'black': 'black',
|
|
235
|
-
'white': 'white',
|
|
236
|
-
'red': 'red',
|
|
237
|
-
'green': 'green',
|
|
238
|
-
'blue': 'blue',
|
|
239
|
-
'yellow': 'yellow',
|
|
240
|
-
'cyan': 'cyan',
|
|
241
|
-
'magenta': 'magenta',
|
|
242
|
-
'gray': 'gray',
|
|
243
|
-
'grey': 'gray',
|
|
244
|
-
'orange': 'yellow',
|
|
245
|
-
'purple': 'magenta',
|
|
246
|
-
'pink': 'red',
|
|
247
|
-
'brown': 'yellow',
|
|
248
|
-
'lightblue': 'cyan',
|
|
249
|
-
'lightgreen': 'green',
|
|
250
|
-
'lightgray': 'gray',
|
|
251
|
-
'lightgrey': 'gray'
|
|
252
|
-
};
|
|
253
|
-
|
|
254
|
-
return colorMap[cssColor.toLowerCase()] || 'white';
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
/**
|
|
258
|
-
* Check if a style should be rendered in terminal
|
|
259
|
-
*/
|
|
260
|
-
shouldRenderStyle(styleType: string, styles?: LogStyles): boolean {
|
|
261
|
-
if (!styles) return true;
|
|
262
|
-
|
|
263
|
-
const styleConfig = (styles as any)[styleType];
|
|
264
|
-
return styleConfig?.show !== false;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
/**
|
|
268
|
-
* Get renderer instance for advanced usage
|
|
269
|
-
*/
|
|
270
|
-
getRenderer(): TerminalRenderer {
|
|
271
|
-
return this.renderer;
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
// Singleton instance for consistent styling
|
|
276
|
-
export const css2ansiAdapter = new CSS2ANSIAdapter();
|
|
277
|
-
|
|
278
|
-
/**
|
|
279
|
-
* Convenience function for quick style adaptation
|
|
280
|
-
*/
|
|
281
|
-
export function adaptToTerminal(
|
|
282
|
-
level: LogLevel,
|
|
283
|
-
message: string,
|
|
284
|
-
timestamp?: string,
|
|
285
|
-
prefix?: string,
|
|
286
|
-
location?: string,
|
|
287
|
-
styles?: LogStyles,
|
|
288
|
-
presetName?: string
|
|
289
|
-
): ANSIStyle {
|
|
290
|
-
return css2ansiAdapter.adaptStyles(level, message, timestamp, prefix, location, styles, presetName);
|
|
291
|
-
}
|
package/src/utils/ansi-colors.ts
DELETED
|
@@ -1,333 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview ANSI color utilities for terminal environments
|
|
3
|
-
* @since 1.0.0
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import type { LogLevel } from '../types/index.js';
|
|
7
|
-
import { supportsANSIColors } from './environment.js';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* ANSI color codes for terminal styling
|
|
11
|
-
*/
|
|
12
|
-
export const ANSI_CODES = {
|
|
13
|
-
// Colors
|
|
14
|
-
black: 30,
|
|
15
|
-
red: 31,
|
|
16
|
-
green: 32,
|
|
17
|
-
yellow: 33,
|
|
18
|
-
blue: 34,
|
|
19
|
-
magenta: 35,
|
|
20
|
-
cyan: 36,
|
|
21
|
-
white: 37,
|
|
22
|
-
|
|
23
|
-
// Bright colors
|
|
24
|
-
brightBlack: 90,
|
|
25
|
-
brightRed: 91,
|
|
26
|
-
brightGreen: 92,
|
|
27
|
-
brightYellow: 93,
|
|
28
|
-
brightBlue: 94,
|
|
29
|
-
brightMagenta: 95,
|
|
30
|
-
brightCyan: 96,
|
|
31
|
-
brightWhite: 97,
|
|
32
|
-
|
|
33
|
-
// Background colors
|
|
34
|
-
bgBlack: 40,
|
|
35
|
-
bgRed: 41,
|
|
36
|
-
bgGreen: 42,
|
|
37
|
-
bgYellow: 43,
|
|
38
|
-
bgBlue: 44,
|
|
39
|
-
bgMagenta: 45,
|
|
40
|
-
bgCyan: 46,
|
|
41
|
-
bgWhite: 47,
|
|
42
|
-
|
|
43
|
-
// Background bright colors
|
|
44
|
-
bgBrightBlack: 100,
|
|
45
|
-
bgBrightRed: 101,
|
|
46
|
-
bgBrightGreen: 102,
|
|
47
|
-
bgBrightYellow: 103,
|
|
48
|
-
bgBrightBlue: 104,
|
|
49
|
-
bgBrightMagenta: 105,
|
|
50
|
-
bgBrightCyan: 106,
|
|
51
|
-
bgBrightWhite: 107,
|
|
52
|
-
|
|
53
|
-
// Styles
|
|
54
|
-
reset: 0,
|
|
55
|
-
bold: 1,
|
|
56
|
-
dim: 2,
|
|
57
|
-
italic: 3,
|
|
58
|
-
underline: 4,
|
|
59
|
-
blink: 5,
|
|
60
|
-
inverse: 7,
|
|
61
|
-
hidden: 8,
|
|
62
|
-
strikethrough: 9,
|
|
63
|
-
|
|
64
|
-
// Reset specific
|
|
65
|
-
resetBold: 22,
|
|
66
|
-
resetDim: 22,
|
|
67
|
-
resetItalic: 23,
|
|
68
|
-
resetUnderline: 24,
|
|
69
|
-
resetBlink: 25,
|
|
70
|
-
resetInverse: 27,
|
|
71
|
-
resetHidden: 28,
|
|
72
|
-
resetStrikethrough: 29
|
|
73
|
-
} as const;
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* ANSI color presets for different log levels
|
|
77
|
-
*/
|
|
78
|
-
export const ANSI_LEVEL_STYLES: Record<LogLevel | 'success', {
|
|
79
|
-
color: number;
|
|
80
|
-
background?: number;
|
|
81
|
-
styles: number[];
|
|
82
|
-
emoji: string;
|
|
83
|
-
}> = {
|
|
84
|
-
debug: {
|
|
85
|
-
color: ANSI_CODES.brightBlack,
|
|
86
|
-
styles: [ANSI_CODES.dim],
|
|
87
|
-
emoji: '🔍'
|
|
88
|
-
},
|
|
89
|
-
info: {
|
|
90
|
-
color: ANSI_CODES.blue,
|
|
91
|
-
styles: [ANSI_CODES.bold],
|
|
92
|
-
emoji: 'ℹ️'
|
|
93
|
-
},
|
|
94
|
-
warn: {
|
|
95
|
-
color: ANSI_CODES.yellow,
|
|
96
|
-
background: ANSI_CODES.bgYellow,
|
|
97
|
-
styles: [ANSI_CODES.bold, ANSI_CODES.black],
|
|
98
|
-
emoji: '⚠️'
|
|
99
|
-
},
|
|
100
|
-
error: {
|
|
101
|
-
color: ANSI_CODES.red,
|
|
102
|
-
background: ANSI_CODES.bgRed,
|
|
103
|
-
styles: [ANSI_CODES.bold],
|
|
104
|
-
emoji: '❌'
|
|
105
|
-
},
|
|
106
|
-
critical: {
|
|
107
|
-
color: ANSI_CODES.white,
|
|
108
|
-
background: ANSI_CODES.bgRed,
|
|
109
|
-
styles: [ANSI_CODES.bold, ANSI_CODES.blink],
|
|
110
|
-
emoji: '🚨'
|
|
111
|
-
},
|
|
112
|
-
success: {
|
|
113
|
-
color: ANSI_CODES.green,
|
|
114
|
-
background: ANSI_CODES.bgGreen,
|
|
115
|
-
styles: [ANSI_CODES.bold],
|
|
116
|
-
emoji: '✅'
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Creates an ANSI escape sequence
|
|
122
|
-
*/
|
|
123
|
-
function ansi(code: number | number[]): string {
|
|
124
|
-
const codes = Array.isArray(code) ? code : [code];
|
|
125
|
-
return `\x1b[${codes.join(';')}m`;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Applies ANSI styling to text
|
|
130
|
-
*/
|
|
131
|
-
export function ansiStyle(text: string, codes: number[]): string {
|
|
132
|
-
if (!supportsANSIColors()) return text;
|
|
133
|
-
return `${ansi(codes)}${text}${ansi(ANSI_CODES.reset)}`;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Applies color to text
|
|
138
|
-
*/
|
|
139
|
-
export function ansiColor(text: string, color: number): string {
|
|
140
|
-
return ansiStyle(text, [color]);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Applies background color to text
|
|
145
|
-
*/
|
|
146
|
-
export function ansiBackground(text: string, bg: number, color?: number): string {
|
|
147
|
-
if (color) {
|
|
148
|
-
return ansiStyle(text, [color, bg]);
|
|
149
|
-
}
|
|
150
|
-
return ansiStyle(text, [bg]);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Makes text bold
|
|
155
|
-
*/
|
|
156
|
-
export function ansiBold(text: string): string {
|
|
157
|
-
return ansiStyle(text, [ANSI_CODES.bold]);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* Makes text dim
|
|
162
|
-
*/
|
|
163
|
-
export function ansiDim(text: string): string {
|
|
164
|
-
return ansiStyle(text, [ANSI_CODES.dim]);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* Underlines text
|
|
169
|
-
*/
|
|
170
|
-
export function ansiUnderline(text: string): string {
|
|
171
|
-
return ansiStyle(text, [ANSI_CODES.underline]);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Specialized formatters for different contexts
|
|
176
|
-
*/
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Format timestamp for terminal
|
|
180
|
-
*/
|
|
181
|
-
export function formatTimestampANSI(timestamp: string): string {
|
|
182
|
-
return ansiColor(timestamp, ANSI_CODES.brightBlack);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
* Format log level for terminal
|
|
187
|
-
*/
|
|
188
|
-
export function formatLogLevelANSI(level: LogLevel, useEmojis: boolean = true): string {
|
|
189
|
-
const style = ANSI_LEVEL_STYLES[level];
|
|
190
|
-
const emoji = useEmojis ? style.emoji : '';
|
|
191
|
-
const label = level.toUpperCase().padEnd(8);
|
|
192
|
-
|
|
193
|
-
if (!supportsANSIColors()) {
|
|
194
|
-
return `${emoji} ${label}`;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
let codes = [style.color, ...style.styles];
|
|
198
|
-
if (style.background) {
|
|
199
|
-
codes.push(style.background);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
return ansiStyle(`${emoji} ${label}`, codes);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* Format success message for terminal
|
|
207
|
-
*/
|
|
208
|
-
export function formatSuccessANSI(message: string, useEmojis: boolean = true): string {
|
|
209
|
-
const style = ANSI_LEVEL_STYLES.success;
|
|
210
|
-
const emoji = useEmojis ? style.emoji : '';
|
|
211
|
-
|
|
212
|
-
if (!supportsANSIColors()) {
|
|
213
|
-
return `${emoji} SUCCESS: ${message}`;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
const prefix = ansiStyle(`${emoji} SUCCESS:`, [style.color, ...style.styles]);
|
|
217
|
-
return `${prefix} ${message}`;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* Format prefix for terminal
|
|
222
|
-
*/
|
|
223
|
-
export function formatPrefixANSI(prefix: string): string {
|
|
224
|
-
if (!supportsANSIColors()) {
|
|
225
|
-
return `[${prefix}]`;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
return ansiStyle(`[${prefix}]`, [ANSI_CODES.cyan, ANSI_CODES.bold]);
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* Format file location for terminal
|
|
233
|
-
*/
|
|
234
|
-
export function formatLocationANSI(location: string): string {
|
|
235
|
-
if (!supportsANSIColors()) {
|
|
236
|
-
return `(${location})`;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
return ansiColor(`(${location})`, ANSI_CODES.brightBlack);
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
/**
|
|
243
|
-
* Format build-specific messages
|
|
244
|
-
*/
|
|
245
|
-
export const BUILD_FORMATTERS = {
|
|
246
|
-
/**
|
|
247
|
-
* Format compilation step
|
|
248
|
-
*/
|
|
249
|
-
compilation: (step: string, status: 'starting' | 'completed' | 'failed' = 'starting') => {
|
|
250
|
-
const stepText = ansiBold(step);
|
|
251
|
-
|
|
252
|
-
switch (status) {
|
|
253
|
-
case 'starting':
|
|
254
|
-
return `${ansiColor('⚙️', ANSI_CODES.blue)} ${stepText}...`;
|
|
255
|
-
case 'completed':
|
|
256
|
-
return `${ansiColor('✓', ANSI_CODES.green)} ${stepText} ${ansiColor('completed', ANSI_CODES.green)}`;
|
|
257
|
-
case 'failed':
|
|
258
|
-
return `${ansiColor('✗', ANSI_CODES.red)} ${stepText} ${ansiColor('failed', ANSI_CODES.red)}`;
|
|
259
|
-
default:
|
|
260
|
-
return stepText;
|
|
261
|
-
}
|
|
262
|
-
},
|
|
263
|
-
|
|
264
|
-
/**
|
|
265
|
-
* Format warning message
|
|
266
|
-
*/
|
|
267
|
-
warning: (message: string) => {
|
|
268
|
-
return `${ansiColor('⚠', ANSI_CODES.yellow)} ${ansiStyle('Warning:', [ANSI_CODES.yellow, ANSI_CODES.bold])} ${message}`;
|
|
269
|
-
},
|
|
270
|
-
|
|
271
|
-
/**
|
|
272
|
-
* Format error message
|
|
273
|
-
*/
|
|
274
|
-
error: (message: string) => {
|
|
275
|
-
return `${ansiColor('✗', ANSI_CODES.red)} ${ansiStyle('Error:', [ANSI_CODES.red, ANSI_CODES.bold])} ${message}`;
|
|
276
|
-
},
|
|
277
|
-
|
|
278
|
-
/**
|
|
279
|
-
* Format success message
|
|
280
|
-
*/
|
|
281
|
-
success: (message: string) => {
|
|
282
|
-
return `${ansiColor('✓', ANSI_CODES.green)} ${ansiColor(message, ANSI_CODES.green)}`;
|
|
283
|
-
},
|
|
284
|
-
|
|
285
|
-
/**
|
|
286
|
-
* Format info message
|
|
287
|
-
*/
|
|
288
|
-
info: (message: string) => {
|
|
289
|
-
return `${ansiColor('ℹ', ANSI_CODES.blue)} ${message}`;
|
|
290
|
-
}
|
|
291
|
-
};
|
|
292
|
-
|
|
293
|
-
/**
|
|
294
|
-
* Terminal-friendly emoji alternatives for environments that don't support them
|
|
295
|
-
*/
|
|
296
|
-
export const EMOJI_ALTERNATIVES = {
|
|
297
|
-
'🔍': '[DEBUG]',
|
|
298
|
-
'ℹ️': '[INFO]',
|
|
299
|
-
'⚠️': '[WARN]',
|
|
300
|
-
'❌': '[ERROR]',
|
|
301
|
-
'🚨': '[CRITICAL]',
|
|
302
|
-
'✅': '[OK]',
|
|
303
|
-
'✓': '[OK]',
|
|
304
|
-
'✗': '[FAIL]',
|
|
305
|
-
'⚙️': '[BUILD]',
|
|
306
|
-
'📦': '[PKG]'
|
|
307
|
-
};
|
|
308
|
-
|
|
309
|
-
/**
|
|
310
|
-
* Replace emojis with text alternatives for non-emoji terminals
|
|
311
|
-
*/
|
|
312
|
-
export function sanitizeEmojis(text: string): string {
|
|
313
|
-
// Check if we're in a terminal that likely supports emojis
|
|
314
|
-
const isModernTerminal = process.env.TERM &&
|
|
315
|
-
(process.env.TERM.includes('xterm') ||
|
|
316
|
-
process.env.TERM.includes('screen') ||
|
|
317
|
-
process.env.TERM.includes('tmux'));
|
|
318
|
-
|
|
319
|
-
const isCI = process.env.CI || process.env.GITHUB_ACTIONS || process.env.JENKINS_URL;
|
|
320
|
-
|
|
321
|
-
// Use emojis if we have a modern terminal and not in CI
|
|
322
|
-
if (isModernTerminal && !isCI) {
|
|
323
|
-
return text;
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
// Replace emojis with text alternatives
|
|
327
|
-
let result = text;
|
|
328
|
-
Object.entries(EMOJI_ALTERNATIVES).forEach(([emoji, alt]) => {
|
|
329
|
-
result = result.replace(new RegExp(emoji, 'g'), alt);
|
|
330
|
-
});
|
|
331
|
-
|
|
332
|
-
return result;
|
|
333
|
-
}
|