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.
@@ -0,0 +1,203 @@
1
+ /**
2
+ * all-in-one.mjs
3
+ *
4
+ * Comprehensive ansimax demo — ESM (import).
5
+ *
6
+ * This example imports directly from `'ansimax'` (npm registry),
7
+ * so you can copy-paste it into any project after `npm install ansimax`.
8
+ *
9
+ * Run:
10
+ * node examples/all-in-one.mjs
11
+ *
12
+ * (Requires `ansimax` installed: `npm install ansimax`)
13
+ */
14
+
15
+ import {
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
+ } from 'ansimax';
30
+
31
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
32
+
33
+ console.clear();
34
+
35
+ // ── 1. Banner with gradient ───────────────────────────────
36
+ console.log(ascii.banner('ANSIMAX', {
37
+ font: 'big',
38
+ align: 'center',
39
+ colorFn: (t) => gradient(t, ['#ff79c6', '#bd93f9', '#8be9fd']),
40
+ }));
41
+ console.log();
42
+
43
+ // ── 2. Setup theme + intro typewriter ────────────────────
44
+ themes.use('dracula');
45
+ await animate.typewriter(' All ansimax features in one script — ESM edition', {
46
+ speed: 25,
47
+ colorFn: (t) => themes.primary(t),
48
+ });
49
+ console.log('\n');
50
+ await sleep(400);
51
+
52
+ // ── 3. Colors ─────────────────────────────────────────────
53
+ console.log(components.section('🎨 Colors', { width: 60 }));
54
+ console.log();
55
+ console.log(' Basic: ',
56
+ color.red('red'), color.green('green'), color.blue('blue'),
57
+ color.yellow('yellow'), color.magenta('magenta'), color.cyan('cyan'));
58
+ console.log(' Bright: ',
59
+ color.brightRed('red'), color.brightGreen('green'), color.brightBlue('blue'),
60
+ color.brightYellow('yellow'), color.brightMagenta('magenta'), color.brightCyan('cyan'));
61
+ console.log(' Modifiers:',
62
+ color.bold('bold'), color.italic('italic'),
63
+ color.underline('underline'), color.dim('dim'), color.inverse('inverse'));
64
+ console.log(' Hex: ',
65
+ color.hex('#ff79c6')('#ff79c6'),
66
+ color.hex('#bd93f9')('#bd93f9'),
67
+ color.hex('#8be9fd')('#8be9fd'),
68
+ color.hex('#50fa7b')('#50fa7b'));
69
+ console.log();
70
+
71
+ // ── 4. Gradients ──────────────────────────────────────────
72
+ console.log(components.section('🌈 Gradients', { width: 60 }));
73
+ console.log();
74
+ console.log(' Rainbow:', rainbow('Rainbow text with multiple colors'));
75
+ console.log(' Sunset: ', colorPresets.sunset('Beautiful sunset gradient'));
76
+ console.log(' Ocean: ', colorPresets.ocean('Deep ocean gradient'));
77
+ console.log(' Fire: ', colorPresets.fire('Burning fire gradient'));
78
+ console.log(' Custom: ', gradient('Custom multi-stop gradient', ['#ff6b6b', '#feca57', '#48dbfb']));
79
+ console.log();
80
+
81
+ // ── 5. ASCII boxes ────────────────────────────────────────
82
+ console.log(components.section('📦 Boxes', { width: 60 }));
83
+ console.log();
84
+ console.log(ascii.box('Single border', { padding: 1, borderStyle: 'single' }));
85
+ console.log(ascii.box('Rounded border', { padding: 1, borderStyle: 'rounded' }));
86
+ console.log(ascii.box('Heavy border', { padding: 1, borderStyle: 'heavy' }));
87
+ console.log();
88
+
89
+ // ── 6. Trees ──────────────────────────────────────────────
90
+ console.log(components.section('🌳 Trees', { width: 60 }));
91
+ console.log();
92
+ const proj = tree({ label: 'project', icon: '📦', color: color.bold });
93
+ const src = proj.add({ label: 'src', icon: '📁' });
94
+ src.addLeaf({ label: 'index.js', icon: '📄' });
95
+ src.addLeaf({ label: 'utils.js', icon: '📄' });
96
+ proj.addLeaf({ label: 'package.json', icon: '📦' });
97
+ proj.addLeaf({ label: 'README.md', icon: '📝' });
98
+ console.log(proj.render({
99
+ style: 'rounded',
100
+ palette: [color.cyan, color.green, color.magenta],
101
+ guideColor: color.dim,
102
+ }));
103
+ console.log();
104
+
105
+ // ── 7. Tables ─────────────────────────────────────────────
106
+ console.log(components.section('📊 Tables', { width: 60 }));
107
+ console.log();
108
+ console.log(components.table([
109
+ ['Module', 'Status', 'Tests'],
110
+ ['colors', color.green('● ready'), '180'],
111
+ ['ascii', color.green('● ready'), '125'],
112
+ ['trees', color.green('● ready'), '87'],
113
+ ], { borderStyle: 'rounded' }));
114
+ console.log();
115
+
116
+ // ── 8. Badges & Status ────────────────────────────────────
117
+ console.log(components.section('🏷️ Badges & Status', { width: 60 }));
118
+ console.log();
119
+ console.log(' ',
120
+ components.badge('VERSION', 'v1.1.2'),
121
+ components.badge('BUILD', 'passing'),
122
+ components.badge('LICENSE', 'Apache 2.0'));
123
+ console.log();
124
+ console.log(components.status('Build started', { type: 'info' }));
125
+ console.log(components.status('Tests passed', { type: 'success' }));
126
+ console.log(components.status('1 deprecation', { type: 'warning' }));
127
+ console.log(components.status('Build failed', { type: 'error' }));
128
+ console.log();
129
+
130
+ // ── 9. Loaders ────────────────────────────────────────────
131
+ console.log(components.section('⏳ Loaders', { width: 60 }));
132
+ console.log();
133
+ let stop = loader.spin('Loading data...', { color: '#bd93f9' });
134
+ await sleep(1200);
135
+ stop('Data loaded successfully!', true);
136
+
137
+ await loader.tasks([
138
+ { text: 'Compiling sources', fn: async () => await sleep(700) },
139
+ { text: 'Bundling modules', fn: async () => await sleep(900) },
140
+ { text: 'Generating type defs', fn: async () => await sleep(600) },
141
+ ]);
142
+ console.log();
143
+
144
+ // ── 10. Pixel art ─────────────────────────────────────────
145
+ console.log(components.section('🎨 Pixel Art', { width: 60 }));
146
+ console.log();
147
+ console.log(' Heart sprite: ', images.sprite('heart'));
148
+ console.log();
149
+ console.log(' Gradient bar:');
150
+ console.log(gradientRect({
151
+ width: 50,
152
+ height: 2,
153
+ colors: ['#ff6b6b', '#feca57', '#48dbfb', '#a29bfe'],
154
+ dither: 'bayer',
155
+ }));
156
+ console.log();
157
+
158
+ // ── 11. Animations ────────────────────────────────────────
159
+ console.log(components.section('✨ Animations', { width: 60 }));
160
+ console.log();
161
+ await animate.fadeIn(' Smooth fade-in animation', { duration: 500 });
162
+ console.log();
163
+ await animate.typewriter(' Typewriter effect typing one char at a time...', { speed: 25 });
164
+ console.log('\n');
165
+
166
+ // ── 12. Timeline ──────────────────────────────────────────
167
+ console.log(components.section('📅 Timeline', { width: 60 }));
168
+ console.log();
169
+ console.log(components.timeline([
170
+ { label: 'Project created', done: true, time: 'Mon' },
171
+ { label: 'Dependencies installed', done: true, time: 'Tue' },
172
+ { label: 'Tests passing', done: true, time: 'Wed' },
173
+ { label: 'Documentation written', done: false, time: 'Thu' },
174
+ { label: 'Published to npm', done: false },
175
+ ]));
176
+ console.log();
177
+
178
+ // ── 13. Themes ────────────────────────────────────────────
179
+ console.log(components.section('🎭 Themes', { width: 60 }));
180
+ console.log();
181
+ for (const name of ['dracula', 'nord', 'monokai', 'cyberpunk', 'matrix']) {
182
+ themes.use(name);
183
+ console.log(' ', name.padEnd(12),
184
+ themes.primary('primary'),
185
+ themes.accent('accent'),
186
+ themes.success('success'),
187
+ themes.warning('warning'),
188
+ themes.error('error'));
189
+ }
190
+ console.log();
191
+
192
+ // ── 14. Final box ─────────────────────────────────────────
193
+ themes.use('dracula');
194
+ console.log(box(
195
+ themes.primary('✨ Ansimax demo complete ✨') + '\n' +
196
+ themes.muted('ESM · import · Zero deps'),
197
+ { padding: 1, borderStyle: 'rounded' },
198
+ ));
199
+ console.log();
200
+
201
+ // ── 15. Farewell ──────────────────────────────────────────
202
+ await animate.fadeOut('Thanks for trying ansimax!', { duration: 800 });
203
+ console.log();
@@ -1,18 +1,18 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2020",
4
- "lib": ["ES2020"],
5
- "module": "ESNext",
6
- "moduleResolution": "bundler",
7
- "esModuleInterop": true,
8
- "strict": true,
9
- "skipLibCheck": true,
10
- "noEmit": true,
11
- "allowJs": true,
12
- "rootDir": ".",
13
- "types": ["node"],
14
- "ignoreDeprecations": "6.0"
15
- },
16
- "include": ["./**/*.ts", "./**/*.js"],
17
- "exclude": ["../node_modules", "../dist"]
18
- }
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "lib": ["ES2020"],
5
+ "module": "ESNext",
6
+ "moduleResolution": "bundler",
7
+ "esModuleInterop": true,
8
+ "strict": true,
9
+ "skipLibCheck": true,
10
+ "noEmit": true,
11
+ "allowJs": true,
12
+ "rootDir": ".",
13
+ "types": ["node"],
14
+ "ignoreDeprecations": "6.0"
15
+ },
16
+ "include": ["./**/*.ts", "./**/*.js"],
17
+ "exclude": ["../node_modules", "../dist"]
18
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ansimax",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "Zero-dependency CLI rendering library: colors, gradients, animations, ASCII art, pixel art, components, and themes \u2014 all in TypeScript.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -119,4 +119,4 @@
119
119
  "publishConfig": {
120
120
  "access": "public"
121
121
  }
122
- }
122
+ }