Browser console UX enhancement library with advanced logging, visualizations, and animations
- ✨ ChartGenerator: Bar, line, and pie charts
- 🎬 AnimationGenerator: Spinners, progress bars, typing effects
- 📊 DiagramGenerator: Sequence, state, and Gantt diagrams
- ⚡ Performance Cache: LRU cache with 85%+ hit rate
- 🛡️ Error Handling: Complete validation and custom error classes
- 🔧 Refactored Architecture: Split into 3 logical modules
- Enhanced FlowGenerator with 6 node types
- Advanced logging with flexible date/time formats
- Log history tracking and search
- Performance timing and profiling
- Cache statistics and management
- Production-ready code quality
- 🎨 4 Built-in Themes (Default, Dark, Matrix, Ocean)
- 📝 Advanced Logging with 6 levels and flexible timestamps
- 📊 Data Visualization with tables, trees, and charts
- 🎬 Animations for better UX feedback
- 📈 Charts (bar, line, pie, horizontal bar)
- 🔄 Flow Diagrams with multiple node types
- 📐 Sequence & State Diagrams
- 🎨 ASCII Art text generator
- ⚡ Performance Optimized with intelligent caching
- 🛡️ Type Safe with full TypeScript support
- 📦 Zero Dependencies - Vanilla TypeScript only
- BoxGenerator - Styled boxes and frames
- TableGenerator - Data tables with headers
- TreeGenerator - Hierarchical structures
- LineGenerator - Decorative lines
- ArrowGenerator - Directional arrows
- FlowGenerator - Process flow diagrams
- AsciiTextGenerator - Large ASCII text
- ChartGenerator - Data visualizations
- AnimationGenerator - UI feedback animations
- DiagramGenerator - Technical diagrams
import zConsole from './zconsole';npm install @nysiris/zconsoleimport zConsole from './zconsole';
// 1. Create instance with theme
const ec = new zConsole('dark');
// 2. Welcome banner
ec.welcome('My App');
// 3. Logging
ec.log.info('Application started');
ec.log.success('Connected to database');
ec.log.error('Failed to load config');
// 4. Data table
ec.table.generate([
['Alice', 25, 'Paris'],
['Bob', 30, 'Lyon']
], {
headers: ['Name', 'Age', 'City'],
zebra: true
});
// 5. Chart
ec.chart.bar([45, 67, 52, 89], ['Q1', 'Q2', 'Q3', 'Q4'], {
title: 'Quarterly Revenue',
showValues: true
});
// 6. Progress bar
const progress = ec.animation.progress(100);
for (let i = 0; i <= 100; i += 10) {
progress.update(i);
await delay(100);
}
progress.complete();ec.log.trace('Detailed trace');
ec.log.debug('Debug info');
ec.log.info('Information');
ec.log.success('Operation succeeded');
ec.log.warn('Warning message');
ec.log.error('Error occurred');ec.log.group('User Actions');
ec.log.info('Login successful');
ec.log.info('Profile updated');
ec.log.groupEnd();ec.log.time('API Call');
await fetchData();
ec.log.timeEnd('API Call');
// Output: ⏱️ API Call: 245.32ms// Show last 10 logs
ec.log.showHistory(10);
// Get history programmatically
const history = ec.log.getHistory(20);ec.chart.bar(
[45, 67, 52, 89],
['Q1', 'Q2', 'Q3', 'Q4'],
{
title: 'Quarterly Revenue',
height: 10,
showValues: true,
colors: ['#3498db', '#2ecc71', '#f39c12', '#e74c3c']
}
);ec.chart.horizontalBar(
[85, 92, 78, 95],
['Alice', 'Bob', 'Charlie', 'Diana'],
{
title: 'Performance Scores',
width: 40
}
);ec.chart.line([15, 18, 22, 25, 28, 26, 23], {
title: 'Temperature Trend',
height: 8,
showGrid: true
});ec.chart.pie(
[35, 28, 20, 12, 5],
['A', 'B', 'C', 'D', 'E'],
{
title: 'Market Share'
}
);const spinner = ec.animation.spinner('dots', 'Loading...');
await doWork();
spinner.stop();Spinner Types:
dots- Rotating dotsline- Spinning linecircle- Rotating circlesquare- Rotating squarearrow- Spinning arrowpulse- Pulsing circlebounce- Bouncing dotsclock- Clock face
const progress = ec.animation.progress(100, { width: 40 });
for (let i = 0; i <= 100; i++) {
progress.update(i, `Processing: ${i}%`);
await delay(50);
}
progress.complete('Done!');await ec.animation.typing('Hello, World!', 50);ec.diagram.sequence(
['Client', 'Server', 'Database'],
[
{ from: 'Client', to: 'Server', message: 'Request' },
{ from: 'Server', to: 'Database', message: 'Query' },
{ from: 'Database', to: 'Server', message: 'Result', type: 'return' },
{ from: 'Server', to: 'Client', message: 'Response', type: 'return' }
]
);ec.diagram.state(
[
{ name: 'Idle', type: 'initial' },
{ name: 'Processing', type: 'normal' },
{ name: 'Complete', type: 'final' }
],
[
{ from: 'Idle', to: 'Processing', label: 'start()' },
{ from: 'Processing', to: 'Complete', label: 'finish()' }
]
);ec.diagram.gantt([
{ name: 'Planning', start: 0, duration: 5, progress: 100 },
{ name: 'Development', start: 5, duration: 15, progress: 60 },
{ name: 'Testing', start: 18, duration: 7, progress: 30 }
]);ec.flow.generate([
{ id: '1', label: 'Start', type: 'start' },
{ id: '2', label: 'Process', type: 'process' },
{ id: '3', label: 'Decision', type: 'decision' },
{ id: '4', label: 'Output', type: 'output' },
{ id: '5', label: 'End', type: 'end' }
], {
width: 30,
borderStyle: 'rounded',
layout: 'vertical'
});Node Types:
start- Starting pointend- Ending pointprocess- Processing stepdecision- Conditional branchinput- Input operationoutput- Output operation
ec.table.generate(
[
['Alice', 25, 'Engineer'],
['Bob', 30, 'Designer'],
['Charlie', 35, 'Manager']
],
{
headers: ['Name', 'Age', 'Role'],
borderStyle: 'rounded',
align: 'center',
zebra: true
}
);const structure = [
{
label: 'src',
children: [
{
label: 'components',
children: [
{ label: 'Button.tsx' },
{ label: 'Input.tsx' }
]
},
{ label: 'utils' }
]
}
];
ec.tree.generate(structure);ec.setTheme('matrix'); // or 'dark', 'ocean', 'default'ec.addTheme('sunset', {
name: 'Sunset',
colors: {
primary: '#FF6B6B',
secondary: '#FFA06B',
success: '#4ECDC4',
warning: '#FFE66D',
error: '#FF4757',
info: '#5F27CD',
debug: '#A55EEA',
text: '#2C2C54',
background: '#FFE4E1',
border: '#FF8C94'
},
styles: {
fontWeight: 'bold',
fontSize: '13px'
}
});
ec.setTheme('sunset');import { DateTimeFormatter } from './zconsole';
// Different formats
DateTimeFormatter.format(new Date(), { format: 'time' });
// → 14:30:45
DateTimeFormatter.format(new Date(), { format: 'datetime' });
// → 2024-10-28 14:30:45
DateTimeFormatter.format(new Date(), { format: 'relative' });
// → il y a 5s
DateTimeFormatter.format(new Date(), {
format: 'custom',
customFormat: 'DD/MM/YYYY à HH:mm'
});
// → 28/10/2024 à 14:30Enhanced Console uses an intelligent LRU cache system:
// Get cache statistics
const stats = ec.getCacheStats();
console.log(stats);
// {
// style: { size: 45, hitRate: '87.3%', ... },
// color: { size: 23, hitRate: '92.1%', ... },
// border: { size: 8, hitRate: '95.5%', ... }
// }
// Clear caches
ec.clearCaches();- Chart generation: <50ms for 50 data points
- Log operation: <1ms
- Theme switching: O(1)
- Cache hit rate: 85-95%
See examples.ts for comprehensive examples including:
- Complete dashboard
- All chart types
- All diagram types
- Animation demos
- Theme switching
- Performance monitoring
class zConsole {
log: EnhancedLogger;
box: BoxGenerator;
table: TableGenerator;
tree: TreeGenerator;
line: LineGenerator;
arrow: ArrowGenerator;
flow: FlowGenerator;
ascii: AsciiTextGenerator;
chart: ChartGenerator;
animation: AnimationGenerator;
diagram: DiagramGenerator;
constructor(theme?: string);
setTheme(name: string): boolean;
addTheme(name: string, theme: Theme): void;
getTheme(name?: string): Theme;
listThemes(): string[];
welcome(appName: string): void;
getCacheStats(): CacheStats;
clearCaches(): void;
}class EnhancedLogger {
// Log levels
trace(...args: any[]): void;
debug(...args: any[]): void;
info(...args: any[]): void;
success(...args: any[]): void;
warn(...args: any[]): void;
error(...args: any[]): void;
// Grouping
group(label: string): void;
groupCollapsed(label: string): void;
groupEnd(): void;
// Timing
time(label: string): void;
timeEnd(label: string): void;
timeLog(label: string, ...args: any[]): void;
// Counting
count(label?: string): void;
countReset(label?: string): void;
// History
getHistory(limit?: number): LogEntry[];
showHistory(limit?: number): void;
clearHistory(): void;
// Configuration
setLevel(level: LogLevel): void;
setTimestamp(show: boolean): void;
setCaller(show: boolean): void;
setDateTimeFormat(format: DateTimeFormat): void;
}MIT License - see LICENSE file
- Inspired by various console enhancement libraries
- Built with TypeScript
- Designed for browser console environments
- Unit tests (Jest/Vitest)
- Build system (Rollup)
- NPM package
- More chart types
- Plugin system
- Export manager
- i18n support
- Node.js support
- Framework wrappers (React, Vue)
- Browser extension
Made with ❤️ and TypeScript
Star ⭐ this repo if you find it useful!