ansimax 1.3.1 → 1.3.3
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 +178 -0
- package/README.es.md +117 -8
- package/README.md +117 -8
- package/dist/index.d.mts +309 -2
- package/dist/index.d.ts +309 -2
- package/dist/index.js +209 -42
- package/dist/index.mjs +208 -42
- package/docs/README.md +110 -0
- package/docs/examples-cjs.md +706 -0
- package/docs/examples-mjs.md +676 -0
- package/docs/examples-ts.md +715 -0
- package/docs/showcase.md +398 -0
- package/examples/all-in-one.cjs +1 -1
- package/examples/all-in-one.mjs +1 -1
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,184 @@
|
|
|
3
3
|
All notable changes to **ansimax** are documented in this file.
|
|
4
4
|
This project follows [Semantic Versioning](https://semver.org/).
|
|
5
5
|
|
|
6
|
+
## [1.3.3] — Feature additions to panels, json, ascii
|
|
7
|
+
|
|
8
|
+
Patch release adding new functionality to three modules. No breaking changes —
|
|
9
|
+
all additions are opt-in via new options/exports.
|
|
10
|
+
|
|
11
|
+
### Added — `panels.grid(blocks, opts)`
|
|
12
|
+
|
|
13
|
+
N-column grid layout with auto-flow (reading order). Each row auto-sizes to
|
|
14
|
+
the tallest block; each column auto-sizes to its widest member.
|
|
15
|
+
|
|
16
|
+
```js
|
|
17
|
+
import { panels, ascii } from 'ansimax';
|
|
18
|
+
|
|
19
|
+
const cards = [
|
|
20
|
+
ascii.box('FILES\n42', { padding: 1 }),
|
|
21
|
+
ascii.box('LINES\n1247', { padding: 1 }),
|
|
22
|
+
ascii.box('TESTS\n38', { padding: 1 }),
|
|
23
|
+
ascii.box('COV\n98%', { padding: 1 }),
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
// 2×2 grid
|
|
27
|
+
console.log(panels.grid(cards, { columns: 2, gapX: 2, gapY: 1 }));
|
|
28
|
+
|
|
29
|
+
// 3-column with auto-flow (7 items → 3 rows: [3, 3, 1])
|
|
30
|
+
console.log(panels.grid(items, { columns: 3, gapX: 4 }));
|
|
31
|
+
|
|
32
|
+
// Fixed cell width for uniform appearance
|
|
33
|
+
console.log(panels.grid(blocks, {
|
|
34
|
+
columns: 4,
|
|
35
|
+
cellWidth: 15,
|
|
36
|
+
alignX: 'center',
|
|
37
|
+
}));
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Options: `columns` (required), `gapX`, `gapY`, `alignX`, `alignY`, `cellWidth`.
|
|
41
|
+
|
|
42
|
+
### Added — `panels.frame` option `titleAlign`
|
|
43
|
+
|
|
44
|
+
Frame titles can now be aligned `'left'`, `'center'` (default), or `'right'`.
|
|
45
|
+
|
|
46
|
+
```js
|
|
47
|
+
panels.frame('Body', { title: 'Section', titleAlign: 'left' });
|
|
48
|
+
// ─ Section ───────────
|
|
49
|
+
//
|
|
50
|
+
// Body
|
|
51
|
+
// ────────────────────
|
|
52
|
+
|
|
53
|
+
panels.frame('Body', { title: 'Section', titleAlign: 'right' });
|
|
54
|
+
// ─────────── Section ─
|
|
55
|
+
//
|
|
56
|
+
// Body
|
|
57
|
+
// ────────────────────
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Added — `ascii.box` options `title` + `titleAlign`
|
|
61
|
+
|
|
62
|
+
Boxes can now have a title in the top border. When the title is wider than the
|
|
63
|
+
content, the box expands to fit it.
|
|
64
|
+
|
|
65
|
+
```js
|
|
66
|
+
console.log(ascii.box('Body content', {
|
|
67
|
+
title: 'Header',
|
|
68
|
+
titleAlign: 'left', // 'left' | 'center' (default) | 'right'
|
|
69
|
+
borderStyle: 'rounded',
|
|
70
|
+
}));
|
|
71
|
+
|
|
72
|
+
// ╭─ Header ──────╮
|
|
73
|
+
// │ Body content │
|
|
74
|
+
// ╰───────────────╯
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Added — `ascii.divider` option `align`
|
|
78
|
+
|
|
79
|
+
Divider labels can now be aligned similar to box titles.
|
|
80
|
+
|
|
81
|
+
```js
|
|
82
|
+
ascii.divider({ label: 'Section', align: 'left', width: 40 });
|
|
83
|
+
// ─ Section ──────────────────────────────
|
|
84
|
+
ascii.divider({ label: 'Section', align: 'center', width: 40 });
|
|
85
|
+
// ─────────────── Section ────────────────
|
|
86
|
+
ascii.divider({ label: 'Section', align: 'right', width: 40 });
|
|
87
|
+
// ────────────────────────────── Section ─
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Added — `json.pretty` native types support: `Map`, `Set`, `Date`
|
|
91
|
+
|
|
92
|
+
```js
|
|
93
|
+
import { json } from 'ansimax';
|
|
94
|
+
|
|
95
|
+
const data = {
|
|
96
|
+
created: new Date('2026-06-13'),
|
|
97
|
+
cache: new Map([['user1', 'Alice'], ['user2', 'Bob']]),
|
|
98
|
+
tags: new Set(['frontend', 'react']),
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
console.log(json.pretty(data));
|
|
102
|
+
// {
|
|
103
|
+
// "created": Date(2026-06-13T00:00:00.000Z),
|
|
104
|
+
// "cache": Map(2) [...],
|
|
105
|
+
// "tags": Set(2) ["frontend", "react"]
|
|
106
|
+
// }
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Added — `json.pretty` option `mode: 'json'`
|
|
110
|
+
|
|
111
|
+
Produces **strict, parseable JSON** instead of display-only output. Useful
|
|
112
|
+
for piping to files, scripts, or other tools.
|
|
113
|
+
|
|
114
|
+
```js
|
|
115
|
+
const out = json.pretty(myData, { mode: 'json' });
|
|
116
|
+
const parsed = JSON.parse(out); // ✓ works
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
In `'json'` mode:
|
|
120
|
+
- Colors are forced off (output is always plain text)
|
|
121
|
+
- `undefined` / functions / symbols are dropped from objects, become `null` in arrays
|
|
122
|
+
- `NaN` / `Infinity` / `-Infinity` become `null`
|
|
123
|
+
- `BigInt` becomes a number (if safe) or a string (if out of safe range)
|
|
124
|
+
- `Date` becomes its ISO string
|
|
125
|
+
- `Map` becomes a plain object (string-keys only)
|
|
126
|
+
- `Set` becomes an array
|
|
127
|
+
- Circular references throw `TypeError` (matches `JSON.stringify` behavior)
|
|
128
|
+
|
|
129
|
+
Default `'display'` mode preserves all v1.3.2 behavior. **No breaking changes.**
|
|
130
|
+
|
|
131
|
+
### Improved — Tests
|
|
132
|
+
|
|
133
|
+
- `+8` tests for `panels.grid`
|
|
134
|
+
- `+3` tests for `panels.frame` titleAlign
|
|
135
|
+
- `+5` tests for `ascii.box` title/titleAlign
|
|
136
|
+
- `+4` tests for `ascii.divider` align
|
|
137
|
+
- `+18` tests for `json` Map/Set/Date/mode
|
|
138
|
+
|
|
139
|
+
### Notes
|
|
140
|
+
|
|
141
|
+
- No runtime dependencies — still zero
|
|
142
|
+
- No breaking changes — drop-in replacement for `1.3.2`
|
|
143
|
+
- All new options have backward-compatible defaults
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## [1.3.2] — Documentation polish for frames + images
|
|
148
|
+
|
|
149
|
+
Patch release improving JSDoc + IntelliSense coverage for the two largest
|
|
150
|
+
modules that were under-documented. No code changes — pure DX upgrade.
|
|
151
|
+
|
|
152
|
+
### Improved — JSDoc with runnable examples
|
|
153
|
+
|
|
154
|
+
**`frames` module (previously 0 examples → now 17):**
|
|
155
|
+
- `frames.play` — 5 examples (basic loop, play-once, abortable, pause/resume, custom onFrame)
|
|
156
|
+
- `frames.generate` — 3 examples (pulsing dot, progress bar, error tolerance)
|
|
157
|
+
- `frames.live` — 3 examples (reactive counter, async data stream, FPS clamping)
|
|
158
|
+
- `frames.morph` — 3 examples (basic, custom charset, chained sequences)
|
|
159
|
+
- `frames.presets` — 3 examples (loadingBar, pulse, wave with custom rendering)
|
|
160
|
+
|
|
161
|
+
**`images` module (previously 0 examples → now 18):**
|
|
162
|
+
- `renderPixelArt` — 4 examples (heart sprite, scaling, background, sprite lookup)
|
|
163
|
+
- `gradientRect` — 7 examples (horizontal, vertical, diagonal, radial, conic, dithered, braille)
|
|
164
|
+
- `createCanvas` — 4 examples (basic scene, animated frame, sprite composition, resize)
|
|
165
|
+
- `SPRITES` — 3 examples (render single, list all, compose on canvas)
|
|
166
|
+
|
|
167
|
+
### Why this matters
|
|
168
|
+
|
|
169
|
+
Before v1.3.2, users hovering `frames.play(...)` in their editor saw just
|
|
170
|
+
the signature `(frames: string[], opts?: PlayOptions): PlayController`.
|
|
171
|
+
Now they see 5 runnable examples showing pause/resume patterns, AbortSignal
|
|
172
|
+
integration, custom rendering callbacks — significantly reducing the
|
|
173
|
+
"what do I pass here?" friction for new users.
|
|
174
|
+
|
|
175
|
+
### Notes
|
|
176
|
+
|
|
177
|
+
- No code changes — pure documentation
|
|
178
|
+
- No runtime dependencies — still zero
|
|
179
|
+
- No new tests required — existing test coverage unchanged
|
|
180
|
+
- Drop-in replacement for `1.3.1`
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
6
184
|
## [1.3.1] — Polish for panels + json
|
|
7
185
|
|
|
8
186
|
Patch release improving the two modules introduced in v1.3.0 — adds layout
|
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)
|
|
@@ -215,6 +215,8 @@ console.log(rainbow('preset rainbow integrado'));
|
|
|
215
215
|
|
|
216
216
|
### Gradientes animados (v1.2.0)
|
|
217
217
|
|
|
218
|
+
<img src="media/animated-gradients.gif" alt="Vista previa de gradientes animados" />
|
|
219
|
+
|
|
218
220
|
```js
|
|
219
221
|
import { animateGradient, sleep } from 'ansimax';
|
|
220
222
|
|
|
@@ -273,6 +275,8 @@ console.log(gradientRect({
|
|
|
273
275
|
|
|
274
276
|
### Gradientes reusables (v1.2.3)
|
|
275
277
|
|
|
278
|
+
<img src="media/reusable-gradients.gif" alt="Vista previa de gradientes reusables" />
|
|
279
|
+
|
|
276
280
|
```js
|
|
277
281
|
import { createGradient, reverseGradient, ascii } from 'ansimax';
|
|
278
282
|
|
|
@@ -319,6 +323,33 @@ console.log(ascii.box('¡Caja arcoiris!', { padding: 1, borderStyle: 'rounded' }
|
|
|
319
323
|
|
|
320
324
|
### Imagen → ASCII (v1.2.5)
|
|
321
325
|
|
|
326
|
+
<div align="center">
|
|
327
|
+
<img src="media/image-ascii-original.png" alt="Foto original" width="40%" />
|
|
328
|
+
</div>
|
|
329
|
+
|
|
330
|
+
<table>
|
|
331
|
+
<tr>
|
|
332
|
+
<td align="center">
|
|
333
|
+
<img src="media/image-ascii-1.png" alt="Modo monocromo" /><br/>
|
|
334
|
+
<sub><b>1. Monocromo</b></sub>
|
|
335
|
+
</td>
|
|
336
|
+
<td align="center">
|
|
337
|
+
<img src="media/image-ascii-2.png" alt="Color + dithering Floyd-Steinberg" /><br/>
|
|
338
|
+
<sub><b>2. Color + Floyd-Steinberg</b></sub>
|
|
339
|
+
</td>
|
|
340
|
+
</tr>
|
|
341
|
+
<tr>
|
|
342
|
+
<td align="center">
|
|
343
|
+
<img src="media/image-ascii-3.png" alt="Detección de bordes (Sobel)" /><br/>
|
|
344
|
+
<sub><b>3. Detección de bordes (Sobel)</b></sub>
|
|
345
|
+
</td>
|
|
346
|
+
<td align="center">
|
|
347
|
+
<img src="media/image-ascii-4.png" alt="Modo rostro para retratos" /><br/>
|
|
348
|
+
<sub><b>4. Modo rostro (retratos)</b></sub>
|
|
349
|
+
</td>
|
|
350
|
+
</tr>
|
|
351
|
+
</table>
|
|
352
|
+
|
|
322
353
|
```js
|
|
323
354
|
import { ascii } from 'ansimax';
|
|
324
355
|
import sharp from 'sharp';
|
|
@@ -342,10 +373,10 @@ for (let y = 0; y < info.height; y++) {
|
|
|
342
373
|
|
|
343
374
|
// Ahora usa ansimax — varias formas:
|
|
344
375
|
|
|
345
|
-
// Monocromo
|
|
376
|
+
// 1. Monocromo
|
|
346
377
|
console.log(ascii.fromImage(pixels, { width: 80 }));
|
|
347
378
|
|
|
348
|
-
// Color + dithering Floyd-Steinberg + ramp detallado
|
|
379
|
+
// 2. Color + dithering Floyd-Steinberg + ramp detallado
|
|
349
380
|
console.log(ascii.fromImage(pixels, {
|
|
350
381
|
width: 100,
|
|
351
382
|
color: true,
|
|
@@ -353,7 +384,7 @@ console.log(ascii.fromImage(pixels, {
|
|
|
353
384
|
ramp: 'detailed',
|
|
354
385
|
}));
|
|
355
386
|
|
|
356
|
-
// Modo detección de bordes (line art)
|
|
387
|
+
// 3. Modo detección de bordes (line art)
|
|
357
388
|
console.log(ascii.fromImage(pixels, {
|
|
358
389
|
width: 80,
|
|
359
390
|
edgeDetect: 'sobel',
|
|
@@ -361,7 +392,7 @@ console.log(ascii.fromImage(pixels, {
|
|
|
361
392
|
ramp: 'blocks',
|
|
362
393
|
}));
|
|
363
394
|
|
|
364
|
-
// Modo rostro para retratos (mejora contraste de tonos medios)
|
|
395
|
+
// 4. Modo rostro para retratos (mejora contraste de tonos medios)
|
|
365
396
|
console.log(ascii.fromImage(pixels, {
|
|
366
397
|
width: 60,
|
|
367
398
|
ramp: 'detailed',
|
|
@@ -371,6 +402,8 @@ console.log(ascii.fromImage(pixels, {
|
|
|
371
402
|
|
|
372
403
|
### Fuentes Figlet (v1.2.5)
|
|
373
404
|
|
|
405
|
+
<img src="media/figlet_fonts.png" alt="Vista previa de fuentes figlet" />
|
|
406
|
+
|
|
374
407
|
```js
|
|
375
408
|
import { readFileSync } from 'node:fs';
|
|
376
409
|
import { parseFiglet, ascii, gradient } from 'ansimax';
|
|
@@ -445,7 +478,7 @@ console.log(components.table([
|
|
|
445
478
|
['loaders', color.green('● listo'), '100%'],
|
|
446
479
|
], { borderStyle: 'rounded' }));
|
|
447
480
|
|
|
448
|
-
console.log(components.badge('VERSION', 'v1.3.
|
|
481
|
+
console.log(components.badge('VERSION', 'v1.3.3'));
|
|
449
482
|
console.log(components.badge('BUILD', 'passing'));
|
|
450
483
|
```
|
|
451
484
|
|
|
@@ -466,6 +499,8 @@ console.log(components.timeline([
|
|
|
466
499
|
|
|
467
500
|
### Loaders y Progreso
|
|
468
501
|
|
|
502
|
+
<img src="media/loaders.png" alt="Vista previa de loaders y barras de progreso" />
|
|
503
|
+
|
|
469
504
|
```js
|
|
470
505
|
import { loader, sleep } from 'ansimax';
|
|
471
506
|
|
|
@@ -495,6 +530,8 @@ await loader.tasks([
|
|
|
495
530
|
|
|
496
531
|
### Animaciones
|
|
497
532
|
|
|
533
|
+
<img src="media/animations-1.gif" alt="Vista previa de animaciones" />
|
|
534
|
+
|
|
498
535
|
```js
|
|
499
536
|
import { animate, gradient, sleep } from 'ansimax';
|
|
500
537
|
|
|
@@ -557,6 +594,8 @@ console.log('tenantB incluye custom?', tenantB.list().includes('custom'));
|
|
|
557
594
|
|
|
558
595
|
### Panels — Layouts divididos (v1.3.0)
|
|
559
596
|
|
|
597
|
+
<img src="media/panels.png" alt="Vista previa de panels y layouts divididos" />
|
|
598
|
+
|
|
560
599
|
```js
|
|
561
600
|
import { panels, ascii } from 'ansimax';
|
|
562
601
|
|
|
@@ -586,6 +625,8 @@ console.log(panels.hsplit([
|
|
|
586
625
|
|
|
587
626
|
### JSON Pretty-print (v1.3.0)
|
|
588
627
|
|
|
628
|
+
<img src="media/json_pretty.png" alt="Vista previa de JSON pretty-print" />
|
|
629
|
+
|
|
589
630
|
```js
|
|
590
631
|
import { json } from 'ansimax';
|
|
591
632
|
|
|
@@ -599,10 +640,12 @@ console.log(json.pretty({
|
|
|
599
640
|
}));
|
|
600
641
|
|
|
601
642
|
// Límite de profundidad — colapsa objetos profundos a {...}
|
|
643
|
+
const deeplyNested = { a: { b: { c: { d: { e: 'muy profundo' } } } } };
|
|
602
644
|
console.log(json.pretty(deeplyNested, { maxDepth: 2 }));
|
|
603
645
|
|
|
604
646
|
// Límite de items — arrays grandes muestran "... (N more)"
|
|
605
|
-
|
|
647
|
+
const largeArray = Array.from({ length: 50 }, (_, i) => `item_${i}`);
|
|
648
|
+
console.log(json.pretty(largeArray, { maxItems: 5 }));
|
|
606
649
|
|
|
607
650
|
// Referencias circulares manejadas con gracia
|
|
608
651
|
const obj = { name: 'foo' };
|
|
@@ -612,6 +655,22 @@ console.log(json.pretty(obj)); // → "self": [Circular]
|
|
|
612
655
|
|
|
613
656
|
---
|
|
614
657
|
|
|
658
|
+
## 📖 Documentación
|
|
659
|
+
|
|
660
|
+
La carpeta [`docs/`](./docs) contiene ejemplos completos para cada módulo:
|
|
661
|
+
|
|
662
|
+
| Documento | Descripción |
|
|
663
|
+
|---|---|
|
|
664
|
+
| [`docs/README.md`](./docs/README.md) | Índice de documentación — empieza aquí |
|
|
665
|
+
| [`docs/examples-ts.md`](./docs/examples-ts.md) | 33 ejemplos en TypeScript (3 por módulo × 11 módulos) |
|
|
666
|
+
| [`docs/examples-mjs.md`](./docs/examples-mjs.md) | 33 ejemplos en JavaScript ESM |
|
|
667
|
+
| [`docs/examples-cjs.md`](./docs/examples-cjs.md) | 33 ejemplos en JavaScript CommonJS |
|
|
668
|
+
| [`docs/showcase.md`](./docs/showcase.md) | App completa que combina todos los módulos |
|
|
669
|
+
|
|
670
|
+
Cada ejemplo es **copy-paste ejecutable** con escenarios realistas de complejidad media — no solo one-liners.
|
|
671
|
+
|
|
672
|
+
---
|
|
673
|
+
|
|
615
674
|
## 📚 Ejemplos
|
|
616
675
|
|
|
617
676
|
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:
|
|
@@ -1006,6 +1065,56 @@ ansimax/
|
|
|
1006
1065
|
|
|
1007
1066
|
## 📝 Changelog
|
|
1008
1067
|
|
|
1068
|
+
### v1.3.3 — Features para panels, json, ascii
|
|
1069
|
+
|
|
1070
|
+
Release patch con nuevas features opt-in. Cero breaking changes:
|
|
1071
|
+
|
|
1072
|
+
- 📐 **`panels.grid(blocks, opts)`** — layout de grid en N columnas con auto-flow, gaps, alineación, y opción de ancho uniforme de celda
|
|
1073
|
+
- 🎯 **`panels.frame` + `ascii.box` + `ascii.divider`** todos reciben opción `titleAlign` (o `align`): `'left'`, `'center'` (default), `'right'`
|
|
1074
|
+
- 🏷️ **`ascii.box` nueva opción `title`** — muestra un label en el borde superior (expande el box si el title es más ancho que el contenido)
|
|
1075
|
+
- 📅 **`json.pretty` soporta Map / Set / Date nativamente** — `Date(...)`, `Map(N) [...]`, `Set(N) [...]` en modo display
|
|
1076
|
+
- 📤 **`json.pretty` nueva opción `mode: 'json'`** — produce JSON estricto y parseable (sin colores, descarta undefined/functions/symbols, lanza en circulares)
|
|
1077
|
+
- 🧪 **+38 tests** entre panels + json + ascii
|
|
1078
|
+
|
|
1079
|
+
```js
|
|
1080
|
+
import { panels, json, ascii } from 'ansimax';
|
|
1081
|
+
|
|
1082
|
+
// Grid de 2×2 con metric cards
|
|
1083
|
+
console.log(panels.grid(cards, { columns: 2, gapX: 2 }));
|
|
1084
|
+
|
|
1085
|
+
// Title en el borde del box
|
|
1086
|
+
console.log(ascii.box('content', { title: 'Section', titleAlign: 'left' }));
|
|
1087
|
+
|
|
1088
|
+
// Output JSON estricto (parseable)
|
|
1089
|
+
const out = json.pretty(data, { mode: 'json' });
|
|
1090
|
+
JSON.parse(out); // ✓ funciona
|
|
1091
|
+
```
|
|
1092
|
+
|
|
1093
|
+
Drop-in replacement para `1.3.2`.
|
|
1094
|
+
|
|
1095
|
+
### v1.3.2 — Pulido de documentación para frames + images
|
|
1096
|
+
|
|
1097
|
+
Release patch con cobertura JSDoc + IntelliSense significativamente mejorada:
|
|
1098
|
+
|
|
1099
|
+
- 📝 **Módulo `frames`** — `play`, `generate`, `live`, `morph`, `presets` ahora tienen JSDoc completo con 17 ejemplos ejecutables
|
|
1100
|
+
- 📝 **Módulo `images`** — `renderPixelArt`, `gradientRect`, `createCanvas`, `SPRITES` ahora tienen 18 ejemplos ejecutables
|
|
1101
|
+
- 🎯 **Total**: +35 nuevos bloques `@example` visibles en tu editor
|
|
1102
|
+
|
|
1103
|
+
```js
|
|
1104
|
+
// Pasando el cursor sobre frames.play() en VS Code ahora muestra patrones de uso:
|
|
1105
|
+
import { frames } from 'ansimax';
|
|
1106
|
+
|
|
1107
|
+
await frames.play(myFrames, {
|
|
1108
|
+
interval: 80,
|
|
1109
|
+
loop: true,
|
|
1110
|
+
signal: ctrl.signal,
|
|
1111
|
+
onFrame: (f, i) => color.cyan(`[${i}] ${f}`),
|
|
1112
|
+
}).promise;
|
|
1113
|
+
```
|
|
1114
|
+
|
|
1115
|
+
Release puramente de documentación — cero cambios en código, API o tests.
|
|
1116
|
+
Drop-in replacement para `1.3.1`.
|
|
1117
|
+
|
|
1009
1118
|
### v1.3.1 — Pulido de panels + json
|
|
1010
1119
|
|
|
1011
1120
|
Release patch que mejora los módulos de v1.3.0 con quality-of-life:
|
|
@@ -1349,4 +1458,4 @@ Ansimax está licenciada bajo **Apache License, Version 2.0** — una licencia p
|
|
|
1349
1458
|
|
|
1350
1459
|
Si Ansimax te ayuda a hacer mejores CLIs, ¡dale ⭐ en [GitHub](https://github.com/Brashkie/ansimax)!
|
|
1351
1460
|
|
|
1352
|
-
</div>
|
|
1461
|
+
</div>
|
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
_Colors • Gradients • Animations • ASCII Art • Pixel Art • Trees • Components • Themes_
|
|
8
8
|
|
|
9
9
|
[](LICENSE)
|
|
10
|
-
[](https://www.npmjs.com/package/ansimax)
|
|
11
11
|
[](tsconfig.json)
|
|
12
12
|
[](#testing)
|
|
13
13
|
[](#testing)
|
|
@@ -215,6 +215,8 @@ console.log(rainbow('built-in rainbow preset'));
|
|
|
215
215
|
|
|
216
216
|
### Animated Gradients (v1.2.0)
|
|
217
217
|
|
|
218
|
+
<img src="media/animated-gradients.gif" alt="Animated gradients preview" />
|
|
219
|
+
|
|
218
220
|
```js
|
|
219
221
|
import { animateGradient, sleep } from 'ansimax';
|
|
220
222
|
|
|
@@ -273,6 +275,8 @@ console.log(gradientRect({
|
|
|
273
275
|
|
|
274
276
|
### Reusable Gradients (v1.2.3)
|
|
275
277
|
|
|
278
|
+
<img src="media/reusable-gradients.gif" alt="Reusable gradients preview" />
|
|
279
|
+
|
|
276
280
|
```js
|
|
277
281
|
import { createGradient, reverseGradient, ascii } from 'ansimax';
|
|
278
282
|
|
|
@@ -319,6 +323,33 @@ console.log(ascii.box('Rainbow box!', { padding: 1, borderStyle: 'rounded' }));
|
|
|
319
323
|
|
|
320
324
|
### Image → ASCII (v1.2.5)
|
|
321
325
|
|
|
326
|
+
<div align="center">
|
|
327
|
+
<img src="media/image-ascii-original.png" alt="Original photo" width="40%" />
|
|
328
|
+
</div>
|
|
329
|
+
|
|
330
|
+
<table>
|
|
331
|
+
<tr>
|
|
332
|
+
<td align="center">
|
|
333
|
+
<img src="media/image-ascii-1.png" alt="Monochrome mode" /><br/>
|
|
334
|
+
<sub><b>1. Monochrome</b></sub>
|
|
335
|
+
</td>
|
|
336
|
+
<td align="center">
|
|
337
|
+
<img src="media/image-ascii-2.png" alt="Color + Floyd-Steinberg dithering" /><br/>
|
|
338
|
+
<sub><b>2. Color + Floyd-Steinberg</b></sub>
|
|
339
|
+
</td>
|
|
340
|
+
</tr>
|
|
341
|
+
<tr>
|
|
342
|
+
<td align="center">
|
|
343
|
+
<img src="media/image-ascii-3.png" alt="Edge detection (Sobel)" /><br/>
|
|
344
|
+
<sub><b>3. Edge detection (Sobel)</b></sub>
|
|
345
|
+
</td>
|
|
346
|
+
<td align="center">
|
|
347
|
+
<img src="media/image-ascii-4.png" alt="Face mode for portraits" /><br/>
|
|
348
|
+
<sub><b>4. Face mode (portraits)</b></sub>
|
|
349
|
+
</td>
|
|
350
|
+
</tr>
|
|
351
|
+
</table>
|
|
352
|
+
|
|
322
353
|
```js
|
|
323
354
|
import { ascii } from 'ansimax';
|
|
324
355
|
import sharp from 'sharp';
|
|
@@ -342,10 +373,10 @@ for (let y = 0; y < info.height; y++) {
|
|
|
342
373
|
|
|
343
374
|
// Now use ansimax — multiple ways:
|
|
344
375
|
|
|
345
|
-
// Monochrome
|
|
376
|
+
// 1. Monochrome
|
|
346
377
|
console.log(ascii.fromImage(pixels, { width: 80 }));
|
|
347
378
|
|
|
348
|
-
// Color + Floyd-Steinberg dithering + detailed ramp
|
|
379
|
+
// 2. Color + Floyd-Steinberg dithering + detailed ramp
|
|
349
380
|
console.log(ascii.fromImage(pixels, {
|
|
350
381
|
width: 100,
|
|
351
382
|
color: true,
|
|
@@ -353,7 +384,7 @@ console.log(ascii.fromImage(pixels, {
|
|
|
353
384
|
ramp: 'detailed',
|
|
354
385
|
}));
|
|
355
386
|
|
|
356
|
-
// Edge-detection mode (line art)
|
|
387
|
+
// 3. Edge-detection mode (line art)
|
|
357
388
|
console.log(ascii.fromImage(pixels, {
|
|
358
389
|
width: 80,
|
|
359
390
|
edgeDetect: 'sobel',
|
|
@@ -361,7 +392,7 @@ console.log(ascii.fromImage(pixels, {
|
|
|
361
392
|
ramp: 'blocks',
|
|
362
393
|
}));
|
|
363
394
|
|
|
364
|
-
// Face mode for portraits (boosts midtone contrast)
|
|
395
|
+
// 4. Face mode for portraits (boosts midtone contrast)
|
|
365
396
|
console.log(ascii.fromImage(pixels, {
|
|
366
397
|
width: 60,
|
|
367
398
|
ramp: 'detailed',
|
|
@@ -371,6 +402,8 @@ console.log(ascii.fromImage(pixels, {
|
|
|
371
402
|
|
|
372
403
|
### Figlet Fonts (v1.2.5)
|
|
373
404
|
|
|
405
|
+
<img src="media/figlet_fonts.png" alt="Figlet fonts preview" />
|
|
406
|
+
|
|
374
407
|
```js
|
|
375
408
|
import { readFileSync } from 'node:fs';
|
|
376
409
|
import { parseFiglet, ascii, gradient } from 'ansimax';
|
|
@@ -445,7 +478,7 @@ console.log(components.table([
|
|
|
445
478
|
['loaders', color.green('● ready'), '100%'],
|
|
446
479
|
], { borderStyle: 'rounded' }));
|
|
447
480
|
|
|
448
|
-
console.log(components.badge('VERSION', 'v1.3.
|
|
481
|
+
console.log(components.badge('VERSION', 'v1.3.3'));
|
|
449
482
|
console.log(components.badge('BUILD', 'passing'));
|
|
450
483
|
```
|
|
451
484
|
|
|
@@ -466,6 +499,8 @@ console.log(components.timeline([
|
|
|
466
499
|
|
|
467
500
|
### Loaders & Progress
|
|
468
501
|
|
|
502
|
+
<img src="media/loaders.png" alt="Loaders and progress bars preview" />
|
|
503
|
+
|
|
469
504
|
```js
|
|
470
505
|
import { loader, sleep } from 'ansimax';
|
|
471
506
|
|
|
@@ -495,6 +530,8 @@ await loader.tasks([
|
|
|
495
530
|
|
|
496
531
|
### Animations
|
|
497
532
|
|
|
533
|
+
<img src="media/animations-1.gif" alt="Animations preview" />
|
|
534
|
+
|
|
498
535
|
```js
|
|
499
536
|
import { animate, gradient, sleep } from 'ansimax';
|
|
500
537
|
|
|
@@ -557,6 +594,8 @@ console.log('tenantB themes include custom?', tenantB.list().includes('custom'))
|
|
|
557
594
|
|
|
558
595
|
### Panels — Split Layouts (v1.3.0)
|
|
559
596
|
|
|
597
|
+
<img src="media/panels.png" alt="Panels and split layouts preview" />
|
|
598
|
+
|
|
560
599
|
```js
|
|
561
600
|
import { panels, ascii } from 'ansimax';
|
|
562
601
|
|
|
@@ -586,6 +625,8 @@ console.log(panels.hsplit([
|
|
|
586
625
|
|
|
587
626
|
### JSON Pretty-print (v1.3.0)
|
|
588
627
|
|
|
628
|
+
<img src="media/json_pretty.png" alt="JSON pretty-print preview" />
|
|
629
|
+
|
|
589
630
|
```js
|
|
590
631
|
import { json } from 'ansimax';
|
|
591
632
|
|
|
@@ -599,10 +640,12 @@ console.log(json.pretty({
|
|
|
599
640
|
}));
|
|
600
641
|
|
|
601
642
|
// Depth limit — collapses deep objects to {...}
|
|
643
|
+
const deeplyNested = { a: { b: { c: { d: { e: 'too deep' } } } } };
|
|
602
644
|
console.log(json.pretty(deeplyNested, { maxDepth: 2 }));
|
|
603
645
|
|
|
604
646
|
// Item limit — huge arrays show "... (N more)"
|
|
605
|
-
|
|
647
|
+
const largeArray = Array.from({ length: 50 }, (_, i) => `item_${i}`);
|
|
648
|
+
console.log(json.pretty(largeArray, { maxItems: 5 }));
|
|
606
649
|
|
|
607
650
|
// Circular references handled gracefully
|
|
608
651
|
const obj = { name: 'foo' };
|
|
@@ -612,6 +655,22 @@ console.log(json.pretty(obj)); // → "self": [Circular]
|
|
|
612
655
|
|
|
613
656
|
---
|
|
614
657
|
|
|
658
|
+
## 📖 Documentation
|
|
659
|
+
|
|
660
|
+
The [`docs/`](./docs) folder contains comprehensive examples for every module:
|
|
661
|
+
|
|
662
|
+
| Document | Description |
|
|
663
|
+
|---|---|
|
|
664
|
+
| [`docs/README.md`](./docs/README.md) | Documentation index — start here |
|
|
665
|
+
| [`docs/examples-ts.md`](./docs/examples-ts.md) | 33 TypeScript examples (3 per module × 11 modules) |
|
|
666
|
+
| [`docs/examples-mjs.md`](./docs/examples-mjs.md) | 33 JavaScript ESM examples |
|
|
667
|
+
| [`docs/examples-cjs.md`](./docs/examples-cjs.md) | 33 JavaScript CommonJS examples |
|
|
668
|
+
| [`docs/showcase.md`](./docs/showcase.md) | Complete demo app combining every module |
|
|
669
|
+
|
|
670
|
+
Every example is **copy-paste runnable** with realistic, mid-complexity scenarios — not just one-liners.
|
|
671
|
+
|
|
672
|
+
---
|
|
673
|
+
|
|
615
674
|
## 📚 Examples
|
|
616
675
|
|
|
617
676
|
Eleven production-grade examples ship in the npm package and are runnable directly. Find them in [`/examples`](./examples) once you install:
|
|
@@ -1006,6 +1065,56 @@ ansimax/
|
|
|
1006
1065
|
|
|
1007
1066
|
## 📝 Changelog
|
|
1008
1067
|
|
|
1068
|
+
### v1.3.3 — Features for panels, json, ascii
|
|
1069
|
+
|
|
1070
|
+
Patch release with new opt-in features. Zero breaking changes:
|
|
1071
|
+
|
|
1072
|
+
- 📐 **`panels.grid(blocks, opts)`** — N-column grid layout with auto-flow, gaps, alignment, and optional uniform cell width
|
|
1073
|
+
- 🎯 **`panels.frame` + `ascii.box` + `ascii.divider`** all get a `titleAlign` (or `align`) option: `'left'`, `'center'` (default), `'right'`
|
|
1074
|
+
- 🏷️ **`ascii.box` new `title` option** — show a label in the top border (expands box if title is wider than content)
|
|
1075
|
+
- 📅 **`json.pretty` supports Map / Set / Date natively** — `Date(...)`, `Map(N) [...]`, `Set(N) [...]` in display mode
|
|
1076
|
+
- 📤 **`json.pretty` new `mode: 'json'`** — produces strict, parseable JSON (no colors, drops undefined/functions/symbols, throws on circular)
|
|
1077
|
+
- 🧪 **+38 tests** across panels + json + ascii
|
|
1078
|
+
|
|
1079
|
+
```js
|
|
1080
|
+
import { panels, json, ascii } from 'ansimax';
|
|
1081
|
+
|
|
1082
|
+
// 2×2 grid of metric cards
|
|
1083
|
+
console.log(panels.grid(cards, { columns: 2, gapX: 2 }));
|
|
1084
|
+
|
|
1085
|
+
// Title in box top border
|
|
1086
|
+
console.log(ascii.box('content', { title: 'Section', titleAlign: 'left' }));
|
|
1087
|
+
|
|
1088
|
+
// Strict JSON output (parseable)
|
|
1089
|
+
const out = json.pretty(data, { mode: 'json' });
|
|
1090
|
+
JSON.parse(out); // ✓ works
|
|
1091
|
+
```
|
|
1092
|
+
|
|
1093
|
+
Drop-in replacement for `1.3.2`.
|
|
1094
|
+
|
|
1095
|
+
### v1.3.2 — Documentation polish for frames + images
|
|
1096
|
+
|
|
1097
|
+
Patch release with significantly improved JSDoc + IntelliSense coverage:
|
|
1098
|
+
|
|
1099
|
+
- 📝 **`frames` module** — `play`, `generate`, `live`, `morph`, `presets` now have full JSDoc with 17 runnable examples
|
|
1100
|
+
- 📝 **`images` module** — `renderPixelArt`, `gradientRect`, `createCanvas`, `SPRITES` now have 18 runnable examples
|
|
1101
|
+
- 🎯 **Total**: +35 new `@example` blocks visible in your editor
|
|
1102
|
+
|
|
1103
|
+
```js
|
|
1104
|
+
// Hovering frames.play() in VS Code now shows usage patterns:
|
|
1105
|
+
import { frames } from 'ansimax';
|
|
1106
|
+
|
|
1107
|
+
await frames.play(myFrames, {
|
|
1108
|
+
interval: 80,
|
|
1109
|
+
loop: true,
|
|
1110
|
+
signal: ctrl.signal,
|
|
1111
|
+
onFrame: (f, i) => color.cyan(`[${i}] ${f}`),
|
|
1112
|
+
}).promise;
|
|
1113
|
+
```
|
|
1114
|
+
|
|
1115
|
+
Pure documentation release — no code, API, or test changes.
|
|
1116
|
+
Drop-in replacement for `1.3.1`.
|
|
1117
|
+
|
|
1009
1118
|
### v1.3.1 — Polish for panels + json
|
|
1010
1119
|
|
|
1011
1120
|
Patch release improving the modules from v1.3.0 with quality-of-life additions:
|
|
@@ -1349,4 +1458,4 @@ Ansimax is licensed under the **Apache License, Version 2.0** — a permissive l
|
|
|
1349
1458
|
|
|
1350
1459
|
If Ansimax helps you ship better CLIs, give it a ⭐ on [GitHub](https://github.com/Brashkie/ansimax)!
|
|
1351
1460
|
|
|
1352
|
-
</div>
|
|
1461
|
+
</div>
|