ansimax 1.2.8 → 1.3.1
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 +233 -0
- package/README.es.md +208 -21
- package/README.md +207 -20
- package/dist/index.d.mts +348 -2
- package/dist/index.d.ts +348 -2
- package/dist/index.js +373 -30
- package/dist/index.mjs +366 -30
- package/examples/all-in-one.cjs +1 -1
- package/examples/all-in-one.mjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,12 +7,13 @@
|
|
|
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
|
-
[](#testing)
|
|
14
14
|
[](#)
|
|
15
|
-
[](#requirements)
|
|
16
|
+
[](#)
|
|
16
17
|
|
|
17
18
|
**English** · [Español](README.es.md)
|
|
18
19
|
|
|
@@ -79,30 +80,40 @@ stop('Build complete', true);
|
|
|
79
80
|
|
|
80
81
|
## 🆚 Comparison with the Node.js ecosystem
|
|
81
82
|
|
|
82
|
-
Ansimax replaces a
|
|
83
|
+
Ansimax replaces a stack of popular Node.js libraries with **one coherent, typed, zero-dependency package**:
|
|
83
84
|
|
|
84
85
|
| Feature | chalk | gradient-string | ora | cli-progress | figlet | boxen | inquirer | cli-table3 | **Ansimax** |
|
|
85
86
|
|---|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|
|
|
86
87
|
| Basic + 256 colors | ✅ | — | — | — | — | — | — | — | ✅ |
|
|
87
88
|
| Truecolor with adaptive fallback | ✅ | ✅ | — | — | — | — | — | — | ✅ |
|
|
88
89
|
| Multi-stop gradients | — | ✅ | — | — | — | — | — | — | ✅ |
|
|
89
|
-
| **Animated gradients** | — | — | — | — | — | — | — | — |
|
|
90
|
+
| **Animated gradients** | — | — | — | — | — | — | — | — | ✅ |
|
|
91
|
+
| **Easing curves (5 presets + custom)** | — | — | — | — | — | — | — | — | ✅ |
|
|
92
|
+
| **Conic gradients (radial sweep)** | — | — | — | — | — | — | — | — | ✅ |
|
|
90
93
|
| ASCII banners | — | — | — | — | ✅ | — | — | — | ✅ |
|
|
94
|
+
| **Image → ASCII converter** | — | — | — | — | — | — | — | — | ✅ |
|
|
95
|
+
| **Figlet `.flf` font parser** | — | — | — | — | ✅ (own) | — | — | — | ✅ (250+ fonts) |
|
|
91
96
|
| Custom font registry | — | — | — | — | partial | — | — | — | ✅ |
|
|
92
|
-
| Boxes with multiple styles | — | — | — | — | — | ✅ | — | — | ✅ |
|
|
97
|
+
| Boxes with multiple styles | — | — | — | — | — | ✅ | — | — | ✅ (6 styles) |
|
|
93
98
|
| Spinners (multiple styles) | — | — | ✅ | — | — | — | — | — | ✅ (11 styles) |
|
|
94
99
|
| Animated progress bars | — | — | — | ✅ | — | — | — | — | ✅ |
|
|
95
100
|
| **Hierarchical/parallel tasks** | — | — | — | — | — | — | — | — | ✅ |
|
|
96
101
|
| Tables (multi-line, ANSI-aware) | — | — | — | — | — | — | — | ✅ | ✅ |
|
|
97
102
|
| Interactive menus + multi-select | — | — | — | — | — | — | ✅ | — | ✅ |
|
|
98
103
|
| **Trees with cycle detection** | — | — | — | — | — | — | — | — | ✅ |
|
|
104
|
+
| **Split layouts (vsplit/hsplit)** | — | — | — | — | — | — | — | — | ✅ (v1.3.0) |
|
|
105
|
+
| **JSON colored pretty-printer** | — | — | — | — | — | — | — | — | ✅ (v1.3.0) |
|
|
99
106
|
| **Pixel art + canvas + sprites** | — | — | — | — | — | — | — | — | ✅ |
|
|
100
107
|
| **Theme system + per-instance isolation** | — | — | — | — | — | — | — | — | ✅ |
|
|
101
108
|
| `AbortSignal` everywhere | — | — | partial | — | — | — | partial | — | ✅ |
|
|
102
109
|
| `NO_COLOR` env support | ✅ | partial | partial | — | — | — | — | — | ✅ |
|
|
103
|
-
|
|
|
104
|
-
|
|
|
105
|
-
| **
|
|
110
|
+
| Stable error codes (`ANSIMAX_*`) | — | — | — | — | — | — | — | — | ✅ |
|
|
111
|
+
| TypeScript-first (strict mode) | partial | partial | ✅ | partial | partial | ✅ | partial | partial | ✅ |
|
|
112
|
+
| **Zero runtime dependencies** | ✅ | — | — | — | — | — | — | — | ✅ |
|
|
113
|
+
| ESM + CJS dual export | partial | partial | ✅ | ✅ | partial | ✅ | partial | partial | ✅ |
|
|
114
|
+
| **Test coverage** | ~95% | partial | partial | partial | partial | partial | partial | partial | **~98% (2000+ tests)** |
|
|
115
|
+
|
|
116
|
+
> Comparison reflects what each library officially supports at time of writing. Some libraries can be combined to approach ansimax's feature set, but at the cost of bundle size, version-skew bugs, and inconsistent APIs.
|
|
106
117
|
|
|
107
118
|
---
|
|
108
119
|
|
|
@@ -225,7 +236,7 @@ await animateGradient('Done!', ['#50fa7b', '#bd93f9'], {
|
|
|
225
236
|
|
|
226
237
|
### Easing Curves (v1.2.0)
|
|
227
238
|
|
|
228
|
-
<img src="media/easing_curves.png" alt="
|
|
239
|
+
<img src="media/easing_curves.png" alt="Easing curves preview" />
|
|
229
240
|
|
|
230
241
|
```js
|
|
231
242
|
import { gradient } from 'ansimax';
|
|
@@ -245,7 +256,7 @@ console.log(gradient('hello world', stops, { easing: (t) => t * t * t }));
|
|
|
245
256
|
|
|
246
257
|
### Conic Gradients (v1.2.0)
|
|
247
258
|
|
|
248
|
-
<img src="media/conic_gradients.png" alt="
|
|
259
|
+
<img src="media/conic_gradients.png" alt="Conic gradients preview" />
|
|
249
260
|
|
|
250
261
|
```js
|
|
251
262
|
import { gradientRect } from 'ansimax';
|
|
@@ -434,7 +445,7 @@ console.log(components.table([
|
|
|
434
445
|
['loaders', color.green('● ready'), '100%'],
|
|
435
446
|
], { borderStyle: 'rounded' }));
|
|
436
447
|
|
|
437
|
-
console.log(components.badge('VERSION', 'v1.
|
|
448
|
+
console.log(components.badge('VERSION', 'v1.3.1'));
|
|
438
449
|
console.log(components.badge('BUILD', 'passing'));
|
|
439
450
|
```
|
|
440
451
|
|
|
@@ -544,6 +555,61 @@ console.log('tenantB themes include custom?', tenantB.list().includes('custom'))
|
|
|
544
555
|
// ↑ false — full isolation
|
|
545
556
|
```
|
|
546
557
|
|
|
558
|
+
### Panels — Split Layouts (v1.3.0)
|
|
559
|
+
|
|
560
|
+
```js
|
|
561
|
+
import { panels, ascii } from 'ansimax';
|
|
562
|
+
|
|
563
|
+
// Side-by-side columns
|
|
564
|
+
const left = ascii.box('Sidebar', { borderStyle: 'rounded' });
|
|
565
|
+
const right = ascii.box('Main view', { borderStyle: 'rounded' });
|
|
566
|
+
|
|
567
|
+
console.log(panels.vsplit([left, right], { gap: 2, align: 'center' }));
|
|
568
|
+
|
|
569
|
+
// Vertical stacking
|
|
570
|
+
console.log(panels.hsplit([
|
|
571
|
+
'── Application ──',
|
|
572
|
+
ascii.box('Body content'),
|
|
573
|
+
'── Footer ──',
|
|
574
|
+
], { gap: 1, align: 'center' }));
|
|
575
|
+
|
|
576
|
+
// Nested — sidebar + main inside an app shell
|
|
577
|
+
console.log(panels.hsplit([
|
|
578
|
+
'── My App ──',
|
|
579
|
+
panels.vsplit([
|
|
580
|
+
ascii.box('Sidebar', { width: 20 }),
|
|
581
|
+
ascii.box('Main', { width: 40 }),
|
|
582
|
+
], { gap: 2 }),
|
|
583
|
+
'── End ──',
|
|
584
|
+
]));
|
|
585
|
+
```
|
|
586
|
+
|
|
587
|
+
### JSON Pretty-print (v1.3.0)
|
|
588
|
+
|
|
589
|
+
```js
|
|
590
|
+
import { json } from 'ansimax';
|
|
591
|
+
|
|
592
|
+
// Colored, depth-aware pretty-printing
|
|
593
|
+
console.log(json.pretty({
|
|
594
|
+
name: 'ansimax',
|
|
595
|
+
version: '1.3.0',
|
|
596
|
+
features: ['colors', 'gradients', 'panels'],
|
|
597
|
+
stats: { tests: 2000, coverage: 0.98 },
|
|
598
|
+
active: true,
|
|
599
|
+
}));
|
|
600
|
+
|
|
601
|
+
// Depth limit — collapses deep objects to {...}
|
|
602
|
+
console.log(json.pretty(deeplyNested, { maxDepth: 2 }));
|
|
603
|
+
|
|
604
|
+
// Item limit — huge arrays show "... (N more)"
|
|
605
|
+
console.log(json.pretty(largeArray, { maxItems: 10 }));
|
|
606
|
+
|
|
607
|
+
// Circular references handled gracefully
|
|
608
|
+
const obj = { name: 'foo' };
|
|
609
|
+
obj.self = obj;
|
|
610
|
+
console.log(json.pretty(obj)); // → "self": [Circular]
|
|
611
|
+
```
|
|
612
|
+
|
|
547
613
|
---
|
|
548
614
|
|
|
549
615
|
## 📚 Examples
|
|
@@ -655,6 +721,68 @@ try {
|
|
|
655
721
|
|
|
656
722
|
---
|
|
657
723
|
|
|
724
|
+
## 🧩 Ecosystem packages
|
|
725
|
+
|
|
726
|
+
The **ansimax ecosystem** is structured in two tiers — companion packages that extend the core, and independent evolutions that target different platforms.
|
|
727
|
+
|
|
728
|
+
### `@ansimax/*` — Companion packages
|
|
729
|
+
|
|
730
|
+
Scoped packages that extend `ansimax` without breaking its zero-dependency promise. Each is published independently but shares ansimax's philosophy and naming.
|
|
731
|
+
|
|
732
|
+
| Package | Status | Description |
|
|
733
|
+
|---|:-:|---|
|
|
734
|
+
| `ansimax` | ✅ stable | Terminal-rendering core. Zero dependencies. |
|
|
735
|
+
| `@ansimax/image` | 🟡 planned | Image-to-ASCII loader — PNG/JPEG/WebP from file/buffer/URL |
|
|
736
|
+
| `@ansimax/cli` | 🟡 planned | Standalone binary — `npx @ansimax/cli demo`, font browser, image converter |
|
|
737
|
+
| `@ansimax/fonts` | 🟡 planned | 250+ figlet `.flf` fonts pre-bundled, ready to use |
|
|
738
|
+
| `@ansimax/sprites` | 🔴 future | Curated sprite library (animals, UI icons, technical diagrams) |
|
|
739
|
+
| `@ansimax/video` | 🔴 future | Video frame extraction → ASCII playback |
|
|
740
|
+
| `@ansimax/themes-extra` | 🔴 future | Community-contributed themes pack |
|
|
741
|
+
|
|
742
|
+
**How they connect:**
|
|
743
|
+
|
|
744
|
+
```
|
|
745
|
+
┌─────────────────────────────┐
|
|
746
|
+
│ ansimax (zero deps) │ ← core, you always install
|
|
747
|
+
│ • colors, ASCII, panels │
|
|
748
|
+
│ • types: PixelGrid, etc. │
|
|
749
|
+
└────────────┬────────────────┘
|
|
750
|
+
│ peer dependency
|
|
751
|
+
┌────────────────────┼────────────────────┐
|
|
752
|
+
▼ ▼ ▼
|
|
753
|
+
@ansimax/image @ansimax/cli @ansimax/fonts
|
|
754
|
+
(deps: jimp) (binary) (data only)
|
|
755
|
+
```
|
|
756
|
+
|
|
757
|
+
Each companion declares `"ansimax": "^X.Y.Z"` as `peerDependency` — semver-coordinated, never duplicated, never out of sync.
|
|
758
|
+
|
|
759
|
+
### `ansimax-*` — Independent evolutions
|
|
760
|
+
|
|
761
|
+
Standalone projects that build **alongside** ansimax for different platforms. Not companions — these are separate identities with their own scope and release cycle.
|
|
762
|
+
|
|
763
|
+
| Package | Status | Description |
|
|
764
|
+
|---|:-:|---|
|
|
765
|
+
| `ansimax-native` | 🔴 future | **Rust + TS rewrite** of the rendering hot path. Native performance via napi-rs. Same API surface as `ansimax`. |
|
|
766
|
+
| `ansimax-web` | 🔴 future | **Browser rendering** layer. ANSI → HTML/CSS conversion + canvas rendering. For demos, docs sites, web terminals. |
|
|
767
|
+
|
|
768
|
+
**Sub-ecosystems**: each of these can have their own scoped sub-packages (`@ansimax-native/image`, `@ansimax-web/canvas`, etc.) over time.
|
|
769
|
+
|
|
770
|
+
### Why two naming conventions?
|
|
771
|
+
|
|
772
|
+
Industry convention used by many mature ecosystems (Babel, Vue, Webpack, etc.):
|
|
773
|
+
|
|
774
|
+
- **`@scope/*`** = "same project family, coordinated release, same team"
|
|
775
|
+
- **`name-*`** = "inspired by / works alongside, independent identity"
|
|
776
|
+
|
|
777
|
+
By using both, ansimax signals:
|
|
778
|
+
- The **core** (`ansimax`) stays small, zero-dep, focused on terminal rendering
|
|
779
|
+
- The **ecosystem** (`@ansimax/*`) grows around it as opt-in extensions
|
|
780
|
+
- **Evolutions** (`ansimax-native`, `ansimax-web`) explore different platforms without compromising the core
|
|
781
|
+
|
|
782
|
+
> 💡 **Coming soon**: When `@ansimax/image` or similar packages are released, this section will link to them. Want one of these built sooner? [Open an issue](https://github.com/Brashkie/ansimax/issues) to vote.
|
|
783
|
+
|
|
784
|
+
---
|
|
785
|
+
|
|
658
786
|
## 🛣️ Roadmap
|
|
659
787
|
|
|
660
788
|
Ansimax is being built toward a **full terminal rendering platform** — a Node-native answer to what Python developers get from `rich` + `textual` combined, with Node-specific improvements where it matters.
|
|
@@ -706,12 +834,12 @@ The roadmap intentionally targets — and aims to surpass — gaps that even mat
|
|
|
706
834
|
- [x] Columns layout (truncate/wrap overflow)
|
|
707
835
|
- [x] Sections (gradient headers with auto-width)
|
|
708
836
|
- [x] Trees (collapsible, max-depth, cycle-safe)
|
|
709
|
-
- [
|
|
837
|
+
- [x] **Panels** — split layouts: `hsplit`, `vsplit` with alignment + nesting (v1.3.0)
|
|
838
|
+
- [x] **JSON/YAML pretty-printing** — colored, depth-limit, circular-safe (v1.3.0)
|
|
710
839
|
- [ ] **Layouts** (flexbox-style positioning)
|
|
711
840
|
- [ ] **Grid system** (CSS Grid-inspired column/row spans)
|
|
712
841
|
- [ ] **Markdown rendering** (headings, lists, code blocks, tables)
|
|
713
842
|
- [ ] **Syntax highlighting** (built-in language grammars)
|
|
714
|
-
- [ ] **JSON/YAML pretty-printing** (with depth limit + collapse)
|
|
715
843
|
- [ ] **Logging integration** (drop-in replacement for `console`/`pino`/`winston` transports)
|
|
716
844
|
|
|
717
845
|
### ✅ Phase 5 — Cursor & screen control
|
|
@@ -826,16 +954,23 @@ The roadmap intentionally targets — and aims to surpass — gaps that even mat
|
|
|
826
954
|
## 🧪 Testing
|
|
827
955
|
|
|
828
956
|
```bash
|
|
829
|
-
npm test # Run all
|
|
957
|
+
npm test # Run all 2000+ tests
|
|
830
958
|
npm run test:watch # Watch mode
|
|
831
959
|
npm run test:coverage # Coverage report
|
|
832
960
|
```
|
|
833
961
|
|
|
834
|
-
Coverage
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
962
|
+
Coverage (as of v1.3.0):
|
|
963
|
+
|
|
964
|
+
| Metric | Score |
|
|
965
|
+
|---|:-:|
|
|
966
|
+
| **Statements** | ~98% |
|
|
967
|
+
| **Branches** | ~95% |
|
|
968
|
+
| **Functions** | ~99% |
|
|
969
|
+
| **Lines** | ~99% |
|
|
970
|
+
| **Total tests** | **2,000+** |
|
|
971
|
+
| **Test suites** | 18 |
|
|
972
|
+
| **CI matrix** | Node 18, 20, 22, latest |
|
|
973
|
+
| **Platforms tested** | Linux, macOS, Windows |
|
|
839
974
|
|
|
840
975
|
---
|
|
841
976
|
|
|
@@ -871,6 +1006,58 @@ ansimax/
|
|
|
871
1006
|
|
|
872
1007
|
## 📝 Changelog
|
|
873
1008
|
|
|
1009
|
+
### v1.3.1 — Polish for panels + json
|
|
1010
|
+
|
|
1011
|
+
Patch release improving the modules from v1.3.0 with quality-of-life additions:
|
|
1012
|
+
|
|
1013
|
+
- 🎯 **`panels.center(block, opts)`** — center a block horizontally (and optionally vertically) in a known width
|
|
1014
|
+
- 🖼️ **`panels.frame(block, opts)`** — lighter alternative to `ascii.box`: top/bottom rules only, with optional title + padding
|
|
1015
|
+
- 📋 **`json.pretty` option `sortKeys`** — alphabetic key order for deterministic diffs
|
|
1016
|
+
- 📐 **`json.pretty` option `inlineArrayMaxLength`** — short arrays of primitives now render as `[1, 2, 3]` on one line (default threshold: 60 chars)
|
|
1017
|
+
- 🧪 **+26 tests** across panels + json modules
|
|
1018
|
+
|
|
1019
|
+
```js
|
|
1020
|
+
import { panels, json } from 'ansimax';
|
|
1021
|
+
|
|
1022
|
+
// Center a box inside the terminal
|
|
1023
|
+
console.log(panels.center(ascii.box('Hello'), { width: 80 }));
|
|
1024
|
+
|
|
1025
|
+
// Lighter decorative frame
|
|
1026
|
+
console.log(panels.frame('Body', { title: 'Header', padding: 1 }));
|
|
1027
|
+
|
|
1028
|
+
// Sorted, with inline arrays
|
|
1029
|
+
console.log(json.pretty({ zebra: [1, 2, 3], apple: 'A' }, { sortKeys: true }));
|
|
1030
|
+
// {
|
|
1031
|
+
// "apple": "A",
|
|
1032
|
+
// "zebra": [1, 2, 3]
|
|
1033
|
+
// }
|
|
1034
|
+
```
|
|
1035
|
+
|
|
1036
|
+
Drop-in replacement for `1.3.0`.
|
|
1037
|
+
|
|
1038
|
+
### v1.3.0 — Phase 4 progress: Panels + JSON pretty-print
|
|
1039
|
+
|
|
1040
|
+
Minor release adding two new top-level modules — split layouts and JSON pretty-printing:
|
|
1041
|
+
|
|
1042
|
+
- 🪟 **`panels` module** — `vsplit` (columns) + `hsplit` (rows) with ANSI-aware width, alignment (`start`/`center`/`end`), gap, fixed-width mode, nesting
|
|
1043
|
+
- 🎨 **`json` module** — colored JSON pretty-printer with depth limit, item limit, string truncation, circular reference detection
|
|
1044
|
+
- 🛣️ **Phase 4 roadmap**: 8/15 → **10/15** complete
|
|
1045
|
+
|
|
1046
|
+
```js
|
|
1047
|
+
import { panels, json, ascii } from 'ansimax';
|
|
1048
|
+
|
|
1049
|
+
// Side-by-side columns
|
|
1050
|
+
console.log(panels.vsplit([
|
|
1051
|
+
ascii.box('Sidebar', { width: 20 }),
|
|
1052
|
+
ascii.box('Main', { width: 40 }),
|
|
1053
|
+
], { gap: 2 }));
|
|
1054
|
+
|
|
1055
|
+
// Pretty-print JSON
|
|
1056
|
+
console.log(json.pretty({ name: 'app', tests: 2000 }, { maxDepth: 3 }));
|
|
1057
|
+
```
|
|
1058
|
+
|
|
1059
|
+
Drop-in replacement for `1.2.8`. Two new modules, zero breaking changes.
|
|
1060
|
+
|
|
874
1061
|
### v1.2.8 — Documentation polish
|
|
875
1062
|
|
|
876
1063
|
Patch release with massively improved JSDoc + IntelliSense coverage:
|