ansimax 1.3.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,128 @@
3
3
  All notable changes to **ansimax** are documented in this file.
4
4
  This project follows [Semantic Versioning](https://semver.org/).
5
5
 
6
+ ## [1.3.1] — Polish for panels + json
7
+
8
+ Patch release improving the two modules introduced in v1.3.0 — adds layout
9
+ helpers, JSON readability options, and tests. No breaking changes.
10
+
11
+ ### Added — `panels.center(block, opts)`
12
+
13
+ Center a multi-line block horizontally (and optionally vertically) within
14
+ a fixed width/height. Useful for centering boxes, banners, or any pre-rendered
15
+ block in a known terminal width.
16
+
17
+ ```js
18
+ import { panels, ascii } from 'ansimax';
19
+
20
+ // Horizontal centering only
21
+ console.log(panels.center('Hello!', { width: 30 }));
22
+ // " Hello! "
23
+
24
+ // Vertical too — content fits in 5 rows
25
+ console.log(panels.center('X', { width: 5, height: 5, align: 'center' }));
26
+
27
+ // Combine with box for a centered card
28
+ console.log(panels.center(ascii.box('Hello'), { width: 80 }));
29
+ ```
30
+
31
+ Exported as `centerBlock` from the main barrel (to avoid colliding with the
32
+ existing `center` text helper). The namespaced form `panels.center` works
33
+ identically.
34
+
35
+ ### Added — `panels.frame(block, opts)`
36
+
37
+ Lighter alternative to `ascii.box`: draws only top/bottom decorative rules
38
+ (not full sides). Supports a centered title, padding, and custom characters.
39
+
40
+ ```js
41
+ import { panels } from 'ansimax';
42
+
43
+ // Simple rules
44
+ console.log(panels.frame('Hello world!'));
45
+ // ─────────────
46
+ // Hello world!
47
+ // ─────────────
48
+
49
+ // With title + padding
50
+ console.log(panels.frame('Body content\nMore content', {
51
+ title: 'Header',
52
+ padding: 1,
53
+ }));
54
+ // ───── Header ─────
55
+ //
56
+ // Body content
57
+ // More content
58
+ //
59
+ // ──────────────────
60
+
61
+ // Custom decoration chars
62
+ console.log(panels.frame('Important!', {
63
+ topChar: '═',
64
+ padding: 2,
65
+ }));
66
+ ```
67
+
68
+ ### Added — `json.pretty` option `sortKeys`
69
+
70
+ Sort object keys alphabetically for deterministic output. Useful for diffs,
71
+ snapshots, and visual scanning of large objects.
72
+
73
+ ```js
74
+ import { json } from 'ansimax';
75
+
76
+ console.log(json.pretty({ zebra: 1, apple: 2, mango: 3 }, { sortKeys: true }));
77
+ // {
78
+ // "apple": 2,
79
+ // "mango": 3,
80
+ // "zebra": 1
81
+ // }
82
+ ```
83
+
84
+ Recursive — applies to all nested objects. Default `false` (preserves
85
+ insertion order).
86
+
87
+ ### Added — `json.pretty` option `inlineArrayMaxLength`
88
+
89
+ Arrays of primitives now render on a single line when their rendered length
90
+ is short enough (default threshold: 60 visible characters). This improves
91
+ readability significantly for typical configs:
92
+
93
+ ```js
94
+ // Before v1.3.1:
95
+ {
96
+ "tags": [
97
+ "frontend",
98
+ "react",
99
+ "typescript"
100
+ ]
101
+ }
102
+
103
+ // In v1.3.1 (default behavior):
104
+ {
105
+ "tags": ["frontend", "react", "typescript"]
106
+ }
107
+ ```
108
+
109
+ Arrays containing objects/arrays never inline regardless of length. Set
110
+ `inlineArrayMaxLength: 0` to restore the v1.3.0 always-expand behavior.
111
+
112
+ ### Improved — Tests
113
+
114
+ - `+11` tests for `panels.center` + `panels.frame`
115
+ - `+15` tests for `json.pretty` `sortKeys` + `inlineArrayMaxLength`
116
+ - Total tests: 2,000+ → **~2,026** across 18 suites
117
+
118
+ ### Notes
119
+
120
+ - No runtime dependencies — still zero
121
+ - No breaking changes — drop-in replacement for `1.3.0`
122
+ - `panels.center` is exposed as `centerBlock` at the top level to avoid
123
+ conflict with the existing `center` text helper; both `panels.center` and
124
+ `centerBlock` reference the same function
125
+
126
+ ---
127
+
6
128
  ## [1.3.0] — Phase 4 progress: Panels + JSON pretty-print
7
129
 
8
130
  Minor release adding **split layout primitives** and **JSON pretty-printing**.
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.3.0-cb3837.svg?style=flat-square)](https://www.npmjs.com/package/ansimax)
10
+ [![npm](https://img.shields.io/badge/npm-v1.3.1-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-2000%2B%20passing-brightgreen.svg?style=flat-square)](#testing)
@@ -445,7 +445,7 @@ console.log(components.table([
445
445
  ['loaders', color.green('● listo'), '100%'],
446
446
  ], { borderStyle: 'rounded' }));
447
447
 
448
- console.log(components.badge('VERSION', 'v1.3.0'));
448
+ console.log(components.badge('VERSION', 'v1.3.1'));
449
449
  console.log(components.badge('BUILD', 'passing'));
450
450
  ```
451
451
 
@@ -1006,6 +1006,35 @@ ansimax/
1006
1006
 
1007
1007
  ## 📝 Changelog
1008
1008
 
1009
+ ### v1.3.1 — Pulido de panels + json
1010
+
1011
+ Release patch que mejora los módulos de v1.3.0 con quality-of-life:
1012
+
1013
+ - 🎯 **`panels.center(block, opts)`** — centra un block horizontalmente (y opcionalmente verticalmente) en un ancho conocido
1014
+ - 🖼️ **`panels.frame(block, opts)`** — alternativa más ligera a `ascii.box`: solo top/bottom con title + padding opcionales
1015
+ - 📋 **`json.pretty` opción `sortKeys`** — orden alfabético de keys para diffs deterministas
1016
+ - 📐 **`json.pretty` opción `inlineArrayMaxLength`** — arrays cortos de primitivos ahora se renderizan como `[1, 2, 3]` en una línea (threshold default: 60 chars)
1017
+ - 🧪 **+26 tests** entre panels + json
1018
+
1019
+ ```js
1020
+ import { panels, json } from 'ansimax';
1021
+
1022
+ // Centrar un box dentro de la terminal
1023
+ console.log(panels.center(ascii.box('Hello'), { width: 80 }));
1024
+
1025
+ // Frame decorativo más ligero
1026
+ console.log(panels.frame('Body', { title: 'Header', padding: 1 }));
1027
+
1028
+ // Sorted, con inline arrays
1029
+ console.log(json.pretty({ zebra: [1, 2, 3], apple: 'A' }, { sortKeys: true }));
1030
+ // {
1031
+ // "apple": "A",
1032
+ // "zebra": [1, 2, 3]
1033
+ // }
1034
+ ```
1035
+
1036
+ Drop-in replacement para `1.3.0`.
1037
+
1009
1038
  ### v1.3.0 — Avance Fase 4: Panels + JSON pretty-print
1010
1039
 
1011
1040
  Release minor que añade dos nuevos módulos top-level — split layouts y pretty-print de JSON:
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.3.0-cb3837.svg?style=flat-square)](https://www.npmjs.com/package/ansimax)
10
+ [![npm](https://img.shields.io/badge/npm-v1.3.1-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-2000%2B%20passing-brightgreen.svg?style=flat-square)](#testing)
@@ -445,7 +445,7 @@ console.log(components.table([
445
445
  ['loaders', color.green('● ready'), '100%'],
446
446
  ], { borderStyle: 'rounded' }));
447
447
 
448
- console.log(components.badge('VERSION', 'v1.3.0'));
448
+ console.log(components.badge('VERSION', 'v1.3.1'));
449
449
  console.log(components.badge('BUILD', 'passing'));
450
450
  ```
451
451
 
@@ -1006,6 +1006,35 @@ ansimax/
1006
1006
 
1007
1007
  ## 📝 Changelog
1008
1008
 
1009
+ ### v1.3.1 — Polish for panels + json
1010
+
1011
+ Patch release improving the modules from v1.3.0 with quality-of-life additions:
1012
+
1013
+ - 🎯 **`panels.center(block, opts)`** — center a block horizontally (and optionally vertically) in a known width
1014
+ - 🖼️ **`panels.frame(block, opts)`** — lighter alternative to `ascii.box`: top/bottom rules only, with optional title + padding
1015
+ - 📋 **`json.pretty` option `sortKeys`** — alphabetic key order for deterministic diffs
1016
+ - 📐 **`json.pretty` option `inlineArrayMaxLength`** — short arrays of primitives now render as `[1, 2, 3]` on one line (default threshold: 60 chars)
1017
+ - 🧪 **+26 tests** across panels + json modules
1018
+
1019
+ ```js
1020
+ import { panels, json } from 'ansimax';
1021
+
1022
+ // Center a box inside the terminal
1023
+ console.log(panels.center(ascii.box('Hello'), { width: 80 }));
1024
+
1025
+ // Lighter decorative frame
1026
+ console.log(panels.frame('Body', { title: 'Header', padding: 1 }));
1027
+
1028
+ // Sorted, with inline arrays
1029
+ console.log(json.pretty({ zebra: [1, 2, 3], apple: 'A' }, { sortKeys: true }));
1030
+ // {
1031
+ // "apple": "A",
1032
+ // "zebra": [1, 2, 3]
1033
+ // }
1034
+ ```
1035
+
1036
+ Drop-in replacement for `1.3.0`.
1037
+
1009
1038
  ### v1.3.0 — Phase 4 progress: Panels + JSON pretty-print
1010
1039
 
1011
1040
  Minor release adding two new top-level modules — split layouts and JSON pretty-printing:
package/dist/index.d.mts CHANGED
@@ -359,7 +359,7 @@ declare const sliceAnsi: (str: string, start: number, end?: number) => string;
359
359
  declare const truncateAnsi: (str: string, width: number, ellipsis?: string) => string;
360
360
  declare const padEnd: (str: string, width: number, ch?: string) => string;
361
361
  declare const padStart: (str: string, width: number, ch?: string) => string;
362
- declare const center: (str: string, width: number, ch?: string) => string;
362
+ declare const center$1: (str: string, width: number, ch?: string) => string;
363
363
  /** Repeats a string until its visible length reaches the target width. */
364
364
  declare const repeatVisible: (str: string, width: number) => string;
365
365
  /**
@@ -2028,9 +2028,120 @@ declare const vsplit: (blocks: string[], opts?: VsplitOptions) => string;
2028
2028
  * ```
2029
2029
  */
2030
2030
  declare const hsplit: (blocks: string[], opts?: HsplitOptions) => string;
2031
+ interface CenterOptions {
2032
+ /** Total width to center within. Required. */
2033
+ width: number;
2034
+ /**
2035
+ * Vertical alignment if `height` is also specified.
2036
+ * Default `'start'`.
2037
+ */
2038
+ align?: Alignment;
2039
+ /**
2040
+ * Total height to fit the block into. Optional — if omitted, only
2041
+ * horizontal centering is applied.
2042
+ */
2043
+ height?: number;
2044
+ }
2045
+ /**
2046
+ * Center a multi-line block horizontally (and optionally vertically)
2047
+ * within a given width/height. Each line is padded with spaces on both
2048
+ * sides; ANSI escapes are preserved.
2049
+ *
2050
+ * @example horizontal centering only
2051
+ * ```js
2052
+ * import { panels } from 'ansimax';
2053
+ *
2054
+ * console.log(panels.center('Hello!', { width: 30 }));
2055
+ * // " Hello! "
2056
+ * ```
2057
+ *
2058
+ * @example multi-line centered in a fixed area
2059
+ * ```js
2060
+ * console.log(panels.center('Line 1\nLine 2\nLine 3', {
2061
+ * width: 30,
2062
+ * height: 7,
2063
+ * align: 'center',
2064
+ * }));
2065
+ * ```
2066
+ *
2067
+ * @example combined with box for a centered card
2068
+ * ```js
2069
+ * import { ascii, panels } from 'ansimax';
2070
+ *
2071
+ * console.log(panels.center(ascii.box('Hello'), { width: 80 }));
2072
+ * // Box appears centered in a 80-wide terminal
2073
+ * ```
2074
+ */
2075
+ declare const center: (block: string, opts: CenterOptions) => string;
2076
+ interface FrameOptions {
2077
+ /**
2078
+ * Padding (in spaces) between the block content and the inner edge of
2079
+ * the frame. Default `0`.
2080
+ */
2081
+ padding?: number;
2082
+ /**
2083
+ * Padding above + below the block. If unset, falls back to `padding`.
2084
+ */
2085
+ paddingY?: number;
2086
+ /**
2087
+ * Padding left + right of the block. If unset, falls back to `padding`.
2088
+ */
2089
+ paddingX?: number;
2090
+ /**
2091
+ * Top decoration character — e.g. `'─'`, `'═'`, `'━'`, `'·'`.
2092
+ * Default `'─'`.
2093
+ */
2094
+ topChar?: string;
2095
+ /**
2096
+ * Bottom decoration character. Default same as `topChar`.
2097
+ */
2098
+ bottomChar?: string;
2099
+ /**
2100
+ * Optional title shown centered in the top edge.
2101
+ */
2102
+ title?: string;
2103
+ }
2104
+ /**
2105
+ * Add decorative top/bottom rule lines around a block (lighter than `ascii.box`
2106
+ * which draws four sides). Useful for visual separation without full borders.
2107
+ *
2108
+ * @example simple top/bottom rules
2109
+ * ```js
2110
+ * console.log(panels.frame('Hello world!'));
2111
+ * // ─────────────
2112
+ * // Hello world!
2113
+ * // ─────────────
2114
+ * ```
2115
+ *
2116
+ * @example with title and padding
2117
+ * ```js
2118
+ * console.log(panels.frame('Body content\nMore content', {
2119
+ * title: 'Header',
2120
+ * padding: 1,
2121
+ * }));
2122
+ * // ───── Header ─────
2123
+ * //
2124
+ * // Body content
2125
+ * // More content
2126
+ * //
2127
+ * // ──────────────────
2128
+ * ```
2129
+ *
2130
+ * @example custom decorations
2131
+ * ```js
2132
+ * console.log(panels.frame('Important!', {
2133
+ * topChar: '═',
2134
+ * bottomChar: '═',
2135
+ * padding: 2,
2136
+ * }));
2137
+ * ```
2138
+ */
2139
+ declare const frame: (block: string, opts?: FrameOptions) => string;
2031
2140
  declare const panels: {
2032
2141
  vsplit: (blocks: string[], opts?: VsplitOptions) => string;
2033
2142
  hsplit: (blocks: string[], opts?: HsplitOptions) => string;
2143
+ center: (block: string, opts: CenterOptions) => string;
2144
+ frame: (block: string, opts?: FrameOptions) => string;
2034
2145
  };
2035
2146
 
2036
2147
  /**
@@ -2071,6 +2182,23 @@ interface PrettyOptions {
2071
2182
  * Maximum string length before truncation with ellipsis. Default `Infinity`.
2072
2183
  */
2073
2184
  maxStringLength?: number;
2185
+ /**
2186
+ * Sort object keys alphabetically. Useful for deterministic diffs (e.g.,
2187
+ * comparing two JSON snapshots) and for visual scanning of large objects.
2188
+ * Default `false` (insertion order preserved).
2189
+ *
2190
+ * @since 1.3.1
2191
+ */
2192
+ sortKeys?: boolean;
2193
+ /**
2194
+ * Arrays of primitives shorter than this character width (in their
2195
+ * rendered form) are displayed on a single line: `[1, 2, 3]` instead of
2196
+ * three lines. Nested objects/arrays never inline regardless of size.
2197
+ * Set to `0` to disable inlining. Default `60`.
2198
+ *
2199
+ * @since 1.3.1
2200
+ */
2201
+ inlineArrayMaxLength?: number;
2074
2202
  }
2075
2203
  /**
2076
2204
  * Pretty-print a JavaScript value with colored output suitable for
@@ -2288,4 +2416,4 @@ declare const ansimax: {
2288
2416
  configure: (opts?: AnsimaxConfig, meta?: ConfigureOptions) => void;
2289
2417
  };
2290
2418
 
2291
- export { ASCII_RAMPS, type Alignment, type AnimateGradientController, type AnimateGradientOptions, type AnimationHooks, type AnimationSpeed, type AnsiCode, type AnsimaxConfig, type AsciiRamp, BEL, BG, type BadgeOptions, type BallOptions, type BannerOptions, type BoxOptions, type BoxStyle, type BreatheOptions, DEFAULTS as CONFIG_DEFAULTS, CSI, type Canvas, type CanvasRenderOptions, type 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 FigletFont, type FigletOptions, type FontMap, type FontName, type FrameCallback, type FrameHandle, type FromImageOptions, type GlitchOptions, type Glyph, type GradientOptions, type GradientRectOptions, type HsplitOptions, type PrettyOptions as JsonPrettyOptions, 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$1 as RenderOptions, type ResizeListener, type ReusableGradient, type RevealOptions, SPINNERS, SPRITES, ST, STYLE, type SectionOptions, type SleepOptions, type SlideOptions, type SpinOptions, type SpinnerType, type StatusOptions, type StatusType, type StopFn, type StreamOptions, type TableBorderStyle, type TableOptions, type Task, type TaskResult, type TasksOptions, type Theme, type BannerOpts as ThemeBannerOpts, type ThemeChangeListener, type ThemeInstance, type ThemeStyleName, type TimelineEvent, type TimelineOptions, type TreeData, type TreeDimensions, type TreeNode, type RenderOptions as TreeRenderOptions, type TreeStyle, type TypeDeleteOptions, type TypewriterOptions, type VsplitOptions, type WalkVisitor, type WaveOptions, type WriteAsyncOptions, animate, animateGradient, ascii, bell, bg256, bgRgb, box, canAnimate, cancelTerminalFrame, center, 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, figletText, filterTree, findInTree, flipHorizontal, flipVertical, frames, fromImage, getConfig, getConfigValue, getRenderCacheSize, getSpeedMultiplier, getTerminalHeight, getTerminalWidth, gradient, gradientColor, gradientRect, graphemes, hasFont, hexToRgb, hideCursor, hsplit, images, isHexColor, isNoColor, json, pretty as jsonPretty, lerp, lerpColor, link, listFonts, listPresets, loader, mapTree, measureTree, memoize, nextTick, onConfigChange, onConfigKeyChange, onResize, once, padBoth, padEnd, padStart, panels, parseFiglet, 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, vsplit, walkTree, withConfig, wordWrap, wrapAnsi, write, writeAsync, writeErr, writeln, writelnErr };
2419
+ export { ASCII_RAMPS, type Alignment, type AnimateGradientController, type AnimateGradientOptions, type AnimationHooks, type AnimationSpeed, type AnsiCode, type AnsimaxConfig, type AsciiRamp, BEL, BG, type BadgeOptions, type BallOptions, type BannerOptions, type BoxOptions, type BoxStyle, type BreatheOptions, DEFAULTS as CONFIG_DEFAULTS, CSI, type Canvas, type CanvasRenderOptions, type CenterOptions, type ColorChain, type ColorFn, type ColorLevel, type ColorMode, type 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 FigletFont, type FigletOptions, type FontMap, type FontName, type FrameCallback, type FrameHandle, type FrameOptions, type FromImageOptions, type GlitchOptions, type Glyph, type GradientOptions, type GradientRectOptions, type HsplitOptions, type PrettyOptions as JsonPrettyOptions, 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$1 as RenderOptions, type ResizeListener, type ReusableGradient, type RevealOptions, SPINNERS, SPRITES, ST, STYLE, type SectionOptions, type SleepOptions, type SlideOptions, type SpinOptions, type SpinnerType, type StatusOptions, type StatusType, type StopFn, type StreamOptions, type TableBorderStyle, type TableOptions, type Task, type TaskResult, type TasksOptions, type Theme, type BannerOpts as ThemeBannerOpts, type ThemeChangeListener, type ThemeInstance, type ThemeStyleName, type TimelineEvent, type TimelineOptions, type TreeData, type TreeDimensions, type TreeNode, type RenderOptions as TreeRenderOptions, type TreeStyle, type TypeDeleteOptions, type TypewriterOptions, type VsplitOptions, type WalkVisitor, type WaveOptions, type WriteAsyncOptions, animate, animateGradient, ascii, bell, bg256, bgRgb, box, canAnimate, cancelTerminalFrame, center$1 as center, center as centerBlock, chain, charWidth, clamp, 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, figletText, filterTree, findInTree, flipHorizontal, flipVertical, frame, frames, fromImage, getConfig, getConfigValue, getRenderCacheSize, getSpeedMultiplier, getTerminalHeight, getTerminalWidth, gradient, gradientColor, gradientRect, graphemes, hasFont, hexToRgb, hideCursor, hsplit, images, isHexColor, isNoColor, json, pretty as jsonPretty, lerp, lerpColor, link, listFonts, listPresets, loader, mapTree, measureTree, memoize, nextTick, onConfigChange, onConfigKeyChange, onResize, once, padBoth, padEnd, padStart, panels, parseFiglet, 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, vsplit, walkTree, withConfig, wordWrap, wrapAnsi, write, writeAsync, writeErr, writeln, writelnErr };
package/dist/index.d.ts CHANGED
@@ -359,7 +359,7 @@ declare const sliceAnsi: (str: string, start: number, end?: number) => string;
359
359
  declare const truncateAnsi: (str: string, width: number, ellipsis?: string) => string;
360
360
  declare const padEnd: (str: string, width: number, ch?: string) => string;
361
361
  declare const padStart: (str: string, width: number, ch?: string) => string;
362
- declare const center: (str: string, width: number, ch?: string) => string;
362
+ declare const center$1: (str: string, width: number, ch?: string) => string;
363
363
  /** Repeats a string until its visible length reaches the target width. */
364
364
  declare const repeatVisible: (str: string, width: number) => string;
365
365
  /**
@@ -2028,9 +2028,120 @@ declare const vsplit: (blocks: string[], opts?: VsplitOptions) => string;
2028
2028
  * ```
2029
2029
  */
2030
2030
  declare const hsplit: (blocks: string[], opts?: HsplitOptions) => string;
2031
+ interface CenterOptions {
2032
+ /** Total width to center within. Required. */
2033
+ width: number;
2034
+ /**
2035
+ * Vertical alignment if `height` is also specified.
2036
+ * Default `'start'`.
2037
+ */
2038
+ align?: Alignment;
2039
+ /**
2040
+ * Total height to fit the block into. Optional — if omitted, only
2041
+ * horizontal centering is applied.
2042
+ */
2043
+ height?: number;
2044
+ }
2045
+ /**
2046
+ * Center a multi-line block horizontally (and optionally vertically)
2047
+ * within a given width/height. Each line is padded with spaces on both
2048
+ * sides; ANSI escapes are preserved.
2049
+ *
2050
+ * @example horizontal centering only
2051
+ * ```js
2052
+ * import { panels } from 'ansimax';
2053
+ *
2054
+ * console.log(panels.center('Hello!', { width: 30 }));
2055
+ * // " Hello! "
2056
+ * ```
2057
+ *
2058
+ * @example multi-line centered in a fixed area
2059
+ * ```js
2060
+ * console.log(panels.center('Line 1\nLine 2\nLine 3', {
2061
+ * width: 30,
2062
+ * height: 7,
2063
+ * align: 'center',
2064
+ * }));
2065
+ * ```
2066
+ *
2067
+ * @example combined with box for a centered card
2068
+ * ```js
2069
+ * import { ascii, panels } from 'ansimax';
2070
+ *
2071
+ * console.log(panels.center(ascii.box('Hello'), { width: 80 }));
2072
+ * // Box appears centered in a 80-wide terminal
2073
+ * ```
2074
+ */
2075
+ declare const center: (block: string, opts: CenterOptions) => string;
2076
+ interface FrameOptions {
2077
+ /**
2078
+ * Padding (in spaces) between the block content and the inner edge of
2079
+ * the frame. Default `0`.
2080
+ */
2081
+ padding?: number;
2082
+ /**
2083
+ * Padding above + below the block. If unset, falls back to `padding`.
2084
+ */
2085
+ paddingY?: number;
2086
+ /**
2087
+ * Padding left + right of the block. If unset, falls back to `padding`.
2088
+ */
2089
+ paddingX?: number;
2090
+ /**
2091
+ * Top decoration character — e.g. `'─'`, `'═'`, `'━'`, `'·'`.
2092
+ * Default `'─'`.
2093
+ */
2094
+ topChar?: string;
2095
+ /**
2096
+ * Bottom decoration character. Default same as `topChar`.
2097
+ */
2098
+ bottomChar?: string;
2099
+ /**
2100
+ * Optional title shown centered in the top edge.
2101
+ */
2102
+ title?: string;
2103
+ }
2104
+ /**
2105
+ * Add decorative top/bottom rule lines around a block (lighter than `ascii.box`
2106
+ * which draws four sides). Useful for visual separation without full borders.
2107
+ *
2108
+ * @example simple top/bottom rules
2109
+ * ```js
2110
+ * console.log(panels.frame('Hello world!'));
2111
+ * // ─────────────
2112
+ * // Hello world!
2113
+ * // ─────────────
2114
+ * ```
2115
+ *
2116
+ * @example with title and padding
2117
+ * ```js
2118
+ * console.log(panels.frame('Body content\nMore content', {
2119
+ * title: 'Header',
2120
+ * padding: 1,
2121
+ * }));
2122
+ * // ───── Header ─────
2123
+ * //
2124
+ * // Body content
2125
+ * // More content
2126
+ * //
2127
+ * // ──────────────────
2128
+ * ```
2129
+ *
2130
+ * @example custom decorations
2131
+ * ```js
2132
+ * console.log(panels.frame('Important!', {
2133
+ * topChar: '═',
2134
+ * bottomChar: '═',
2135
+ * padding: 2,
2136
+ * }));
2137
+ * ```
2138
+ */
2139
+ declare const frame: (block: string, opts?: FrameOptions) => string;
2031
2140
  declare const panels: {
2032
2141
  vsplit: (blocks: string[], opts?: VsplitOptions) => string;
2033
2142
  hsplit: (blocks: string[], opts?: HsplitOptions) => string;
2143
+ center: (block: string, opts: CenterOptions) => string;
2144
+ frame: (block: string, opts?: FrameOptions) => string;
2034
2145
  };
2035
2146
 
2036
2147
  /**
@@ -2071,6 +2182,23 @@ interface PrettyOptions {
2071
2182
  * Maximum string length before truncation with ellipsis. Default `Infinity`.
2072
2183
  */
2073
2184
  maxStringLength?: number;
2185
+ /**
2186
+ * Sort object keys alphabetically. Useful for deterministic diffs (e.g.,
2187
+ * comparing two JSON snapshots) and for visual scanning of large objects.
2188
+ * Default `false` (insertion order preserved).
2189
+ *
2190
+ * @since 1.3.1
2191
+ */
2192
+ sortKeys?: boolean;
2193
+ /**
2194
+ * Arrays of primitives shorter than this character width (in their
2195
+ * rendered form) are displayed on a single line: `[1, 2, 3]` instead of
2196
+ * three lines. Nested objects/arrays never inline regardless of size.
2197
+ * Set to `0` to disable inlining. Default `60`.
2198
+ *
2199
+ * @since 1.3.1
2200
+ */
2201
+ inlineArrayMaxLength?: number;
2074
2202
  }
2075
2203
  /**
2076
2204
  * Pretty-print a JavaScript value with colored output suitable for
@@ -2288,4 +2416,4 @@ declare const ansimax: {
2288
2416
  configure: (opts?: AnsimaxConfig, meta?: ConfigureOptions) => void;
2289
2417
  };
2290
2418
 
2291
- export { ASCII_RAMPS, type Alignment, type AnimateGradientController, type AnimateGradientOptions, type AnimationHooks, type AnimationSpeed, type AnsiCode, type AnsimaxConfig, type AsciiRamp, BEL, BG, type BadgeOptions, type BallOptions, type BannerOptions, type BoxOptions, type BoxStyle, type BreatheOptions, DEFAULTS as CONFIG_DEFAULTS, CSI, type Canvas, type CanvasRenderOptions, type 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 FigletFont, type FigletOptions, type FontMap, type FontName, type FrameCallback, type FrameHandle, type FromImageOptions, type GlitchOptions, type Glyph, type GradientOptions, type GradientRectOptions, type HsplitOptions, type PrettyOptions as JsonPrettyOptions, 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$1 as RenderOptions, type ResizeListener, type ReusableGradient, type RevealOptions, SPINNERS, SPRITES, ST, STYLE, type SectionOptions, type SleepOptions, type SlideOptions, type SpinOptions, type SpinnerType, type StatusOptions, type StatusType, type StopFn, type StreamOptions, type TableBorderStyle, type TableOptions, type Task, type TaskResult, type TasksOptions, type Theme, type BannerOpts as ThemeBannerOpts, type ThemeChangeListener, type ThemeInstance, type ThemeStyleName, type TimelineEvent, type TimelineOptions, type TreeData, type TreeDimensions, type TreeNode, type RenderOptions as TreeRenderOptions, type TreeStyle, type TypeDeleteOptions, type TypewriterOptions, type VsplitOptions, type WalkVisitor, type WaveOptions, type WriteAsyncOptions, animate, animateGradient, ascii, bell, bg256, bgRgb, box, canAnimate, cancelTerminalFrame, center, 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, figletText, filterTree, findInTree, flipHorizontal, flipVertical, frames, fromImage, getConfig, getConfigValue, getRenderCacheSize, getSpeedMultiplier, getTerminalHeight, getTerminalWidth, gradient, gradientColor, gradientRect, graphemes, hasFont, hexToRgb, hideCursor, hsplit, images, isHexColor, isNoColor, json, pretty as jsonPretty, lerp, lerpColor, link, listFonts, listPresets, loader, mapTree, measureTree, memoize, nextTick, onConfigChange, onConfigKeyChange, onResize, once, padBoth, padEnd, padStart, panels, parseFiglet, 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, vsplit, walkTree, withConfig, wordWrap, wrapAnsi, write, writeAsync, writeErr, writeln, writelnErr };
2419
+ export { ASCII_RAMPS, type Alignment, type AnimateGradientController, type AnimateGradientOptions, type AnimationHooks, type AnimationSpeed, type AnsiCode, type AnsimaxConfig, type AsciiRamp, BEL, BG, type BadgeOptions, type BallOptions, type BannerOptions, type BoxOptions, type BoxStyle, type BreatheOptions, DEFAULTS as CONFIG_DEFAULTS, CSI, type Canvas, type CanvasRenderOptions, type CenterOptions, type ColorChain, type ColorFn, type ColorLevel, type ColorMode, type 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 FigletFont, type FigletOptions, type FontMap, type FontName, type FrameCallback, type FrameHandle, type FrameOptions, type FromImageOptions, type GlitchOptions, type Glyph, type GradientOptions, type GradientRectOptions, type HsplitOptions, type PrettyOptions as JsonPrettyOptions, 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$1 as RenderOptions, type ResizeListener, type ReusableGradient, type RevealOptions, SPINNERS, SPRITES, ST, STYLE, type SectionOptions, type SleepOptions, type SlideOptions, type SpinOptions, type SpinnerType, type StatusOptions, type StatusType, type StopFn, type StreamOptions, type TableBorderStyle, type TableOptions, type Task, type TaskResult, type TasksOptions, type Theme, type BannerOpts as ThemeBannerOpts, type ThemeChangeListener, type ThemeInstance, type ThemeStyleName, type TimelineEvent, type TimelineOptions, type TreeData, type TreeDimensions, type TreeNode, type RenderOptions as TreeRenderOptions, type TreeStyle, type TypeDeleteOptions, type TypewriterOptions, type VsplitOptions, type WalkVisitor, type WaveOptions, type WriteAsyncOptions, animate, animateGradient, ascii, bell, bg256, bgRgb, box, canAnimate, cancelTerminalFrame, center$1 as center, center as centerBlock, chain, charWidth, clamp, 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, figletText, filterTree, findInTree, flipHorizontal, flipVertical, frame, frames, fromImage, getConfig, getConfigValue, getRenderCacheSize, getSpeedMultiplier, getTerminalHeight, getTerminalWidth, gradient, gradientColor, gradientRect, graphemes, hasFont, hexToRgb, hideCursor, hsplit, images, isHexColor, isNoColor, json, pretty as jsonPretty, lerp, lerpColor, link, listFonts, listPresets, loader, mapTree, measureTree, memoize, nextTick, onConfigChange, onConfigKeyChange, onResize, once, padBoth, padEnd, padStart, panels, parseFiglet, 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, vsplit, walkTree, withConfig, wordWrap, wrapAnsi, write, writeAsync, writeErr, writeln, writelnErr };