@mks2508/better-logger 0.0.1 → 0.0.2-alpha.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/.claude/settings.local.json +10 -1
- package/.github/workflows/ci.yml +319 -0
- package/.github/workflows/release.yml +269 -0
- package/.npmrc.bak +1 -0
- package/README.md +577 -0
- package/demo.html +840 -0
- package/dist/chunks/Logger-BQhMKy_T.js +2 -0
- package/dist/chunks/Logger-BQhMKy_T.js.map +1 -0
- package/dist/chunks/Logger-BrFKFZcD.js +978 -0
- package/dist/chunks/Logger-BrFKFZcD.js.map +1 -0
- package/dist/chunks/core-2opW4Pi3.js +194 -0
- package/dist/chunks/core-2opW4Pi3.js.map +1 -0
- package/dist/chunks/core-DyugwSYZ.js +4 -0
- package/dist/chunks/core-DyugwSYZ.js.map +1 -0
- package/dist/chunks/exports-BNP3R7dp.js +421 -0
- package/dist/chunks/exports-BNP3R7dp.js.map +1 -0
- package/dist/chunks/exports-U1xLBXrY.js +2 -0
- package/dist/chunks/exports-U1xLBXrY.js.map +1 -0
- package/dist/chunks/styling-DhUDzwlE.js +654 -0
- package/dist/chunks/styling-DhUDzwlE.js.map +1 -0
- package/dist/chunks/styling-tmRDI28D.js +2 -0
- package/dist/chunks/styling-tmRDI28D.js.map +1 -0
- package/dist/core.cjs +2 -0
- package/dist/core.cjs.map +1 -0
- package/dist/core.js +244 -0
- package/dist/core.js.map +1 -0
- package/dist/exports.cjs +2 -0
- package/dist/exports.cjs.map +1 -0
- package/dist/exports.js +237 -0
- package/dist/exports.js.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.js +105 -0
- package/dist/index.js.map +1 -0
- package/dist/styling.cjs +2 -0
- package/dist/styling.cjs.map +1 -0
- package/dist/styling.js +146 -0
- package/dist/styling.js.map +1 -0
- package/dist/types/core.d.ts +211 -0
- package/dist/types/exports.d.ts +600 -0
- package/dist/types/index.d.ts +675 -0
- package/dist/types/styling.d.ts +751 -0
- package/docs/CORE.md +264 -0
- package/docs/EXPORTS.md +467 -0
- package/docs/STYLING.md +405 -0
- package/index.html +28 -4
- package/package.json +37 -4
- package/src/Logger.ts +28 -8
- package/src/cli/CommandProcessor.ts +2 -2
- package/src/cli/commands/ExportCommand.ts +5 -0
- package/src/cli/commands/StatusCommand.ts +11 -10
- package/src/core.ts +320 -0
- package/src/example.ts +184 -62
- package/src/exports-module.ts +311 -0
- package/src/handlers/ExportLogHandler.ts +34 -13
- package/src/index.ts +97 -79
- package/src/main.ts +77 -7
- package/src/styling-module.ts +244 -0
- package/src/utils/stackTrace.ts +39 -10
- package/src/utils/timestamps.ts +1 -1
- package/tsconfig.json +40 -14
- package/vite.config.ts +84 -0
- package/dist/assets/index-DxvJByYN.js +0 -183
- package/dist/index.html +0 -334
package/src/main.ts
CHANGED
|
@@ -14,10 +14,29 @@ import {
|
|
|
14
14
|
createScopedLogger,
|
|
15
15
|
cli,
|
|
16
16
|
setTheme,
|
|
17
|
-
|
|
17
|
+
setBannerType,
|
|
18
|
+
showBanner,
|
|
19
|
+
logWithSVG,
|
|
20
|
+
logAnimated,
|
|
21
|
+
createStyle,
|
|
22
|
+
stylePresets
|
|
23
|
+
} from './index.js';
|
|
18
24
|
|
|
19
|
-
|
|
20
|
-
|
|
25
|
+
import {
|
|
26
|
+
demonstrateBanners,
|
|
27
|
+
demonstrateThemes,
|
|
28
|
+
demonstrateSVG,
|
|
29
|
+
demonstrateAnimations,
|
|
30
|
+
demonstrateCLI,
|
|
31
|
+
demonstrateExports,
|
|
32
|
+
demonstrateAllFeatures as demoAllFeatures
|
|
33
|
+
} from './example.js';
|
|
34
|
+
|
|
35
|
+
console.log('%cBetter Logger Demo Ready! 🚀',
|
|
36
|
+
'background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 10px 20px; border-radius: 8px; font-weight: bold; font-size: 14px;');
|
|
37
|
+
|
|
38
|
+
console.log('📋 Available test functions: testDebug(), testBanners(), testThemes(), and more!');
|
|
39
|
+
console.log('💻 CLI Available: cli("/help") for commands');
|
|
21
40
|
|
|
22
41
|
function testDebug() {
|
|
23
42
|
debug("This is a debug message.", { user: "test", id: 123 });
|
|
@@ -86,8 +105,33 @@ function testTrace() {
|
|
|
86
105
|
innerFunction();
|
|
87
106
|
}
|
|
88
107
|
|
|
108
|
+
// Visual feature tests
|
|
109
|
+
function testBanners() {
|
|
110
|
+
demonstrateBanners();
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function testThemes() {
|
|
114
|
+
demonstrateThemes();
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function testSVG() {
|
|
118
|
+
demonstrateSVG();
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function testAnimations() {
|
|
122
|
+
demonstrateAnimations();
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function testCLI() {
|
|
126
|
+
demonstrateCLI();
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function testExports() {
|
|
130
|
+
demonstrateExports();
|
|
131
|
+
}
|
|
132
|
+
|
|
89
133
|
function testAllFeatures() {
|
|
90
|
-
group("🌟 Demonstrating
|
|
134
|
+
group("🌟 Demonstrating Core Logger Features");
|
|
91
135
|
testDebug();
|
|
92
136
|
testInfo();
|
|
93
137
|
testWarn();
|
|
@@ -100,10 +144,16 @@ function testAllFeatures() {
|
|
|
100
144
|
testScopedLogger();
|
|
101
145
|
testTrace();
|
|
102
146
|
groupEnd();
|
|
147
|
+
|
|
148
|
+
setTimeout(() => {
|
|
149
|
+
info('🎨 Running visual features demo...');
|
|
150
|
+
demoAllFeatures();
|
|
151
|
+
}, 2000);
|
|
103
152
|
}
|
|
104
153
|
|
|
105
154
|
// Expose functions to global scope for onclick attributes in index.html
|
|
106
155
|
if (typeof window !== 'undefined') {
|
|
156
|
+
// Core logging tests
|
|
107
157
|
(window as any).testDebug = testDebug;
|
|
108
158
|
(window as any).testInfo = testInfo;
|
|
109
159
|
(window as any).testWarn = testWarn;
|
|
@@ -117,10 +167,30 @@ if (typeof window !== 'undefined') {
|
|
|
117
167
|
(window as any).testTrace = testTrace;
|
|
118
168
|
(window as any).testAllFeatures = testAllFeatures;
|
|
119
169
|
|
|
120
|
-
//
|
|
170
|
+
// Visual feature tests
|
|
171
|
+
(window as any).testBanners = testBanners;
|
|
172
|
+
(window as any).testThemes = testThemes;
|
|
173
|
+
(window as any).testSVG = testSVG;
|
|
174
|
+
(window as any).testAnimations = testAnimations;
|
|
175
|
+
(window as any).testCLI = testCLI;
|
|
176
|
+
(window as any).testExports = testExports;
|
|
177
|
+
|
|
178
|
+
// Direct access to library functions
|
|
121
179
|
(window as any).cli = cli;
|
|
122
180
|
(window as any).setTheme = setTheme;
|
|
181
|
+
(window as any).setBannerType = setBannerType;
|
|
182
|
+
(window as any).showBanner = showBanner;
|
|
183
|
+
(window as any).logWithSVG = logWithSVG;
|
|
184
|
+
(window as any).logAnimated = logAnimated;
|
|
185
|
+
(window as any).createStyle = createStyle;
|
|
186
|
+
(window as any).stylePresets = stylePresets;
|
|
123
187
|
|
|
124
|
-
// Display
|
|
125
|
-
|
|
188
|
+
// Display welcome info
|
|
189
|
+
setTimeout(() => {
|
|
190
|
+
console.log('%c💡 Quick Start Guide', stylePresets.info);
|
|
191
|
+
console.log('🎨 Visual: testBanners(), testThemes(), testSVG(), testAnimations()');
|
|
192
|
+
console.log('📊 Core: testTable(), testGrouping(), testTiming(), testTrace()');
|
|
193
|
+
console.log('💻 CLI: cli("/help") - Try commands like "/theme neon", "/banner ascii"');
|
|
194
|
+
console.log('🌟 Full Demo: testAllFeatures()');
|
|
195
|
+
}, 1000);
|
|
126
196
|
}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Styling Module - Advanced visual features for Better Logger
|
|
3
|
+
* @version 0.0.1
|
|
4
|
+
*
|
|
5
|
+
* This module provides advanced styling features including SVG support, CSS animations,
|
|
6
|
+
* themed banners, and visual enhancements for console logging.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
// Import core logger
|
|
10
|
+
import { Logger } from './Logger.js';
|
|
11
|
+
|
|
12
|
+
// Styling imports
|
|
13
|
+
import {
|
|
14
|
+
StyleBuilder,
|
|
15
|
+
StylePresets,
|
|
16
|
+
THEME_PRESETS,
|
|
17
|
+
THEME_BANNERS,
|
|
18
|
+
displayInitBanner,
|
|
19
|
+
BANNER_VARIANTS
|
|
20
|
+
} from './styling/index.js';
|
|
21
|
+
|
|
22
|
+
// Types
|
|
23
|
+
import type {
|
|
24
|
+
ThemeVariant,
|
|
25
|
+
BannerType,
|
|
26
|
+
StyleOptions
|
|
27
|
+
} from './types/index.js';
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Enhanced Logger with advanced styling capabilities
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* import { StyledLogger } from '@mks2508/better-logger/styling';
|
|
35
|
+
*
|
|
36
|
+
* const logger = new StyledLogger();
|
|
37
|
+
* logger.setTheme('neon');
|
|
38
|
+
* logger.logAnimated('🌟 Animated message!');
|
|
39
|
+
* logger.logWithSVG('Custom SVG Logo', svgContent);
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export class StyledLogger extends Logger {
|
|
43
|
+
/**
|
|
44
|
+
* Log with SVG background image
|
|
45
|
+
*
|
|
46
|
+
* @param message - The message to log
|
|
47
|
+
* @param svgContent - SVG content as string (optional)
|
|
48
|
+
* @param options - Styling options
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* logger.logWithSVG('My App', '<svg>...</svg>', {
|
|
53
|
+
* width: 400,
|
|
54
|
+
* height: 80,
|
|
55
|
+
* padding: '40px 200px'
|
|
56
|
+
* });
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
logWithSVG(message: string, svgContent?: string, options: StyleOptions = {}): void {
|
|
60
|
+
super.logWithSVG(message, svgContent, options);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Log with animated background gradient
|
|
65
|
+
*
|
|
66
|
+
* @param message - The message to log
|
|
67
|
+
* @param duration - Animation duration in seconds
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```typescript
|
|
71
|
+
* logger.logAnimated('🚀 Loading...', 2);
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
logAnimated(message: string, duration: number = 3): void {
|
|
75
|
+
super.logAnimated(message, duration);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Display banner with specified type
|
|
80
|
+
*
|
|
81
|
+
* @param bannerType - Type of banner to display
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* logger.showBanner('animated');
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
showBanner(bannerType?: BannerType): void {
|
|
89
|
+
super.showBanner(bannerType);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Set banner type for initialization display
|
|
94
|
+
*
|
|
95
|
+
* @param bannerType - Type of banner to display
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```typescript
|
|
99
|
+
* logger.setBannerType('svg');
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
setBannerType(bannerType: BannerType): void {
|
|
103
|
+
super.setBannerType(bannerType);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Sets the logger theme with visual banner
|
|
108
|
+
*
|
|
109
|
+
* @param theme - Theme variant to apply
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```typescript
|
|
113
|
+
* logger.setTheme('cyberpunk'); // Shows themed banner
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
setTheme(theme: ThemeVariant): void {
|
|
117
|
+
super.setTheme(theme);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Create singleton instance
|
|
122
|
+
const styledLogger = new StyledLogger();
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Utility functions for creating custom styles
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```typescript
|
|
129
|
+
* import { createStyle, StyleBuilder } from '@mks2508/better-logger/styling';
|
|
130
|
+
*
|
|
131
|
+
* const myStyle = createStyle()
|
|
132
|
+
* .bg('linear-gradient(45deg, #ff6b6b, #feca57)')
|
|
133
|
+
* .color('white')
|
|
134
|
+
* .padding('10px')
|
|
135
|
+
* .build();
|
|
136
|
+
*
|
|
137
|
+
* console.log('%cCustom Message', myStyle);
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
export const createStyle = () => new StyleBuilder();
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Pre-built style presets
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* ```typescript
|
|
147
|
+
* import { stylePresets } from '@mks2508/better-logger/styling';
|
|
148
|
+
*
|
|
149
|
+
* console.log('%cSuccess!', stylePresets.success);
|
|
150
|
+
* console.log('%cError!', stylePresets.error);
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
export const stylePresets = {
|
|
154
|
+
success: StylePresets.success().build(),
|
|
155
|
+
error: StylePresets.error().build(),
|
|
156
|
+
warning: StylePresets.warning().build(),
|
|
157
|
+
info: StylePresets.info().build(),
|
|
158
|
+
accent: StylePresets.accent().build(),
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Available themes for the logger
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* ```typescript
|
|
166
|
+
* import { themes } from '@mks2508/better-logger/styling';
|
|
167
|
+
*
|
|
168
|
+
* console.log('Available themes:', Object.keys(themes));
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
171
|
+
export const themes = Object.keys(THEME_PRESETS);
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Available banner types
|
|
175
|
+
*
|
|
176
|
+
* @example
|
|
177
|
+
* ```typescript
|
|
178
|
+
* import { bannerTypes } from '@mks2508/better-logger/styling';
|
|
179
|
+
*
|
|
180
|
+
* console.log('Available banners:', bannerTypes);
|
|
181
|
+
* ```
|
|
182
|
+
*/
|
|
183
|
+
export const bannerTypes = Object.keys(BANNER_VARIANTS);
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Display initialization banner
|
|
187
|
+
*
|
|
188
|
+
* @param bannerType - Type of banner to display
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* ```typescript
|
|
192
|
+
* import { showInitBanner } from '@mks2508/better-logger/styling';
|
|
193
|
+
*
|
|
194
|
+
* showInitBanner('animated');
|
|
195
|
+
* ```
|
|
196
|
+
*/
|
|
197
|
+
export const showInitBanner = (bannerType?: BannerType) => {
|
|
198
|
+
displayInitBanner(bannerType);
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Export individual styled logging methods
|
|
203
|
+
*/
|
|
204
|
+
export const debug = (...args: any[]) => styledLogger.debug(...args);
|
|
205
|
+
export const info = (...args: any[]) => styledLogger.info(...args);
|
|
206
|
+
export const warn = (...args: any[]) => styledLogger.warn(...args);
|
|
207
|
+
export const error = (...args: any[]) => styledLogger.error(...args);
|
|
208
|
+
export const success = (...args: any[]) => styledLogger.success(...args);
|
|
209
|
+
export const critical = (...args: any[]) => styledLogger.critical(...args);
|
|
210
|
+
export const trace = (...args: any[]) => styledLogger.trace(...args);
|
|
211
|
+
export const table = (data: any, columns?: string[]) => styledLogger.table(data, columns);
|
|
212
|
+
export const group = (label: string, collapsed?: boolean) => styledLogger.group(label, collapsed);
|
|
213
|
+
export const groupEnd = () => styledLogger.groupEnd();
|
|
214
|
+
export const time = (label: string) => styledLogger.time(label);
|
|
215
|
+
export const timeEnd = (label: string) => styledLogger.timeEnd(label);
|
|
216
|
+
export const setGlobalPrefix = (prefix: string) => styledLogger.setGlobalPrefix(prefix);
|
|
217
|
+
export const createScopedLogger = (prefix: string) => styledLogger.createScopedLogger(prefix);
|
|
218
|
+
export const setVerbosity = (level: any) => styledLogger.setVerbosity(level);
|
|
219
|
+
export const setTheme = (theme: ThemeVariant) => styledLogger.setTheme(theme);
|
|
220
|
+
export const setBannerType = (bannerType: BannerType) => styledLogger.setBannerType(bannerType);
|
|
221
|
+
export const showBanner = (bannerType?: BannerType) => styledLogger.showBanner(bannerType);
|
|
222
|
+
export const logWithSVG = (message: string, svgContent?: string, options?: StyleOptions) =>
|
|
223
|
+
styledLogger.logWithSVG(message, svgContent, options);
|
|
224
|
+
export const logAnimated = (message: string, duration?: number) =>
|
|
225
|
+
styledLogger.logAnimated(message, duration);
|
|
226
|
+
|
|
227
|
+
// Export the singleton as default
|
|
228
|
+
export default styledLogger;
|
|
229
|
+
|
|
230
|
+
// Re-export styling utilities
|
|
231
|
+
export {
|
|
232
|
+
StyleBuilder,
|
|
233
|
+
StylePresets,
|
|
234
|
+
THEME_PRESETS,
|
|
235
|
+
THEME_BANNERS,
|
|
236
|
+
BANNER_VARIANTS
|
|
237
|
+
} from './styling/index.js';
|
|
238
|
+
|
|
239
|
+
// Re-export types
|
|
240
|
+
export type {
|
|
241
|
+
ThemeVariant,
|
|
242
|
+
BannerType,
|
|
243
|
+
StyleOptions
|
|
244
|
+
} from './types/index.js';
|
package/src/utils/stackTrace.ts
CHANGED
|
@@ -10,7 +10,9 @@ import type { StackInfo } from '../types/index.js';
|
|
|
10
10
|
export function parseStackTrace(): StackInfo | null {
|
|
11
11
|
try {
|
|
12
12
|
const stack = new Error().stack;
|
|
13
|
-
if (!stack)
|
|
13
|
+
if (!stack) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
14
16
|
|
|
15
17
|
const lines = stack.split('\n').filter(line => line.trim());
|
|
16
18
|
|
|
@@ -18,6 +20,10 @@ export function parseStackTrace(): StackInfo | null {
|
|
|
18
20
|
for (let i = 1; i < lines.length; i++) {
|
|
19
21
|
const line = lines[i];
|
|
20
22
|
|
|
23
|
+
if (!line) {
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
|
|
21
27
|
// Skip if line contains Logger methods or parseStackTrace
|
|
22
28
|
if (line.includes('parseStackTrace') ||
|
|
23
29
|
line.includes('Logger.') ||
|
|
@@ -47,16 +53,39 @@ export function parseStackTrace(): StackInfo | null {
|
|
|
47
53
|
}
|
|
48
54
|
}
|
|
49
55
|
|
|
50
|
-
if (match) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
if (!match) {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const [, functionName, file, lineStr, columnStr] = match;
|
|
61
|
+
|
|
62
|
+
if (!file) {
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Process file path - remove query params and get filename
|
|
67
|
+
const fileParts = file.split('/');
|
|
68
|
+
const fileName = fileParts[fileParts.length - 1];
|
|
69
|
+
if (!fileName) {
|
|
70
|
+
continue;
|
|
59
71
|
}
|
|
72
|
+
const cleanFileName = fileName.split('?')[0];
|
|
73
|
+
|
|
74
|
+
// Parse line and column numbers
|
|
75
|
+
const lineNum = lineStr ? parseInt(lineStr, 10) : 0;
|
|
76
|
+
const columnNum = columnStr ? parseInt(columnStr, 10) : 0;
|
|
77
|
+
|
|
78
|
+
// Clean function name
|
|
79
|
+
const cleanFunction = functionName && functionName.trim()
|
|
80
|
+
? functionName.trim()
|
|
81
|
+
: undefined;
|
|
82
|
+
|
|
83
|
+
return {
|
|
84
|
+
file: cleanFileName ? cleanFileName : 'unknown',
|
|
85
|
+
line: lineNum,
|
|
86
|
+
column: columnNum,
|
|
87
|
+
function: cleanFunction
|
|
88
|
+
};
|
|
60
89
|
}
|
|
61
90
|
|
|
62
91
|
return null;
|
package/src/utils/timestamps.ts
CHANGED
|
@@ -29,7 +29,7 @@ export function parseRelativeTime(timeStr: string): number {
|
|
|
29
29
|
const [, amount, unit] = match;
|
|
30
30
|
const multiplier = TIME_UNITS[unit as keyof typeof TIME_UNITS];
|
|
31
31
|
|
|
32
|
-
return parseInt(amount, 10) * multiplier;
|
|
32
|
+
return parseInt(amount || '0', 10) * multiplier;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
/**
|
package/tsconfig.json
CHANGED
|
@@ -1,24 +1,50 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
3
|
"target": "ES2022",
|
|
4
|
-
"useDefineForClassFields": true,
|
|
5
|
-
"module": "ESNext",
|
|
6
4
|
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"moduleResolution": "node",
|
|
7
7
|
"skipLibCheck": true,
|
|
8
|
-
|
|
9
|
-
/*
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
8
|
+
|
|
9
|
+
/* Library Build Configuration */
|
|
10
|
+
"declaration": true,
|
|
11
|
+
"declarationMap": true,
|
|
12
|
+
"outDir": "dist",
|
|
13
|
+
"rootDir": "src",
|
|
14
|
+
"emitDeclarationOnly": false,
|
|
15
|
+
|
|
16
|
+
/* Module System */
|
|
17
|
+
"esModuleInterop": true,
|
|
18
|
+
"allowSyntheticDefaultImports": true,
|
|
19
|
+
"forceConsistentCasingInFileNames": true,
|
|
20
|
+
"isolatedModules": true,
|
|
13
21
|
"moduleDetection": "force",
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
/*
|
|
22
|
+
"verbatimModuleSyntax": false,
|
|
23
|
+
|
|
24
|
+
/* Type Checking */
|
|
17
25
|
"strict": true,
|
|
18
|
-
"
|
|
19
|
-
"
|
|
26
|
+
"noImplicitAny": true,
|
|
27
|
+
"strictNullChecks": true,
|
|
28
|
+
"strictFunctionTypes": true,
|
|
29
|
+
"noImplicitReturns": true,
|
|
20
30
|
"noFallthroughCasesInSwitch": true,
|
|
21
|
-
"
|
|
31
|
+
"noUncheckedIndexedAccess": true,
|
|
32
|
+
|
|
33
|
+
/* Advanced */
|
|
34
|
+
"resolveJsonModule": true,
|
|
35
|
+
"allowImportingTsExtensions": false,
|
|
36
|
+
"noEmit": false,
|
|
37
|
+
"incremental": true,
|
|
38
|
+
"tsBuildInfoFile": "./dist/.tsbuildinfo"
|
|
22
39
|
},
|
|
23
|
-
"include": [
|
|
40
|
+
"include": [
|
|
41
|
+
"src/**/*"
|
|
42
|
+
],
|
|
43
|
+
"exclude": [
|
|
44
|
+
"node_modules",
|
|
45
|
+
"dist",
|
|
46
|
+
"**/*.test.ts",
|
|
47
|
+
"**/*.spec.ts",
|
|
48
|
+
"**/*.d.ts"
|
|
49
|
+
]
|
|
24
50
|
}
|
package/vite.config.ts
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { defineConfig } from 'vite'
|
|
2
|
+
import { resolve } from 'path'
|
|
3
|
+
import dts from 'vite-plugin-dts'
|
|
4
|
+
|
|
5
|
+
export default defineConfig({
|
|
6
|
+
plugins: [
|
|
7
|
+
dts({
|
|
8
|
+
include: ['src/**/*'],
|
|
9
|
+
exclude: ['src/**/*.test.ts', 'src/**/*.spec.ts', 'src/main.ts', 'src/example.ts'],
|
|
10
|
+
outDir: 'dist/types',
|
|
11
|
+
rollupTypes: true,
|
|
12
|
+
insertTypesEntry: true,
|
|
13
|
+
})
|
|
14
|
+
],
|
|
15
|
+
build: {
|
|
16
|
+
lib: {
|
|
17
|
+
entry: {
|
|
18
|
+
// Main entry - Full logger with all features
|
|
19
|
+
index: resolve(__dirname, 'src/index.ts'),
|
|
20
|
+
|
|
21
|
+
// Core module - Minimal logger without advanced features
|
|
22
|
+
core: resolve(__dirname, 'src/core.ts'),
|
|
23
|
+
|
|
24
|
+
// Styling module - Advanced visual features
|
|
25
|
+
styling: resolve(__dirname, 'src/styling-module.ts'),
|
|
26
|
+
|
|
27
|
+
// Exports module - Export and remote handlers
|
|
28
|
+
exports: resolve(__dirname, 'src/exports-module.ts')
|
|
29
|
+
},
|
|
30
|
+
name: 'BetterLogger',
|
|
31
|
+
formats: ['es', 'cjs'],
|
|
32
|
+
fileName: (format, entryName) => {
|
|
33
|
+
const ext = format === 'cjs' ? 'cjs' : 'js';
|
|
34
|
+
return `${entryName}.${ext}`;
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
rollupOptions: {
|
|
38
|
+
external: [],
|
|
39
|
+
output: {
|
|
40
|
+
globals: {},
|
|
41
|
+
exports: 'named',
|
|
42
|
+
preserveModules: false,
|
|
43
|
+
chunkFileNames: 'chunks/[name]-[hash].js',
|
|
44
|
+
manualChunks: (id) => {
|
|
45
|
+
// Separate styling features into their own chunk
|
|
46
|
+
if (id.includes('styling/') || id.includes('banners.ts') || id.includes('themes.ts')) {
|
|
47
|
+
return 'styling';
|
|
48
|
+
}
|
|
49
|
+
// Separate export handlers
|
|
50
|
+
if (id.includes('handlers/Export') || id.includes('handlers/Remote')) {
|
|
51
|
+
return 'exports';
|
|
52
|
+
}
|
|
53
|
+
// Core functionality
|
|
54
|
+
if (id.includes('src/types/') || id.includes('src/utils/')) {
|
|
55
|
+
return 'core';
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
sourcemap: true,
|
|
61
|
+
minify: 'terser',
|
|
62
|
+
terserOptions: {
|
|
63
|
+
compress: {
|
|
64
|
+
drop_console: false,
|
|
65
|
+
drop_debugger: true,
|
|
66
|
+
pure_funcs: ['console.debug'],
|
|
67
|
+
passes: 2
|
|
68
|
+
},
|
|
69
|
+
mangle: {
|
|
70
|
+
properties: false,
|
|
71
|
+
keep_classnames: true,
|
|
72
|
+
keep_fnames: true
|
|
73
|
+
},
|
|
74
|
+
format: {
|
|
75
|
+
comments: false,
|
|
76
|
+
preserve_annotations: true
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
target: 'es2022'
|
|
80
|
+
},
|
|
81
|
+
define: {
|
|
82
|
+
'process.env.NODE_ENV': JSON.stringify('production')
|
|
83
|
+
}
|
|
84
|
+
})
|