ansimax 1.1.0 → 1.1.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/CHANGELOG.md +324 -0
- package/README.es.md +148 -47
- package/README.md +147 -46
- package/dist/index.js +39 -8
- package/dist/index.mjs +39 -8
- package/examples/01-quick-smoke.ts +121 -0
- package/examples/02-colors-gradients.ts +108 -0
- package/examples/03-ascii-banners.ts +81 -0
- package/examples/04-trees.ts +117 -0
- package/examples/05-components.ts +96 -0
- package/examples/06-pixel-art.ts +116 -0
- package/examples/07-animations.ts +68 -0
- package/examples/08-loaders.ts +98 -0
- package/examples/09-themes.ts +90 -0
- package/examples/10-everything.ts +133 -0
- package/examples/all-in-one.cjs +210 -0
- package/examples/all-in-one.mjs +203 -0
- package/examples/tsconfig.json +18 -18
- package/package.json +2 -2
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 07 — Animations
|
|
3
|
+
*
|
|
4
|
+
* Tests typewriter, fadeIn, fadeOut, slide, pulse, wave, glitch, reveal.
|
|
5
|
+
*
|
|
6
|
+
* Run: npx tsx examples/07-animations.ts
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { animate, gradient, color } from '../src/index.js';
|
|
10
|
+
|
|
11
|
+
console.log();
|
|
12
|
+
console.log(color.bold('━━━ Animations Demo ━━━'));
|
|
13
|
+
console.log();
|
|
14
|
+
|
|
15
|
+
// Helper to add pause between animations
|
|
16
|
+
const pause = (ms: number): Promise<void> => new Promise((r) => setTimeout(r, ms));
|
|
17
|
+
|
|
18
|
+
// 1. Typewriter
|
|
19
|
+
console.log(color.dim('// 1. Typewriter'));
|
|
20
|
+
await animate.typewriter('Welcome to the ansimax demo...', { speed: 30 });
|
|
21
|
+
await pause(300);
|
|
22
|
+
|
|
23
|
+
// 2. Typewriter with gradient
|
|
24
|
+
console.log(color.dim('\n// 2. Typewriter + gradient'));
|
|
25
|
+
await animate.typewriter('Colorful typewriter effect!', {
|
|
26
|
+
speed: 35,
|
|
27
|
+
colorFn: (t) => gradient(t, ['#ff79c6', '#bd93f9', '#8be9fd']),
|
|
28
|
+
});
|
|
29
|
+
await pause(300);
|
|
30
|
+
|
|
31
|
+
// 3. FadeIn
|
|
32
|
+
console.log(color.dim('\n// 3. FadeIn'));
|
|
33
|
+
await animate.fadeIn('Fading in smoothly', { duration: 600 });
|
|
34
|
+
await pause(300);
|
|
35
|
+
|
|
36
|
+
// 4. FadeOut
|
|
37
|
+
console.log(color.dim('\n// 4. FadeOut'));
|
|
38
|
+
await animate.fadeOut('Fading out now...', { duration: 600 });
|
|
39
|
+
await pause(300);
|
|
40
|
+
|
|
41
|
+
// 5. Slide
|
|
42
|
+
console.log(color.dim('\n// 5. Slide from left'));
|
|
43
|
+
await animate.slide('Sliding into view', { duration: 400, direction: 'left' });
|
|
44
|
+
await pause(300);
|
|
45
|
+
|
|
46
|
+
// 6. Pulse
|
|
47
|
+
console.log(color.dim('\n// 6. Pulse'));
|
|
48
|
+
await animate.pulse('Pulsing text...', { cycles: 3, duration: 1500 });
|
|
49
|
+
await pause(300);
|
|
50
|
+
|
|
51
|
+
// 7. Wave
|
|
52
|
+
console.log(color.dim('\n// 7. Wave'));
|
|
53
|
+
await animate.wave('Wave animation!', { duration: 1500 });
|
|
54
|
+
await pause(300);
|
|
55
|
+
|
|
56
|
+
// 8. Glitch
|
|
57
|
+
console.log(color.dim('\n// 8. Glitch'));
|
|
58
|
+
await animate.glitch('GLITCHED TEXT', { duration: 1000 });
|
|
59
|
+
await pause(300);
|
|
60
|
+
|
|
61
|
+
// 9. Reveal
|
|
62
|
+
console.log(color.dim('\n// 9. Reveal'));
|
|
63
|
+
await animate.reveal('Revealing secret message', { duration: 1000 });
|
|
64
|
+
await pause(300);
|
|
65
|
+
|
|
66
|
+
console.log();
|
|
67
|
+
console.log(color.bold(color.green('✓ Animations test complete')));
|
|
68
|
+
console.log();
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 08 — Loaders
|
|
3
|
+
* Real spinner types: dots, dots2, line, arrow, bounce, star, moon, clock, pong, aesthetic, blocks
|
|
4
|
+
*
|
|
5
|
+
* Run: npx tsx examples/08-loaders.ts
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { loader, SPINNERS, color } from '../src/index.js';
|
|
9
|
+
|
|
10
|
+
const sleep = (ms: number): Promise<void> => new Promise((r) => setTimeout(r, ms));
|
|
11
|
+
|
|
12
|
+
console.log();
|
|
13
|
+
console.log(color.bold('━━━ Available Spinners ━━━'));
|
|
14
|
+
console.log();
|
|
15
|
+
console.log(' ', Object.keys(SPINNERS).join(', '));
|
|
16
|
+
console.log();
|
|
17
|
+
|
|
18
|
+
console.log(color.bold('━━━ Basic spinner with success ━━━'));
|
|
19
|
+
let stop = loader.spin('Loading data...', { color: '#bd93f9' });
|
|
20
|
+
await sleep(1500);
|
|
21
|
+
stop('Data loaded!', true);
|
|
22
|
+
|
|
23
|
+
console.log(color.dim('\n// Spinner with failure'));
|
|
24
|
+
stop = loader.spin('Connecting to API...', { color: '#ff5555' });
|
|
25
|
+
await sleep(1500);
|
|
26
|
+
stop('Connection failed', false);
|
|
27
|
+
|
|
28
|
+
console.log(color.bold('\n━━━ Different spinner types ━━━'));
|
|
29
|
+
const types = ['dots', 'line', 'arrow', 'star', 'bounce', 'moon'] as const;
|
|
30
|
+
for (const type of types) {
|
|
31
|
+
stop = loader.spin(`Type: ${type}`, { type, color: '#50fa7b' });
|
|
32
|
+
await sleep(1000);
|
|
33
|
+
stop();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
console.log(color.bold('\n━━━ Static progress bar ━━━'));
|
|
37
|
+
console.log();
|
|
38
|
+
console.log(' ', loader.progress(0, { width: 30 }));
|
|
39
|
+
console.log(' ', loader.progress(33, { width: 30 }));
|
|
40
|
+
console.log(' ', loader.progress(66, { width: 30 }));
|
|
41
|
+
console.log(' ', loader.progress(100, { width: 30 }));
|
|
42
|
+
console.log();
|
|
43
|
+
|
|
44
|
+
console.log(color.bold('━━━ Animated progress ━━━'));
|
|
45
|
+
console.log();
|
|
46
|
+
await loader.progressAnimate(100, 'Downloading file', {
|
|
47
|
+
color: '#50fa7b',
|
|
48
|
+
delay: 15,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
console.log(color.bold('\n━━━ Sequential tasks ━━━'));
|
|
52
|
+
console.log();
|
|
53
|
+
await loader.tasks([
|
|
54
|
+
{ text: 'Cloning repository', fn: async () => await sleep(800) },
|
|
55
|
+
{ text: 'Installing dependencies', fn: async () => await sleep(1200) },
|
|
56
|
+
{ text: 'Building project', fn: async () => await sleep(900) },
|
|
57
|
+
{ text: 'Running tests', fn: async () => await sleep(700) },
|
|
58
|
+
]);
|
|
59
|
+
|
|
60
|
+
console.log(color.bold('\n━━━ Parallel tasks ━━━'));
|
|
61
|
+
console.log();
|
|
62
|
+
await loader.tasks([
|
|
63
|
+
{ text: 'Type check', fn: async () => await sleep(1000) },
|
|
64
|
+
{ text: 'Lint', fn: async () => await sleep(1500) },
|
|
65
|
+
{ text: 'Bundle', fn: async () => await sleep(800) },
|
|
66
|
+
{ text: 'Generate types', fn: async () => await sleep(1200) },
|
|
67
|
+
], { parallel: true });
|
|
68
|
+
|
|
69
|
+
console.log(color.bold('\n━━━ Hierarchical tasks ━━━'));
|
|
70
|
+
console.log();
|
|
71
|
+
await loader.tasks([
|
|
72
|
+
{
|
|
73
|
+
text: 'Build',
|
|
74
|
+
fn: async () => await sleep(500),
|
|
75
|
+
subtasks: [
|
|
76
|
+
{ text: 'TypeScript', fn: async () => await sleep(800) },
|
|
77
|
+
{ text: 'Bundle ESM', fn: async () => await sleep(600) },
|
|
78
|
+
{ text: 'Bundle CJS', fn: async () => await sleep(600) },
|
|
79
|
+
],
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
text: 'Test',
|
|
83
|
+
fn: async () => await sleep(500),
|
|
84
|
+
subtasks: [
|
|
85
|
+
{ text: 'Unit tests', fn: async () => await sleep(900) },
|
|
86
|
+
{ text: 'Integration tests', fn: async () => await sleep(700) },
|
|
87
|
+
],
|
|
88
|
+
},
|
|
89
|
+
]);
|
|
90
|
+
|
|
91
|
+
console.log(color.bold('\n━━━ Countdown ━━━'));
|
|
92
|
+
console.log();
|
|
93
|
+
await loader.countdown(3, { color: '#ff79c6', prefix: 'Starting in ', suffix: 's' });
|
|
94
|
+
console.log(color.green(' Started!'));
|
|
95
|
+
|
|
96
|
+
console.log();
|
|
97
|
+
console.log(color.bold(color.green('✓ Loaders test complete')));
|
|
98
|
+
console.log();
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 09 — Themes
|
|
3
|
+
*
|
|
4
|
+
* Run: npx tsx examples/09-themes.ts
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { themes, createTheme, color } from '../src/index.js';
|
|
8
|
+
|
|
9
|
+
console.log();
|
|
10
|
+
console.log(color.bold('━━━ Built-in Themes ━━━'));
|
|
11
|
+
console.log();
|
|
12
|
+
|
|
13
|
+
const builtIns = ['dracula', 'nord', 'monokai', 'cyberpunk', 'pastel', 'matrix', 'ocean', 'sunset'];
|
|
14
|
+
for (const name of builtIns) {
|
|
15
|
+
themes.use(name);
|
|
16
|
+
console.log(' ', name.padEnd(12),
|
|
17
|
+
themes.primary('primary'),
|
|
18
|
+
themes.secondary('secondary'),
|
|
19
|
+
themes.accent('accent'),
|
|
20
|
+
themes.success('success'),
|
|
21
|
+
themes.warning('warning'),
|
|
22
|
+
themes.error('error'),
|
|
23
|
+
themes.info('info'),
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
console.log();
|
|
27
|
+
|
|
28
|
+
console.log(color.bold('━━━ Background helpers ━━━'));
|
|
29
|
+
console.log();
|
|
30
|
+
themes.use('dracula');
|
|
31
|
+
console.log(' ',
|
|
32
|
+
themes.bgPrimary(' bgPrimary '), '',
|
|
33
|
+
themes.bgAccent(' bgAccent '), '',
|
|
34
|
+
);
|
|
35
|
+
console.log();
|
|
36
|
+
|
|
37
|
+
console.log(color.bold('━━━ Theme info ━━━'));
|
|
38
|
+
console.log();
|
|
39
|
+
console.log(' themes.list():', themes.list().join(', '));
|
|
40
|
+
console.log(' themes.current().name:', themes.current().name);
|
|
41
|
+
console.log();
|
|
42
|
+
|
|
43
|
+
console.log(color.bold('━━━ Listener (onChange) ━━━'));
|
|
44
|
+
console.log();
|
|
45
|
+
const off = themes.onChange((newTheme, oldTheme) => {
|
|
46
|
+
console.log(` ${color.dim('event:')} ${oldTheme.name} → ${color.bold(newTheme.name)}`);
|
|
47
|
+
});
|
|
48
|
+
themes.use('nord');
|
|
49
|
+
themes.use('matrix');
|
|
50
|
+
themes.use('cyberpunk');
|
|
51
|
+
off();
|
|
52
|
+
console.log();
|
|
53
|
+
|
|
54
|
+
console.log(color.bold('━━━ Register custom theme ━━━'));
|
|
55
|
+
console.log();
|
|
56
|
+
themes.register('custom-blue', {
|
|
57
|
+
name: 'Custom Blue',
|
|
58
|
+
primary: '#3b82f6',
|
|
59
|
+
secondary: '#2563eb',
|
|
60
|
+
accent: '#60a5fa',
|
|
61
|
+
success: '#10b981',
|
|
62
|
+
warning: '#fbbf24',
|
|
63
|
+
error: '#ef4444',
|
|
64
|
+
info: '#06b6d4',
|
|
65
|
+
muted: '#6b7280',
|
|
66
|
+
bg: '#1e293b',
|
|
67
|
+
surface: '#334155',
|
|
68
|
+
text: '#f1f5f9',
|
|
69
|
+
gradient: ['#3b82f6', '#60a5fa', '#93c5fd'],
|
|
70
|
+
});
|
|
71
|
+
themes.use('custom-blue');
|
|
72
|
+
console.log(' ', themes.primary('Custom theme is now active'));
|
|
73
|
+
console.log(' ', themes.gradient('Theme gradient!'));
|
|
74
|
+
console.log(' current:', themes.current().name);
|
|
75
|
+
console.log();
|
|
76
|
+
|
|
77
|
+
console.log(color.bold('━━━ Per-instance isolation ━━━'));
|
|
78
|
+
console.log();
|
|
79
|
+
const tenantA = createTheme('nord');
|
|
80
|
+
const tenantB = createTheme('matrix');
|
|
81
|
+
console.log(' tenantA current:', tenantA.current().name);
|
|
82
|
+
console.log(' tenantB current:', tenantB.current().name);
|
|
83
|
+
console.log(' (Each instance has its own state)');
|
|
84
|
+
console.log();
|
|
85
|
+
|
|
86
|
+
themes.use('dracula');
|
|
87
|
+
themes.unregister('custom-blue');
|
|
88
|
+
|
|
89
|
+
console.log(color.bold(color.green('✓ Themes test complete')));
|
|
90
|
+
console.log();
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 10 — Everything Together
|
|
3
|
+
*
|
|
4
|
+
* Run: npx tsx examples/10-everything.ts
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
color,
|
|
9
|
+
gradient,
|
|
10
|
+
ascii,
|
|
11
|
+
loader,
|
|
12
|
+
animate,
|
|
13
|
+
components,
|
|
14
|
+
themes,
|
|
15
|
+
images,
|
|
16
|
+
gradientRect,
|
|
17
|
+
tree,
|
|
18
|
+
} from '../src/index.js';
|
|
19
|
+
|
|
20
|
+
const sleep = (ms: number): Promise<void> => new Promise((r) => setTimeout(r, ms));
|
|
21
|
+
|
|
22
|
+
console.clear();
|
|
23
|
+
|
|
24
|
+
// 1. Banner with gradient
|
|
25
|
+
console.log(ascii.banner('ANSIMAX', {
|
|
26
|
+
font: 'big',
|
|
27
|
+
align: 'center',
|
|
28
|
+
colorFn: (t) => gradient(t, ['#ff79c6', '#bd93f9', '#8be9fd']),
|
|
29
|
+
}));
|
|
30
|
+
console.log();
|
|
31
|
+
|
|
32
|
+
themes.use('dracula');
|
|
33
|
+
|
|
34
|
+
// 2. Typewriter intro
|
|
35
|
+
await animate.typewriter('Welcome to the comprehensive ansimax showcase...', {
|
|
36
|
+
speed: 25,
|
|
37
|
+
colorFn: (t) => themes.primary(t),
|
|
38
|
+
});
|
|
39
|
+
console.log();
|
|
40
|
+
await sleep(500);
|
|
41
|
+
|
|
42
|
+
// 3. Section header
|
|
43
|
+
console.log(components.section('📦 Project Setup', { width: 60 }));
|
|
44
|
+
console.log();
|
|
45
|
+
|
|
46
|
+
// 4. Tree
|
|
47
|
+
const project = tree({ label: 'my-microservices', icon: '📦', color: color.bold });
|
|
48
|
+
const api = project.add({ label: 'api', icon: '🌐' });
|
|
49
|
+
api.addLeaf({ label: 'auth-service', icon: '🔐' });
|
|
50
|
+
api.addLeaf({ label: 'user-service', icon: '👤' });
|
|
51
|
+
api.addLeaf({ label: 'payment-service', icon: '💳' });
|
|
52
|
+
const infra = project.add({ label: 'infra', icon: '☁️' });
|
|
53
|
+
infra.addLeaf({ label: 'database', icon: '🗄️' });
|
|
54
|
+
infra.addLeaf({ label: 'cache', icon: '⚡' });
|
|
55
|
+
project.addLeaf({ label: 'docs', icon: '📝' });
|
|
56
|
+
|
|
57
|
+
console.log(project.render({
|
|
58
|
+
style: 'rounded',
|
|
59
|
+
palette: [themes.primary, themes.accent, themes.success],
|
|
60
|
+
guideColor: themes.muted,
|
|
61
|
+
}));
|
|
62
|
+
console.log();
|
|
63
|
+
|
|
64
|
+
// 5. Badges
|
|
65
|
+
console.log(components.section('🏷️ Status', { width: 60 }));
|
|
66
|
+
console.log();
|
|
67
|
+
console.log(' ',
|
|
68
|
+
components.badge('VERSION', 'v1.1.0'),
|
|
69
|
+
components.badge('BUILD', 'passing'),
|
|
70
|
+
components.badge('TESTS', '1848 ✓'),
|
|
71
|
+
components.badge('LICENSE', 'Apache 2.0'),
|
|
72
|
+
);
|
|
73
|
+
console.log();
|
|
74
|
+
await sleep(500);
|
|
75
|
+
|
|
76
|
+
// 6. Hierarchical tasks
|
|
77
|
+
console.log(components.section('🚀 Deployment', { width: 60 }));
|
|
78
|
+
console.log();
|
|
79
|
+
await loader.tasks([
|
|
80
|
+
{
|
|
81
|
+
text: 'Build services',
|
|
82
|
+
fn: async () => await sleep(300),
|
|
83
|
+
subtasks: [
|
|
84
|
+
{ text: 'auth-service', fn: async () => await sleep(800) },
|
|
85
|
+
{ text: 'user-service', fn: async () => await sleep(600) },
|
|
86
|
+
{ text: 'payment-service', fn: async () => await sleep(900) },
|
|
87
|
+
],
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
text: 'Deploy to staging',
|
|
91
|
+
fn: async () => await sleep(1200),
|
|
92
|
+
},
|
|
93
|
+
]);
|
|
94
|
+
|
|
95
|
+
// 7. Service status
|
|
96
|
+
console.log();
|
|
97
|
+
console.log(components.section('📊 Service Status', { width: 60 }));
|
|
98
|
+
console.log();
|
|
99
|
+
console.log(components.table([
|
|
100
|
+
['Service', 'Status', 'Version', 'Latency'],
|
|
101
|
+
['auth-service', themes.success('● healthy'), 'v2.1.0', '14ms'],
|
|
102
|
+
['user-service', themes.success('● healthy'), 'v1.8.3', '22ms'],
|
|
103
|
+
['payment-service', themes.warning('● degraded'), 'v1.2.0', '180ms'],
|
|
104
|
+
['database', themes.success('● healthy'), 'pg-15.4', '3ms'],
|
|
105
|
+
['cache', themes.success('● healthy'), 'redis-7', '1ms'],
|
|
106
|
+
], { borderStyle: 'rounded' }));
|
|
107
|
+
console.log();
|
|
108
|
+
|
|
109
|
+
// 8. Pixel art
|
|
110
|
+
console.log(components.section('🎉 Complete', { width: 60 }));
|
|
111
|
+
console.log();
|
|
112
|
+
console.log(' ', images.sprite('star'), ' ', images.sprite('heart'), ' ', images.sprite('star'));
|
|
113
|
+
console.log();
|
|
114
|
+
|
|
115
|
+
// 9. Gradient bar (using top-level gradientRect — verified works)
|
|
116
|
+
console.log(gradientRect({
|
|
117
|
+
width: 60,
|
|
118
|
+
height: 2,
|
|
119
|
+
colors: ['#ff6b6b', '#feca57', '#48dbfb', '#a29bfe', '#fd79a8'],
|
|
120
|
+
dither: 'bayer',
|
|
121
|
+
}));
|
|
122
|
+
console.log();
|
|
123
|
+
|
|
124
|
+
// 10. Final summary
|
|
125
|
+
console.log(ascii.box(
|
|
126
|
+
themes.primary('✨ All systems deployed successfully ✨') + '\n' +
|
|
127
|
+
themes.muted('Total time: 7.2s · Services: 6 · Tests: 1848'),
|
|
128
|
+
{ padding: 1, borderStyle: 'rounded' },
|
|
129
|
+
));
|
|
130
|
+
console.log();
|
|
131
|
+
|
|
132
|
+
await animate.fadeOut('Thank you for using ansimax!', { duration: 800 });
|
|
133
|
+
console.log();
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* all-in-one.cjs
|
|
3
|
+
*
|
|
4
|
+
* Comprehensive ansimax demo — CommonJS (require).
|
|
5
|
+
*
|
|
6
|
+
* This example uses `require('ansimax')` directly so it works in
|
|
7
|
+
* any CommonJS project after `npm install ansimax`.
|
|
8
|
+
*
|
|
9
|
+
* Run:
|
|
10
|
+
* node examples/all-in-one.cjs
|
|
11
|
+
*
|
|
12
|
+
* (Requires `ansimax` installed: `npm install ansimax`)
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
const {
|
|
16
|
+
color,
|
|
17
|
+
gradient,
|
|
18
|
+
rainbow,
|
|
19
|
+
colorPresets,
|
|
20
|
+
ascii,
|
|
21
|
+
loader,
|
|
22
|
+
animate,
|
|
23
|
+
components,
|
|
24
|
+
themes,
|
|
25
|
+
images,
|
|
26
|
+
gradientRect,
|
|
27
|
+
tree,
|
|
28
|
+
box,
|
|
29
|
+
} = require('ansimax');
|
|
30
|
+
|
|
31
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
32
|
+
|
|
33
|
+
async function main() {
|
|
34
|
+
console.clear();
|
|
35
|
+
|
|
36
|
+
// ── 1. Banner with gradient ───────────────────────────────
|
|
37
|
+
console.log(ascii.banner('ANSIMAX', {
|
|
38
|
+
font: 'big',
|
|
39
|
+
align: 'center',
|
|
40
|
+
colorFn: (t) => gradient(t, ['#ff79c6', '#bd93f9', '#8be9fd']),
|
|
41
|
+
}));
|
|
42
|
+
console.log();
|
|
43
|
+
|
|
44
|
+
// ── 2. Setup theme + intro typewriter ────────────────────
|
|
45
|
+
themes.use('dracula');
|
|
46
|
+
await animate.typewriter(' All ansimax features in one script — CommonJS edition', {
|
|
47
|
+
speed: 25,
|
|
48
|
+
colorFn: (t) => themes.primary(t),
|
|
49
|
+
});
|
|
50
|
+
console.log('\n');
|
|
51
|
+
await sleep(400);
|
|
52
|
+
|
|
53
|
+
// ── 3. Colors ─────────────────────────────────────────────
|
|
54
|
+
console.log(components.section('🎨 Colors', { width: 60 }));
|
|
55
|
+
console.log();
|
|
56
|
+
console.log(' Basic: ',
|
|
57
|
+
color.red('red'), color.green('green'), color.blue('blue'),
|
|
58
|
+
color.yellow('yellow'), color.magenta('magenta'), color.cyan('cyan'));
|
|
59
|
+
console.log(' Bright: ',
|
|
60
|
+
color.brightRed('red'), color.brightGreen('green'), color.brightBlue('blue'),
|
|
61
|
+
color.brightYellow('yellow'), color.brightMagenta('magenta'), color.brightCyan('cyan'));
|
|
62
|
+
console.log(' Modifiers:',
|
|
63
|
+
color.bold('bold'), color.italic('italic'),
|
|
64
|
+
color.underline('underline'), color.dim('dim'), color.inverse('inverse'));
|
|
65
|
+
console.log(' Hex: ',
|
|
66
|
+
color.hex('#ff79c6')('#ff79c6'),
|
|
67
|
+
color.hex('#bd93f9')('#bd93f9'),
|
|
68
|
+
color.hex('#8be9fd')('#8be9fd'),
|
|
69
|
+
color.hex('#50fa7b')('#50fa7b'));
|
|
70
|
+
console.log();
|
|
71
|
+
|
|
72
|
+
// ── 4. Gradients ──────────────────────────────────────────
|
|
73
|
+
console.log(components.section('🌈 Gradients', { width: 60 }));
|
|
74
|
+
console.log();
|
|
75
|
+
console.log(' Rainbow:', rainbow('Rainbow text with multiple colors'));
|
|
76
|
+
console.log(' Sunset: ', colorPresets.sunset('Beautiful sunset gradient'));
|
|
77
|
+
console.log(' Ocean: ', colorPresets.ocean('Deep ocean gradient'));
|
|
78
|
+
console.log(' Fire: ', colorPresets.fire('Burning fire gradient'));
|
|
79
|
+
console.log(' Custom: ', gradient('Custom multi-stop gradient', ['#ff6b6b', '#feca57', '#48dbfb']));
|
|
80
|
+
console.log();
|
|
81
|
+
|
|
82
|
+
// ── 5. ASCII boxes ────────────────────────────────────────
|
|
83
|
+
console.log(components.section('📦 Boxes', { width: 60 }));
|
|
84
|
+
console.log();
|
|
85
|
+
console.log(ascii.box('Single border', { padding: 1, borderStyle: 'single' }));
|
|
86
|
+
console.log(ascii.box('Rounded border', { padding: 1, borderStyle: 'rounded' }));
|
|
87
|
+
console.log(ascii.box('Heavy border', { padding: 1, borderStyle: 'heavy' }));
|
|
88
|
+
console.log();
|
|
89
|
+
|
|
90
|
+
// ── 6. Trees ──────────────────────────────────────────────
|
|
91
|
+
console.log(components.section('🌳 Trees', { width: 60 }));
|
|
92
|
+
console.log();
|
|
93
|
+
const proj = tree({ label: 'project', icon: '📦', color: color.bold });
|
|
94
|
+
const src = proj.add({ label: 'src', icon: '📁' });
|
|
95
|
+
src.addLeaf({ label: 'index.js', icon: '📄' });
|
|
96
|
+
src.addLeaf({ label: 'utils.js', icon: '📄' });
|
|
97
|
+
proj.addLeaf({ label: 'package.json', icon: '📦' });
|
|
98
|
+
proj.addLeaf({ label: 'README.md', icon: '📝' });
|
|
99
|
+
console.log(proj.render({
|
|
100
|
+
style: 'rounded',
|
|
101
|
+
palette: [color.cyan, color.green, color.magenta],
|
|
102
|
+
guideColor: color.dim,
|
|
103
|
+
}));
|
|
104
|
+
console.log();
|
|
105
|
+
|
|
106
|
+
// ── 7. Tables ─────────────────────────────────────────────
|
|
107
|
+
console.log(components.section('📊 Tables', { width: 60 }));
|
|
108
|
+
console.log();
|
|
109
|
+
console.log(components.table([
|
|
110
|
+
['Module', 'Status', 'Tests'],
|
|
111
|
+
['colors', color.green('● ready'), '180'],
|
|
112
|
+
['ascii', color.green('● ready'), '125'],
|
|
113
|
+
['trees', color.green('● ready'), '87'],
|
|
114
|
+
], { borderStyle: 'rounded' }));
|
|
115
|
+
console.log();
|
|
116
|
+
|
|
117
|
+
// ── 8. Badges & Status ────────────────────────────────────
|
|
118
|
+
console.log(components.section('🏷️ Badges & Status', { width: 60 }));
|
|
119
|
+
console.log();
|
|
120
|
+
console.log(' ',
|
|
121
|
+
components.badge('VERSION', 'v1.1.2'),
|
|
122
|
+
components.badge('BUILD', 'passing'),
|
|
123
|
+
components.badge('LICENSE', 'Apache 2.0'));
|
|
124
|
+
console.log();
|
|
125
|
+
console.log(components.status('Build started', { type: 'info' }));
|
|
126
|
+
console.log(components.status('Tests passed', { type: 'success' }));
|
|
127
|
+
console.log(components.status('1 deprecation', { type: 'warning' }));
|
|
128
|
+
console.log(components.status('Build failed', { type: 'error' }));
|
|
129
|
+
console.log();
|
|
130
|
+
|
|
131
|
+
// ── 9. Loaders ────────────────────────────────────────────
|
|
132
|
+
console.log(components.section('⏳ Loaders', { width: 60 }));
|
|
133
|
+
console.log();
|
|
134
|
+
let stop = loader.spin('Loading data...', { color: '#bd93f9' });
|
|
135
|
+
await sleep(1200);
|
|
136
|
+
stop('Data loaded successfully!', true);
|
|
137
|
+
|
|
138
|
+
await loader.tasks([
|
|
139
|
+
{ text: 'Compiling sources', fn: async () => await sleep(700) },
|
|
140
|
+
{ text: 'Bundling modules', fn: async () => await sleep(900) },
|
|
141
|
+
{ text: 'Generating type defs', fn: async () => await sleep(600) },
|
|
142
|
+
]);
|
|
143
|
+
console.log();
|
|
144
|
+
|
|
145
|
+
// ── 10. Pixel art ─────────────────────────────────────────
|
|
146
|
+
console.log(components.section('🎨 Pixel Art', { width: 60 }));
|
|
147
|
+
console.log();
|
|
148
|
+
console.log(' Heart sprite: ', images.sprite('heart'));
|
|
149
|
+
console.log();
|
|
150
|
+
console.log(' Gradient bar:');
|
|
151
|
+
console.log(gradientRect({
|
|
152
|
+
width: 50,
|
|
153
|
+
height: 2,
|
|
154
|
+
colors: ['#ff6b6b', '#feca57', '#48dbfb', '#a29bfe'],
|
|
155
|
+
dither: 'bayer',
|
|
156
|
+
}));
|
|
157
|
+
console.log();
|
|
158
|
+
|
|
159
|
+
// ── 11. Animations ────────────────────────────────────────
|
|
160
|
+
console.log(components.section('✨ Animations', { width: 60 }));
|
|
161
|
+
console.log();
|
|
162
|
+
await animate.fadeIn(' Smooth fade-in animation', { duration: 500 });
|
|
163
|
+
console.log();
|
|
164
|
+
await animate.typewriter(' Typewriter effect typing one char at a time...', { speed: 25 });
|
|
165
|
+
console.log('\n');
|
|
166
|
+
|
|
167
|
+
// ── 12. Timeline ──────────────────────────────────────────
|
|
168
|
+
console.log(components.section('📅 Timeline', { width: 60 }));
|
|
169
|
+
console.log();
|
|
170
|
+
console.log(components.timeline([
|
|
171
|
+
{ label: 'Project created', done: true, time: 'Mon' },
|
|
172
|
+
{ label: 'Dependencies installed', done: true, time: 'Tue' },
|
|
173
|
+
{ label: 'Tests passing', done: true, time: 'Wed' },
|
|
174
|
+
{ label: 'Documentation written', done: false, time: 'Thu' },
|
|
175
|
+
{ label: 'Published to npm', done: false },
|
|
176
|
+
]));
|
|
177
|
+
console.log();
|
|
178
|
+
|
|
179
|
+
// ── 13. Themes ────────────────────────────────────────────
|
|
180
|
+
console.log(components.section('🎭 Themes', { width: 60 }));
|
|
181
|
+
console.log();
|
|
182
|
+
for (const name of ['dracula', 'nord', 'monokai', 'cyberpunk', 'matrix']) {
|
|
183
|
+
themes.use(name);
|
|
184
|
+
console.log(' ', name.padEnd(12),
|
|
185
|
+
themes.primary('primary'),
|
|
186
|
+
themes.accent('accent'),
|
|
187
|
+
themes.success('success'),
|
|
188
|
+
themes.warning('warning'),
|
|
189
|
+
themes.error('error'));
|
|
190
|
+
}
|
|
191
|
+
console.log();
|
|
192
|
+
|
|
193
|
+
// ── 14. Final box ─────────────────────────────────────────
|
|
194
|
+
themes.use('dracula');
|
|
195
|
+
console.log(box(
|
|
196
|
+
themes.primary('✨ Ansimax demo complete ✨') + '\n' +
|
|
197
|
+
themes.muted('CommonJS · require · Zero deps'),
|
|
198
|
+
{ padding: 1, borderStyle: 'rounded' },
|
|
199
|
+
));
|
|
200
|
+
console.log();
|
|
201
|
+
|
|
202
|
+
// ── 15. Farewell ──────────────────────────────────────────
|
|
203
|
+
await animate.fadeOut('Thanks for trying ansimax!', { duration: 800 });
|
|
204
|
+
console.log();
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
main().catch((err) => {
|
|
208
|
+
console.error('Error:', err);
|
|
209
|
+
process.exit(1);
|
|
210
|
+
});
|