ansimax 1.1.2 → 1.2.0
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 +103 -1
- package/README.es.md +71 -6
- package/README.md +71 -6
- package/dist/index.d.mts +78 -2
- package/dist/index.d.ts +78 -2
- package/dist/index.js +128 -8
- package/dist/index.mjs +127 -8
- 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,108 @@
|
|
|
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.2.0] — Phase 2 complete: animated, eased & conic gradients
|
|
7
|
+
|
|
8
|
+
Minor release closing the **gradient engine roadmap (Phase 2)** with three
|
|
9
|
+
long-awaited capabilities. All additions are fully backwards-compatible —
|
|
10
|
+
existing `gradient()` calls work identically.
|
|
11
|
+
|
|
12
|
+
### Added — Easing curves
|
|
13
|
+
|
|
14
|
+
`gradient()` now accepts an `easing` option to control how colors are
|
|
15
|
+
distributed along the text. Five built-in curves plus custom functions:
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
gradient('hello world', ['#ff0000', '#0000ff'], { easing: 'ease-in' });
|
|
19
|
+
gradient('hello world', ['#ff0000', '#0000ff'], { easing: 'ease-out' });
|
|
20
|
+
gradient('hello world', ['#ff0000', '#0000ff'], { easing: 'ease-in-out' });
|
|
21
|
+
gradient('hello world', ['#ff0000', '#0000ff'], { easing: 'cubic-bezier' });
|
|
22
|
+
|
|
23
|
+
// Or pass a custom EasingFn (t → eased t, both in [0,1])
|
|
24
|
+
gradient('hello world', ['#ff0000', '#0000ff'], { easing: (t) => t * t * t });
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
- `linear` — even distribution (default, identical to pre-1.2.0 behavior)
|
|
28
|
+
- `ease-in` — concentrates colors at the end (quadratic)
|
|
29
|
+
- `ease-out` — concentrates colors at the start (quadratic)
|
|
30
|
+
- `ease-in-out` — slow at both ends, fast in middle
|
|
31
|
+
- `cubic-bezier` — CSS-style `ease` curve (Newton-Raphson approximated)
|
|
32
|
+
- Out-of-range custom easings are clamped to `[0, 1]` automatically
|
|
33
|
+
|
|
34
|
+
### Added — Phase offset (flowing colors)
|
|
35
|
+
|
|
36
|
+
`gradient()` now accepts a `phase` parameter `[0, 1)` that shifts the
|
|
37
|
+
gradient along the text. Combined with an animation loop, this produces
|
|
38
|
+
a flowing color effect:
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
gradient('hello', ['#ff0000', '#0000ff'], { phase: 0.5 });
|
|
42
|
+
// negative values wrap forward; NaN/Infinity falls back to 0
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Added — `animateGradient()` API
|
|
46
|
+
|
|
47
|
+
High-level API for animated gradients with proper lifecycle management:
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
import { animateGradient } from 'ansimax';
|
|
51
|
+
|
|
52
|
+
const ctrl = animateGradient('Loading...', ['#ff79c6', '#bd93f9', '#8be9fd'], {
|
|
53
|
+
duration: 2000,
|
|
54
|
+
fps: 30,
|
|
55
|
+
direction: 'forward', // or 'reverse'
|
|
56
|
+
infinite: true,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
// Later
|
|
60
|
+
ctrl.stop();
|
|
61
|
+
// Or via AbortController
|
|
62
|
+
const abort = new AbortController();
|
|
63
|
+
animateGradient('hi', stops, { signal: abort.signal });
|
|
64
|
+
abort.abort();
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Returns an `AnimateGradientController` with `.stop()` and `.done` (Promise).
|
|
68
|
+
Supports `AbortSignal`, custom render via `onFrame`, fps cap at 60,
|
|
69
|
+
and direction reversal.
|
|
70
|
+
|
|
71
|
+
### Added — Conic gradients
|
|
72
|
+
|
|
73
|
+
`gradientRect()` now supports `style: 'conic'` for radial sweeps around
|
|
74
|
+
the center point:
|
|
75
|
+
|
|
76
|
+
```ts
|
|
77
|
+
import { gradientRect } from 'ansimax';
|
|
78
|
+
|
|
79
|
+
console.log(gradientRect({
|
|
80
|
+
width: 30, height: 15,
|
|
81
|
+
colors: ['#ff0000', '#00ff00', '#0000ff', '#ff0000'],
|
|
82
|
+
style: 'conic',
|
|
83
|
+
startAngle: 0, // rotation in degrees
|
|
84
|
+
dither: 'bayer',
|
|
85
|
+
}));
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
- `startAngle` (degrees) rotates the sweep
|
|
89
|
+
- Non-finite `startAngle` falls back to `0`
|
|
90
|
+
- Compatible with all existing options (`dither`, `braille`, `width`, `height`)
|
|
91
|
+
|
|
92
|
+
### Added — New exports
|
|
93
|
+
|
|
94
|
+
- `animateGradient` — function
|
|
95
|
+
- `AnimateGradientOptions` / `AnimateGradientController` — types
|
|
96
|
+
- `EasingName` — union type of built-in curve names
|
|
97
|
+
- `EasingFn` — `(t: number) => number` curve type
|
|
98
|
+
|
|
99
|
+
### Notes
|
|
100
|
+
|
|
101
|
+
- All 1848 + 30 new tests pass.
|
|
102
|
+
- Backwards-compatible: existing `gradient()` calls work identically.
|
|
103
|
+
- No new runtime dependencies.
|
|
104
|
+
- Phase 2 of the [roadmap](README.md#%EF%B8%8F-roadmap) is now **fully complete**.
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
6
108
|
## [1.1.2] — maturity & robustness
|
|
7
109
|
|
|
8
110
|
Patch release focused on maturity: better error semantics, defensive
|
|
@@ -321,4 +423,4 @@ Hierarchical text renderer inspired by Rich's `Tree`.
|
|
|
321
423
|
- TypeScript types exported.
|
|
322
424
|
- Adaptive color rendering (NO_COLOR / FORCE_COLOR / TTY detection).
|
|
323
425
|
- AbortSignal support across all blocking APIs.
|
|
324
|
-
- 750+ tests, 85%+ coverage.
|
|
426
|
+
- 750+ tests, 85%+ coverage.
|
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)
|
|
@@ -202,6 +202,53 @@ console.log(gradient('fuego a océano', ['#ff6b6b', '#feca57', '#48dbfb']));
|
|
|
202
202
|
console.log(rainbow('preset rainbow integrado'));
|
|
203
203
|
```
|
|
204
204
|
|
|
205
|
+
### Gradientes animados (v1.2.0)
|
|
206
|
+
|
|
207
|
+
```ts
|
|
208
|
+
import { animateGradient, sleep } from 'ansimax';
|
|
209
|
+
|
|
210
|
+
// Animación de flujo de color — corre hasta llamar stop()
|
|
211
|
+
const ctrl = animateGradient('Cargando...', ['#ff79c6', '#bd93f9', '#8be9fd'], {
|
|
212
|
+
duration: 2000, // ms por ciclo
|
|
213
|
+
fps: 30,
|
|
214
|
+
direction: 'forward', // o 'reverse'
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
await sleep(3000);
|
|
218
|
+
ctrl.stop();
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### Curvas de interpolación (v1.2.0)
|
|
222
|
+
|
|
223
|
+
```ts
|
|
224
|
+
import { gradient } from 'ansimax';
|
|
225
|
+
|
|
226
|
+
// Cinco easings built-in + soporte para funciones personalizadas
|
|
227
|
+
gradient('hola mundo', stops, { easing: 'linear' });
|
|
228
|
+
gradient('hola mundo', stops, { easing: 'ease-in' });
|
|
229
|
+
gradient('hola mundo', stops, { easing: 'ease-out' });
|
|
230
|
+
gradient('hola mundo', stops, { easing: 'ease-in-out' });
|
|
231
|
+
gradient('hola mundo', stops, { easing: 'cubic-bezier' });
|
|
232
|
+
|
|
233
|
+
// O tu propia función de easing (t → t suavizado, ambos en [0,1])
|
|
234
|
+
gradient('hola mundo', stops, { easing: (t) => t * t * t });
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### Gradientes cónicos (v1.2.0)
|
|
238
|
+
|
|
239
|
+
```ts
|
|
240
|
+
import { gradientRect } from 'ansimax';
|
|
241
|
+
|
|
242
|
+
// Barrido radial alrededor del centro — rueda arcoíris
|
|
243
|
+
console.log(gradientRect({
|
|
244
|
+
width: 30, height: 15,
|
|
245
|
+
colors: ['#ff0000', '#ffff00', '#00ff00', '#00ffff', '#0000ff', '#ff00ff', '#ff0000'],
|
|
246
|
+
style: 'conic',
|
|
247
|
+
startAngle: 0, // ángulo de rotación en grados
|
|
248
|
+
dither: 'bayer',
|
|
249
|
+
}));
|
|
250
|
+
```
|
|
251
|
+
|
|
205
252
|
### ASCII Art
|
|
206
253
|
|
|
207
254
|
<img src="media/ascii_art.png" alt="ASCII art" />
|
|
@@ -277,7 +324,7 @@ console.log(components.table([
|
|
|
277
324
|
['loaders', color.green('● listo'), '100%'],
|
|
278
325
|
], { borderStyle: 'rounded' }));
|
|
279
326
|
|
|
280
|
-
console.log(components.badge('VERSION', 'v1.
|
|
327
|
+
console.log(components.badge('VERSION', 'v1.2.0'));
|
|
281
328
|
console.log(components.badge('BUILD', 'passing'));
|
|
282
329
|
```
|
|
283
330
|
|
|
@@ -487,9 +534,9 @@ El roadmap apunta intencionalmente — y busca superar — gaps que ni siquiera
|
|
|
487
534
|
- [x] Gradientes a ángulo arbitrario
|
|
488
535
|
- [x] Dithering Bayer 4×4 para transiciones tonales suaves
|
|
489
536
|
- [x] UX single-stop (comportamiento estilo CSS)
|
|
490
|
-
- [
|
|
491
|
-
- [
|
|
492
|
-
- [
|
|
537
|
+
- [x] **Gradientes animados** — flujo de color en el tiempo con `animateGradient()` (v1.2.0)
|
|
538
|
+
- [x] **Curvas de interpolación** — `linear` / `ease-in` / `ease-out` / `ease-in-out` / `cubic-bezier` / personalizado (v1.2.0)
|
|
539
|
+
- [x] **Gradientes cónicos** — barrido radial con `style: 'conic'` (v1.2.0)
|
|
493
540
|
|
|
494
541
|
### 🟡 Fase 3 — Motor ASCII
|
|
495
542
|
- [x] Fuentes de bloque (`big`, `small`)
|
|
@@ -679,6 +726,24 @@ ansimax/
|
|
|
679
726
|
|
|
680
727
|
## 📝 Changelog
|
|
681
728
|
|
|
729
|
+
### v1.2.0 — Fase 2 completa: gradientes animados, easing y cónicos
|
|
730
|
+
|
|
731
|
+
Release minor que cierra el roadmap del motor de gradientes con tres features potentes:
|
|
732
|
+
|
|
733
|
+
- 🌊 **`animateGradient()`** — flujo de color en el tiempo con ciclo de vida apropiado (Promise, signal, fps, direction)
|
|
734
|
+
- 📐 **Curvas de interpolación** — `linear` / `ease-in` / `ease-out` / `ease-in-out` / `cubic-bezier` / funciones personalizadas
|
|
735
|
+
- ⭕ **Gradientes cónicos** — `gradientRect({ style: 'conic', startAngle })` para barridos radiales
|
|
736
|
+
|
|
737
|
+
```ts
|
|
738
|
+
import { animateGradient } from 'ansimax';
|
|
739
|
+
|
|
740
|
+
const ctrl = animateGradient('Cargando...', ['#ff79c6', '#bd93f9', '#8be9fd']);
|
|
741
|
+
await sleep(3000);
|
|
742
|
+
ctrl.stop();
|
|
743
|
+
```
|
|
744
|
+
|
|
745
|
+
Totalmente retrocompatible — todo programa 1.1.x corre idénticamente.
|
|
746
|
+
|
|
682
747
|
### v1.1.2 — Madurez y robustez
|
|
683
748
|
|
|
684
749
|
Release patch enfocado en refinamientos de calidad — sin cambios en la API.
|
|
@@ -795,4 +860,4 @@ Ansimax está licenciada bajo **Apache License, Version 2.0** — una licencia p
|
|
|
795
860
|
|
|
796
861
|
Si Ansimax te ayuda a hacer mejores CLIs, ¡dale ⭐ en [GitHub](https://github.com/Brashkie/ansimax)!
|
|
797
862
|
|
|
798
|
-
</div>
|
|
863
|
+
</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)
|
|
@@ -202,6 +202,53 @@ console.log(gradient('fire to ocean', ['#ff6b6b', '#feca57', '#48dbfb']));
|
|
|
202
202
|
console.log(rainbow('built-in rainbow preset'));
|
|
203
203
|
```
|
|
204
204
|
|
|
205
|
+
### Animated Gradients (v1.2.0)
|
|
206
|
+
|
|
207
|
+
```ts
|
|
208
|
+
import { animateGradient, sleep } from 'ansimax';
|
|
209
|
+
|
|
210
|
+
// Color flow animation — runs until you call stop()
|
|
211
|
+
const ctrl = animateGradient('Loading...', ['#ff79c6', '#bd93f9', '#8be9fd'], {
|
|
212
|
+
duration: 2000, // ms per cycle
|
|
213
|
+
fps: 30,
|
|
214
|
+
direction: 'forward', // or 'reverse'
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
await sleep(3000);
|
|
218
|
+
ctrl.stop();
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### Easing Curves (v1.2.0)
|
|
222
|
+
|
|
223
|
+
```ts
|
|
224
|
+
import { gradient } from 'ansimax';
|
|
225
|
+
|
|
226
|
+
// Five built-in easings + custom function support
|
|
227
|
+
gradient('hello world', stops, { easing: 'linear' });
|
|
228
|
+
gradient('hello world', stops, { easing: 'ease-in' });
|
|
229
|
+
gradient('hello world', stops, { easing: 'ease-out' });
|
|
230
|
+
gradient('hello world', stops, { easing: 'ease-in-out' });
|
|
231
|
+
gradient('hello world', stops, { easing: 'cubic-bezier' });
|
|
232
|
+
|
|
233
|
+
// Or pass your own easing function (t → eased t, both in [0,1])
|
|
234
|
+
gradient('hello world', stops, { easing: (t) => t * t * t });
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### Conic Gradients (v1.2.0)
|
|
238
|
+
|
|
239
|
+
```ts
|
|
240
|
+
import { gradientRect } from 'ansimax';
|
|
241
|
+
|
|
242
|
+
// Radial sweep around center — rainbow wheel
|
|
243
|
+
console.log(gradientRect({
|
|
244
|
+
width: 30, height: 15,
|
|
245
|
+
colors: ['#ff0000', '#ffff00', '#00ff00', '#00ffff', '#0000ff', '#ff00ff', '#ff0000'],
|
|
246
|
+
style: 'conic',
|
|
247
|
+
startAngle: 0, // rotation angle in degrees
|
|
248
|
+
dither: 'bayer',
|
|
249
|
+
}));
|
|
250
|
+
```
|
|
251
|
+
|
|
205
252
|
### ASCII Art
|
|
206
253
|
|
|
207
254
|
<img src="media/ascii_art.png" alt="ASCII art" />
|
|
@@ -277,7 +324,7 @@ console.log(components.table([
|
|
|
277
324
|
['loaders', color.green('● ready'), '100%'],
|
|
278
325
|
], { borderStyle: 'rounded' }));
|
|
279
326
|
|
|
280
|
-
console.log(components.badge('VERSION', 'v1.
|
|
327
|
+
console.log(components.badge('VERSION', 'v1.2.0'));
|
|
281
328
|
console.log(components.badge('BUILD', 'passing'));
|
|
282
329
|
```
|
|
283
330
|
|
|
@@ -487,9 +534,9 @@ The roadmap intentionally targets — and aims to surpass — gaps that even mat
|
|
|
487
534
|
- [x] Arbitrary-angle gradients
|
|
488
535
|
- [x] Bayer 4×4 dithering for smooth tonal transitions
|
|
489
536
|
- [x] Single-stop UX (CSS-style behavior)
|
|
490
|
-
- [
|
|
491
|
-
- [
|
|
492
|
-
- [
|
|
537
|
+
- [x] **Animated gradients** — color flow over time with `animateGradient()` (v1.2.0)
|
|
538
|
+
- [x] **Gradient interpolation curves** — `linear` / `ease-in` / `ease-out` / `ease-in-out` / `cubic-bezier` / custom (v1.2.0)
|
|
539
|
+
- [x] **Conic gradients** — radial sweep with `style: 'conic'` (v1.2.0)
|
|
493
540
|
|
|
494
541
|
### 🟡 Phase 3 — ASCII engine
|
|
495
542
|
- [x] Block fonts (`big`, `small`)
|
|
@@ -679,6 +726,24 @@ ansimax/
|
|
|
679
726
|
|
|
680
727
|
## 📝 Changelog
|
|
681
728
|
|
|
729
|
+
### v1.2.0 — Phase 2 complete: animated, eased & conic gradients
|
|
730
|
+
|
|
731
|
+
Minor release closing the gradient engine roadmap with three powerful features:
|
|
732
|
+
|
|
733
|
+
- 🌊 **`animateGradient()`** — color flow over time with proper lifecycle (Promise, signal, fps, direction)
|
|
734
|
+
- 📐 **Easing curves** — `linear` / `ease-in` / `ease-out` / `ease-in-out` / `cubic-bezier` / custom functions
|
|
735
|
+
- ⭕ **Conic gradients** — `gradientRect({ style: 'conic', startAngle })` for radial sweeps
|
|
736
|
+
|
|
737
|
+
```ts
|
|
738
|
+
import { animateGradient } from 'ansimax';
|
|
739
|
+
|
|
740
|
+
const ctrl = animateGradient('Loading...', ['#ff79c6', '#bd93f9', '#8be9fd']);
|
|
741
|
+
await sleep(3000);
|
|
742
|
+
ctrl.stop();
|
|
743
|
+
```
|
|
744
|
+
|
|
745
|
+
Fully backwards-compatible — every 1.1.x program runs identically.
|
|
746
|
+
|
|
682
747
|
### v1.1.2 — Maturity & robustness
|
|
683
748
|
|
|
684
749
|
Patch release focused on quality refinements — no API changes.
|
|
@@ -795,4 +860,4 @@ Ansimax is licensed under the **Apache License, Version 2.0** — a permissive l
|
|
|
795
860
|
|
|
796
861
|
If Ansimax helps you ship better CLIs, give it a ⭐ on [GitHub](https://github.com/Brashkie/ansimax)!
|
|
797
862
|
|
|
798
|
-
</div>
|
|
863
|
+
</div>
|
package/dist/index.d.mts
CHANGED
|
@@ -538,13 +538,84 @@ declare const colorLevel: () => ColorLevel;
|
|
|
538
538
|
/** Clear adaptive escape caches. Call after a color level change. */
|
|
539
539
|
declare const clearColorCache: () => void;
|
|
540
540
|
declare const compose: (...fns: ColorFn[]) => ColorFn;
|
|
541
|
+
/**
|
|
542
|
+
* Built-in easing curves. Each takes a t in [0, 1] and returns an eased t
|
|
543
|
+
* in [0, 1]. Used for non-linear gradient progression.
|
|
544
|
+
*/
|
|
545
|
+
type EasingName = 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'cubic-bezier';
|
|
546
|
+
type EasingFn = (t: number) => number;
|
|
541
547
|
declare const stripAnsi: (str: string) => string;
|
|
542
548
|
interface GradientOptions {
|
|
543
549
|
/** Skip ANSI escapes in the input instead of overwriting them. */
|
|
544
550
|
preserveAnsi?: boolean;
|
|
551
|
+
/**
|
|
552
|
+
* Interpolation curve. Default `'linear'`.
|
|
553
|
+
* - `'linear'` — even color distribution
|
|
554
|
+
* - `'ease-in'` — slow start, fast end (concentrates colors at the right)
|
|
555
|
+
* - `'ease-out'` — fast start, slow end (concentrates colors at the left)
|
|
556
|
+
* - `'ease-in-out'` — slow at both ends, fast in middle
|
|
557
|
+
* - `'cubic-bezier'` — CSS-style ease (smooth S-curve)
|
|
558
|
+
* - Or pass a custom `EasingFn` that maps `[0,1] → [0,1]`.
|
|
559
|
+
*/
|
|
560
|
+
easing?: EasingName | EasingFn;
|
|
561
|
+
/**
|
|
562
|
+
* Phase offset in `[0, 1)` — shifts the gradient along the text.
|
|
563
|
+
* Use with an animation loop to produce a flowing color effect:
|
|
564
|
+
* `gradient(text, colors, { phase: (Date.now() / 100) % 1 })`
|
|
565
|
+
*/
|
|
566
|
+
phase?: number;
|
|
545
567
|
}
|
|
546
568
|
declare const gradient: (text: unknown, stops: string[] | null | undefined, opts?: GradientOptions) => string;
|
|
547
569
|
declare const rainbow: ColorFn;
|
|
570
|
+
interface AnimateGradientOptions {
|
|
571
|
+
/** Total animation duration in ms. Default `2000`. */
|
|
572
|
+
duration?: number;
|
|
573
|
+
/** Frames per second. Default `30`. Capped to `60`. */
|
|
574
|
+
fps?: number;
|
|
575
|
+
/** Loop infinitely. Default `true`. Use `signal` to stop. */
|
|
576
|
+
infinite?: boolean;
|
|
577
|
+
/** Cycle count when `infinite: false`. Default `1`. */
|
|
578
|
+
cycles?: number;
|
|
579
|
+
/** Direction: `'forward'` (default) shifts colors right; `'reverse'` shifts left. */
|
|
580
|
+
direction?: 'forward' | 'reverse';
|
|
581
|
+
/** Easing curve for the gradient itself (not the time progression). */
|
|
582
|
+
easing?: EasingName | EasingFn;
|
|
583
|
+
/** Preserve embedded ANSI escapes. Default `false`. */
|
|
584
|
+
preserveAnsi?: boolean;
|
|
585
|
+
/** Abort signal — stops the animation cleanly. */
|
|
586
|
+
signal?: AbortSignal;
|
|
587
|
+
/**
|
|
588
|
+
* Callback fired on every frame with the new colored string.
|
|
589
|
+
* If omitted, frames are written to stdout via cursor-up redraw.
|
|
590
|
+
*/
|
|
591
|
+
onFrame?: (frame: string, phase: number) => void;
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* Render a gradient that "flows" through the text over time. Returns a
|
|
595
|
+
* controller with a `.stop()` method. When `infinite: true` (default),
|
|
596
|
+
* the animation continues until `.stop()` is called or `signal` aborts.
|
|
597
|
+
*
|
|
598
|
+
* @example
|
|
599
|
+
* ```ts
|
|
600
|
+
* const ctrl = animateGradient('Loading...', ['#ff79c6', '#bd93f9', '#8be9fd']);
|
|
601
|
+
* await sleep(3000);
|
|
602
|
+
* ctrl.stop();
|
|
603
|
+
* ```
|
|
604
|
+
*
|
|
605
|
+
* @example with custom render callback
|
|
606
|
+
* ```ts
|
|
607
|
+
* animateGradient('hi', ['#f00', '#0f0'], {
|
|
608
|
+
* onFrame: (frame) => myCustomRender(frame),
|
|
609
|
+
* });
|
|
610
|
+
* ```
|
|
611
|
+
*/
|
|
612
|
+
interface AnimateGradientController {
|
|
613
|
+
/** Stops the animation. Safe to call multiple times. */
|
|
614
|
+
stop: () => void;
|
|
615
|
+
/** Promise that resolves when animation finishes (stop / abort / cycle limit). */
|
|
616
|
+
done: Promise<void>;
|
|
617
|
+
}
|
|
618
|
+
declare const animateGradient: (text: string, stops: string[], opts?: AnimateGradientOptions) => AnimateGradientController;
|
|
548
619
|
declare const PRESET_DEFS: {
|
|
549
620
|
readonly sunset: readonly ["#ff6b6b", "#feca57", "#48dbfb"];
|
|
550
621
|
readonly ocean: readonly ["#0575e6", "#021b79"];
|
|
@@ -1408,9 +1479,14 @@ interface GradientRectOptions {
|
|
|
1408
1479
|
height?: number;
|
|
1409
1480
|
colors?: string[];
|
|
1410
1481
|
/** Built-in style. Use `angle` for arbitrary directions. */
|
|
1411
|
-
style?: 'horizontal' | 'vertical' | 'diagonal' | 'radial';
|
|
1482
|
+
style?: 'horizontal' | 'vertical' | 'diagonal' | 'radial' | 'conic';
|
|
1412
1483
|
/** Custom angle in degrees (0=right, 90=down). Overrides `style`. */
|
|
1413
1484
|
angle?: number;
|
|
1485
|
+
/**
|
|
1486
|
+
* Starting angle (degrees) for conic gradients. Default `0` (= right of center).
|
|
1487
|
+
* Rotates the radial sweep around the center point.
|
|
1488
|
+
*/
|
|
1489
|
+
startAngle?: number;
|
|
1414
1490
|
/** Dithering algorithm. 'bayer' improves perceived smoothness. */
|
|
1415
1491
|
dither?: 'none' | 'bayer';
|
|
1416
1492
|
/** Render in braille mode for 2× horizontal × 4× vertical resolution. */
|
|
@@ -1625,4 +1701,4 @@ declare const ansimax: {
|
|
|
1625
1701
|
configure: (opts?: AnsimaxConfig, meta?: ConfigureOptions) => void;
|
|
1626
1702
|
};
|
|
1627
1703
|
|
|
1628
|
-
export { type AnimationHooks, type AnimationSpeed, type AnsiCode, type AnsimaxConfig, BEL, BG, type BadgeOptions, type BallOptions, type BannerOptions, type BoxOptions, type BoxStyle, type BreatheOptions, DEFAULTS as CONFIG_DEFAULTS, CSI, type Canvas, type CanvasRenderOptions, type ColorChain, type ColorFn, type ColorLevel, type ColorMode, 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 EraseMode, FG, FRAME_MS, type FadeOptions, type FontMap, type FontName, type FrameCallback, type FrameHandle, type GlitchOptions, type Glyph, type GradientOptions, type GradientRectOptions, type LineDiff, type LiveController, type LiveOptions, type LoadingBarOptions, type LogoOptions, MENU_CANCELLED, type MemoizeOptions, type MenuInput, type MenuOptions, type MenuOutput, type MenuResult, type MultiLoader, type MultiLoaderItem, OSC, 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, type ResizeListener, 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$1 as TreeRenderOptions, type TreeStyle, type TypeDeleteOptions, type TypewriterOptions, type WalkVisitor, type WaveOptions, type WriteAsyncOptions, animate, ascii, bell, bg256, bgRgb, box, canAnimate, cancelTerminalFrame, center, chain, charWidth, clamp, clearAnsiCache, clearColorCache, clearRenderCache, clearThemeColorCache, color, colorLevel, presets as colorPresets, components, compose, configure, countNodes, createCanvas, createOutputBuffer, createTheme, cursor, debounce, ansimax as default, diffLines, escapeRegex, fg256, fgRgb, filterTree, findInTree, flipHorizontal, flipVertical, frames, getConfig, getConfigValue, getRenderCacheSize, getSpeedMultiplier, getTerminalHeight, getTerminalWidth, gradient, gradientColor, gradientRect, graphemes, hasFont, hexToRgb, hideCursor, images, isHexColor, isNoColor, lerp, lerpColor, link, listFonts, listPresets, loader, mapTree, measureTree, memoize, nextTick, onConfigChange, onConfigKeyChange, onResize, once, padBoth, padEnd, padStart, pauseListeners, presetNames, rainbow, registerFont, registerPreset, renderPixelArt, renderTree, renderTreeStream, repeatVisible, requestTerminalFrame, reset, resetColorSupportCache, resetConfig, resetCursorRefCount, resetFramesCursorCount, resetLoaderCursorCount, resetNoColor, resumeListeners, rgbTo256, rgbToHex, rotate90, safeJson, screen, setNoColor, setTitle, sgr, showCursor, sleep, sleepFrame, sliceAnsi, stripAnsi$1 as stripAnsi, stripAnsi$2 as stripAnsiCodes, stripAnsi as stripAnsiColors, supportsColor, supportsColorLevel, termSize, themes, throttle, tree, trees, truncateAnsi, visibleLen, walkTree, withConfig, wordWrap, wrapAnsi, write, writeAsync, writeErr, writeln, writelnErr };
|
|
1704
|
+
export { type AnimateGradientController, type AnimateGradientOptions, type AnimationHooks, type AnimationSpeed, type AnsiCode, type AnsimaxConfig, BEL, BG, type BadgeOptions, type BallOptions, type BannerOptions, type BoxOptions, type BoxStyle, type BreatheOptions, DEFAULTS as CONFIG_DEFAULTS, CSI, type Canvas, type CanvasRenderOptions, type ColorChain, type ColorFn, type ColorLevel, type ColorMode, 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 EasingName, type EraseMode, FG, FRAME_MS, type FadeOptions, type FontMap, type FontName, type FrameCallback, type FrameHandle, type GlitchOptions, type Glyph, type GradientOptions, type GradientRectOptions, type LineDiff, type LiveController, type LiveOptions, type LoadingBarOptions, type LogoOptions, MENU_CANCELLED, type MemoizeOptions, type MenuInput, type MenuOptions, type MenuOutput, type MenuResult, type MultiLoader, type MultiLoaderItem, OSC, 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, type ResizeListener, 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$1 as TreeRenderOptions, type TreeStyle, type TypeDeleteOptions, type TypewriterOptions, type WalkVisitor, type WaveOptions, type WriteAsyncOptions, animate, animateGradient, ascii, bell, bg256, bgRgb, box, canAnimate, cancelTerminalFrame, center, chain, charWidth, clamp, clearAnsiCache, clearColorCache, clearRenderCache, clearThemeColorCache, color, colorLevel, presets as colorPresets, components, compose, configure, countNodes, createCanvas, createOutputBuffer, createTheme, cursor, debounce, ansimax as default, diffLines, escapeRegex, fg256, fgRgb, filterTree, findInTree, flipHorizontal, flipVertical, frames, getConfig, getConfigValue, getRenderCacheSize, getSpeedMultiplier, getTerminalHeight, getTerminalWidth, gradient, gradientColor, gradientRect, graphemes, hasFont, hexToRgb, hideCursor, images, isHexColor, isNoColor, lerp, lerpColor, link, listFonts, listPresets, loader, mapTree, measureTree, memoize, nextTick, onConfigChange, onConfigKeyChange, onResize, once, padBoth, padEnd, padStart, pauseListeners, presetNames, rainbow, registerFont, registerPreset, renderPixelArt, renderTree, renderTreeStream, repeatVisible, requestTerminalFrame, reset, resetColorSupportCache, resetConfig, resetCursorRefCount, resetFramesCursorCount, resetLoaderCursorCount, resetNoColor, resumeListeners, rgbTo256, rgbToHex, rotate90, safeJson, screen, setNoColor, setTitle, sgr, showCursor, sleep, sleepFrame, sliceAnsi, stripAnsi$1 as stripAnsi, stripAnsi$2 as stripAnsiCodes, stripAnsi as stripAnsiColors, supportsColor, supportsColorLevel, termSize, themes, throttle, tree, trees, truncateAnsi, visibleLen, walkTree, withConfig, wordWrap, wrapAnsi, write, writeAsync, writeErr, writeln, writelnErr };
|
package/dist/index.d.ts
CHANGED
|
@@ -538,13 +538,84 @@ declare const colorLevel: () => ColorLevel;
|
|
|
538
538
|
/** Clear adaptive escape caches. Call after a color level change. */
|
|
539
539
|
declare const clearColorCache: () => void;
|
|
540
540
|
declare const compose: (...fns: ColorFn[]) => ColorFn;
|
|
541
|
+
/**
|
|
542
|
+
* Built-in easing curves. Each takes a t in [0, 1] and returns an eased t
|
|
543
|
+
* in [0, 1]. Used for non-linear gradient progression.
|
|
544
|
+
*/
|
|
545
|
+
type EasingName = 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'cubic-bezier';
|
|
546
|
+
type EasingFn = (t: number) => number;
|
|
541
547
|
declare const stripAnsi: (str: string) => string;
|
|
542
548
|
interface GradientOptions {
|
|
543
549
|
/** Skip ANSI escapes in the input instead of overwriting them. */
|
|
544
550
|
preserveAnsi?: boolean;
|
|
551
|
+
/**
|
|
552
|
+
* Interpolation curve. Default `'linear'`.
|
|
553
|
+
* - `'linear'` — even color distribution
|
|
554
|
+
* - `'ease-in'` — slow start, fast end (concentrates colors at the right)
|
|
555
|
+
* - `'ease-out'` — fast start, slow end (concentrates colors at the left)
|
|
556
|
+
* - `'ease-in-out'` — slow at both ends, fast in middle
|
|
557
|
+
* - `'cubic-bezier'` — CSS-style ease (smooth S-curve)
|
|
558
|
+
* - Or pass a custom `EasingFn` that maps `[0,1] → [0,1]`.
|
|
559
|
+
*/
|
|
560
|
+
easing?: EasingName | EasingFn;
|
|
561
|
+
/**
|
|
562
|
+
* Phase offset in `[0, 1)` — shifts the gradient along the text.
|
|
563
|
+
* Use with an animation loop to produce a flowing color effect:
|
|
564
|
+
* `gradient(text, colors, { phase: (Date.now() / 100) % 1 })`
|
|
565
|
+
*/
|
|
566
|
+
phase?: number;
|
|
545
567
|
}
|
|
546
568
|
declare const gradient: (text: unknown, stops: string[] | null | undefined, opts?: GradientOptions) => string;
|
|
547
569
|
declare const rainbow: ColorFn;
|
|
570
|
+
interface AnimateGradientOptions {
|
|
571
|
+
/** Total animation duration in ms. Default `2000`. */
|
|
572
|
+
duration?: number;
|
|
573
|
+
/** Frames per second. Default `30`. Capped to `60`. */
|
|
574
|
+
fps?: number;
|
|
575
|
+
/** Loop infinitely. Default `true`. Use `signal` to stop. */
|
|
576
|
+
infinite?: boolean;
|
|
577
|
+
/** Cycle count when `infinite: false`. Default `1`. */
|
|
578
|
+
cycles?: number;
|
|
579
|
+
/** Direction: `'forward'` (default) shifts colors right; `'reverse'` shifts left. */
|
|
580
|
+
direction?: 'forward' | 'reverse';
|
|
581
|
+
/** Easing curve for the gradient itself (not the time progression). */
|
|
582
|
+
easing?: EasingName | EasingFn;
|
|
583
|
+
/** Preserve embedded ANSI escapes. Default `false`. */
|
|
584
|
+
preserveAnsi?: boolean;
|
|
585
|
+
/** Abort signal — stops the animation cleanly. */
|
|
586
|
+
signal?: AbortSignal;
|
|
587
|
+
/**
|
|
588
|
+
* Callback fired on every frame with the new colored string.
|
|
589
|
+
* If omitted, frames are written to stdout via cursor-up redraw.
|
|
590
|
+
*/
|
|
591
|
+
onFrame?: (frame: string, phase: number) => void;
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* Render a gradient that "flows" through the text over time. Returns a
|
|
595
|
+
* controller with a `.stop()` method. When `infinite: true` (default),
|
|
596
|
+
* the animation continues until `.stop()` is called or `signal` aborts.
|
|
597
|
+
*
|
|
598
|
+
* @example
|
|
599
|
+
* ```ts
|
|
600
|
+
* const ctrl = animateGradient('Loading...', ['#ff79c6', '#bd93f9', '#8be9fd']);
|
|
601
|
+
* await sleep(3000);
|
|
602
|
+
* ctrl.stop();
|
|
603
|
+
* ```
|
|
604
|
+
*
|
|
605
|
+
* @example with custom render callback
|
|
606
|
+
* ```ts
|
|
607
|
+
* animateGradient('hi', ['#f00', '#0f0'], {
|
|
608
|
+
* onFrame: (frame) => myCustomRender(frame),
|
|
609
|
+
* });
|
|
610
|
+
* ```
|
|
611
|
+
*/
|
|
612
|
+
interface AnimateGradientController {
|
|
613
|
+
/** Stops the animation. Safe to call multiple times. */
|
|
614
|
+
stop: () => void;
|
|
615
|
+
/** Promise that resolves when animation finishes (stop / abort / cycle limit). */
|
|
616
|
+
done: Promise<void>;
|
|
617
|
+
}
|
|
618
|
+
declare const animateGradient: (text: string, stops: string[], opts?: AnimateGradientOptions) => AnimateGradientController;
|
|
548
619
|
declare const PRESET_DEFS: {
|
|
549
620
|
readonly sunset: readonly ["#ff6b6b", "#feca57", "#48dbfb"];
|
|
550
621
|
readonly ocean: readonly ["#0575e6", "#021b79"];
|
|
@@ -1408,9 +1479,14 @@ interface GradientRectOptions {
|
|
|
1408
1479
|
height?: number;
|
|
1409
1480
|
colors?: string[];
|
|
1410
1481
|
/** Built-in style. Use `angle` for arbitrary directions. */
|
|
1411
|
-
style?: 'horizontal' | 'vertical' | 'diagonal' | 'radial';
|
|
1482
|
+
style?: 'horizontal' | 'vertical' | 'diagonal' | 'radial' | 'conic';
|
|
1412
1483
|
/** Custom angle in degrees (0=right, 90=down). Overrides `style`. */
|
|
1413
1484
|
angle?: number;
|
|
1485
|
+
/**
|
|
1486
|
+
* Starting angle (degrees) for conic gradients. Default `0` (= right of center).
|
|
1487
|
+
* Rotates the radial sweep around the center point.
|
|
1488
|
+
*/
|
|
1489
|
+
startAngle?: number;
|
|
1414
1490
|
/** Dithering algorithm. 'bayer' improves perceived smoothness. */
|
|
1415
1491
|
dither?: 'none' | 'bayer';
|
|
1416
1492
|
/** Render in braille mode for 2× horizontal × 4× vertical resolution. */
|
|
@@ -1625,4 +1701,4 @@ declare const ansimax: {
|
|
|
1625
1701
|
configure: (opts?: AnsimaxConfig, meta?: ConfigureOptions) => void;
|
|
1626
1702
|
};
|
|
1627
1703
|
|
|
1628
|
-
export { type AnimationHooks, type AnimationSpeed, type AnsiCode, type AnsimaxConfig, BEL, BG, type BadgeOptions, type BallOptions, type BannerOptions, type BoxOptions, type BoxStyle, type BreatheOptions, DEFAULTS as CONFIG_DEFAULTS, CSI, type Canvas, type CanvasRenderOptions, type ColorChain, type ColorFn, type ColorLevel, type ColorMode, 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 EraseMode, FG, FRAME_MS, type FadeOptions, type FontMap, type FontName, type FrameCallback, type FrameHandle, type GlitchOptions, type Glyph, type GradientOptions, type GradientRectOptions, type LineDiff, type LiveController, type LiveOptions, type LoadingBarOptions, type LogoOptions, MENU_CANCELLED, type MemoizeOptions, type MenuInput, type MenuOptions, type MenuOutput, type MenuResult, type MultiLoader, type MultiLoaderItem, OSC, 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, type ResizeListener, 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$1 as TreeRenderOptions, type TreeStyle, type TypeDeleteOptions, type TypewriterOptions, type WalkVisitor, type WaveOptions, type WriteAsyncOptions, animate, ascii, bell, bg256, bgRgb, box, canAnimate, cancelTerminalFrame, center, chain, charWidth, clamp, clearAnsiCache, clearColorCache, clearRenderCache, clearThemeColorCache, color, colorLevel, presets as colorPresets, components, compose, configure, countNodes, createCanvas, createOutputBuffer, createTheme, cursor, debounce, ansimax as default, diffLines, escapeRegex, fg256, fgRgb, filterTree, findInTree, flipHorizontal, flipVertical, frames, getConfig, getConfigValue, getRenderCacheSize, getSpeedMultiplier, getTerminalHeight, getTerminalWidth, gradient, gradientColor, gradientRect, graphemes, hasFont, hexToRgb, hideCursor, images, isHexColor, isNoColor, lerp, lerpColor, link, listFonts, listPresets, loader, mapTree, measureTree, memoize, nextTick, onConfigChange, onConfigKeyChange, onResize, once, padBoth, padEnd, padStart, pauseListeners, presetNames, rainbow, registerFont, registerPreset, renderPixelArt, renderTree, renderTreeStream, repeatVisible, requestTerminalFrame, reset, resetColorSupportCache, resetConfig, resetCursorRefCount, resetFramesCursorCount, resetLoaderCursorCount, resetNoColor, resumeListeners, rgbTo256, rgbToHex, rotate90, safeJson, screen, setNoColor, setTitle, sgr, showCursor, sleep, sleepFrame, sliceAnsi, stripAnsi$1 as stripAnsi, stripAnsi$2 as stripAnsiCodes, stripAnsi as stripAnsiColors, supportsColor, supportsColorLevel, termSize, themes, throttle, tree, trees, truncateAnsi, visibleLen, walkTree, withConfig, wordWrap, wrapAnsi, write, writeAsync, writeErr, writeln, writelnErr };
|
|
1704
|
+
export { type AnimateGradientController, type AnimateGradientOptions, type AnimationHooks, type AnimationSpeed, type AnsiCode, type AnsimaxConfig, BEL, BG, type BadgeOptions, type BallOptions, type BannerOptions, type BoxOptions, type BoxStyle, type BreatheOptions, DEFAULTS as CONFIG_DEFAULTS, CSI, type Canvas, type CanvasRenderOptions, type ColorChain, type ColorFn, type ColorLevel, type ColorMode, 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 EasingName, type EraseMode, FG, FRAME_MS, type FadeOptions, type FontMap, type FontName, type FrameCallback, type FrameHandle, type GlitchOptions, type Glyph, type GradientOptions, type GradientRectOptions, type LineDiff, type LiveController, type LiveOptions, type LoadingBarOptions, type LogoOptions, MENU_CANCELLED, type MemoizeOptions, type MenuInput, type MenuOptions, type MenuOutput, type MenuResult, type MultiLoader, type MultiLoaderItem, OSC, 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, type ResizeListener, 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$1 as TreeRenderOptions, type TreeStyle, type TypeDeleteOptions, type TypewriterOptions, type WalkVisitor, type WaveOptions, type WriteAsyncOptions, animate, animateGradient, ascii, bell, bg256, bgRgb, box, canAnimate, cancelTerminalFrame, center, chain, charWidth, clamp, clearAnsiCache, clearColorCache, clearRenderCache, clearThemeColorCache, color, colorLevel, presets as colorPresets, components, compose, configure, countNodes, createCanvas, createOutputBuffer, createTheme, cursor, debounce, ansimax as default, diffLines, escapeRegex, fg256, fgRgb, filterTree, findInTree, flipHorizontal, flipVertical, frames, getConfig, getConfigValue, getRenderCacheSize, getSpeedMultiplier, getTerminalHeight, getTerminalWidth, gradient, gradientColor, gradientRect, graphemes, hasFont, hexToRgb, hideCursor, images, isHexColor, isNoColor, lerp, lerpColor, link, listFonts, listPresets, loader, mapTree, measureTree, memoize, nextTick, onConfigChange, onConfigKeyChange, onResize, once, padBoth, padEnd, padStart, pauseListeners, presetNames, rainbow, registerFont, registerPreset, renderPixelArt, renderTree, renderTreeStream, repeatVisible, requestTerminalFrame, reset, resetColorSupportCache, resetConfig, resetCursorRefCount, resetFramesCursorCount, resetLoaderCursorCount, resetNoColor, resumeListeners, rgbTo256, rgbToHex, rotate90, safeJson, screen, setNoColor, setTitle, sgr, showCursor, sleep, sleepFrame, sliceAnsi, stripAnsi$1 as stripAnsi, stripAnsi$2 as stripAnsiCodes, stripAnsi as stripAnsiColors, supportsColor, supportsColorLevel, termSize, themes, throttle, tree, trees, truncateAnsi, visibleLen, walkTree, withConfig, wordWrap, wrapAnsi, write, writeAsync, writeErr, writeln, writelnErr };
|
package/dist/index.js
CHANGED
|
@@ -46,6 +46,7 @@ __export(index_exports, {
|
|
|
46
46
|
ST: () => ST,
|
|
47
47
|
STYLE: () => STYLE,
|
|
48
48
|
animate: () => animate,
|
|
49
|
+
animateGradient: () => animateGradient,
|
|
49
50
|
ascii: () => ascii,
|
|
50
51
|
bell: () => bell,
|
|
51
52
|
bg256: () => bg256,
|
|
@@ -1114,6 +1115,37 @@ var compose = (...fns) => (text) => {
|
|
|
1114
1115
|
if (opens === "") return s;
|
|
1115
1116
|
return opens + s + reset();
|
|
1116
1117
|
};
|
|
1118
|
+
var _cubicBezier = (t, x1 = 0.25, y1 = 0.1, x2 = 0.25, y2 = 1) => {
|
|
1119
|
+
if (t <= 0) return 0;
|
|
1120
|
+
if (t >= 1) return 1;
|
|
1121
|
+
let s = t;
|
|
1122
|
+
for (let i = 0; i < 8; i++) {
|
|
1123
|
+
const s22 = s * s;
|
|
1124
|
+
const s32 = s22 * s;
|
|
1125
|
+
const oneMinusS = 1 - s;
|
|
1126
|
+
const oneMinusS2 = oneMinusS * oneMinusS;
|
|
1127
|
+
const fx = 3 * oneMinusS2 * s * x1 + 3 * oneMinusS * s22 * x2 + s32 - t;
|
|
1128
|
+
const dfx = 3 * oneMinusS2 * x1 + 6 * oneMinusS * s * (x2 - x1) + 3 * s22 * (1 - x2);
|
|
1129
|
+
if (Math.abs(dfx) < 1e-6) break;
|
|
1130
|
+
s -= fx / dfx;
|
|
1131
|
+
s = Math.min(1, Math.max(0, s));
|
|
1132
|
+
}
|
|
1133
|
+
const s2 = s * s;
|
|
1134
|
+
const s3 = s2 * s;
|
|
1135
|
+
return 3 * (1 - s) * (1 - s) * s * y1 + 3 * (1 - s) * s2 * y2 + s3;
|
|
1136
|
+
};
|
|
1137
|
+
var EASINGS = {
|
|
1138
|
+
"linear": (t) => t,
|
|
1139
|
+
"ease-in": (t) => t * t,
|
|
1140
|
+
"ease-out": (t) => 1 - (1 - t) * (1 - t),
|
|
1141
|
+
"ease-in-out": (t) => t < 0.5 ? 2 * t * t : 1 - Math.pow(-2 * t + 2, 2) / 2,
|
|
1142
|
+
"cubic-bezier": (t) => _cubicBezier(t)
|
|
1143
|
+
};
|
|
1144
|
+
var resolveEasing = (e) => {
|
|
1145
|
+
if (typeof e === "function") return e;
|
|
1146
|
+
if (typeof e === "string" && EASINGS[e]) return EASINGS[e];
|
|
1147
|
+
return EASINGS.linear;
|
|
1148
|
+
};
|
|
1117
1149
|
var stripAnsi3 = stripAnsi;
|
|
1118
1150
|
var gradient = (text, stops, opts = {}) => {
|
|
1119
1151
|
const s = coerceText(text);
|
|
@@ -1125,13 +1157,15 @@ var gradient = (text, stops, opts = {}) => {
|
|
|
1125
1157
|
const c = colors[0];
|
|
1126
1158
|
return adaptiveFg(c.r, c.g, c.b) + s + reset();
|
|
1127
1159
|
}
|
|
1128
|
-
const { preserveAnsi = false } = opts;
|
|
1160
|
+
const { preserveAnsi = false, easing, phase = 0 } = opts;
|
|
1161
|
+
const easingFn = resolveEasing(easing);
|
|
1162
|
+
const phaseN = Number.isFinite(phase) ? (phase % 1 + 1) % 1 : 0;
|
|
1129
1163
|
if (!preserveAnsi || !s.includes("\x1B")) {
|
|
1130
|
-
return _gradientPlain(s, colors);
|
|
1164
|
+
return _gradientPlain(s, colors, easingFn, phaseN);
|
|
1131
1165
|
}
|
|
1132
|
-
return _gradientAnsiAware(s, colors);
|
|
1166
|
+
return _gradientAnsiAware(s, colors, easingFn, phaseN);
|
|
1133
1167
|
};
|
|
1134
|
-
var _gradientPlain = (text, colors) => {
|
|
1168
|
+
var _gradientPlain = (text, colors, easingFn, phase) => {
|
|
1135
1169
|
const chars = [...text];
|
|
1136
1170
|
const visible = chars.filter((c) => c !== " ").length;
|
|
1137
1171
|
if (visible === 0) return text;
|
|
@@ -1144,7 +1178,10 @@ var _gradientPlain = (text, colors) => {
|
|
|
1144
1178
|
out += ch;
|
|
1145
1179
|
continue;
|
|
1146
1180
|
}
|
|
1147
|
-
|
|
1181
|
+
let t = visible === 1 ? 0 : colorIdx / visibleMinus;
|
|
1182
|
+
t = (t + phase) % 1;
|
|
1183
|
+
t = easingFn(t);
|
|
1184
|
+
t = Math.min(1, Math.max(0, t));
|
|
1148
1185
|
const scaled = t * (colorCount - 1);
|
|
1149
1186
|
const lo = Math.floor(scaled);
|
|
1150
1187
|
const hi = Math.min(lo + 1, colorCount - 1);
|
|
@@ -1155,7 +1192,7 @@ var _gradientPlain = (text, colors) => {
|
|
|
1155
1192
|
return out;
|
|
1156
1193
|
};
|
|
1157
1194
|
var ANSI_TOKEN = /\x1b\[[0-9;?]*[a-zA-Z]/y;
|
|
1158
|
-
var _gradientAnsiAware = (text, colors) => {
|
|
1195
|
+
var _gradientAnsiAware = (text, colors, easingFn, phase) => {
|
|
1159
1196
|
const visible = stripAnsi3(text).split("").filter((c) => c !== " ").length;
|
|
1160
1197
|
if (visible === 0) return text;
|
|
1161
1198
|
let out = "";
|
|
@@ -1181,7 +1218,10 @@ var _gradientAnsiAware = (text, colors) => {
|
|
|
1181
1218
|
if (ch === " ") {
|
|
1182
1219
|
out += ch;
|
|
1183
1220
|
} else {
|
|
1184
|
-
|
|
1221
|
+
let t = visible === 1 ? 0 : colorIdx / visibleMinus;
|
|
1222
|
+
t = (t + phase) % 1;
|
|
1223
|
+
t = easingFn(t);
|
|
1224
|
+
t = Math.min(1, Math.max(0, t));
|
|
1185
1225
|
const scaled = t * (colorCount - 1);
|
|
1186
1226
|
const lo = Math.floor(scaled);
|
|
1187
1227
|
const hi = Math.min(lo + 1, colorCount - 1);
|
|
@@ -1195,6 +1235,76 @@ var _gradientAnsiAware = (text, colors) => {
|
|
|
1195
1235
|
};
|
|
1196
1236
|
var RAINBOW = ["#ff0000", "#ff7f00", "#ffff00", "#00ff00", "#0000ff", "#8b00ff"];
|
|
1197
1237
|
var rainbow = (text) => gradient(text, RAINBOW);
|
|
1238
|
+
var animateGradient = (text, stops, opts = {}) => {
|
|
1239
|
+
const {
|
|
1240
|
+
duration = 2e3,
|
|
1241
|
+
fps = 30,
|
|
1242
|
+
infinite = true,
|
|
1243
|
+
cycles = 1,
|
|
1244
|
+
direction = "forward",
|
|
1245
|
+
easing,
|
|
1246
|
+
preserveAnsi = false,
|
|
1247
|
+
signal,
|
|
1248
|
+
onFrame
|
|
1249
|
+
} = opts;
|
|
1250
|
+
const safeFps = Math.min(60, Math.max(1, Number.isFinite(fps) ? fps : 30));
|
|
1251
|
+
const safeDuration2 = Math.max(100, Number.isFinite(duration) ? duration : 2e3);
|
|
1252
|
+
const safeCycles = Math.max(1, Number.isFinite(cycles) ? cycles : 1);
|
|
1253
|
+
const frameInterval2 = 1e3 / safeFps;
|
|
1254
|
+
let stopped = false;
|
|
1255
|
+
let timer = null;
|
|
1256
|
+
let resolveDone = (
|
|
1257
|
+
/* istanbul ignore next */
|
|
1258
|
+
() => {
|
|
1259
|
+
}
|
|
1260
|
+
);
|
|
1261
|
+
const done = new Promise((res) => {
|
|
1262
|
+
resolveDone = res;
|
|
1263
|
+
});
|
|
1264
|
+
const stop = () => {
|
|
1265
|
+
if (stopped) return;
|
|
1266
|
+
stopped = true;
|
|
1267
|
+
if (timer != null) {
|
|
1268
|
+
clearInterval(timer);
|
|
1269
|
+
timer = null;
|
|
1270
|
+
}
|
|
1271
|
+
resolveDone();
|
|
1272
|
+
};
|
|
1273
|
+
if (signal) {
|
|
1274
|
+
if (signal.aborted) {
|
|
1275
|
+
stop();
|
|
1276
|
+
return { stop, done };
|
|
1277
|
+
}
|
|
1278
|
+
signal.addEventListener("abort", stop, { once: true });
|
|
1279
|
+
}
|
|
1280
|
+
const startTime = Date.now();
|
|
1281
|
+
const renderFrame = () => {
|
|
1282
|
+
if (stopped) return;
|
|
1283
|
+
const elapsed = Date.now() - startTime;
|
|
1284
|
+
let phase = elapsed / safeDuration2 % 1;
|
|
1285
|
+
if (direction === "reverse") phase = 1 - phase;
|
|
1286
|
+
const frame = gradient(text, stops, { preserveAnsi, easing, phase });
|
|
1287
|
+
if (onFrame) {
|
|
1288
|
+
onFrame(frame, phase);
|
|
1289
|
+
} else {
|
|
1290
|
+
try {
|
|
1291
|
+
process.stdout.write("\r" + frame);
|
|
1292
|
+
} catch {
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
if (!infinite) {
|
|
1296
|
+
const completedCycles = Math.floor(elapsed / safeDuration2);
|
|
1297
|
+
if (completedCycles >= safeCycles) {
|
|
1298
|
+
stop();
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
};
|
|
1302
|
+
renderFrame();
|
|
1303
|
+
if (!stopped) {
|
|
1304
|
+
timer = setInterval(renderFrame, frameInterval2);
|
|
1305
|
+
}
|
|
1306
|
+
return { stop, done };
|
|
1307
|
+
};
|
|
1198
1308
|
var PRESET_DEFS = {
|
|
1199
1309
|
sunset: ["#ff6b6b", "#feca57", "#48dbfb"],
|
|
1200
1310
|
ocean: ["#0575e6", "#021b79"],
|
|
@@ -4833,6 +4943,7 @@ var gradientRect = (opts = {}) => {
|
|
|
4833
4943
|
colors = ["#ff0000", "#0000ff"],
|
|
4834
4944
|
style = "horizontal",
|
|
4835
4945
|
angle,
|
|
4946
|
+
startAngle = 0,
|
|
4836
4947
|
dither = "none",
|
|
4837
4948
|
braille = false
|
|
4838
4949
|
} = opts;
|
|
@@ -4871,7 +4982,15 @@ var gradientRect = (opts = {}) => {
|
|
|
4871
4982
|
} else if (style === "horizontal") t = col / (safeW - 1);
|
|
4872
4983
|
else if (style === "vertical") t = row / (safeH - 1);
|
|
4873
4984
|
else if (style === "diagonal") t = (col + row) / (safeW + safeH - 2);
|
|
4874
|
-
else {
|
|
4985
|
+
else if (style === "conic") {
|
|
4986
|
+
const cx = safeW / 2, cy = safeH / 2;
|
|
4987
|
+
const dx = col - cx;
|
|
4988
|
+
const dy = row - cy;
|
|
4989
|
+
const startRad = (Number.isFinite(startAngle) ? startAngle : 0) * Math.PI / 180;
|
|
4990
|
+
let angleRad = Math.atan2(dy, dx) - startRad;
|
|
4991
|
+
angleRad = (angleRad % (2 * Math.PI) + 2 * Math.PI) % (2 * Math.PI);
|
|
4992
|
+
t = angleRad / (2 * Math.PI);
|
|
4993
|
+
} else {
|
|
4875
4994
|
const cx = safeW / 2, cy = safeH / 2;
|
|
4876
4995
|
const dx = (col - cx) / cx;
|
|
4877
4996
|
const dy = (row - cy) / cy;
|
|
@@ -5323,6 +5442,7 @@ var index_default = ansimax;
|
|
|
5323
5442
|
ST,
|
|
5324
5443
|
STYLE,
|
|
5325
5444
|
animate,
|
|
5445
|
+
animateGradient,
|
|
5326
5446
|
ascii,
|
|
5327
5447
|
bell,
|
|
5328
5448
|
bg256,
|
package/dist/index.mjs
CHANGED
|
@@ -942,6 +942,37 @@ var compose = (...fns) => (text) => {
|
|
|
942
942
|
if (opens === "") return s;
|
|
943
943
|
return opens + s + reset();
|
|
944
944
|
};
|
|
945
|
+
var _cubicBezier = (t, x1 = 0.25, y1 = 0.1, x2 = 0.25, y2 = 1) => {
|
|
946
|
+
if (t <= 0) return 0;
|
|
947
|
+
if (t >= 1) return 1;
|
|
948
|
+
let s = t;
|
|
949
|
+
for (let i = 0; i < 8; i++) {
|
|
950
|
+
const s22 = s * s;
|
|
951
|
+
const s32 = s22 * s;
|
|
952
|
+
const oneMinusS = 1 - s;
|
|
953
|
+
const oneMinusS2 = oneMinusS * oneMinusS;
|
|
954
|
+
const fx = 3 * oneMinusS2 * s * x1 + 3 * oneMinusS * s22 * x2 + s32 - t;
|
|
955
|
+
const dfx = 3 * oneMinusS2 * x1 + 6 * oneMinusS * s * (x2 - x1) + 3 * s22 * (1 - x2);
|
|
956
|
+
if (Math.abs(dfx) < 1e-6) break;
|
|
957
|
+
s -= fx / dfx;
|
|
958
|
+
s = Math.min(1, Math.max(0, s));
|
|
959
|
+
}
|
|
960
|
+
const s2 = s * s;
|
|
961
|
+
const s3 = s2 * s;
|
|
962
|
+
return 3 * (1 - s) * (1 - s) * s * y1 + 3 * (1 - s) * s2 * y2 + s3;
|
|
963
|
+
};
|
|
964
|
+
var EASINGS = {
|
|
965
|
+
"linear": (t) => t,
|
|
966
|
+
"ease-in": (t) => t * t,
|
|
967
|
+
"ease-out": (t) => 1 - (1 - t) * (1 - t),
|
|
968
|
+
"ease-in-out": (t) => t < 0.5 ? 2 * t * t : 1 - Math.pow(-2 * t + 2, 2) / 2,
|
|
969
|
+
"cubic-bezier": (t) => _cubicBezier(t)
|
|
970
|
+
};
|
|
971
|
+
var resolveEasing = (e) => {
|
|
972
|
+
if (typeof e === "function") return e;
|
|
973
|
+
if (typeof e === "string" && EASINGS[e]) return EASINGS[e];
|
|
974
|
+
return EASINGS.linear;
|
|
975
|
+
};
|
|
945
976
|
var stripAnsi3 = stripAnsi;
|
|
946
977
|
var gradient = (text, stops, opts = {}) => {
|
|
947
978
|
const s = coerceText(text);
|
|
@@ -953,13 +984,15 @@ var gradient = (text, stops, opts = {}) => {
|
|
|
953
984
|
const c = colors[0];
|
|
954
985
|
return adaptiveFg(c.r, c.g, c.b) + s + reset();
|
|
955
986
|
}
|
|
956
|
-
const { preserveAnsi = false } = opts;
|
|
987
|
+
const { preserveAnsi = false, easing, phase = 0 } = opts;
|
|
988
|
+
const easingFn = resolveEasing(easing);
|
|
989
|
+
const phaseN = Number.isFinite(phase) ? (phase % 1 + 1) % 1 : 0;
|
|
957
990
|
if (!preserveAnsi || !s.includes("\x1B")) {
|
|
958
|
-
return _gradientPlain(s, colors);
|
|
991
|
+
return _gradientPlain(s, colors, easingFn, phaseN);
|
|
959
992
|
}
|
|
960
|
-
return _gradientAnsiAware(s, colors);
|
|
993
|
+
return _gradientAnsiAware(s, colors, easingFn, phaseN);
|
|
961
994
|
};
|
|
962
|
-
var _gradientPlain = (text, colors) => {
|
|
995
|
+
var _gradientPlain = (text, colors, easingFn, phase) => {
|
|
963
996
|
const chars = [...text];
|
|
964
997
|
const visible = chars.filter((c) => c !== " ").length;
|
|
965
998
|
if (visible === 0) return text;
|
|
@@ -972,7 +1005,10 @@ var _gradientPlain = (text, colors) => {
|
|
|
972
1005
|
out += ch;
|
|
973
1006
|
continue;
|
|
974
1007
|
}
|
|
975
|
-
|
|
1008
|
+
let t = visible === 1 ? 0 : colorIdx / visibleMinus;
|
|
1009
|
+
t = (t + phase) % 1;
|
|
1010
|
+
t = easingFn(t);
|
|
1011
|
+
t = Math.min(1, Math.max(0, t));
|
|
976
1012
|
const scaled = t * (colorCount - 1);
|
|
977
1013
|
const lo = Math.floor(scaled);
|
|
978
1014
|
const hi = Math.min(lo + 1, colorCount - 1);
|
|
@@ -983,7 +1019,7 @@ var _gradientPlain = (text, colors) => {
|
|
|
983
1019
|
return out;
|
|
984
1020
|
};
|
|
985
1021
|
var ANSI_TOKEN = /\x1b\[[0-9;?]*[a-zA-Z]/y;
|
|
986
|
-
var _gradientAnsiAware = (text, colors) => {
|
|
1022
|
+
var _gradientAnsiAware = (text, colors, easingFn, phase) => {
|
|
987
1023
|
const visible = stripAnsi3(text).split("").filter((c) => c !== " ").length;
|
|
988
1024
|
if (visible === 0) return text;
|
|
989
1025
|
let out = "";
|
|
@@ -1009,7 +1045,10 @@ var _gradientAnsiAware = (text, colors) => {
|
|
|
1009
1045
|
if (ch === " ") {
|
|
1010
1046
|
out += ch;
|
|
1011
1047
|
} else {
|
|
1012
|
-
|
|
1048
|
+
let t = visible === 1 ? 0 : colorIdx / visibleMinus;
|
|
1049
|
+
t = (t + phase) % 1;
|
|
1050
|
+
t = easingFn(t);
|
|
1051
|
+
t = Math.min(1, Math.max(0, t));
|
|
1013
1052
|
const scaled = t * (colorCount - 1);
|
|
1014
1053
|
const lo = Math.floor(scaled);
|
|
1015
1054
|
const hi = Math.min(lo + 1, colorCount - 1);
|
|
@@ -1023,6 +1062,76 @@ var _gradientAnsiAware = (text, colors) => {
|
|
|
1023
1062
|
};
|
|
1024
1063
|
var RAINBOW = ["#ff0000", "#ff7f00", "#ffff00", "#00ff00", "#0000ff", "#8b00ff"];
|
|
1025
1064
|
var rainbow = (text) => gradient(text, RAINBOW);
|
|
1065
|
+
var animateGradient = (text, stops, opts = {}) => {
|
|
1066
|
+
const {
|
|
1067
|
+
duration = 2e3,
|
|
1068
|
+
fps = 30,
|
|
1069
|
+
infinite = true,
|
|
1070
|
+
cycles = 1,
|
|
1071
|
+
direction = "forward",
|
|
1072
|
+
easing,
|
|
1073
|
+
preserveAnsi = false,
|
|
1074
|
+
signal,
|
|
1075
|
+
onFrame
|
|
1076
|
+
} = opts;
|
|
1077
|
+
const safeFps = Math.min(60, Math.max(1, Number.isFinite(fps) ? fps : 30));
|
|
1078
|
+
const safeDuration2 = Math.max(100, Number.isFinite(duration) ? duration : 2e3);
|
|
1079
|
+
const safeCycles = Math.max(1, Number.isFinite(cycles) ? cycles : 1);
|
|
1080
|
+
const frameInterval2 = 1e3 / safeFps;
|
|
1081
|
+
let stopped = false;
|
|
1082
|
+
let timer = null;
|
|
1083
|
+
let resolveDone = (
|
|
1084
|
+
/* istanbul ignore next */
|
|
1085
|
+
() => {
|
|
1086
|
+
}
|
|
1087
|
+
);
|
|
1088
|
+
const done = new Promise((res) => {
|
|
1089
|
+
resolveDone = res;
|
|
1090
|
+
});
|
|
1091
|
+
const stop = () => {
|
|
1092
|
+
if (stopped) return;
|
|
1093
|
+
stopped = true;
|
|
1094
|
+
if (timer != null) {
|
|
1095
|
+
clearInterval(timer);
|
|
1096
|
+
timer = null;
|
|
1097
|
+
}
|
|
1098
|
+
resolveDone();
|
|
1099
|
+
};
|
|
1100
|
+
if (signal) {
|
|
1101
|
+
if (signal.aborted) {
|
|
1102
|
+
stop();
|
|
1103
|
+
return { stop, done };
|
|
1104
|
+
}
|
|
1105
|
+
signal.addEventListener("abort", stop, { once: true });
|
|
1106
|
+
}
|
|
1107
|
+
const startTime = Date.now();
|
|
1108
|
+
const renderFrame = () => {
|
|
1109
|
+
if (stopped) return;
|
|
1110
|
+
const elapsed = Date.now() - startTime;
|
|
1111
|
+
let phase = elapsed / safeDuration2 % 1;
|
|
1112
|
+
if (direction === "reverse") phase = 1 - phase;
|
|
1113
|
+
const frame = gradient(text, stops, { preserveAnsi, easing, phase });
|
|
1114
|
+
if (onFrame) {
|
|
1115
|
+
onFrame(frame, phase);
|
|
1116
|
+
} else {
|
|
1117
|
+
try {
|
|
1118
|
+
process.stdout.write("\r" + frame);
|
|
1119
|
+
} catch {
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
if (!infinite) {
|
|
1123
|
+
const completedCycles = Math.floor(elapsed / safeDuration2);
|
|
1124
|
+
if (completedCycles >= safeCycles) {
|
|
1125
|
+
stop();
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
};
|
|
1129
|
+
renderFrame();
|
|
1130
|
+
if (!stopped) {
|
|
1131
|
+
timer = setInterval(renderFrame, frameInterval2);
|
|
1132
|
+
}
|
|
1133
|
+
return { stop, done };
|
|
1134
|
+
};
|
|
1026
1135
|
var PRESET_DEFS = {
|
|
1027
1136
|
sunset: ["#ff6b6b", "#feca57", "#48dbfb"],
|
|
1028
1137
|
ocean: ["#0575e6", "#021b79"],
|
|
@@ -4661,6 +4770,7 @@ var gradientRect = (opts = {}) => {
|
|
|
4661
4770
|
colors = ["#ff0000", "#0000ff"],
|
|
4662
4771
|
style = "horizontal",
|
|
4663
4772
|
angle,
|
|
4773
|
+
startAngle = 0,
|
|
4664
4774
|
dither = "none",
|
|
4665
4775
|
braille = false
|
|
4666
4776
|
} = opts;
|
|
@@ -4699,7 +4809,15 @@ var gradientRect = (opts = {}) => {
|
|
|
4699
4809
|
} else if (style === "horizontal") t = col / (safeW - 1);
|
|
4700
4810
|
else if (style === "vertical") t = row / (safeH - 1);
|
|
4701
4811
|
else if (style === "diagonal") t = (col + row) / (safeW + safeH - 2);
|
|
4702
|
-
else {
|
|
4812
|
+
else if (style === "conic") {
|
|
4813
|
+
const cx = safeW / 2, cy = safeH / 2;
|
|
4814
|
+
const dx = col - cx;
|
|
4815
|
+
const dy = row - cy;
|
|
4816
|
+
const startRad = (Number.isFinite(startAngle) ? startAngle : 0) * Math.PI / 180;
|
|
4817
|
+
let angleRad = Math.atan2(dy, dx) - startRad;
|
|
4818
|
+
angleRad = (angleRad % (2 * Math.PI) + 2 * Math.PI) % (2 * Math.PI);
|
|
4819
|
+
t = angleRad / (2 * Math.PI);
|
|
4820
|
+
} else {
|
|
4703
4821
|
const cx = safeW / 2, cy = safeH / 2;
|
|
4704
4822
|
const dx = (col - cx) / cx;
|
|
4705
4823
|
const dy = (row - cy) / cy;
|
|
@@ -5150,6 +5268,7 @@ export {
|
|
|
5150
5268
|
ST,
|
|
5151
5269
|
STYLE,
|
|
5152
5270
|
animate,
|
|
5271
|
+
animateGradient,
|
|
5153
5272
|
ascii,
|
|
5154
5273
|
bell,
|
|
5155
5274
|
bg256,
|
package/examples/all-in-one.cjs
CHANGED
|
@@ -118,7 +118,7 @@ async function main() {
|
|
|
118
118
|
console.log(components.section('🏷️ Badges & Status', { width: 60 }));
|
|
119
119
|
console.log();
|
|
120
120
|
console.log(' ',
|
|
121
|
-
components.badge('VERSION', 'v1.
|
|
121
|
+
components.badge('VERSION', 'v1.2.0'),
|
|
122
122
|
components.badge('BUILD', 'passing'),
|
|
123
123
|
components.badge('LICENSE', 'Apache 2.0'));
|
|
124
124
|
console.log();
|
package/examples/all-in-one.mjs
CHANGED
|
@@ -117,7 +117,7 @@ console.log();
|
|
|
117
117
|
console.log(components.section('🏷️ Badges & Status', { width: 60 }));
|
|
118
118
|
console.log();
|
|
119
119
|
console.log(' ',
|
|
120
|
-
components.badge('VERSION', 'v1.
|
|
120
|
+
components.badge('VERSION', 'v1.2.0'),
|
|
121
121
|
components.badge('BUILD', 'passing'),
|
|
122
122
|
components.badge('LICENSE', 'Apache 2.0'));
|
|
123
123
|
console.log();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ansimax",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Zero-dependency CLI rendering library: colors, gradients, animations, ASCII art, pixel art, components, and themes \u2014 all in TypeScript.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|