ansimax 1.3.0 → 1.3.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,398 @@
1
+ # šŸŽ¬ ansimax — Complete showcase
2
+
3
+ A complete, runnable demo app combining **every module** of ansimax in one realistic scenario. Save as `showcase.mjs` and run:
4
+
5
+ ```bash
6
+ node showcase.mjs
7
+ ```
8
+
9
+ This file is **pure JavaScript ESM** — no transpilation needed. You can copy-paste the whole thing into a single `.mjs` file and it will work.
10
+
11
+ > ā±ļø Approximate runtime: ~12 seconds (it's animated; the demo has intentional delays).
12
+
13
+ ---
14
+
15
+ ## šŸ“‚ The scenario
16
+
17
+ We're going to build a fake CLI for a fictional service called **`stardust`** — a code-generation tool. The CLI does what real tools do: shows a banner, fetches data, runs build tasks, prints a results table, displays a project tree, and renders some pixel art.
18
+
19
+ This showcases:
20
+
21
+ 1. **`color`** + **`gradient`** — Header banner
22
+ 2. **`ascii`** — figlet text + box
23
+ 3. **`animate`** — Typewriter intro
24
+ 4. **`loader`** — Spinner during "fetch"
25
+ 5. **`loader.tasks`** — Multi-step build pipeline
26
+ 6. **`components`** — Status messages + table + badges + timeline
27
+ 7. **`themes`** — Switch active theme mid-run
28
+ 8. **`trees`** — Display project structure
29
+ 9. **`frames`** — Animated transitions
30
+ 10. **`images`** — Pixel art finale
31
+ 11. **`panels`** — Side-by-side layouts
32
+ 12. **`json`** — Pretty-printed config
33
+
34
+ ---
35
+
36
+ ## šŸš€ The complete code
37
+
38
+ ```js
39
+ // ─────────────────────────────────────────────────────────────
40
+ // ansimax — complete showcase (v1.3.2)
41
+ //
42
+ // Run: node showcase.mjs
43
+ // ─────────────────────────────────────────────────────────────
44
+
45
+ import {
46
+ color, gradient, animateGradient,
47
+ ascii, animate, loader, frames,
48
+ components, themes, trees,
49
+ renderPixelArt, gradientRect, SPRITES, createCanvas,
50
+ panels, json,
51
+ } from 'ansimax';
52
+
53
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
54
+
55
+ // ─────────────────────────────────────────────────────────────
56
+ // Step 1 — Header banner (color, gradient, ascii)
57
+ // ─────────────────────────────────────────────────────────────
58
+
59
+ console.clear();
60
+
61
+ const banner = ascii.figletText('STARDUST', { font: 'standard' });
62
+ const colored = gradient(banner, ['#ff79c6', '#bd93f9', '#8be9fd']);
63
+ console.log(colored);
64
+
65
+ console.log(
66
+ panels.center(
67
+ color.bold('✨ Code generation, simplified ✨'),
68
+ { width: 70 },
69
+ ),
70
+ );
71
+ console.log();
72
+
73
+ await sleep(400);
74
+
75
+ // ─────────────────────────────────────────────────────────────
76
+ // Step 2 — Animated intro (animate.typewriter)
77
+ // ─────────────────────────────────────────────────────────────
78
+
79
+ const introLines = [
80
+ '> Initializing stardust v2.4.1',
81
+ '> Loading configuration from .stardustrc',
82
+ '> Checking for updates...',
83
+ ];
84
+
85
+ for (const line of introLines) {
86
+ await animate.typewriter(color.green(line), { speed: 22 });
87
+ console.log();
88
+ await sleep(150);
89
+ }
90
+
91
+ console.log();
92
+ await sleep(300);
93
+
94
+ // ─────────────────────────────────────────────────────────────
95
+ // Step 3 — Show registered themes + switch (themes)
96
+ // ─────────────────────────────────────────────────────────────
97
+
98
+ console.log(color.cyan('šŸŽØ Available themes: ') + themes.list().join(', '));
99
+
100
+ themes.use('dracula');
101
+ console.log(color.cyan(`šŸŽØ Active theme: `) + themes.current().name);
102
+ console.log();
103
+
104
+ await sleep(500);
105
+
106
+ // ─────────────────────────────────────────────────────────────
107
+ // Step 4 — Loader spinner during "fetch" (loader.spin)
108
+ // ─────────────────────────────────────────────────────────────
109
+
110
+ const stop = loader.spin('Fetching template from registry...', {
111
+ type: 'dots',
112
+ color: '#bd93f9',
113
+ });
114
+
115
+ await sleep(1500);
116
+ stop('Template loaded: react-app-typescript', true);
117
+ console.log();
118
+
119
+ await sleep(300);
120
+
121
+ // ─────────────────────────────────────────────────────────────
122
+ // Step 5 — Hierarchical tasks (loader.tasks)
123
+ // ─────────────────────────────────────────────────────────────
124
+
125
+ console.log(color.bold('\nšŸ“¦ Building project...\n'));
126
+
127
+ await loader.tasks([
128
+ {
129
+ text: 'Scaffold project structure',
130
+ fn: async () => sleep(400),
131
+ subtasks: [
132
+ { text: 'Create directories', fn: async () => sleep(150) },
133
+ { text: 'Copy template files', fn: async () => sleep(300) },
134
+ { text: 'Generate package.json', fn: async () => sleep(200) },
135
+ ],
136
+ },
137
+ {
138
+ text: 'Install dependencies',
139
+ fn: async () => sleep(200),
140
+ subtasks: [
141
+ { text: 'Resolve versions', fn: async () => sleep(300) },
142
+ { text: 'Download packages', fn: async () => sleep(600) },
143
+ { text: 'Link binaries', fn: async () => sleep(200) },
144
+ ],
145
+ },
146
+ { text: 'Run initial build', fn: async () => sleep(500) },
147
+ { text: 'Verify integrity', fn: async () => sleep(250) },
148
+ ]);
149
+
150
+ console.log();
151
+ await sleep(300);
152
+
153
+ // ─────────────────────────────────────────────────────────────
154
+ // Step 6 — Components: status, badge, table (components)
155
+ // ─────────────────────────────────────────────────────────────
156
+
157
+ console.log(components.status('success', 'Build completed in 2.4s'));
158
+ console.log(components.status('warn', '3 deprecation notices (run `stardust audit` for details)'));
159
+ console.log(components.status('info', 'Project ready at ./my-app'));
160
+ console.log();
161
+
162
+ console.log(
163
+ components.badge('VERSION', 'v2.4.1'),
164
+ components.badge('PROJECT', 'my-app'),
165
+ components.badge('FRAMEWORK', 'react'),
166
+ components.badge('TEMPLATE', 'typescript'),
167
+ );
168
+ console.log();
169
+
170
+ console.log(components.table([
171
+ ['Stage', 'Duration', 'Status'],
172
+ ['Scaffold', '650ms', color.green('āœ“ done')],
173
+ ['Dependencies', '1100ms', color.green('āœ“ done')],
174
+ ['Build', '500ms', color.green('āœ“ done')],
175
+ ['Verify', '250ms', color.green('āœ“ done')],
176
+ ['Total', '2500ms', color.green('āœ“ success')],
177
+ ], { borderStyle: 'rounded', padding: 1 }));
178
+
179
+ console.log();
180
+ await sleep(500);
181
+
182
+ // ─────────────────────────────────────────────────────────────
183
+ // Step 7 — Project structure (trees)
184
+ // ─────────────────────────────────────────────────────────────
185
+
186
+ console.log(color.bold('šŸ“ Project structure:\n'));
187
+
188
+ console.log(trees.tree({
189
+ label: 'my-app/',
190
+ children: [
191
+ {
192
+ label: 'src/',
193
+ children: [
194
+ { label: 'components/', children: [
195
+ { label: 'App.tsx' },
196
+ { label: 'Header.tsx' },
197
+ { label: 'Footer.tsx' },
198
+ ]},
199
+ { label: 'pages/', children: [
200
+ { label: 'Home.tsx' },
201
+ { label: 'About.tsx' },
202
+ ]},
203
+ { label: 'index.tsx' },
204
+ { label: 'styles.css' },
205
+ ],
206
+ },
207
+ { label: 'public/', children: [
208
+ { label: 'favicon.ico' },
209
+ { label: 'logo.svg' },
210
+ ]},
211
+ { label: 'package.json' },
212
+ { label: 'tsconfig.json' },
213
+ { label: 'README.md' },
214
+ ],
215
+ }, { style: 'unicode' }));
216
+
217
+ console.log();
218
+ await sleep(500);
219
+
220
+ // ─────────────────────────────────────────────────────────────
221
+ // Step 8 — Timeline of release milestones (components.timeline)
222
+ // ─────────────────────────────────────────────────────────────
223
+
224
+ console.log(color.bold('šŸ—“ļø Release milestones:\n'));
225
+
226
+ console.log(components.timeline([
227
+ { label: 'v1.0 — Initial release', time: 'Jan 2025', done: true },
228
+ { label: 'v1.5 — TypeScript support', time: 'Mar 2025', done: true },
229
+ { label: 'v2.0 — Plugin system', time: 'Jul 2025', done: true },
230
+ { label: 'v2.4 — Current stable', time: 'Now', done: true },
231
+ { label: 'v2.5 — Templates marketplace', time: 'Q2 2026', done: false },
232
+ { label: 'v3.0 — AI-powered scaffolding', time: 'Q4 2026', done: false },
233
+ ], { node: 'ā—', connector: '│' }));
234
+
235
+ console.log();
236
+ await sleep(500);
237
+
238
+ // ─────────────────────────────────────────────────────────────
239
+ // Step 9 — Config preview with JSON pretty-print (json)
240
+ // ─────────────────────────────────────────────────────────────
241
+
242
+ console.log(color.bold('āš™ļø Generated configuration:\n'));
243
+
244
+ console.log(json.pretty({
245
+ name: 'my-app',
246
+ version: '0.1.0',
247
+ framework: 'react',
248
+ features: ['typescript', 'eslint', 'prettier', 'testing-library'],
249
+ scripts: {
250
+ dev: 'stardust dev',
251
+ build: 'stardust build',
252
+ test: 'stardust test',
253
+ },
254
+ meta: {
255
+ generatedBy: 'stardust',
256
+ generatedAt: '2026-06-13T10:00:00Z',
257
+ template: 'react-app-typescript',
258
+ },
259
+ }, { sortKeys: false }));
260
+
261
+ console.log();
262
+ await sleep(500);
263
+
264
+ // ─────────────────────────────────────────────────────────────
265
+ // Step 10 — Side-by-side panel layout (panels)
266
+ // ─────────────────────────────────────────────────────────────
267
+
268
+ console.log(color.bold('šŸ“Š Quick stats:\n'));
269
+
270
+ const leftCard = ascii.box(
271
+ color.cyan('FILES\n') +
272
+ color.bold('42'),
273
+ { borderStyle: 'rounded', padding: 1 },
274
+ );
275
+
276
+ const midCard = ascii.box(
277
+ color.magenta('LINES\n') +
278
+ color.bold('1,247'),
279
+ { borderStyle: 'rounded', padding: 1 },
280
+ );
281
+
282
+ const rightCard = ascii.box(
283
+ color.green('TESTS\n') +
284
+ color.bold('38/38'),
285
+ { borderStyle: 'rounded', padding: 1 },
286
+ );
287
+
288
+ console.log(panels.vsplit([leftCard, midCard, rightCard], { gap: 2 }));
289
+
290
+ console.log();
291
+ await sleep(500);
292
+
293
+ // ─────────────────────────────────────────────────────────────
294
+ // Step 11 — Frame animation finale (frames)
295
+ // ─────────────────────────────────────────────────────────────
296
+
297
+ console.log();
298
+
299
+ const morphed = frames.morph('LOADING...', 'COMPLETE!', 16, 'ā–‘ā–’ā–“ā–ˆā–“ā–’ā–‘');
300
+ await frames.play(morphed, { interval: 70, loop: false }).promise;
301
+
302
+ console.log();
303
+ await sleep(400);
304
+
305
+ // ─────────────────────────────────────────────────────────────
306
+ // Step 12 — Pixel art + canvas finale (images)
307
+ // ─────────────────────────────────────────────────────────────
308
+
309
+ console.log(color.bold('\nšŸŽØ Generated by stardust:\n'));
310
+
311
+ // A small banner with gradient rectangle + pixel art sprite
312
+ const canvas = createCanvas(50, 12, { r: 25, g: 25, b: 40 });
313
+
314
+ // Decorative frame
315
+ const cyan = { r: 0, g: 200, b: 255 };
316
+ const pink = { r: 255, g: 105, b: 180 };
317
+ const yellow = { r: 255, g: 220, b: 0 };
318
+
319
+ canvas.drawRect(0, 0, 50, 12, cyan, false); // border
320
+ canvas.drawCircle(10, 6, 3, pink, true);
321
+ canvas.drawCircle(40, 6, 3, yellow, true);
322
+
323
+ canvas.print();
324
+
325
+ console.log();
326
+ console.log(renderPixelArt(SPRITES.star.pixels, { scale: 2 }));
327
+ console.log();
328
+
329
+ await sleep(500);
330
+
331
+ // ─────────────────────────────────────────────────────────────
332
+ // Step 13 — Final animated gradient farewell
333
+ // ─────────────────────────────────────────────────────────────
334
+
335
+ console.log();
336
+ const farewell = animateGradient(
337
+ '✨ Built with ansimax — see you next time! ✨',
338
+ ['#ff79c6', '#bd93f9', '#8be9fd', '#50fa7b', '#ffd93d'],
339
+ {
340
+ interval: 70,
341
+ cycles: 2,
342
+ duration: 600,
343
+ infinite: false,
344
+ },
345
+ );
346
+
347
+ await farewell.promise;
348
+ console.log('\n');
349
+
350
+ console.log(panels.frame(
351
+ color.brightBlack(' npm install ansimax | github.com/Brashkie/ansimax '),
352
+ { title: ' Get started ', padding: 1 },
353
+ ));
354
+
355
+ console.log();
356
+ ```
357
+
358
+ ---
359
+
360
+ ## šŸŽÆ What this showcase demonstrates
361
+
362
+ | Module | Where it's used |
363
+ |---|---|
364
+ | `color` | Status messages, table cells, stats cards |
365
+ | `gradient` | Header banner, animated farewell |
366
+ | `ascii` | Figlet banner, boxes for stats cards |
367
+ | `animate` | Typewriter intro lines |
368
+ | `loader` | Spinner + hierarchical tasks pipeline |
369
+ | `components` | Status messages, badges, table, timeline |
370
+ | `themes` | Theme listing + switching |
371
+ | `trees` | Project structure visualization |
372
+ | `frames` | Morph animation for "LOADING → COMPLETE" |
373
+ | `images` | Canvas drawing + sprite rendering |
374
+ | `panels` | Three-column stats layout, centering header, frame footer |
375
+ | `json` | Generated config display |
376
+
377
+ ---
378
+
379
+ ## šŸ› ļø Customizing the showcase
380
+
381
+ Want to use this as a starter for your own CLI? Here's what to change:
382
+
383
+ 1. **Replace `STARDUST` banner** with your own brand name
384
+ 2. **Edit `intro` lines** to describe your tool's startup process
385
+ 3. **Replace the build task list** with your actual workflow steps
386
+ 4. **Update the config JSON** with your tool's real output format
387
+ 5. **Swap pixel art sprite** with your logo (use `SPRITES.heart`, `SPRITES.crown`, etc., or build a custom one)
388
+
389
+ The structure is intentionally generic — any code-generation, build, deploy, or scaffolding tool can adapt this pattern.
390
+
391
+ ---
392
+
393
+ ## šŸŽÆ Next steps
394
+
395
+ - **Back to docs index?** → [`README.md`](./README.md)
396
+ - **TypeScript examples?** → [`examples-ts.md`](./examples-ts.md)
397
+ - **ESM examples?** → [`examples-mjs.md`](./examples-mjs.md)
398
+ - **CommonJS examples?** → [`examples-cjs.md`](./examples-cjs.md)
@@ -118,7 +118,7 @@ async function main() {
118
118
  console.log(components.section('šŸ·ļø Badges & Status', { width: 60 }));
119
119
  console.log();
120
120
  console.log(' ',
121
- components.badge('VERSION', 'v1.3.0'),
121
+ components.badge('VERSION', 'v1.3.2'),
122
122
  components.badge('BUILD', 'passing'),
123
123
  components.badge('LICENSE', 'Apache 2.0'));
124
124
  console.log();
@@ -117,7 +117,7 @@ console.log();
117
117
  console.log(components.section('šŸ·ļø Badges & Status', { width: 60 }));
118
118
  console.log();
119
119
  console.log(' ',
120
- components.badge('VERSION', 'v1.3.0'),
120
+ components.badge('VERSION', 'v1.3.2'),
121
121
  components.badge('BUILD', 'passing'),
122
122
  components.badge('LICENSE', 'Apache 2.0'));
123
123
  console.log();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ansimax",
3
- "version": "1.3.0",
3
+ "version": "1.3.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",
@@ -93,6 +93,7 @@
93
93
  "files": [
94
94
  "dist",
95
95
  "examples",
96
+ "docs",
96
97
  "README.md",
97
98
  "README.es.md",
98
99
  "CHANGELOG.md",