ansimax 1.2.3 → 1.2.4

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 CHANGED
@@ -3,6 +3,76 @@
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.4] — Gradient utilities + inspectability
7
+
8
+ Patch release adding gradient inspection and manipulation utilities.
9
+ No breaking changes — `createGradient()` callers from 1.2.3 continue
10
+ to work, but now have access to metadata.
11
+
12
+ ### Added — `ReusableGradient` metadata
13
+
14
+ `createGradient()` now returns a `ReusableGradient` — still callable
15
+ like before, but with frozen metadata for inspection and debugging:
16
+
17
+ ```ts
18
+ const fire = createGradient(['#ff5555', '#ffb86c', '#f1fa8c'], {
19
+ easing: 'ease-in',
20
+ });
21
+
22
+ // All still callable
23
+ console.log(fire('hello'));
24
+
25
+ // New: read-only inspection
26
+ fire.stops; // → ['#ff5555', '#ffb86c', '#f1fa8c']
27
+ fire.resolvedStops; // → [{r:255,g:85,b:85}, {r:255,g:184,b:108}, ...]
28
+ fire.defaultOptions; // → { easing: 'ease-in' }
29
+ ```
30
+
31
+ All three properties are frozen — attempting to mutate them throws in
32
+ strict mode and silently fails in sloppy mode.
33
+
34
+ ### Added — `reverseGradient()` helper
35
+
36
+ Returns a new gradient with stops in reverse order. Works with both
37
+ plain arrays and `ReusableGradient` instances. Default options are
38
+ preserved when reversing a `ReusableGradient`:
39
+
40
+ ```ts
41
+ const fire = createGradient(['#ff5555', '#ffb86c', '#f1fa8c']);
42
+ const ice = reverseGradient(fire); // → '#f1fa8c' → '#ffb86c' → '#ff5555'
43
+
44
+ console.log(fire('warm side'));
45
+ console.log(ice('cool side'));
46
+
47
+ // Also works with plain arrays
48
+ reverseGradient(['#f00', '#0f0', '#00f']); // → ['#00f', '#0f0', '#f00']
49
+ ```
50
+
51
+ The original array / gradient is never mutated.
52
+
53
+ ### Added — `presets` alias (canonical name)
54
+
55
+ Previously `presets` was exported only as `colorPresets`. Many users
56
+ referenced `presets` based on docs and got `ReferenceError`. Now both
57
+ names point to the same object:
58
+
59
+ ```ts
60
+ import { presets, colorPresets } from 'ansimax';
61
+
62
+ presets === colorPresets; // → true
63
+ ```
64
+
65
+ `colorPresets` remains for backwards compatibility; new code can use
66
+ either name.
67
+
68
+ ### Notes
69
+
70
+ - Coverage holds steady at ~98%.
71
+ - No new runtime dependencies — still zero.
72
+ - All 1892 + 22 new tests pass.
73
+
74
+ ---
75
+
6
76
  ## [1.2.3] — Gradient factory + performance
7
77
 
