ansimax 1.4.0 → 1.4.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 +188 -0
- package/README.es.md +47 -2
- package/README.md +47 -2
- package/dist/index.d.mts +175 -97
- package/dist/index.d.ts +175 -97
- package/dist/index.js +189 -121
- package/dist/index.mjs +186 -121
- package/examples/all-in-one.cjs +1 -1
- package/examples/all-in-one.mjs +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,194 @@
|
|
|
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.4.2] — Internal consolidation v3
|
|
7
|
+
|
|
8
|
+
Patch release continuing the DRY work from v1.3.7. Three more helper
|
|
9
|
+
patterns that were duplicated across modules are now consolidated into
|
|
10
|
+
`utils/helpers` and exported. **Zero behavior changes** — the
|
|
11
|
+
consolidated implementations are byte-identical to the inline copies
|
|
12
|
+
they replace.
|
|
13
|
+
|
|
14
|
+
### Added — Three new exported helpers
|
|
15
|
+
|
|
16
|
+
**`ensureString(value)`** — coerce any value to a string, with `null`
|
|
17
|
+
and `undefined` becoming `''` (not `'null'`/`'undefined'`):
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
import { ensureString } from 'ansimax';
|
|
21
|
+
|
|
22
|
+
ensureString('hello') // → 'hello'
|
|
23
|
+
ensureString(42) // → '42'
|
|
24
|
+
ensureString(null) // → ''
|
|
25
|
+
ensureString(undefined) // → ''
|
|
26
|
+
ensureString({}) // → '[object Object]'
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
**`clampNonNeg(value, fallback?)`** — coerce to a non-negative integer
|
|
30
|
+
(≥ 0), with floor and fallback for non-finite input:
|
|
31
|
+
|
|
32
|
+
```js
|
|
33
|
+
import { clampNonNeg } from 'ansimax';
|
|
34
|
+
|
|
35
|
+
clampNonNeg(5.7) // → 5
|
|
36
|
+
clampNonNeg(-3) // → 0
|
|
37
|
+
clampNonNeg(NaN, 10) // → 10
|
|
38
|
+
clampNonNeg('abc', 5) // → 5
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
**`clampPositiveInt(value, fallback?)`** — coerce to a positive integer
|
|
42
|
+
(≥ 1), with floor and fallback. Default fallback is `1`:
|
|
43
|
+
|
|
44
|
+
```js
|
|
45
|
+
import { clampPositiveInt } from 'ansimax';
|
|
46
|
+
|
|
47
|
+
clampPositiveInt(5.7) // → 5
|
|
48
|
+
clampPositiveInt(0) // → 1 (clamped up)
|
|
49
|
+
clampPositiveInt(NaN, 10) // → 10
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Improved — Internal consolidation
|
|
53
|
+
|
|
54
|
+
Removed **10 duplicate inline implementations** across modules:
|
|
55
|
+
|
|
56
|
+
| Helper | Was duplicated in | Now imported from |
|
|
57
|
+
|---|---|---|
|
|
58
|
+
| `ensureString` | components, frames, loaders, trees (×4 identical) | `utils/helpers` |
|
|
59
|
+
| `clampNonNeg` | components, trees (×2 identical) | `utils/helpers` |
|
|
60
|
+
| `clampPositive` / `clampPositiveInt` | components, loaders (×3 identical) | `utils/helpers` |
|
|
61
|
+
|
|
62
|
+
What's left intentionally:
|
|
63
|
+
- `utils/ansi.ts` keeps its own private versions (architectural choice
|
|
64
|
+
from v1.3.7 — `ansi` and `helpers` stay at the bottom of the
|
|
65
|
+
dependency graph with no cross-imports)
|
|
66
|
+
- `ascii/index.ts` keeps a distinct `ensureString(value, paramName)`
|
|
67
|
+
variant that throws with parameter info (different semantics, not a
|
|
68
|
+
duplicate)
|
|
69
|
+
|
|
70
|
+
### Improved — Tests
|
|
71
|
+
|
|
72
|
+
- `+5` tests for `ensureString` (string/number/boolean/null/object)
|
|
73
|
+
- `+6` tests for `clampNonNeg` (range, floor, fallback, default, clamp)
|
|
74
|
+
- `+6` tests for `clampPositiveInt` (clamp-up, range, floor, fallback)
|
|
75
|
+
- `+1` test for barrel re-exports
|
|
76
|
+
|
|
77
|
+
Total: **+18 tests**.
|
|
78
|
+
|
|
79
|
+
### Notes
|
|
80
|
+
|
|
81
|
+
- **Zero behavior changes** — drop-in replacement for `1.4.1`
|
|
82
|
+
- **Zero API changes** — only additions (3 new exports)
|
|
83
|
+
- All call sites use explicit `fallback` arguments → compatible with
|
|
84
|
+
default-arg signatures of the exported helpers
|
|
85
|
+
- ~30 lines of duplicated source removed across 4 modules
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## [1.4.1] — Grid v2 + markdown internal refactor
|
|
90
|
+
|
|
91
|
+
Patch release with two improvements: **grid** gains CSS Grid-style
|
|
92
|
+
column spans + uniform row heights + flow direction control, and the
|
|
93
|
+
**markdown** module is internally refactored from a 522-line monolith
|
|
94
|
+
into 4 focused files (no API changes).
|
|
95
|
+
|
|
96
|
+
### Added — `panels.grid` v2
|
|
97
|
+
|
|
98
|
+
**`colSpan: number[]`** — per-block column span (CSS Grid-style):
|
|
99
|
+
|
|
100
|
+
```js
|
|
101
|
+
import { panels, ascii } from 'ansimax';
|
|
102
|
+
|
|
103
|
+
const header = ascii.box('Dashboard', { borderStyle: 'rounded' });
|
|
104
|
+
const sidebar = ascii.box('Sidebar', { borderStyle: 'rounded' });
|
|
105
|
+
const content = ascii.box('Main content area', { borderStyle: 'rounded' });
|
|
106
|
+
const footer = ascii.box('Footer', { borderStyle: 'rounded' });
|
|
107
|
+
|
|
108
|
+
// 2 columns, header + footer span the full width
|
|
109
|
+
console.log(panels.grid([header, sidebar, content, footer], {
|
|
110
|
+
columns: 2,
|
|
111
|
+
colSpan: [2, 1, 1, 2],
|
|
112
|
+
}));
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Auto-flow: each block consumes its `span` columns. If a row's remaining
|
|
116
|
+
capacity can't fit the next block, the layout wraps to a new row.
|
|
117
|
+
Invalid spans (NaN, negative, > columns) are normalized to safe values.
|
|
118
|
+
|
|
119
|
+
**`cellHeight: number | null`** — uniform vertical sizing per row:
|
|
120
|
+
|
|
121
|
+
```js
|
|
122
|
+
// All rows exactly 5 lines tall — short blocks padded, tall blocks truncated
|
|
123
|
+
panels.grid(blocks, { columns: 3, cellHeight: 5 });
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Complements the existing `cellWidth` option for fully uniform grids.
|
|
127
|
+
|
|
128
|
+
**`flow: 'row' | 'column'`** — auto-flow direction:
|
|
129
|
+
|
|
130
|
+
```js
|
|
131
|
+
// Default: row flow (left-to-right, then wrap down)
|
|
132
|
+
panels.grid([1, 2, 3, 4, 5, 6], { columns: 3, flow: 'row' });
|
|
133
|
+
// 1 2 3
|
|
134
|
+
// 4 5 6
|
|
135
|
+
|
|
136
|
+
// Column flow (top-to-bottom, then wrap right)
|
|
137
|
+
panels.grid([1, 2, 3, 4, 5, 6], { columns: 3, flow: 'column' });
|
|
138
|
+
// 1 3 5
|
|
139
|
+
// 2 4 6
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
When `colSpan` contains values > 1, flow is forced to `'row'` (the
|
|
143
|
+
column-flow + spans combination requires a full packing algorithm,
|
|
144
|
+
deferred to a later release).
|
|
145
|
+
|
|
146
|
+
### Improved — `markdown` module refactored
|
|
147
|
+
|
|
148
|
+
The single-file `src/markdown/index.ts` (522 lines) split into 5 files
|
|
149
|
+
of focused responsibility — **zero API changes, fully backward compatible**:
|
|
150
|
+
|
|
151
|
+
```
|
|
152
|
+
src/markdown/
|
|
153
|
+
├── types.ts — Public types (MarkdownTheme, Block, …)
|
|
154
|
+
├── theme.ts — Color palettes (THEMES record, private)
|
|
155
|
+
├── block-parser.ts — parseBlocks + line regexes
|
|
156
|
+
├── inline-parser.ts — parseInline + protected-code placeholders
|
|
157
|
+
├── renderer.ts — render (dispatches blocks → ansimax primitives)
|
|
158
|
+
└── index.ts — Re-exports + `markdown` namespace
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
External imports keep working unchanged:
|
|
162
|
+
|
|
163
|
+
```js
|
|
164
|
+
import { markdown, parseMarkdownBlocks, parseMarkdownInline, renderMarkdown }
|
|
165
|
+
from 'ansimax';
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Submodule imports now also work (advanced use):
|
|
169
|
+
|
|
170
|
+
```js
|
|
171
|
+
import { parseBlocks } from 'ansimax/markdown/block-parser'; // tree-shake friendly
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Improved — Tests
|
|
175
|
+
|
|
176
|
+
- `+18` tests for `colSpan` (defaults, clamping, wrapping, invalid input)
|
|
177
|
+
- `+4` tests for `cellHeight` (pad, truncate, null, zero clamp)
|
|
178
|
+
- `+5` tests for `flow` (row, column, non-multiples, fallback with colSpan)
|
|
179
|
+
- `+1` integration test (colSpan + cellHeight together)
|
|
180
|
+
- `+4` tests verifying submodule imports work after refactor
|
|
181
|
+
|
|
182
|
+
Total: **+32 tests** in `panels.test.ts` and `markdown.test.ts`.
|
|
183
|
+
|
|
184
|
+
### Notes
|
|
185
|
+
|
|
186
|
+
- **Zero behavior changes** for v1.4.0 users — `panels.grid` without the
|
|
187
|
+
new options produces byte-identical output
|
|
188
|
+
- **Zero breaking changes** — `markdown` API surface unchanged
|
|
189
|
+
- Submodule imports enabled (`ansimax/markdown/block-parser`) for
|
|
190
|
+
tree-shaking-friendly bundling
|
|
191
|
+
|
|
192
|
+
---
|
|
193
|
+
|
|
6
194
|
## [1.4.0] — Phase 4 closure: Markdown rendering
|
|
7
195
|
|
|
8
196
|
**Minor release** introducing the long-planned `markdown` module — the
|
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)
|
|
@@ -478,7 +478,7 @@ console.log(components.table([
|
|
|
478
478
|
['loaders', color.green('● listo'), '100%'],
|
|
479
479
|
], { borderStyle: 'rounded' }));
|
|
480
480
|
|
|
481
|
-
console.log(components.badge('VERSION', 'v1.4.
|
|
481
|
+
console.log(components.badge('VERSION', 'v1.4.2'));
|
|
482
482
|
console.log(components.badge('BUILD', 'passing'));
|
|
483
483
|
```
|
|
484
484
|
|
|
@@ -1065,6 +1065,51 @@ ansimax/
|
|
|
1065
1065
|
|
|
1066
1066
|
## 📝 Changelog
|
|
1067
1067
|
|
|
1068
|
+
### v1.4.2 — Consolidación interna v3
|
|
1069
|
+
|
|
1070
|
+
Release patch continuando el trabajo DRY de v1.3.7. Cero cambios de comportamiento:
|
|
1071
|
+
|
|
1072
|
+
- ➕ **`ensureString(value)`** — coerce a string (null/undefined → '')
|
|
1073
|
+
- ➕ **`clampNonNeg(n, fallback?)`** — entero no-negativo con fallback seguro
|
|
1074
|
+
- ➕ **`clampPositiveInt(n, fallback?)`** — entero positivo (≥ 1) con fallback seguro
|
|
1075
|
+
- 🧹 Removidas **10 implementaciones inline duplicadas** entre components, frames, loaders, trees
|
|
1076
|
+
- 🧪 **+18 tests** para los helpers consolidados
|
|
1077
|
+
|
|
1078
|
+
```js
|
|
1079
|
+
import { ensureString, clampNonNeg, clampPositiveInt } from 'ansimax';
|
|
1080
|
+
|
|
1081
|
+
ensureString(null) // → ''
|
|
1082
|
+
clampNonNeg(-3) // → 0
|
|
1083
|
+
clampPositiveInt(0) // → 1 (clamped up)
|
|
1084
|
+
clampPositiveInt(NaN, 10) // → 10 (fallback)
|
|
1085
|
+
```
|
|
1086
|
+
|
|
1087
|
+
Drop-in replacement para `1.4.1`.
|
|
1088
|
+
|
|
1089
|
+
### v1.4.1 — Grid v2 + refactor markdown
|
|
1090
|
+
|
|
1091
|
+
Release patch. Cero breaking changes:
|
|
1092
|
+
|
|
1093
|
+
- 🎯 **`panels.grid` — colSpan**: span de columnas por bloque (auto-flow estilo CSS Grid)
|
|
1094
|
+
- 📏 **`panels.grid` — cellHeight**: alturas de fila uniformes (complementa `cellWidth`)
|
|
1095
|
+
- 🔀 **`panels.grid` — flow**: dirección de auto-flow `'row'` (default) o `'column'`
|
|
1096
|
+
- 📁 **`markdown` refactorizado** de monolito de 522 líneas → 5 submódulos enfocados (API sin cambios)
|
|
1097
|
+
- 🌳 Imports de submódulo habilitados: `import { parseBlocks } from 'ansimax/markdown/block-parser'`
|
|
1098
|
+
- 🧪 **+32 tests**
|
|
1099
|
+
|
|
1100
|
+
```js
|
|
1101
|
+
import { panels, ascii } from 'ansimax';
|
|
1102
|
+
|
|
1103
|
+
// Header span ambas columnas, luego sidebar + content lado a lado
|
|
1104
|
+
panels.grid([header, sidebar, content], {
|
|
1105
|
+
columns: 2,
|
|
1106
|
+
colSpan: [2, 1, 1],
|
|
1107
|
+
cellHeight: 10, // altura de fila uniforme
|
|
1108
|
+
});
|
|
1109
|
+
```
|
|
1110
|
+
|
|
1111
|
+
Drop-in replacement para `1.4.0`.
|
|
1112
|
+
|
|
1068
1113
|
### v1.4.0 — Cierre de Fase 4: Renderizado Markdown 🎉
|
|
1069
1114
|
|
|
1070
1115
|
**Release minor** completando la Fase 4 con el nuevo módulo `markdown`:
|
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)
|
|
@@ -478,7 +478,7 @@ console.log(components.table([
|
|
|
478
478
|
['loaders', color.green('● ready'), '100%'],
|
|
479
479
|
], { borderStyle: 'rounded' }));
|
|
480
480
|
|
|
481
|
-
console.log(components.badge('VERSION', 'v1.4.
|
|
481
|
+
console.log(components.badge('VERSION', 'v1.4.2'));
|
|
482
482
|
console.log(components.badge('BUILD', 'passing'));
|
|
483
483
|
```
|
|
484
484
|
|
|
@@ -1065,6 +1065,51 @@ ansimax/
|
|
|
1065
1065
|
|
|
1066
1066
|
## 📝 Changelog
|
|
1067
1067
|
|
|
1068
|
+
### v1.4.2 — Internal consolidation v3
|
|
1069
|
+
|
|
1070
|
+
Patch release continuing v1.3.7's DRY work. Zero behavior changes:
|
|
1071
|
+
|
|
1072
|
+
- ➕ **`ensureString(value)`** — coerce to string (null/undefined → '')
|
|
1073
|
+
- ➕ **`clampNonNeg(n, fallback?)`** — non-negative integer with safe fallback
|
|
1074
|
+
- ➕ **`clampPositiveInt(n, fallback?)`** — positive integer (≥ 1) with safe fallback
|
|
1075
|
+
- 🧹 Removed **10 duplicate inline implementations** across components, frames, loaders, trees
|
|
1076
|
+
- 🧪 **+18 tests** for the consolidated helpers
|
|
1077
|
+
|
|
1078
|
+
```js
|
|
1079
|
+
import { ensureString, clampNonNeg, clampPositiveInt } from 'ansimax';
|
|
1080
|
+
|
|
1081
|
+
ensureString(null) // → ''
|
|
1082
|
+
clampNonNeg(-3) // → 0
|
|
1083
|
+
clampPositiveInt(0) // → 1 (clamped up)
|
|
1084
|
+
clampPositiveInt(NaN, 10) // → 10 (fallback)
|
|
1085
|
+
```
|
|
1086
|
+
|
|
1087
|
+
Drop-in replacement for `1.4.1`.
|
|
1088
|
+
|
|
1089
|
+
### v1.4.1 — Grid v2 + markdown refactor
|
|
1090
|
+
|
|
1091
|
+
Patch release. Zero breaking changes:
|
|
1092
|
+
|
|
1093
|
+
- 🎯 **`panels.grid` — colSpan**: per-block column span (CSS Grid-style auto-flow)
|
|
1094
|
+
- 📏 **`panels.grid` — cellHeight**: uniform row heights (complements `cellWidth`)
|
|
1095
|
+
- 🔀 **`panels.grid` — flow**: `'row'` (default) or `'column'` auto-flow direction
|
|
1096
|
+
- 📁 **`markdown` refactored** from 522-line monolith → 5 focused submodules (API unchanged)
|
|
1097
|
+
- 🌳 Submodule imports enabled: `import { parseBlocks } from 'ansimax/markdown/block-parser'`
|
|
1098
|
+
- 🧪 **+32 tests**
|
|
1099
|
+
|
|
1100
|
+
```js
|
|
1101
|
+
import { panels, ascii } from 'ansimax';
|
|
1102
|
+
|
|
1103
|
+
// Header spans both columns, then sidebar + content side by side
|
|
1104
|
+
panels.grid([header, sidebar, content], {
|
|
1105
|
+
columns: 2,
|
|
1106
|
+
colSpan: [2, 1, 1],
|
|
1107
|
+
cellHeight: 10, // uniform row height
|
|
1108
|
+
});
|
|
1109
|
+
```
|
|
1110
|
+
|
|
1111
|
+
Drop-in replacement for `1.4.0`.
|
|
1112
|
+
|
|
1068
1113
|
### v1.4.0 — Phase 4 closure: Markdown rendering 🎉
|
|
1069
1114
|
|
|
1070
1115
|
**Minor release** completing Phase 4 with the new `markdown` module:
|
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,76 @@
|
|
|
1
|
+
/** Visual theme for rendered output. */
|
|
2
|
+
type MarkdownTheme = 'dark' | 'light';
|
|
3
|
+
interface MarkdownOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Maximum width in columns. Long lines wrap. Default: terminal width
|
|
6
|
+
* or 80 if unavailable.
|
|
7
|
+
*/
|
|
8
|
+
width?: number;
|
|
9
|
+
/**
|
|
10
|
+
* Color theme. `'dark'` (default) uses bright colors for dark backgrounds.
|
|
11
|
+
* `'light'` uses dimmer/contrast colors for light backgrounds.
|
|
12
|
+
*/
|
|
13
|
+
theme?: MarkdownTheme;
|
|
14
|
+
/**
|
|
15
|
+
* Override the gradient used for top-level (`# H1`) headings. Receives
|
|
16
|
+
* a list of hex colors. Default uses the dracula palette.
|
|
17
|
+
*/
|
|
18
|
+
headingGradient?: string[];
|
|
19
|
+
/**
|
|
20
|
+
* Render code blocks inside an ASCII box. Default `true`. If `false`,
|
|
21
|
+
* code blocks render as indented dim text.
|
|
22
|
+
*/
|
|
23
|
+
boxCodeBlocks?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Inline code background tint. Default `true`. If `false`, inline code
|
|
26
|
+
* shows only as dim text (cleaner in some terminals).
|
|
27
|
+
*/
|
|
28
|
+
inlineCodeBackground?: boolean;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Internal options shape passed to `parseInline`. Exposed for advanced
|
|
32
|
+
* use cases that bypass `render` (custom block handlers, etc.).
|
|
33
|
+
*
|
|
34
|
+
* @since 1.4.0
|
|
35
|
+
*/
|
|
36
|
+
interface InlineOptions {
|
|
37
|
+
theme: MarkdownTheme;
|
|
38
|
+
inlineCodeBackground: boolean;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Block-level token after parsing the markdown into structural pieces.
|
|
42
|
+
* Tokens contain raw inline text — inline parsing happens at render time.
|
|
43
|
+
*
|
|
44
|
+
* @since 1.4.0
|
|
45
|
+
*/
|
|
46
|
+
type Block = {
|
|
47
|
+
type: 'heading';
|
|
48
|
+
level: number;
|
|
49
|
+
text: string;
|
|
50
|
+
} | {
|
|
51
|
+
type: 'paragraph';
|
|
52
|
+
text: string;
|
|
53
|
+
} | {
|
|
54
|
+
type: 'codeblock';
|
|
55
|
+
lang: string;
|
|
56
|
+
code: string;
|
|
57
|
+
} | {
|
|
58
|
+
type: 'list';
|
|
59
|
+
ordered: boolean;
|
|
60
|
+
items: string[];
|
|
61
|
+
} | {
|
|
62
|
+
type: 'blockquote';
|
|
63
|
+
text: string;
|
|
64
|
+
} | {
|
|
65
|
+
type: 'table';
|
|
66
|
+
headers: string[];
|
|
67
|
+
rows: string[][];
|
|
68
|
+
} | {
|
|
69
|
+
type: 'hr';
|
|
70
|
+
} | {
|
|
71
|
+
type: 'blank';
|
|
72
|
+
};
|
|
73
|
+
|
|
1
74
|
/** Color rendering capability. 'none' suppresses all color output. */
|
|
2
75
|
type ColorMode = 'none' | 'basic' | '256' | 'truecolor' | 'auto';
|
|
3
76
|
/** Animation pacing multiplier preset. */
|
|
@@ -204,6 +277,60 @@ declare const clampPercent: (p: unknown) => number;
|
|
|
204
277
|
* @since 1.3.7
|
|
205
278
|
*/
|
|
206
279
|
declare const clampInt: (value: unknown, min: number, max: number, fallback?: number) => number;
|
|
280
|
+
/**
|
|
281
|
+
* Coerce any value to a string. Non-strings go through `String()`. `null`
|
|
282
|
+
* and `undefined` become `''` (not `'null'`/`'undefined'`). Consolidates
|
|
283
|
+
* the `typeof v === 'string' ? v : String(v ?? '')` pattern previously
|
|
284
|
+
* duplicated across 5 modules (components, frames, loaders, trees, ansi).
|
|
285
|
+
*
|
|
286
|
+
* @example
|
|
287
|
+
* ```ts
|
|
288
|
+
* ensureString('hello') // → 'hello'
|
|
289
|
+
* ensureString(42) // → '42'
|
|
290
|
+
* ensureString(null) // → ''
|
|
291
|
+
* ensureString(undefined) // → ''
|
|
292
|
+
* ensureString({}) // → '[object Object]'
|
|
293
|
+
* ```
|
|
294
|
+
*
|
|
295
|
+
* @since 1.4.2
|
|
296
|
+
*/
|
|
297
|
+
declare const ensureString: (v: unknown) => string;
|
|
298
|
+
/**
|
|
299
|
+
* Coerce to a non-negative integer (≥ 0). Falls back to `fallback` for
|
|
300
|
+
* non-finite input. Floors fractional values.
|
|
301
|
+
*
|
|
302
|
+
* Consolidates the `Math.max(0, Math.floor(n))` pattern previously
|
|
303
|
+
* duplicated as a private `clampNonNeg` in components + trees.
|
|
304
|
+
*
|
|
305
|
+
* @example
|
|
306
|
+
* ```ts
|
|
307
|
+
* clampNonNeg(5.7) // → 5
|
|
308
|
+
* clampNonNeg(-3) // → 0
|
|
309
|
+
* clampNonNeg(NaN, 10) // → 10
|
|
310
|
+
* clampNonNeg('abc', 5) // → 5
|
|
311
|
+
* ```
|
|
312
|
+
*
|
|
313
|
+
* @since 1.4.2
|
|
314
|
+
*/
|
|
315
|
+
declare const clampNonNeg: (n: unknown, fallback?: number) => number;
|
|
316
|
+
/**
|
|
317
|
+
* Coerce to a positive integer (≥ 1). Falls back to `fallback` for
|
|
318
|
+
* non-finite input. Floors fractional values.
|
|
319
|
+
*
|
|
320
|
+
* Consolidates the `Math.max(1, Math.floor(n))` pattern previously
|
|
321
|
+
* duplicated as private `clampPositive` / `clampPositiveInt` in
|
|
322
|
+
* components + loaders.
|
|
323
|
+
*
|
|
324
|
+
* @example
|
|
325
|
+
* ```ts
|
|
326
|
+
* clampPositiveInt(5.7) // → 5
|
|
327
|
+
* clampPositiveInt(0) // → 1 (clamped up)
|
|
328
|
+
* clampPositiveInt(NaN, 10) // → 10
|
|
329
|
+
* ```
|
|
330
|
+
*
|
|
331
|
+
* @since 1.4.2
|
|
332
|
+
*/
|
|
333
|
+
declare const clampPositiveInt: (n: unknown, fallback?: number) => number;
|
|
207
334
|
/** Returns true when a string is a valid 3- or 6-digit hex color. */
|
|
208
335
|
declare const isHexColor: (hex: string) => boolean;
|
|
209
336
|
/**
|
|
@@ -2713,6 +2840,46 @@ interface GridOptions {
|
|
|
2713
2840
|
* use the max width of the widest block in their column.
|
|
2714
2841
|
*/
|
|
2715
2842
|
cellWidth?: number | null;
|
|
2843
|
+
/**
|
|
2844
|
+
* **v1.4.1+** Fix each row to this height (in lines). When the block has
|
|
2845
|
+
* fewer lines, it is padded (using `alignY`). When it has more lines, it
|
|
2846
|
+
* is truncated. If omitted (default), rows take the natural height of
|
|
2847
|
+
* their tallest block.
|
|
2848
|
+
*
|
|
2849
|
+
* @since 1.4.1
|
|
2850
|
+
*/
|
|
2851
|
+
cellHeight?: number | null;
|
|
2852
|
+
/**
|
|
2853
|
+
* **v1.4.1+** Per-block column span. `colSpan[i]` is the number of
|
|
2854
|
+
* columns block `i` occupies. Defaults to `1` for every block when
|
|
2855
|
+
* omitted or shorter than `blocks`.
|
|
2856
|
+
*
|
|
2857
|
+
* The auto-flow algorithm wraps to the next row when the current row's
|
|
2858
|
+
* remaining capacity is less than the next block's span. Spans that
|
|
2859
|
+
* exceed `columns` are clamped to `columns`.
|
|
2860
|
+
*
|
|
2861
|
+
* @example
|
|
2862
|
+
* ```js
|
|
2863
|
+
* // Header spans full width, then 2 cells in a row
|
|
2864
|
+
* panels.grid([header, left, right], {
|
|
2865
|
+
* columns: 2,
|
|
2866
|
+
* colSpan: [2, 1, 1],
|
|
2867
|
+
* });
|
|
2868
|
+
* ```
|
|
2869
|
+
*
|
|
2870
|
+
* @since 1.4.1
|
|
2871
|
+
*/
|
|
2872
|
+
colSpan?: number[];
|
|
2873
|
+
/**
|
|
2874
|
+
* **v1.4.1+** Auto-flow direction. `'row'` (default) fills cells
|
|
2875
|
+
* left-to-right then wraps to the next row — matches CSS Grid's
|
|
2876
|
+
* `grid-auto-flow: row`. `'column'` fills top-to-bottom then wraps to
|
|
2877
|
+
* the next column. Not applicable when `colSpan` is set with any
|
|
2878
|
+
* span > 1 (forces 'row' mode).
|
|
2879
|
+
*
|
|
2880
|
+
* @since 1.4.1
|
|
2881
|
+
*/
|
|
2882
|
+
flow?: 'row' | 'column';
|
|
2716
2883
|
}
|
|
2717
2884
|
/**
|
|
2718
2885
|
* Arrange blocks in a grid of N columns, flowing left-to-right then
|
|
@@ -2887,63 +3054,6 @@ declare const json: {
|
|
|
2887
3054
|
pretty: (value: unknown, opts?: PrettyOptions) => string;
|
|
2888
3055
|
};
|
|
2889
3056
|
|
|
2890
|
-
/** Visual theme for rendered output. */
|
|
2891
|
-
type MarkdownTheme = 'dark' | 'light';
|
|
2892
|
-
interface MarkdownOptions {
|
|
2893
|
-
/**
|
|
2894
|
-
* Maximum width in columns. Long lines wrap. Default: terminal width
|
|
2895
|
-
* or 80 if unavailable.
|
|
2896
|
-
*/
|
|
2897
|
-
width?: number;
|
|
2898
|
-
/**
|
|
2899
|
-
* Color theme. `'dark'` (default) uses bright colors for dark backgrounds.
|
|
2900
|
-
* `'light'` uses dimmer/contrast colors for light backgrounds.
|
|
2901
|
-
*/
|
|
2902
|
-
theme?: MarkdownTheme;
|
|
2903
|
-
/**
|
|
2904
|
-
* Override the gradient used for top-level (`# H1`) headings. Receives
|
|
2905
|
-
* a list of hex colors. Default uses the dracula palette.
|
|
2906
|
-
*/
|
|
2907
|
-
headingGradient?: string[];
|
|
2908
|
-
/**
|
|
2909
|
-
* Render code blocks inside an ASCII box. Default `true`. If `false`,
|
|
2910
|
-
* code blocks render as indented dim text.
|
|
2911
|
-
*/
|
|
2912
|
-
boxCodeBlocks?: boolean;
|
|
2913
|
-
/**
|
|
2914
|
-
* Inline code background tint. Default `true`. If `false`, inline code
|
|
2915
|
-
* shows only as dim text (cleaner in some terminals).
|
|
2916
|
-
*/
|
|
2917
|
-
inlineCodeBackground?: boolean;
|
|
2918
|
-
}
|
|
2919
|
-
/** Block-level token after parsing the markdown into structural pieces. */
|
|
2920
|
-
type Block = {
|
|
2921
|
-
type: 'heading';
|
|
2922
|
-
level: number;
|
|
2923
|
-
text: string;
|
|
2924
|
-
} | {
|
|
2925
|
-
type: 'paragraph';
|
|
2926
|
-
text: string;
|
|
2927
|
-
} | {
|
|
2928
|
-
type: 'codeblock';
|
|
2929
|
-
lang: string;
|
|
2930
|
-
code: string;
|
|
2931
|
-
} | {
|
|
2932
|
-
type: 'list';
|
|
2933
|
-
ordered: boolean;
|
|
2934
|
-
items: string[];
|
|
2935
|
-
} | {
|
|
2936
|
-
type: 'blockquote';
|
|
2937
|
-
text: string;
|
|
2938
|
-
} | {
|
|
2939
|
-
type: 'table';
|
|
2940
|
-
headers: string[];
|
|
2941
|
-
rows: string[][];
|
|
2942
|
-
} | {
|
|
2943
|
-
type: 'hr';
|
|
2944
|
-
} | {
|
|
2945
|
-
type: 'blank';
|
|
2946
|
-
};
|
|
2947
3057
|
/**
|
|
2948
3058
|
* Parse markdown source into a flat sequence of block tokens.
|
|
2949
3059
|
* Tokens contain raw inline text — inline parsing happens at render time.
|
|
@@ -2951,15 +3061,14 @@ type Block = {
|
|
|
2951
3061
|
* @since 1.4.0
|
|
2952
3062
|
*/
|
|
2953
3063
|
declare const parseBlocks: (source: string) => Block[];
|
|
3064
|
+
|
|
2954
3065
|
/**
|
|
2955
3066
|
* Apply inline markdown markup (bold/italic/code/links/etc.) to a string.
|
|
2956
3067
|
*
|
|
2957
3068
|
* @since 1.4.0
|
|
2958
3069
|
*/
|
|
2959
|
-
declare const parseInline: (text: string, opts?:
|
|
2960
|
-
|
|
2961
|
-
inlineCodeBackground: boolean;
|
|
2962
|
-
}) => string;
|
|
3070
|
+
declare const parseInline: (text: string, opts?: InlineOptions) => string;
|
|
3071
|
+
|
|
2963
3072
|
/**
|
|
2964
3073
|
* Render a markdown source string to a terminal-ready string with ANSI
|
|
2965
3074
|
* styling. Handles headings, paragraphs, code blocks, lists, blockquotes,
|
|
@@ -2988,6 +3097,7 @@ declare const parseInline: (text: string, opts?: {
|
|
|
2988
3097
|
* @since 1.4.0
|
|
2989
3098
|
*/
|
|
2990
3099
|
declare const render: (source: string, opts?: MarkdownOptions) => string;
|
|
3100
|
+
|
|
2991
3101
|
/**
|
|
2992
3102
|
* Markdown → terminal renderer. Use `markdown.render(source, opts?)` to
|
|
2993
3103
|
* convert a markdown string to an ANSI-styled string ready for
|
|
@@ -3001,10 +3111,7 @@ declare const render: (source: string, opts?: MarkdownOptions) => string;
|
|
|
3001
3111
|
declare const markdown: {
|
|
3002
3112
|
render: (source: string, opts?: MarkdownOptions) => string;
|
|
3003
3113
|
parseBlocks: (source: string) => Block[];
|
|
3004
|
-
parseInline: (text: string, opts?:
|
|
3005
|
-
theme: MarkdownTheme;
|
|
3006
|
-
inlineCodeBackground: boolean;
|
|
3007
|
-
}) => string;
|
|
3114
|
+
parseInline: (text: string, opts?: InlineOptions) => string;
|
|
3008
3115
|
};
|
|
3009
3116
|
|
|
3010
3117
|
type EasingFunction = (t: number) => number;
|
|
@@ -3220,38 +3327,9 @@ declare const ansimax: {
|
|
|
3220
3327
|
};
|
|
3221
3328
|
markdown: {
|
|
3222
3329
|
render: (source: string, opts?: MarkdownOptions) => string;
|
|
3223
|
-
parseBlocks: (source: string) =>
|
|
3224
|
-
|
|
3225
|
-
level: number;
|
|
3226
|
-
text: string;
|
|
3227
|
-
} | {
|
|
3228
|
-
type: "paragraph";
|
|
3229
|
-
text: string;
|
|
3230
|
-
} | {
|
|
3231
|
-
type: "codeblock";
|
|
3232
|
-
lang: string;
|
|
3233
|
-
code: string;
|
|
3234
|
-
} | {
|
|
3235
|
-
type: "list";
|
|
3236
|
-
ordered: boolean;
|
|
3237
|
-
items: string[];
|
|
3238
|
-
} | {
|
|
3239
|
-
type: "blockquote";
|
|
3240
|
-
text: string;
|
|
3241
|
-
} | {
|
|
3242
|
-
type: "table";
|
|
3243
|
-
headers: string[];
|
|
3244
|
-
rows: string[][];
|
|
3245
|
-
} | {
|
|
3246
|
-
type: "hr";
|
|
3247
|
-
} | {
|
|
3248
|
-
type: "blank";
|
|
3249
|
-
})[];
|
|
3250
|
-
parseInline: (text: string, opts?: {
|
|
3251
|
-
theme: MarkdownTheme;
|
|
3252
|
-
inlineCodeBackground: boolean;
|
|
3253
|
-
}) => string;
|
|
3330
|
+
parseBlocks: (source: string) => Block[];
|
|
3331
|
+
parseInline: (text: string, opts?: InlineOptions) => string;
|
|
3254
3332
|
};
|
|
3255
3333
|
};
|
|
3256
3334
|
|
|
3257
|
-
export { ASCII_RAMPS, type Alignment, type AnimateGradientController, type AnimateGradientOptions, type AnimationHooks, type AnimationSpeed, type AnsiCode, type AnsimaxConfig, type AsciiRamp, BEL, BG, type BadgeOptions, type BallOptions, type BannerOptions, type BoxOptions, type BoxStyle, type BreatheOptions, DEFAULTS as CONFIG_DEFAULTS, CSI, type Canvas, type CanvasRenderOptions, type CenterOptions, type ColorChain, type ColorFn, type ColorLevel, type ColorMode, type ColorSpace, type ColorSupport, type ColumnsOptions, type ConfigChangeListener, type ConfigKey, type ConfigKeyListener, type ConfigureOptions, type CountdownOptions, type CustomOptions, DEFAULT_TERM_COLS, DEFAULT_TERM_ROWS, type DebounceOptions, type DiffType, type Dimensions, type DividerOptions, type DotsOptions, ESC, type EasingFn, type EasingFunction, type EasingLibraryName, type EasingName, type EraseMode, FG, FRAME_MS, type FadeOptions, type FigletFont, type FigletOptions, type FontMap, type FontName, type FrameCallback, type FrameHandle, type FrameOptions, type FromImageOptions, type GlitchOptions, type Glyph, type GradientOptions, type GradientRectOptions, type GridOptions, type HSL, type HsplitOptions, type PrettyOptions as JsonPrettyOptions, type LineDiff, type LiveController, type LiveOptions, type LoadingBarOptions, type LogoOptions, MENU_CANCELLED, type MarkdownOptions, type MarkdownTheme, type MemoizeOptions, type MenuInput, type MenuOptions, type MenuOutput, type MenuResult, type MultiLoader, type MultiLoaderItem, OSC, type Oklab, type OnResizeOptions, type OutputBuffer, type ParallelOptions, type ParallelStep, type Pixel, type PixelGrid, type PlayController, type PlayOptions, type PresetName, type ProgressAnimateOptions, type ProgressBarOptions, type ProgressOptions, type PulseOptions, type RGB, type RGBA, type RegisterFontOptions, type RenderOptions$1 as RenderOptions, type ResizeListener, type ReusableGradient, type RevealOptions, SPINNERS, SPRITES, ST, STYLE, type SectionOptions, type SleepOptions, type SlideOptions, type SpinOptions, type SpinnerType, type StatusOptions, type StatusType, type StopFn, type StreamOptions, type TableBorderStyle, type TableOptions, type Task, type TaskResult, type TasksOptions, type Theme, type BannerOpts as ThemeBannerOpts, type ThemeChangeListener, type ThemeInstance, type ThemeStyleName, type TimelineEvent, type TimelineOptions, type TreeData, type TreeDimensions, type TreeNode, type RenderOptions as TreeRenderOptions, type TreeStyle, type TypeDeleteOptions, type TypewriterOptions, type VsplitOptions, type WalkVisitor, type WaveOptions, type WriteAsyncOptions, animate, animateGradient, ascii, bell, bg256, bgRgb, box, canAnimate, cancelTerminalFrame, center$1 as center, center as centerBlock, chain, charWidth, clamp, clampByte, clampInt, clampPercent, clearAnsiCache, clearColorCache, clearLine, clearRenderCache, clearThemeColorCache, color, colorLevel, presets as colorPresets, components, compose, configure, countNodes, createCanvas, createGradient, createOutputBuffer, createTheme, cursor, debounce, ansimax as default, diffLines, easings, escapeForRegex, escapeRegex, fg256, fgRgb, figletText, filterTree, findInTree, flipHorizontal, flipVertical, frame, frames, fromImage, getConfig, getConfigValue, getRenderCacheSize, getSpeedMultiplier, getTerminalHeight, getTerminalWidth, gradient, gradientColor, gradientRect, gradientStops, graphemes, grid, hasFont, hexToRgb, hideCursor, hslToRgb, hsplit, hyperlink, images, isFiniteNumber, isHexColor, isNoColor, json, pretty as jsonPretty, lerp, lerpColor, link, listFonts, listPresets, loader, mapTree, markdown, measureBlock, measureTree, memoize, mixColors, nextTick, oklabToRgb, onConfigChange, onConfigKeyChange, onResize, once, padBoth, padEnd, padStart, panels, parseFiglet, parseBlocks as parseMarkdownBlocks, parseInline as parseMarkdownInline, pauseListeners, presetNames, presets, quantizeColor, rainbow, registerFont, registerPreset, render as renderMarkdown, renderPixelArt, renderTree, renderTreeStream, repeatVisible, requestTerminalFrame, reset, resetColorSupportCache, resetConfig, resetCursorRefCount, resetFramesCursorCount, resetLoaderCursorCount, resetNoColor, resolveEasingByName, resumeListeners, reverseGradient, rgbTo256, rgbToHex, rgbToHsl, rgbToOklab, rotate90, safeInt, safeJson, screen, setConfigValue, setNoColor, setTitle, sgr, showCursor, sleep, sleepFrame, sliceAnsi, stripAnsi$2 as stripAnsi, stripAnsi$1 as stripAnsiCodes, stripAnsi as stripAnsiColors, subscribeConfig, supportsColor, supportsColorLevel, termSize, themes, throttle, tree, trees, truncateAnsi, visibleLen, vsplit, walkTree, withConfig, wordWrap, wrapAnsi, write, writeAsync, writeErr, writeln, writelnErr };
|
|
3335
|
+
export { ASCII_RAMPS, type Alignment, type AnimateGradientController, type AnimateGradientOptions, type AnimationHooks, type AnimationSpeed, type AnsiCode, type AnsimaxConfig, type AsciiRamp, BEL, BG, type BadgeOptions, type BallOptions, type BannerOptions, type BoxOptions, type BoxStyle, type BreatheOptions, DEFAULTS as CONFIG_DEFAULTS, CSI, type Canvas, type CanvasRenderOptions, type CenterOptions, type ColorChain, type ColorFn, type ColorLevel, type ColorMode, type ColorSpace, type ColorSupport, type ColumnsOptions, type ConfigChangeListener, type ConfigKey, type ConfigKeyListener, type ConfigureOptions, type CountdownOptions, type CustomOptions, DEFAULT_TERM_COLS, DEFAULT_TERM_ROWS, type DebounceOptions, type DiffType, type Dimensions, type DividerOptions, type DotsOptions, ESC, type EasingFn, type EasingFunction, type EasingLibraryName, type EasingName, type EraseMode, FG, FRAME_MS, type FadeOptions, type FigletFont, type FigletOptions, type FontMap, type FontName, type FrameCallback, type FrameHandle, type FrameOptions, type FromImageOptions, type GlitchOptions, type Glyph, type GradientOptions, type GradientRectOptions, type GridOptions, type HSL, type HsplitOptions, type PrettyOptions as JsonPrettyOptions, type LineDiff, type LiveController, type LiveOptions, type LoadingBarOptions, type LogoOptions, MENU_CANCELLED, type MarkdownOptions, type MarkdownTheme, type MemoizeOptions, type MenuInput, type MenuOptions, type MenuOutput, type MenuResult, type MultiLoader, type MultiLoaderItem, OSC, type Oklab, type OnResizeOptions, type OutputBuffer, type ParallelOptions, type ParallelStep, type Pixel, type PixelGrid, type PlayController, type PlayOptions, type PresetName, type ProgressAnimateOptions, type ProgressBarOptions, type ProgressOptions, type PulseOptions, type RGB, type RGBA, type RegisterFontOptions, type RenderOptions$1 as RenderOptions, type ResizeListener, type ReusableGradient, type RevealOptions, SPINNERS, SPRITES, ST, STYLE, type SectionOptions, type SleepOptions, type SlideOptions, type SpinOptions, type SpinnerType, type StatusOptions, type StatusType, type StopFn, type StreamOptions, type TableBorderStyle, type TableOptions, type Task, type TaskResult, type TasksOptions, type Theme, type BannerOpts as ThemeBannerOpts, type ThemeChangeListener, type ThemeInstance, type ThemeStyleName, type TimelineEvent, type TimelineOptions, type TreeData, type TreeDimensions, type TreeNode, type RenderOptions as TreeRenderOptions, type TreeStyle, type TypeDeleteOptions, type TypewriterOptions, type VsplitOptions, type WalkVisitor, type WaveOptions, type WriteAsyncOptions, animate, animateGradient, ascii, bell, bg256, bgRgb, box, canAnimate, cancelTerminalFrame, center$1 as center, center as centerBlock, chain, charWidth, clamp, clampByte, clampInt, clampNonNeg, clampPercent, clampPositiveInt, clearAnsiCache, clearColorCache, clearLine, clearRenderCache, clearThemeColorCache, color, colorLevel, presets as colorPresets, components, compose, configure, countNodes, createCanvas, createGradient, createOutputBuffer, createTheme, cursor, debounce, ansimax as default, diffLines, easings, ensureString, escapeForRegex, escapeRegex, fg256, fgRgb, figletText, filterTree, findInTree, flipHorizontal, flipVertical, frame, frames, fromImage, getConfig, getConfigValue, getRenderCacheSize, getSpeedMultiplier, getTerminalHeight, getTerminalWidth, gradient, gradientColor, gradientRect, gradientStops, graphemes, grid, hasFont, hexToRgb, hideCursor, hslToRgb, hsplit, hyperlink, images, isFiniteNumber, isHexColor, isNoColor, json, pretty as jsonPretty, lerp, lerpColor, link, listFonts, listPresets, loader, mapTree, markdown, measureBlock, measureTree, memoize, mixColors, nextTick, oklabToRgb, onConfigChange, onConfigKeyChange, onResize, once, padBoth, padEnd, padStart, panels, parseFiglet, parseBlocks as parseMarkdownBlocks, parseInline as parseMarkdownInline, pauseListeners, presetNames, presets, quantizeColor, rainbow, registerFont, registerPreset, render as renderMarkdown, renderPixelArt, renderTree, renderTreeStream, repeatVisible, requestTerminalFrame, reset, resetColorSupportCache, resetConfig, resetCursorRefCount, resetFramesCursorCount, resetLoaderCursorCount, resetNoColor, resolveEasingByName, resumeListeners, reverseGradient, rgbTo256, rgbToHex, rgbToHsl, rgbToOklab, rotate90, safeInt, safeJson, screen, setConfigValue, setNoColor, setTitle, sgr, showCursor, sleep, sleepFrame, sliceAnsi, stripAnsi$2 as stripAnsi, stripAnsi$1 as stripAnsiCodes, stripAnsi as stripAnsiColors, subscribeConfig, supportsColor, supportsColorLevel, termSize, themes, throttle, tree, trees, truncateAnsi, visibleLen, vsplit, walkTree, withConfig, wordWrap, wrapAnsi, write, writeAsync, writeErr, writeln, writelnErr };
|