ansimax 1.2.8 → 1.3.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/dist/index.d.ts CHANGED
@@ -1904,6 +1904,224 @@ declare const clearThemeColorCache: () => void;
1904
1904
  */
1905
1905
  declare const themes: ThemeInstance;
1906
1906
 
1907
+ /**
1908
+ * ansimax — panels module
1909
+ * ─────────────────────────────────────────────
1910
+ *
1911
+ * Split layouts for composing terminal UIs: hsplit (top/bottom) and
1912
+ * vsplit (left/right). Both operate on already-rendered string blocks
1913
+ * (typically from `ascii.box`, `components.table`, etc.) and handle:
1914
+ *
1915
+ * • ANSI-aware width measurement
1916
+ * • Variable height (each block keeps its own line count)
1917
+ * • Alignment within columns
1918
+ * • Configurable gap between blocks
1919
+ * • Nesting (panels can contain panels)
1920
+ *
1921
+ * Philosophy: panels do composition, not styling. Style your blocks
1922
+ * first (with `ascii.box`, `components.timeline`, etc.), then compose
1923
+ * them with `panels.hsplit` / `panels.vsplit`.
1924
+ */
1925
+ type Alignment = 'start' | 'center' | 'end';
1926
+ interface VsplitOptions {
1927
+ /** Horizontal gap (in space characters) between columns. Default `1`. */
1928
+ gap?: number;
1929
+ /**
1930
+ * Vertical alignment of shorter blocks within the joined column row.
1931
+ * `'start'` (default) keeps blocks top-aligned; shorter blocks have
1932
+ * padding below. `'center'` centers each block. `'end'` aligns to bottom.
1933
+ */
1934
+ align?: Alignment;
1935
+ /**
1936
+ * Pad each block with spaces to a fixed width. Useful for grids where
1937
+ * each cell should be the same size regardless of content.
1938
+ * If omitted, each column uses its natural max-line width.
1939
+ */
1940
+ widths?: number[] | null;
1941
+ }
1942
+ interface HsplitOptions {
1943
+ /** Vertical gap (in blank lines) between rows. Default `0`. */
1944
+ gap?: number;
1945
+ /**
1946
+ * Horizontal alignment of narrower blocks within the joined width.
1947
+ * `'start'` (default) keeps blocks left-aligned. `'center'` and `'end'`
1948
+ * pad with spaces on the appropriate side.
1949
+ */
1950
+ align?: Alignment;
1951
+ }
1952
+ /**
1953
+ * Split blocks side-by-side (left / right / right ...).
1954
+ *
1955
+ * Each block is split into lines, then joined column-by-column with a
1956
+ * configurable gap. Shorter blocks are padded to match the tallest one.
1957
+ *
1958
+ * @param blocks - Pre-rendered string blocks (multi-line OK).
1959
+ * @param opts - Layout options.
1960
+ *
1961
+ * @example basic two-column layout
1962
+ * ```js
1963
+ * import { panels, ascii } from 'ansimax';
1964
+ *
1965
+ * console.log(panels.vsplit([
1966
+ * ascii.box('Left side', { borderStyle: 'rounded' }),
1967
+ * ascii.box('Right side', { borderStyle: 'rounded' }),
1968
+ * ], { gap: 2 }));
1969
+ * ```
1970
+ *
1971
+ * @example three columns with centered vertical alignment
1972
+ * ```js
1973
+ * console.log(panels.vsplit([
1974
+ * 'Short',
1975
+ * 'A\nMedium\nblock',
1976
+ * 'A\nlonger\nblock\nwith\nfive lines',
1977
+ * ], { align: 'center', gap: 4 }));
1978
+ * ```
1979
+ *
1980
+ * @example fixed column widths (grid-like)
1981
+ * ```js
1982
+ * console.log(panels.vsplit([col1, col2, col3], {
1983
+ * widths: [20, 30, 20],
1984
+ * gap: 2,
1985
+ * }));
1986
+ * ```
1987
+ */
1988
+ declare const vsplit: (blocks: string[], opts?: VsplitOptions) => string;
1989
+ /**
1990
+ * Stack blocks vertically (top / bottom / bottom ...).
1991
+ *
1992
+ * Each block is concatenated with `\n` between them. With `gap > 0`,
1993
+ * additional blank lines are inserted between blocks.
1994
+ *
1995
+ * @param blocks - Pre-rendered string blocks (multi-line OK).
1996
+ * @param opts - Layout options.
1997
+ *
1998
+ * @example basic stacking
1999
+ * ```js
2000
+ * import { panels, ascii } from 'ansimax';
2001
+ *
2002
+ * console.log(panels.hsplit([
2003
+ * '── Header ──',
2004
+ * ascii.box('Body content', { borderStyle: 'rounded' }),
2005
+ * '── Footer ──',
2006
+ * ]));
2007
+ * ```
2008
+ *
2009
+ * @example with vertical gap + centered alignment
2010
+ * ```js
2011
+ * console.log(panels.hsplit([
2012
+ * 'Top',
2013
+ * ascii.box('Middle'),
2014
+ * 'Bottom',
2015
+ * ], { gap: 1, align: 'center' }));
2016
+ * ```
2017
+ *
2018
+ * @example nested (an hsplit inside a vsplit)
2019
+ * ```js
2020
+ * const sidebar = ascii.box('Sidebar', { width: 20 });
2021
+ * const main = ascii.box('Main content area', { width: 40 });
2022
+ *
2023
+ * console.log(panels.hsplit([
2024
+ * '── Application ──',
2025
+ * panels.vsplit([sidebar, main], { gap: 2 }),
2026
+ * '── End ──',
2027
+ * ]));
2028
+ * ```
2029
+ */
2030
+ declare const hsplit: (blocks: string[], opts?: HsplitOptions) => string;
2031
+ declare const panels: {
2032
+ vsplit: (blocks: string[], opts?: VsplitOptions) => string;
2033
+ hsplit: (blocks: string[], opts?: HsplitOptions) => string;
2034
+ };
2035
+
2036
+ /**
2037
+ * ansimax — json module
2038
+ * ─────────────────────────────────────────────
2039
+ *
2040
+ * Colored JSON / YAML pretty-printer for terminal display.
2041
+ *
2042
+ * Features:
2043
+ * • Configurable indent
2044
+ * • Color-coded by value type (string, number, boolean, null, key)
2045
+ * • Max depth with collapse marker (`{...}` / `[...]`)
2046
+ * • Circular reference detection (avoids infinite recursion)
2047
+ * • ANSI cleanly disabled in NO_COLOR / non-TTY environments
2048
+ *
2049
+ * Philosophy: data → human-readable text. Not a parser, not a validator —
2050
+ * just pretty rendering of in-memory JS values.
2051
+ */
2052
+ interface PrettyOptions {
2053
+ /** Indent width in spaces. Default `2`. */
2054
+ indent?: number;
2055
+ /**
2056
+ * Apply ANSI colors to keys/values. Default `true`. Auto-disabled when
2057
+ * `NO_COLOR` is set or output is non-TTY.
2058
+ */
2059
+ colors?: boolean;
2060
+ /**
2061
+ * Maximum nesting depth. Objects/arrays beyond this level are collapsed
2062
+ * to `{...}` / `[...]`. Default `Infinity` (no limit).
2063
+ */
2064
+ maxDepth?: number;
2065
+ /**
2066
+ * Maximum array length to display fully. Arrays longer than this show
2067
+ * the first N items + a `... (M more)` marker. Default `Infinity`.
2068
+ */
2069
+ maxItems?: number;
2070
+ /**
2071
+ * Maximum string length before truncation with ellipsis. Default `Infinity`.
2072
+ */
2073
+ maxStringLength?: number;
2074
+ }
2075
+ /**
2076
+ * Pretty-print a JavaScript value with colored output suitable for
2077
+ * terminal display. Handles primitives, objects, arrays, and circular
2078
+ * references gracefully.
2079
+ *
2080
+ * @param value - Any JavaScript value to render.
2081
+ * @param opts - Optional formatting configuration.
2082
+ *
2083
+ * @example basic
2084
+ * ```js
2085
+ * import { json } from 'ansimax';
2086
+ *
2087
+ * console.log(json.pretty({
2088
+ * name: 'ansimax',
2089
+ * version: '1.3.0',
2090
+ * features: ['colors', 'gradients', 'panels'],
2091
+ * stats: { tests: 2000, coverage: 0.98 },
2092
+ * }));
2093
+ * ```
2094
+ *
2095
+ * @example with depth limit (collapses deeply nested objects)
2096
+ * ```js
2097
+ * console.log(json.pretty(deeplyNestedObject, { maxDepth: 2 }));
2098
+ * // Anything beyond depth 2 renders as {...} or [...]
2099
+ * ```
2100
+ *
2101
+ * @example with item limit (for huge arrays)
2102
+ * ```js
2103
+ * console.log(json.pretty(largeArray, { maxItems: 10 }));
2104
+ * // Shows first 10 items + "... (N more)"
2105
+ * ```
2106
+ *
2107
+ * @example monochrome (e.g. for log files)
2108
+ * ```js
2109
+ * console.log(json.pretty(data, { colors: false }));
2110
+ * ```
2111
+ *
2112
+ * @example handles circular references
2113
+ * ```js
2114
+ * const obj = { name: 'foo' };
2115
+ * obj.self = obj; // circular!
2116
+ * console.log(json.pretty(obj));
2117
+ * // → { "name": "foo", "self": [Circular] }
2118
+ * ```
2119
+ */
2120
+ declare const pretty: (value: unknown, opts?: PrettyOptions) => string;
2121
+ declare const json: {
2122
+ pretty: (value: unknown, opts?: PrettyOptions) => string;
2123
+ };
2124
+
1907
2125
  declare const ansimax: {
1908
2126
  color: {
1909
2127
  black: ColorFn;
@@ -2070,4 +2288,4 @@ declare const ansimax: {
2070
2288
  configure: (opts?: AnsimaxConfig, meta?: ConfigureOptions) => void;
2071
2289
  };
2072
2290
 
2073
- export { ASCII_RAMPS, 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 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 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, images, isHexColor, isNoColor, lerp, lerpColor, link, listFonts, listPresets, loader, mapTree, measureTree, memoize, nextTick, onConfigChange, onConfigKeyChange, onResize, once, padBoth, padEnd, padStart, 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, walkTree, withConfig, wordWrap, wrapAnsi, write, writeAsync, writeErr, writeln, writelnErr };
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 };
package/dist/index.js CHANGED
@@ -101,9 +101,12 @@ __export(index_exports, {
101
101
  hasFont: () => hasFont,
102
102
  hexToRgb: () => hexToRgb,
103
103
  hideCursor: () => hideCursor,
104
+ hsplit: () => hsplit,
104
105
  images: () => images,
105
106
  isHexColor: () => isHexColor,
106
107
  isNoColor: () => isNoColor,
108
+ json: () => json,
109
+ jsonPretty: () => pretty,
107
110
  lerp: () => lerp,
108
111
  lerpColor: () => lerpColor,
109
112
  link: () => link,
@@ -121,6 +124,7 @@ __export(index_exports, {
121
124
  padBoth: () => padBoth,
122
125
  padEnd: () => padEnd,
123
126
  padStart: () => padStart,
127
+ panels: () => panels,
124
128
  parseFiglet: () => parseFiglet,
125
129
  pauseListeners: () => pauseListeners,
126
130
  presetNames: () => presetNames,
@@ -166,6 +170,7 @@ __export(index_exports, {
166
170
  trees: () => trees,
167
171
  truncateAnsi: () => truncateAnsi,
168
172
  visibleLen: () => visibleLen,
173
+ vsplit: () => vsplit,
169
174
  walkTree: () => walkTree,
170
175
  withConfig: () => withConfig,
171
176
  wordWrap: () => wordWrap,
@@ -5608,6 +5613,225 @@ var images = {
5608
5613
  clearAnsiCache
5609
5614
  };
5610
5615
 
5616
+ // src/panels/index.ts
5617
+ var _splitBlock = (block) => {
5618
+ if (typeof block !== "string" || block.length === 0) {
5619
+ return { lines: [""], maxWidth: 0 };
5620
+ }
5621
+ const lines = block.split("\n");
5622
+ let maxWidth = 0;
5623
+ for (const line of lines) {
5624
+ const w = visibleLen(line);
5625
+ if (w > maxWidth) maxWidth = w;
5626
+ }
5627
+ return { lines, maxWidth };
5628
+ };
5629
+ var _padLinesRight = (lines, targetWidth) => {
5630
+ return lines.map((line) => padEnd(line, targetWidth, " "));
5631
+ };
5632
+ var _padLinesAligned = (lines, targetWidth, align) => {
5633
+ return lines.map((line) => {
5634
+ const w = visibleLen(line);
5635
+ const space = Math.max(0, targetWidth - w);
5636
+ if (space === 0) return line;
5637
+ if (align === "end") return " ".repeat(space) + line;
5638
+ if (align === "center") {
5639
+ const left = Math.floor(space / 2);
5640
+ const right = space - left;
5641
+ return " ".repeat(left) + line + " ".repeat(right);
5642
+ }
5643
+ return line + " ".repeat(space);
5644
+ });
5645
+ };
5646
+ var _alignVertical = (lines, targetLines, width, align) => {
5647
+ const current = lines.length;
5648
+ if (current >= targetLines) return lines.slice(0, targetLines);
5649
+ const diff = targetLines - current;
5650
+ const empty = " ".repeat(width);
5651
+ if (align === "end") {
5652
+ return [...Array(diff).fill(empty), ...lines];
5653
+ }
5654
+ if (align === "center") {
5655
+ const above = Math.floor(diff / 2);
5656
+ const below = diff - above;
5657
+ return [...Array(above).fill(empty), ...lines, ...Array(below).fill(empty)];
5658
+ }
5659
+ return [...lines, ...Array(diff).fill(empty)];
5660
+ };
5661
+ var vsplit = (blocks, opts = {}) => {
5662
+ if (!Array.isArray(blocks) || blocks.length === 0) return "";
5663
+ const { gap = 1, align = "start", widths = null } = opts;
5664
+ const safeGap = Math.max(0, Math.floor(gap));
5665
+ const splits = blocks.map((b) => _splitBlock(b));
5666
+ const colWidths = splits.map((s, i) => {
5667
+ if (widths && Array.isArray(widths) && widths[i] != null) {
5668
+ return Math.max(0, Math.floor(widths[i]));
5669
+ }
5670
+ return s.maxWidth;
5671
+ });
5672
+ const targetLines = splits.reduce((m, s) => Math.max(m, s.lines.length), 0);
5673
+ const normalized = splits.map((s, i) => {
5674
+ const w = colWidths[i];
5675
+ const padded = _padLinesRight(s.lines, w);
5676
+ return _alignVertical(padded, targetLines, w, align);
5677
+ });
5678
+ const gapStr = " ".repeat(safeGap);
5679
+ const result = [];
5680
+ for (let r = 0; r < targetLines; r++) {
5681
+ const row = normalized.map((block) => block[r] ?? "").join(gapStr);
5682
+ result.push(row);
5683
+ }
5684
+ return result.join("\n");
5685
+ };
5686
+ var hsplit = (blocks, opts = {}) => {
5687
+ if (!Array.isArray(blocks) || blocks.length === 0) return "";
5688
+ const { gap = 0, align = "start" } = opts;
5689
+ const safeGap = Math.max(0, Math.floor(gap));
5690
+ const splits = blocks.map((b) => _splitBlock(b));
5691
+ const maxWidth = splits.reduce((m, s) => Math.max(m, s.maxWidth), 0);
5692
+ const aligned = splits.map((s) => _padLinesAligned(s.lines, maxWidth, align));
5693
+ const gapLines = safeGap > 0 ? Array(safeGap).fill(" ".repeat(maxWidth)) : [];
5694
+ const parts = [];
5695
+ for (let i = 0; i < aligned.length; i++) {
5696
+ parts.push(...aligned[i]);
5697
+ if (i < aligned.length - 1 && gapLines.length > 0) {
5698
+ parts.push(...gapLines);
5699
+ }
5700
+ }
5701
+ return parts.join("\n");
5702
+ };
5703
+ var panels = {
5704
+ vsplit,
5705
+ hsplit
5706
+ };
5707
+
5708
+ // src/json/index.ts
5709
+ var COLORS = {
5710
+ key: FG.cyan,
5711
+ string: FG.green,
5712
+ number: FG.yellow,
5713
+ boolean: FG.magenta,
5714
+ null: FG.brightBlack,
5715
+ bracket: FG.white,
5716
+ comment: FG.brightBlack
5717
+ };
5718
+ var _c = (text, code, useColor) => useColor ? sgr(code) + text + reset() : text;
5719
+ var _truncString = (s, maxLength) => {
5720
+ if (!Number.isFinite(maxLength) || s.length <= maxLength) return s;
5721
+ if (maxLength <= 3) return s.slice(0, maxLength);
5722
+ return s.slice(0, maxLength - 3) + "...";
5723
+ };
5724
+ var _formatPrimitive = (value, opts) => {
5725
+ const { useColor, maxStringLength } = opts;
5726
+ if (value === null) {
5727
+ return _c("null", COLORS.null, useColor);
5728
+ }
5729
+ if (value === void 0) {
5730
+ return _c("undefined", COLORS.null, useColor);
5731
+ }
5732
+ if (typeof value === "string") {
5733
+ const truncated = _truncString(value, maxStringLength);
5734
+ const quoted = JSON.stringify(truncated);
5735
+ return _c(quoted, COLORS.string, useColor);
5736
+ }
5737
+ if (typeof value === "number") {
5738
+ if (Number.isNaN(value)) return _c("NaN", COLORS.number, useColor);
5739
+ if (!Number.isFinite(value)) {
5740
+ return _c(value > 0 ? "Infinity" : "-Infinity", COLORS.number, useColor);
5741
+ }
5742
+ return _c(String(value), COLORS.number, useColor);
5743
+ }
5744
+ if (typeof value === "boolean") {
5745
+ return _c(String(value), COLORS.boolean, useColor);
5746
+ }
5747
+ if (typeof value === "bigint") {
5748
+ return _c(`${value}n`, COLORS.number, useColor);
5749
+ }
5750
+ if (typeof value === "function") {
5751
+ const name = value.name || "anonymous";
5752
+ return _c(`[Function: ${name}]`, COLORS.comment, useColor);
5753
+ }
5754
+ if (typeof value === "symbol") {
5755
+ return _c(value.toString(), COLORS.comment, useColor);
5756
+ }
5757
+ return _c(String(value), COLORS.comment, useColor);
5758
+ };
5759
+ var _renderValue = (value, depth, config) => {
5760
+ const { indent, maxDepth, maxItems, maxStringLength, useColor, seen } = config;
5761
+ if (value === null || typeof value !== "object") {
5762
+ return _formatPrimitive(value, { useColor, maxStringLength });
5763
+ }
5764
+ if (seen.has(value)) {
5765
+ return _c("[Circular]", COLORS.comment, useColor);
5766
+ }
5767
+ seen.add(value);
5768
+ if (depth >= maxDepth) {
5769
+ if (Array.isArray(value)) {
5770
+ return _c("[", COLORS.bracket, useColor) + _c("...", COLORS.comment, useColor) + _c("]", COLORS.bracket, useColor);
5771
+ }
5772
+ return _c("{", COLORS.bracket, useColor) + _c("...", COLORS.comment, useColor) + _c("}", COLORS.bracket, useColor);
5773
+ }
5774
+ const pad = " ".repeat(indent * (depth + 1));
5775
+ const closePad = " ".repeat(indent * depth);
5776
+ if (Array.isArray(value)) {
5777
+ if (value.length === 0) {
5778
+ return _c("[]", COLORS.bracket, useColor);
5779
+ }
5780
+ const items = [];
5781
+ const displayCount = Math.min(value.length, maxItems);
5782
+ for (let i = 0; i < displayCount; i++) {
5783
+ const rendered = _renderValue(value[i], depth + 1, config);
5784
+ items.push(pad + rendered);
5785
+ }
5786
+ if (value.length > maxItems) {
5787
+ const remaining = value.length - maxItems;
5788
+ items.push(pad + _c(`... (${remaining} more)`, COLORS.comment, useColor));
5789
+ }
5790
+ return _c("[", COLORS.bracket, useColor) + "\n" + items.join(",\n") + "\n" + closePad + _c("]", COLORS.bracket, useColor);
5791
+ }
5792
+ const keys = Object.keys(value);
5793
+ if (keys.length === 0) {
5794
+ return _c("{}", COLORS.bracket, useColor);
5795
+ }
5796
+ const entries = [];
5797
+ for (const key of keys) {
5798
+ const keyStr = JSON.stringify(key);
5799
+ const renderedKey = _c(keyStr, COLORS.key, useColor);
5800
+ const renderedVal = _renderValue(
5801
+ value[key],
5802
+ depth + 1,
5803
+ config
5804
+ );
5805
+ entries.push(`${pad}${renderedKey}: ${renderedVal}`);
5806
+ }
5807
+ return _c("{", COLORS.bracket, useColor) + "\n" + entries.join(",\n") + "\n" + closePad + _c("}", COLORS.bracket, useColor);
5808
+ };
5809
+ var pretty = (value, opts = {}) => {
5810
+ const {
5811
+ indent = 2,
5812
+ colors = true,
5813
+ maxDepth = Infinity,
5814
+ maxItems = Infinity,
5815
+ maxStringLength = Infinity
5816
+ } = opts;
5817
+ const safeIndent = Math.max(0, Math.floor(Number(indent) || 0));
5818
+ const safeMaxDepth = Number.isFinite(maxDepth) ? Math.max(0, Math.floor(maxDepth)) : Infinity;
5819
+ const safeMaxItems = Number.isFinite(maxItems) ? Math.max(0, Math.floor(maxItems)) : Infinity;
5820
+ const safeMaxStrLen = Number.isFinite(maxStringLength) ? Math.max(0, Math.floor(maxStringLength)) : Infinity;
5821
+ const useColor = colors && !isNoColor();
5822
+ return _renderValue(value, 0, {
5823
+ indent: safeIndent,
5824
+ maxDepth: safeMaxDepth,
5825
+ maxItems: safeMaxItems,
5826
+ maxStringLength: safeMaxStrLen,
5827
+ useColor,
5828
+ seen: /* @__PURE__ */ new WeakSet()
5829
+ });
5830
+ };
5831
+ var json = {
5832
+ pretty
5833
+ };
5834
+
5611
5835
  // src/configure.ts
5612
5836
  var DEFAULTS = Object.freeze({
5613
5837
  colorMode: "auto",
@@ -5896,9 +6120,12 @@ var index_default = ansimax;
5896
6120
  hasFont,
5897
6121
  hexToRgb,
5898
6122
  hideCursor,
6123
+ hsplit,
5899
6124
  images,
5900
6125
  isHexColor,
5901
6126
  isNoColor,
6127
+ json,
6128
+ jsonPretty,
5902
6129
  lerp,
5903
6130
  lerpColor,
5904
6131
  link,
@@ -5916,6 +6143,7 @@ var index_default = ansimax;
5916
6143
  padBoth,
5917
6144
  padEnd,
5918
6145
  padStart,
6146
+ panels,
5919
6147
  parseFiglet,
5920
6148
  pauseListeners,
5921
6149
  presetNames,
@@ -5961,6 +6189,7 @@ var index_default = ansimax;
5961
6189
  trees,
5962
6190
  truncateAnsi,
5963
6191
  visibleLen,
6192
+ vsplit,
5964
6193
  walkTree,
5965
6194
  withConfig,
5966
6195
  wordWrap,