8
78
  Patch release adding a new performance-oriented API and refinements. No
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](https://img.shields.io/badge/license-Apache%202.0-blue.svg?style=flat-square)](LICENSE)
10
- [![npm](https://img.shields.io/badge/npm-v1.2.3-cb3837.svg?style=flat-square)](https://www.npmjs.com/package/ansimax)
10
+ [![npm](https://img.shields.io/badge/npm-v1.2.4-cb3837.svg?style=flat-square)](https://www.npmjs.com/package/ansimax)
11
11
  [![TypeScript](https://img.shields.io/badge/TypeScript-strict-3178c6.svg?style=flat-square)](tsconfig.json)
12
12
  [![Coverage](https://img.shields.io/badge/coverage-98%25-brightgreen.svg?style=flat-square)](#testing)
13
13
  [![Tests](https://img.shields.io/badge/tests-1700%2B%20passing-brightgreen.svg?style=flat-square)](#testing)
@@ -263,7 +263,7 @@ console.log(gradientRect({
263
263
  ### Gradientes reusables (v1.2.3)
264
264
 
265
265
  ```ts
266
- import { createGradient, ascii } from 'ansimax';
266
+ import { createGradient, reverseGradient, ascii } from 'ansimax';
267
267
 
268
268
  // Pre-resuelve los stops de hex una vez — significativamente más rápido para uso repetido
269
269
  const fire = createGradient(['#ff5555', '#ffb86c', '#f1fa8c']);
@@ -275,6 +275,14 @@ console.log(fire('Tercera línea'));
275
275
  // Úsalo como colorFn para banners — misma firma de ColorFn
276
276
  console.log(ascii.banner('FIRE', { colorFn: fire }));
277
277
 
278
+ // v1.2.4: inspecciona metadata
279
+ console.log('Stops:', fire.stops); // → ['#ff5555', '#ffb86c', '#f1fa8c']
280
+ console.log('Resolved:', fire.resolvedStops); // → [{r:255,g:85,b:85}, ...]
281
+
282
+ // v1.2.4: invierte un gradiente (preserva las opciones por defecto)
283
+ const ice = reverseGradient(fire);
284
+ console.log(ice('Lado frío'));
285
+
278
286
  // Las opciones por-llamada aún funcionan — perfecto para animación
279
287
  for (let p = 0; p < 1; p += 0.05) {
280
288
  process.stdout.write('\r' + fire('fluyendo', { phase: p }));
@@ -357,7 +365,7 @@ console.log(components.table([
357
365
  ['loaders', color.green('● listo'), '100%'],
358
366
  ], { borderStyle: 'rounded' }));
359
367
 
360
- console.log(components.badge('VERSION', 'v1.2.3'));
368
+ console.log(components.badge('VERSION', 'v1.2.4'));
361
369
  console.log(components.badge('BUILD', 'passing'));
362
370
  ```
363
371
 
@@ -759,6 +767,27 @@ ansimax/
759
767
 
760
768
  ## 📝 Changelog
761
769
 
770
+ ### v1.2.4 — Utilidades de gradiente + inspectabilidad
771
+
772
+ Release patch añadiendo metadata de inspección y un helper `reverseGradient()`:
773
+
774
+ - 🔍 **`ReusableGradient` expone `.stops`, `.resolvedStops`, `.defaultOptions`** — todos congelados, todos de solo lectura
775
+ - 🔄 **Helper `reverseGradient()`** — invierte el orden de stops de un gradiente (funciona con arrays o `ReusableGradient`)
776
+ - 🎯 **`presets` exportado con su nombre canónico** — junto al alias existente `colorPresets`
777
+
778
+ ```ts
779
+ import { createGradient, reverseGradient } from 'ansimax';
780
+
781
+ const fire = createGradient(['#ff5555', '#ffb86c', '#f1fa8c']);
782
+ const ice = reverseGradient(fire);
783
+
784
+ console.log(fire.stops); // ['#ff5555', '#ffb86c', '#f1fa8c'] — read-only
785
+ console.log(fire('cálido'));
786
+ console.log(ice('frío'));
787
+ ```
788
+
789
+ Drop-in replacement para `1.2.3`.
790
+
762
791
  ### v1.2.3 — Factory de gradientes + performance
763
792
 
764
793
  Release patch añadiendo una API orientada a performance:
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](https://img.shields.io/badge/license-Apache%202.0-blue.svg?style=flat-square)](LICENSE)
10
- [![npm](https://img.shields.io/badge/npm-v1.2.3-cb3837.svg?style=flat-square)](https://www.npmjs.com/package/ansimax)
10
+ [![npm](https://img.shields.io/badge/npm-v1.2.4-cb3837.svg?style=flat-square)](https://www.npmjs.com/package/ansimax)
11
11
  [![TypeScript](https://img.shields.io/badge/TypeScript-strict-3178c6.svg?style=flat-square)](tsconfig.json)
12
12
  [![Coverage](https://img.shields.io/badge/coverage-98%25-brightgreen.svg?style=flat-square)](#testing)
13
13
  [![Tests](https://img.shields.io/badge/tests-1700%2B%20passing-brightgreen.svg?style=flat-square)](#testing)
@@ -263,7 +263,7 @@ console.log(gradientRect({
263
263
  ### Reusable Gradients (v1.2.3)
264
264
 
265
265
  ```ts
266
- import { createGradient, ascii } from 'ansimax';
266
+ import { createGradient, reverseGradient, ascii } from 'ansimax';
267
267
 
268
268
  // Pre-resolve hex stops once — significantly faster for repeated use
269
269
  const fire = createGradient(['#ff5555', '#ffb86c', '#f1fa8c']);
@@ -275,6 +275,14 @@ console.log(fire('Third line'));
275
275
  // Use as a colorFn for banners — same ColorFn signature
276
276
  console.log(ascii.banner('FIRE', { colorFn: fire }));
277
277
 
278
+ // v1.2.4: inspect metadata
279
+ console.log('Stops:', fire.stops); // → ['#ff5555', '#ffb86c', '#f1fa8c']
280
+ console.log('Resolved:', fire.resolvedStops); // → [{r:255,g:85,b:85}, ...]
281
+
282
+ // v1.2.4: reverse a gradient (preserves default options)
283
+ const ice = reverseGradient(fire);
284
+ console.log(ice('Cool side'));
285
+
278
286
  // Per-call options still work — perfect for animation
279
287
  for (let p = 0; p < 1; p += 0.05) {
280
288
  process.stdout.write('\r' + fire('flowing', { phase: p }));
@@ -357,7 +365,7 @@ console.log(components.table([
357
365
  ['loaders', color.green('● ready'), '100%'],
358
366
  ], { borderStyle: 'rounded' }));
359
367
 
360
- console.log(components.badge('VERSION', 'v1.2.3'));
368
+ console.log(components.badge('VERSION', 'v1.2.4'));
361
369
  console.log(components.badge('BUILD', 'passing'));
362
370
  ```
363
371
 
@@ -759,6 +767,27 @@ ansimax/
759
767
 
760
768
  ## 📝 Changelog
761
769
 
770
+ ### v1.2.4 — Gradient utilities + inspectability
771
+
772
+ Patch release adding inspection metadata and a `reverseGradient()` helper:
773
+
774
+ - 🔍 **`ReusableGradient` exposes `.stops`, `.resolvedStops`, `.defaultOptions`** — all frozen, all read-only
775
+ - 🔄 **`reverseGradient()` helper** — flips a gradient's stop order (works with arrays or `ReusableGradient`)
776
+ - 🎯 **`presets` exported as canonical name** — alongside the existing `colorPresets` alias
777
+
778
+ ```ts
779
+ import { createGradient, reverseGradient } from 'ansimax';
780
+
781
+ const fire = createGradient(['#ff5555', '#ffb86c', '#f1fa8c']);
782
+ const ice = reverseGradient(fire);
783
+
784
+ console.log(fire.stops); // ['#ff5555', '#ffb86c', '#f1fa8c'] — read-only
785
+ console.log(fire('warm'));
786
+ console.log(ice('cool'));
787
+ ```
788
+
789
+ Drop-in replacement for `1.2.3`.
790
+
762
791
  ### v1.2.3 — Gradient factory + performance
763
792
 
764
793
  Patch release adding a performance-oriented API:
package/dist/index.d.mts CHANGED
@@ -622,7 +622,47 @@ declare const gradient: (text: unknown, stops: string[] | null | undefined, opts
622
622
  * }
623
623
  * ```
624
624
  */
625
- declare const createGradient: (stops: string[] | null | undefined, defaultOpts?: Omit<GradientOptions, "phase">) => ((text: unknown, opts?: GradientOptions) => string);
625
+ /**
626
+ * The function returned by `createGradient()`. Callable just like `gradient()`,
627
+ * but also exposes metadata for inspection and chaining.
628
+ */
629
+ interface ReusableGradient {
630
+ /** Apply the gradient to text. */
631
+ (text: unknown, opts?: GradientOptions): string;
632
+ /** The original hex stops that were passed to `createGradient()`. */
633
+ readonly stops: readonly string[];
634
+ /** The resolved RGB stops (after filtering invalid hex). */
635
+ readonly resolvedStops: readonly Readonly<RGB>[];
636
+ /** Default options frozen at factory time. */
637
+ readonly defaultOptions: Readonly<Omit<GradientOptions, 'phase'>>;
638
+ }
639
+ declare const createGradient: (stops: string[] | null | undefined, defaultOpts?: Omit<GradientOptions, "phase">) => ReusableGradient;
640
+ /**
641
+ * Return a new gradient with the stops reversed. Useful for symmetric
642
+ * effects (e.g. fade in / fade out) or to flip an existing palette.
643
+ *
644
+ * Accepts either:
645
+ * - A `ReusableGradient` returned from `createGradient()` — returns a new one
646
+ * - An array of hex stops — returns a new array with the order flipped
647
+ *
648
+ * @example
649
+ * ```ts
650
+ * const fire = createGradient(['#ff5555', '#ffb86c', '#f1fa8c']);
651
+ * const ice = reverseGradient(fire); // ReusableGradient with reversed stops
652
+ *
653
+ * console.log(fire('warm side'));
654
+ * console.log(ice('cool side'));
655
+ * ```
656
+ *
657
+ * @example with plain stops
658
+ * ```ts
659
+ * const stops = ['#ff0000', '#00ff00', '#0000ff'];
660
+ * const reversed = reverseGradient(stops);
661
+ * // → ['#0000ff', '#00ff00', '#ff0000']
662
+ * ```
663
+ */
664
+ declare function reverseGradient(grad: ReusableGradient): ReusableGradient;
665
+ declare function reverseGradient(stops: string[]): string[];
626
666
  declare const rainbow: ColorFn;
627
667
  interface AnimateGradientOptions {
628
668
  /** Total animation duration in ms. Default `2000`. */
@@ -1767,4 +1807,4 @@ declare const ansimax: {
1767
1807
  configure: (opts?: AnsimaxConfig, meta?: ConfigureOptions) => void;
1768
1808
  };
1769
1809
 
1770
- 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, createGradient, 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 };
1810
+ 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 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$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, createGradient, 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, presets, rainbow, registerFont, registerPreset, renderPixelArt, renderTree, renderTreeStream, repeatVisible, requestTerminalFrame, reset, resetColorSupportCache, resetConfig, resetCursorRefCount, resetFramesCursorCount, resetLoaderCursorCount, resetNoColor, resumeListeners, reverseGradient, 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
@@ -622,7 +622,47 @@ declare const gradient: (text: unknown, stops: string[] | null | undefined, opts
622
622
  * }
623
623
  * ```
624
624
  */
625
- declare const createGradient: (stops: string[] | null | undefined, defaultOpts?: Omit<GradientOptions, "phase">) => ((text: unknown, opts?: GradientOptions) => string);
625
+ /**
626
+ * The function returned by `createGradient()`. Callable just like `gradient()`,
627
+ * but also exposes metadata for inspection and chaining.
628
+ */
629
+ interface ReusableGradient {
630
+ /** Apply the gradient to text. */
631
+ (text: unknown, opts?: GradientOptions): string;
632
+ /** The original hex stops that were passed to `createGradient()`. */
633
+ readonly stops: readonly string[];
634
+ /** The resolved RGB stops (after filtering invalid hex). */
635
+ readonly resolvedStops: readonly Readonly<RGB>[];
636
+ /** Default options frozen at factory time. */
637
+ readonly defaultOptions: Readonly<Omit<GradientOptions, 'phase'>>;
638
+ }
639
+ declare const createGradient: (stops: string[] | null | undefined, defaultOpts?: Omit<GradientOptions, "phase">) => ReusableGradient;
640
+ /**
641
+ * Return a new gradient with the stops reversed. Useful for symmetric
642
+ * effects (e.g. fade in / fade out) or to flip an existing palette.
643
+ *
644
+ * Accepts either:
645
+ * - A `ReusableGradient` returned from `createGradient()` — returns a new one
646
+ * - An array of hex stops — returns a new array with the order flipped
647
+ *
648
+ * @example
649
+ * ```ts
650
+ * const fire = createGradient(['#ff5555', '#ffb86c', '#f1fa8c']);
651
+ * const ice = reverseGradient(fire); // ReusableGradient with reversed stops
652
+ *
653
+ * console.log(fire('warm side'));
654
+ * console.log(ice('cool side'));
655
+ * ```
656
+ *
657
+ * @example with plain stops
658
+ * ```ts
659
+ * const stops = ['#ff0000', '#00ff00', '#0000ff'];
660
+ * const reversed = reverseGradient(stops);
661
+ * // → ['#0000ff', '#00ff00', '#ff0000']
662
+ * ```
663
+ */
664
+ declare function reverseGradient(grad: ReusableGradient): ReusableGradient;
665
+ declare function reverseGradient(stops: string[]): string[];
626
666
  declare const rainbow: ColorFn;
627
667
  interface AnimateGradientOptions {
628
668
  /** Total animation duration in ms. Default `2000`. */
@@ -1767,4 +1807,4 @@ declare const ansimax: {
1767
1807
  configure: (opts?: AnsimaxConfig, meta?: ConfigureOptions) => void;
1768
1808
  };
1769
1809
 
1770
- 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, createGradient, 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 };
1810
+ 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 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$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, createGradient, 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, presets, rainbow, registerFont, registerPreset, renderPixelArt, renderTree, renderTreeStream, repeatVisible, requestTerminalFrame, reset, resetColorSupportCache, resetConfig, resetCursorRefCount, resetFramesCursorCount, resetLoaderCursorCount, resetNoColor, resumeListeners, reverseGradient, 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
@@ -120,6 +120,7 @@ __export(index_exports, {
120
120
  padStart: () => padStart,
121
121
  pauseListeners: () => pauseListeners,
122
122
  presetNames: () => presetNames,
123
+ presets: () => presets,
123
124
  rainbow: () => rainbow,
124
125
  registerFont: () => registerFont,
125
126
  registerPreset: () => registerPreset,
@@ -136,6 +137,7 @@ __export(index_exports, {
136
137
  resetLoaderCursorCount: () => resetLoaderCursorCount,
137
138
  resetNoColor: () => resetNoColor,
138
139
  resumeListeners: () => resumeListeners,
140
+ reverseGradient: () => reverseGradient,
139
141
  rgbTo256: () => rgbTo256,
140
142
  rgbToHex: () => rgbToHex,
141
143
  rotate90: () => rotate90,
@@ -1167,10 +1169,11 @@ var gradient = (text, stops, opts = {}) => {
1167
1169
  return _gradientAnsiAware(s, colors, easingFn, phaseN);
1168
1170
  };
1169
1171
  var createGradient = (stops, defaultOpts = {}) => {
1170
- const colors = Array.isArray(stops) ? stops.map(safeHex).filter((c) => c !== null) : [];
1172
+ const originalStops = Array.isArray(stops) ? [...stops] : [];
1173
+ const colors = originalStops.map(safeHex).filter((c) => c !== null);
1171
1174
  const defaultEasingFn = resolveEasing(defaultOpts.easing);
1172
1175
  const defaultPreserveAnsi = defaultOpts.preserveAnsi ?? false;
1173
- return (text, opts = {}) => {
1176
+ const fn = ((text, opts = {}) => {
1174
1177
  const s = coerceText(text);
1175
1178
  if (!s || isNoColor()) return s;
1176
1179
  if (colors.length === 0) return s;
@@ -1186,8 +1189,31 @@ var createGradient = (stops, defaultOpts = {}) => {
1186
1189
  return _gradientPlain(s, colors, easingFn, phaseN);
1187
1190
  }
1188
1191
  return _gradientAnsiAware(s, colors, easingFn, phaseN);
1189
- };
1192
+ });
1193
+ Object.defineProperty(fn, "stops", {
1194
+ value: Object.freeze(originalStops),
1195
+ enumerable: true,
1196
+ writable: false
1197
+ });
1198
+ Object.defineProperty(fn, "resolvedStops", {
1199
+ value: Object.freeze(colors.map((c) => Object.freeze({ ...c }))),
1200
+ enumerable: true,
1201
+ writable: false
1202
+ });
1203
+ Object.defineProperty(fn, "defaultOptions", {
1204
+ value: Object.freeze({ ...defaultOpts }),
1205
+ enumerable: true,
1206
+ writable: false
1207
+ });
1208
+ return fn;
1190
1209
  };
1210
+ function reverseGradient(input) {
1211
+ if (Array.isArray(input)) {
1212
+ return [...input].reverse();
1213
+ }
1214
+ const reversedStops = [...input.stops].reverse();
1215
+ return createGradient(reversedStops, input.defaultOptions);
1216
+ }
1191
1217
  var _gradientPlain = (text, colors, easingFn, phase) => {
1192
1218
  const chars = [...text];
1193
1219
  const visible = chars.filter((c) => c !== " ").length;
@@ -5560,6 +5586,7 @@ var index_default = ansimax;
5560
5586
  padStart,
5561
5587
  pauseListeners,
5562
5588
  presetNames,
5589
+ presets,
5563
5590
  rainbow,
5564
5591
  registerFont,
5565
5592
  registerPreset,
@@ -5576,6 +5603,7 @@ var index_default = ansimax;
5576
5603
  resetLoaderCursorCount,
5577
5604
  resetNoColor,
5578
5605
  resumeListeners,
5606
+ reverseGradient,
5579
5607
  rgbTo256,
5580
5608
  rgbToHex,
5581
5609
  rotate90,
package/dist/index.mjs CHANGED
@@ -993,10 +993,11 @@ var gradient = (text, stops, opts = {}) => {
993
993
  return _gradientAnsiAware(s, colors, easingFn, phaseN);
994
994
  };
995
995
  var createGradient = (stops, defaultOpts = {}) => {
996
- const colors = Array.isArray(stops) ? stops.map(safeHex).filter((c) => c !== null) : [];
996
+ const originalStops = Array.isArray(stops) ? [...stops] : [];
997
+ const colors = originalStops.map(safeHex).filter((c) => c !== null);
997
998
  const defaultEasingFn = resolveEasing(defaultOpts.easing);
998
999
  const defaultPreserveAnsi = defaultOpts.preserveAnsi ?? false;
999
- return (text, opts = {}) => {
1000
+ const fn = ((text, opts = {}) => {
1000
1001
  const s = coerceText(text);
1001
1002
  if (!s || isNoColor()) return s;
1002
1003
  if (colors.length === 0) return s;
@@ -1012,8 +1013,31 @@ var createGradient = (stops, defaultOpts = {}) => {
1012
1013
  return _gradientPlain(s, colors, easingFn, phaseN);
1013
1014
  }
1014
1015
  return _gradientAnsiAware(s, colors, easingFn, phaseN);
1015
- };
1016
+ });
1017
+ Object.defineProperty(fn, "stops", {
1018
+ value: Object.freeze(originalStops),
1019
+ enumerable: true,
1020
+ writable: false
1021
+ });
1022
+ Object.defineProperty(fn, "resolvedStops", {
1023
+ value: Object.freeze(colors.map((c) => Object.freeze({ ...c }))),
1024
+ enumerable: true,
1025
+ writable: false
1026
+ });
1027
+ Object.defineProperty(fn, "defaultOptions", {
1028
+ value: Object.freeze({ ...defaultOpts }),
1029
+ enumerable: true,
1030
+ writable: false
1031
+ });
1032
+ return fn;
1016
1033
  };
1034
+ function reverseGradient(input) {
1035
+ if (Array.isArray(input)) {
1036
+ return [...input].reverse();
1037
+ }
1038
+ const reversedStops = [...input.stops].reverse();
1039
+ return createGradient(reversedStops, input.defaultOptions);
1040
+ }
1017
1041
  var _gradientPlain = (text, colors, easingFn, phase) => {
1018
1042
  const chars = [...text];
1019
1043
  const visible = chars.filter((c) => c !== " ").length;
@@ -5386,6 +5410,7 @@ export {
5386
5410
  padStart,
5387
5411
  pauseListeners,
5388
5412
  presetNames,
5413
+ presets,
5389
5414
  rainbow,
5390
5415
  registerFont,
5391
5416
  registerPreset,
@@ -5402,6 +5427,7 @@ export {
5402
5427
  resetLoaderCursorCount,
5403
5428
  resetNoColor,
5404
5429
  resumeListeners,
5430
+ reverseGradient,
5405
5431
  rgbTo256,
5406
5432
  rgbToHex,
5407
5433
  rotate90,
@@ -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.2.3'),
121
+ components.badge('VERSION', 'v1.2.4'),
122
122
  components.badge('BUILD', 'passing'),
123
123
  components.badge('LICENSE', 'Apache 2.0'));
124
124
  console.log();
@@ -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.2.3'),
120
+ components.badge('VERSION', 'v1.2.4'),
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.2.3",
3
+ "version": "1.2.4",
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",