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
package/README.es.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
_Colores • Gradientes • Animaciones • ASCII Art • Pixel Art • Árboles • Componentes • Temas_
|
|
8
8
|
|
|
9
9
|
[](LICENSE)
|
|
10
|
-
[](https://www.npmjs.com/package/ansimax)
|
|
11
11
|
[](tsconfig.json)
|
|
12
12
|
[](#testing)
|
|
13
13
|
[](#testing)
|
|
@@ -20,6 +20,27 @@ _Colores • Gradientes • Animaciones • ASCII Art • Pixel Art • Árboles
|
|
|
20
20
|
|
|
21
21
|
---
|
|
22
22
|
|
|
23
|
+
<div align="center">
|
|
24
|
+
|
|
25
|
+
### 🎬 Vista previa
|
|
26
|
+
|
|
27
|
+
<table>
|
|
28
|
+
<tr>
|
|
29
|
+
<td align="center">
|
|
30
|
+
<strong>Animaciones</strong><br/>
|
|
31
|
+
<img src="media/animations.gif" alt="Demo de animaciones de Ansimax" width="420"/>
|
|
32
|
+
</td>
|
|
33
|
+
<td align="center">
|
|
34
|
+
<strong>Loaders</strong><br/>
|
|
35
|
+
<img src="media/loaders.gif" alt="Demo de loaders de Ansimax" width="420"/>
|
|
36
|
+
</td>
|
|
37
|
+
</tr>
|
|
38
|
+
</table>
|
|
39
|
+
|
|
40
|
+
</div>
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
23
44
|
## 🌟 ¿Qué es Ansimax?
|
|
24
45
|
|
|
25
46
|
Ansimax es una **librería de renderizado todo-en-uno** para construir interfaces de terminal hermosas en Node.js. Un solo paquete reemplaza un stack de más de 8 dependencias — colores, gradientes, ASCII art, spinners, barras de progreso, tablas, menús, árboles, temas, pixel art — combinadas en una única API coherente de TypeScript con **cero dependencias en runtime**.
|
|
@@ -29,14 +50,14 @@ npm install ansimax
|
|
|
29
50
|
```
|
|
30
51
|
|
|
31
52
|
```ts
|
|
32
|
-
import { color, gradient, ascii, loader } from 'ansimax';
|
|
53
|
+
import { color, gradient, ascii, loader, sleep } from 'ansimax';
|
|
33
54
|
|
|
34
55
|
console.log(ascii.banner('hola', {
|
|
35
56
|
colorFn: (t) => gradient(t, ['#ff79c6', '#bd93f9', '#8be9fd']),
|
|
36
57
|
}));
|
|
37
58
|
|
|
38
59
|
const stop = loader.spin('Construyendo proyecto', { color: '#bd93f9' });
|
|
39
|
-
await
|
|
60
|
+
await sleep(1500);
|
|
40
61
|
stop('Build completado', true);
|
|
41
62
|
```
|
|
42
63
|
|
|
@@ -102,14 +123,14 @@ yarn add ansimax
|
|
|
102
123
|
## ⚡ Ejemplo en 30 segundos
|
|
103
124
|
|
|
104
125
|
```ts
|
|
105
|
-
import { color, gradient, loader, ascii } from 'ansimax';
|
|
126
|
+
import { color, gradient, loader, ascii, sleep } from 'ansimax';
|
|
106
127
|
|
|
107
128
|
console.log(ascii.banner('deploy', {
|
|
108
129
|
colorFn: (t) => gradient(t, ['#ff6b6b', '#feca57', '#48dbfb']),
|
|
109
130
|
}));
|
|
110
131
|
|
|
111
132
|
const stop = loader.spin('Construyendo proyecto', { color: '#bd93f9' });
|
|
112
|
-
await
|
|
133
|
+
await sleep(1500); // simula trabajo asíncrono
|
|
113
134
|
stop('Build completado', true); // ✓ + color de éxito
|
|
114
135
|
|
|
115
136
|
console.log(color.green('✓') + ' Listo en ' + color.bold('1.4s'));
|
|
@@ -166,12 +187,19 @@ console.log(themes.primary('primary de cyberpunk'));
|
|
|
166
187
|
<img src="media/colors.png" alt="Colores y gradientes" />
|
|
167
188
|
|
|
168
189
|
```ts
|
|
169
|
-
import { color, gradient } from 'ansimax';
|
|
190
|
+
import { color, gradient, rainbow } from 'ansimax';
|
|
191
|
+
|
|
192
|
+
// Colores básicos
|
|
193
|
+
console.log(color.red('rojo'), color.green('verde'), color.blue('azul'));
|
|
170
194
|
|
|
171
|
-
|
|
172
|
-
color.bold(
|
|
173
|
-
|
|
174
|
-
|
|
195
|
+
// Modificadores de estilo
|
|
196
|
+
console.log(color.bold('negrita'), color.italic('itálica'), color.underline('subrayado'));
|
|
197
|
+
|
|
198
|
+
// Gradiente multi-stop
|
|
199
|
+
console.log(gradient('fuego a océano', ['#ff6b6b', '#feca57', '#48dbfb']));
|
|
200
|
+
|
|
201
|
+
// Preset rainbow integrado
|
|
202
|
+
console.log(rainbow('preset rainbow integrado'));
|
|
175
203
|
```
|
|
176
204
|
|
|
177
205
|
### ASCII Art
|
|
@@ -181,13 +209,13 @@ color.rainbow('preset rainbow integrado');
|
|
|
181
209
|
```ts
|
|
182
210
|
import { ascii, gradient } from 'ansimax';
|
|
183
211
|
|
|
184
|
-
ascii.banner('HOLA', {
|
|
212
|
+
console.log(ascii.banner('HOLA', {
|
|
185
213
|
font: 'big',
|
|
186
214
|
align: 'center',
|
|
187
215
|
colorFn: (t) => gradient(t, ['#ff79c6', '#bd93f9']),
|
|
188
|
-
});
|
|
216
|
+
}));
|
|
189
217
|
|
|
190
|
-
ascii.box('¡Caja arcoiris!', { padding: 1, borderStyle: 'rounded' });
|
|
218
|
+
console.log(ascii.box('¡Caja arcoiris!', { padding: 1, borderStyle: 'rounded' }));
|
|
191
219
|
```
|
|
192
220
|
|
|
193
221
|
### Árboles
|
|
@@ -214,7 +242,7 @@ console.log(proyecto.render({
|
|
|
214
242
|
<img src="media/pixel_art.png" alt="Pixel art" />
|
|
215
243
|
|
|
216
244
|
```ts
|
|
217
|
-
import { images, createCanvas, gradientRect } from 'ansimax';
|
|
245
|
+
import { images, createCanvas, gradientRect, SPRITES } from 'ansimax';
|
|
218
246
|
|
|
219
247
|
// Sprite integrado
|
|
220
248
|
console.log(images.sprite('heart'));
|
|
@@ -230,7 +258,8 @@ console.log(gradientRect({
|
|
|
230
258
|
const c = createCanvas(40, 10);
|
|
231
259
|
c.fill({ r: 18, g: 18, b: 38 });
|
|
232
260
|
c.drawCircle(20, 5, 4, { r: 255, g: 200, b: 0 }, true);
|
|
233
|
-
|
|
261
|
+
const starSprite = SPRITES.star;
|
|
262
|
+
if (starSprite) c.drawSprite(2, 2, starSprite.pixels);
|
|
234
263
|
c.print();
|
|
235
264
|
```
|
|
236
265
|
|
|
@@ -241,15 +270,15 @@ c.print();
|
|
|
241
270
|
```ts
|
|
242
271
|
import { components, color } from 'ansimax';
|
|
243
272
|
|
|
244
|
-
components.table([
|
|
273
|
+
console.log(components.table([
|
|
245
274
|
['Módulo', 'Estado', 'Cobertura'],
|
|
246
275
|
['colors', color.green('● listo'), '100%'],
|
|
247
276
|
['animations', color.green('● listo'), '100%'],
|
|
248
277
|
['loaders', color.green('● listo'), '100%'],
|
|
249
|
-
], { borderStyle: 'rounded' });
|
|
278
|
+
], { borderStyle: 'rounded' }));
|
|
250
279
|
|
|
251
|
-
components.badge('VERSION', 'v1.1.
|
|
252
|
-
components.badge('BUILD', 'passing');
|
|
280
|
+
console.log(components.badge('VERSION', 'v1.1.2'));
|
|
281
|
+
console.log(components.badge('BUILD', 'passing'));
|
|
253
282
|
```
|
|
254
283
|
|
|
255
284
|
### Timeline
|
|
@@ -257,22 +286,24 @@ components.badge('BUILD', 'passing');
|
|
|
257
286
|
<img src="media/timeline.png" alt="Timeline" />
|
|
258
287
|
|
|
259
288
|
```ts
|
|
260
|
-
components
|
|
289
|
+
import { components } from 'ansimax';
|
|
290
|
+
|
|
291
|
+
console.log(components.timeline([
|
|
261
292
|
{ label: 'Init del proyecto', done: true, time: '10:00' },
|
|
262
293
|
{ label: 'Pipeline de build', done: true, time: '10:15' },
|
|
263
294
|
{ label: 'Correr tests', done: false, time: '10:32' },
|
|
264
295
|
{ label: 'Deploy a npm', done: false },
|
|
265
|
-
]);
|
|
296
|
+
]));
|
|
266
297
|
```
|
|
267
298
|
|
|
268
299
|
### Loaders y Progreso
|
|
269
300
|
|
|
270
301
|
```ts
|
|
271
|
-
import { loader } from 'ansimax';
|
|
302
|
+
import { loader, sleep } from 'ansimax';
|
|
272
303
|
|
|
273
304
|
// Spinner con éxito/fallo
|
|
274
305
|
const stop = loader.spin('Cargando...', { color: '#bd93f9' });
|
|
275
|
-
await
|
|
306
|
+
await sleep(1500);
|
|
276
307
|
stop('¡Listo!', true); // ✓ ícono verde
|
|
277
308
|
|
|
278
309
|
// Barra de progreso animada
|
|
@@ -282,18 +313,22 @@ await loader.progressAnimate(100, 'Descargando', {
|
|
|
282
313
|
|
|
283
314
|
// Tareas jerárquicas con ejecución paralela
|
|
284
315
|
await loader.tasks([
|
|
285
|
-
{
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
316
|
+
{
|
|
317
|
+
text: 'Build',
|
|
318
|
+
fn: async () => await sleep(500),
|
|
319
|
+
subtasks: [
|
|
320
|
+
{ text: 'TypeScript', fn: async () => await sleep(800) },
|
|
321
|
+
{ text: 'Bundle', fn: async () => await sleep(600) },
|
|
322
|
+
],
|
|
323
|
+
},
|
|
324
|
+
{ text: 'Test', fn: async () => await sleep(700) },
|
|
290
325
|
], { parallel: true });
|
|
291
326
|
```
|
|
292
327
|
|
|
293
328
|
### Animaciones
|
|
294
329
|
|
|
295
330
|
```ts
|
|
296
|
-
import { animate, gradient } from 'ansimax';
|
|
331
|
+
import { animate, gradient, sleep } from 'ansimax';
|
|
297
332
|
|
|
298
333
|
await animate.typewriter('Bienvenido al wizard de deployment...', {
|
|
299
334
|
speed: 30,
|
|
@@ -304,9 +339,9 @@ await animate.fadeIn('Carga completa', { duration: 600 });
|
|
|
304
339
|
|
|
305
340
|
// Carrera de pasos contra timeout — nunca se cuelga
|
|
306
341
|
await animate.parallel([
|
|
307
|
-
async () => await
|
|
308
|
-
async () => await
|
|
309
|
-
async () => await
|
|
342
|
+
async () => await sleep(500), // simulación de chequeo de red
|
|
343
|
+
async () => await sleep(700), // simulación de chequeo de base de datos
|
|
344
|
+
async () => await sleep(400), // simulación de chequeo de auth
|
|
310
345
|
], { timeout: 5000 });
|
|
311
346
|
```
|
|
312
347
|
|
|
@@ -319,7 +354,7 @@ import { themes, createTheme } from 'ansimax';
|
|
|
319
354
|
|
|
320
355
|
// Temas built-in
|
|
321
356
|
themes.use('dracula');
|
|
322
|
-
themes.primary('hola');
|
|
357
|
+
console.log(themes.primary('hola'));
|
|
323
358
|
|
|
324
359
|
// Escuchar cambios
|
|
325
360
|
const off = themes.onChange((nuevo, anterior) => {
|
|
@@ -329,28 +364,60 @@ const off = themes.onChange((nuevo, anterior) => {
|
|
|
329
364
|
// Multi-tenant: cada instancia totalmente aislada
|
|
330
365
|
const tenantA = createTheme('nord');
|
|
331
366
|
const tenantB = createTheme('matrix');
|
|
332
|
-
|
|
367
|
+
|
|
368
|
+
// Definir un tema personalizado y registrarlo SÓLO en tenantA
|
|
369
|
+
tenantA.register('custom', {
|
|
370
|
+
name: 'Custom',
|
|
371
|
+
primary: '#ff5e5e',
|
|
372
|
+
secondary: '#5e5eff',
|
|
373
|
+
accent: '#5eff5e',
|
|
374
|
+
success: '#10b981',
|
|
375
|
+
warning: '#fbbf24',
|
|
376
|
+
error: '#ef4444',
|
|
377
|
+
info: '#06b6d4',
|
|
378
|
+
muted: '#6b7280',
|
|
379
|
+
bg: '#1e293b',
|
|
380
|
+
surface: '#334155',
|
|
381
|
+
text: '#f1f5f9',
|
|
382
|
+
gradient: ['#ff5e5e', '#5eff5e', '#5e5eff'],
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
console.log('tenantA incluye custom?', tenantA.list().includes('custom'));
|
|
386
|
+
console.log('tenantB incluye custom?', tenantB.list().includes('custom'));
|
|
387
|
+
// ↑ false — aislamiento total
|
|
333
388
|
```
|
|
334
389
|
|
|
335
390
|
---
|
|
336
391
|
|
|
337
392
|
## 📚 Ejemplos
|
|
338
393
|
|
|
339
|
-
|
|
394
|
+
Once ejemplos de calidad de producción se publican en el paquete npm y son ejecutables directamente. Los encuentras en [`/examples`](./examples) después de instalar:
|
|
340
395
|
|
|
341
396
|
| Archivo | Qué demuestra |
|
|
342
397
|
|---|---|
|
|
343
|
-
| `
|
|
344
|
-
| `
|
|
345
|
-
| `
|
|
346
|
-
| `
|
|
347
|
-
| `
|
|
348
|
-
| `
|
|
349
|
-
| `
|
|
398
|
+
| `01-quick-smoke.ts` | Test rápido de humo — verifica que cada import principal funciona |
|
|
399
|
+
| `02-colors-gradients.ts` | Toda función de color, tipos de gradiente, presets, compose, API chain |
|
|
400
|
+
| `03-ascii-banners.ts` | Banners (`big`/`small`), 6 estilos de caja, divisores, compositor de logos |
|
|
401
|
+
| `04-trees.ts` | Tree builder + API data-plana, 4 estilos, palettes, algoritmos (walk/find/map/filter) |
|
|
402
|
+
| `05-components.ts` | Tablas, badges, status, secciones, columnas, timelines, barras de progreso |
|
|
403
|
+
| `06-pixel-art.ts` | Sprites, canvas personalizado, gradient rects con dither, transforms (flip/rotate) |
|
|
404
|
+
| `07-animations.ts` | typewriter, fadeIn/Out, slide, pulse, wave, glitch, reveal |
|
|
405
|
+
| `08-loaders.ts` | Estilos de spinner, progreso animado, tareas jerárquicas, cuenta regresiva |
|
|
406
|
+
| `09-themes.ts` | Los 8 temas integrados, listeners, registro de temas personalizados, aislamiento por instancia |
|
|
407
|
+
| `10-everything.ts` | Showcase completo — cada módulo ejercitado en un demo cohesivo |
|
|
408
|
+
| `all-in-one.mjs` | Demo completo en **ESM** (JS puro con `import`) — sin necesidad de TypeScript |
|
|
409
|
+
| `all-in-one.cjs` | Demo completo en **CommonJS** (JS puro con `require`) — sin necesidad de TypeScript |
|
|
350
410
|
|
|
351
411
|
Ejecuta cualquier ejemplo con:
|
|
352
412
|
```bash
|
|
353
|
-
|
|
413
|
+
# Ejemplos en TypeScript
|
|
414
|
+
npx tsx examples/10-everything.ts
|
|
415
|
+
|
|
416
|
+
# JS puro — ESM
|
|
417
|
+
node examples/all-in-one.mjs
|
|
418
|
+
|
|
419
|
+
# JS puro — CommonJS
|
|
420
|
+
node examples/all-in-one.cjs
|
|
354
421
|
```
|
|
355
422
|
|
|
356
423
|
---
|
|
@@ -388,11 +455,11 @@ const off = onConfigKeyChange('theme', (nuevo, anterior) => {
|
|
|
388
455
|
|
|
389
456
|
// Override temporal + restauración automática al completar o lanzar
|
|
390
457
|
await withConfig({ animationSpeed: 'fast' }, async () => {
|
|
391
|
-
|
|
458
|
+
// ...tu código en modo fast aquí...
|
|
392
459
|
});
|
|
393
460
|
|
|
394
461
|
// Modo strict captura typos en config
|
|
395
|
-
configure({ unknwnKey: 'x' }, { strict: true }); // lanza RangeError
|
|
462
|
+
// configure({ unknwnKey: 'x' }, { strict: true }); // lanza RangeError
|
|
396
463
|
```
|
|
397
464
|
|
|
398
465
|
---
|
|
@@ -604,7 +671,7 @@ ansimax/
|
|
|
604
671
|
│ ├── trees/ Builder de árboles + algoritmos
|
|
605
672
|
│ ├── utils/ Primitivas ANSI + helpers
|
|
606
673
|
│ └── configure.ts Config global + subscribers
|
|
607
|
-
├── examples/
|
|
674
|
+
├── examples/ 10 ejemplos (TS) + 2 (JS — ESM y CJS) — todas las funciones cubiertas
|
|
608
675
|
└── __tests__/ 16 test suites, 1700+ tests
|
|
609
676
|
```
|
|
610
677
|
|
|
@@ -612,6 +679,28 @@ ansimax/
|
|
|
612
679
|
|
|
613
680
|
## 📝 Changelog
|
|
614
681
|
|
|
682
|
+
### v1.1.2 — Madurez y robustez
|
|
683
|
+
|
|
684
|
+
Release patch enfocado en refinamientos de calidad — sin cambios en la API.
|
|
685
|
+
|
|
686
|
+
- 🛡️ **Bump defensivo de `process.setMaxListeners`** — previene `MaxListenersExceededWarning` en setups con HMR / nodemon / ts-node-dev donde los módulos de ansimax re-registran handlers de restauración de cursor
|
|
687
|
+
- 🧪 **`TypeError` uniforme para validación de themes** — `themes.register()` ahora arroja consistentemente `TypeError` para errores estructurales / de tipo (antes era mezcla de `Error` y `TypeError`)
|
|
688
|
+
- 🎯 **`themes.use()` arroja `RangeError`** para nombres de tema desconocidos (antes `Error`) — mejor match semántico con "valor fuera del set permitido"
|
|
689
|
+
- 📝 **Re-exports más limpios en el barrel** — comentario de header ahora documenta aliases legacy y recomienda nombres canónicos
|
|
690
|
+
|
|
691
|
+
Drop-in replacement para `1.1.1`.
|
|
692
|
+
|
|
693
|
+
### v1.1.1 — Fixes de bugs + ejemplos limpios
|
|
694
|
+
|
|
695
|
+
Release patch que arregla dos bugs encontrados en testing real de v1.1.0, más una carpeta de ejemplos refrescada.
|
|
696
|
+
|
|
697
|
+
- 🐛 **Fix de crash en `box()`** con `padding: { x, y }` — ahora cae graciosamente al default para padding no-numérico (también maneja NaN, Infinity, strings)
|
|
698
|
+
- 🐛 **Fix de leak de cursor en `components.menu()`** al salir abruptamente (Ctrl+C, SIGTERM) — handlers de cleanup de emergencia ahora restauran el cursor incluso cuando el proceso se mata mid-menu
|
|
699
|
+
- 📚 **Nuevos ejemplos** — 10 ejemplos en TypeScript + 2 variantes en JS puro (`all-in-one.mjs` para ESM, `all-in-one.cjs` para CommonJS)
|
|
700
|
+
- 📖 **READMEs actualizados** — GIFs de preview en el header, GIF de showcase completo en el footer
|
|
701
|
+
|
|
702
|
+
Sin cambios en la API — drop-in replacement para `1.1.0`.
|
|
703
|
+
|
|
615
704
|
### v1.1.0 — Hardening exhaustivo + nuevas features
|
|
616
705
|
|
|
617
706
|
Una pasada masiva de robustez sobre todo módulo, más un nuevo módulo `trees`. **100% retrocompatible** — toda API existente funciona idéntica.
|
|
@@ -676,6 +765,18 @@ Si Ansimax te ahorra tiempo, por favor dale estrella al repo en [GitHub](https:/
|
|
|
676
765
|
|
|
677
766
|
---
|
|
678
767
|
|
|
768
|
+
## 🎬 Showcase completo
|
|
769
|
+
|
|
770
|
+
<div align="center">
|
|
771
|
+
|
|
772
|
+
<img src="media/all-ansimax.gif" alt="Showcase completo de Ansimax — todo en acción" width="720"/>
|
|
773
|
+
|
|
774
|
+
_Todas las funciones en acción — typewriter, gradientes, banners ASCII, árboles, tablas, spinners, temas y pixel art_
|
|
775
|
+
|
|
776
|
+
</div>
|
|
777
|
+
|
|
778
|
+
---
|
|
779
|
+
|
|
679
780
|
## 📜 Licencia
|
|
680
781
|
|
|
681
782
|
[Apache License 2.0](LICENSE) © 2026 Brashkie
|
|
@@ -694,4 +795,4 @@ Ansimax está licenciada bajo **Apache License, Version 2.0** — una licencia p
|
|
|
694
795
|
|
|
695
796
|
Si Ansimax te ayuda a hacer mejores CLIs, ¡dale ⭐ en [GitHub](https://github.com/Brashkie/ansimax)!
|
|
696
797
|
|
|
697
|
-
</div>
|
|
798
|
+
</div>
|