ansimax 1.2.8 → 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/dist/index.js CHANGED
@@ -56,6 +56,7 @@ __export(index_exports, {
56
56
  canAnimate: () => canAnimate,
57
57
  cancelTerminalFrame: () => cancelTerminalFrame,
58
58
  center: () => center,
59
+ centerBlock: () => center2,
59
60
  chain: () => chain,
60
61
  charWidth: () => charWidth,
61
62
  clamp: () => clamp,
@@ -86,6 +87,7 @@ __export(index_exports, {
86
87
  findInTree: () => findInTree,
87
88
  flipHorizontal: () => flipHorizontal,
88
89
  flipVertical: () => flipVertical,
90
+ frame: () => frame,
89
91
  frames: () => frames,
90
92
  fromImage: () => fromImage,
91
93
  getConfig: () => getConfig,
@@ -101,9 +103,12 @@ __export(index_exports, {
101
103
  hasFont: () => hasFont,
102
104
  hexToRgb: () => hexToRgb,
103
105
  hideCursor: () => hideCursor,
106
+ hsplit: () => hsplit,
104
107
  images: () => images,
105
108
  isHexColor: () => isHexColor,
106
109
  isNoColor: () => isNoColor,
110
+ json: () => json,
111
+ jsonPretty: () => pretty,
107
112
  lerp: () => lerp,
108
113
  lerpColor: () => lerpColor,
109
114
  link: () => link,
@@ -121,6 +126,7 @@ __export(index_exports, {
121
126
  padBoth: () => padBoth,
122
127
  padEnd: () => padEnd,
123
128
  padStart: () => padStart,
129
+ panels: () => panels,
124
130
  parseFiglet: () => parseFiglet,
125
131
  pauseListeners: () => pauseListeners,
126
132
  presetNames: () => presetNames,
@@ -166,6 +172,7 @@ __export(index_exports, {
166
172
  trees: () => trees,
167
173
  truncateAnsi: () => truncateAnsi,
168
174
  visibleLen: () => visibleLen,
175
+ vsplit: () => vsplit,
169
176
  walkTree: () => walkTree,
170
177
  withConfig: () => withConfig,
171
178
  wordWrap: () => wordWrap,
@@ -1342,13 +1349,13 @@ var animateGradient = (text, stops, opts = {}) => {
1342
1349
  const elapsed = Date.now() - startTime;
1343
1350
  let phase = elapsed / safeDuration2 % 1;
1344
1351
  if (direction === "reverse") phase = 1 - phase;
1345
- const frame = gradient(text, stops, { preserveAnsi, easing, phase });
1352
+ const frame2 = gradient(text, stops, { preserveAnsi, easing, phase });
1346
1353
  if (onFrame) {
1347
- onFrame(frame, phase);
1354
+ onFrame(frame2, phase);
1348
1355
  } else {
1349
1356
  try {
1350
1357
  if (process?.stdout?.write) {
1351
- process.stdout.write("\r" + frame);
1358
+ process.stdout.write("\r" + frame2);
1352
1359
  }
1353
1360
  } catch {
1354
1361
  }
@@ -1638,9 +1645,9 @@ var safeWrite = (data) => {
1638
1645
  } catch {
1639
1646
  }
1640
1647
  };
1641
- var fireFrame = (hooks, frame) => {
1648
+ var fireFrame = (hooks, frame2) => {
1642
1649
  try {
1643
- hooks?.onFrame?.(frame);
1650
+ hooks?.onFrame?.(frame2);
1644
1651
  } catch {
1645
1652
  }
1646
1653
  };
@@ -1672,7 +1679,7 @@ var typewriter = async (text, opts = {}) => {
1672
1679
  registerCrashHandlers();
1673
1680
  hideCursorSafe();
1674
1681
  let aborted = false;
1675
- let frame = 0;
1682
+ let frame2 = 0;
1676
1683
  try {
1677
1684
  for (const ch of text) {
1678
1685
  if (isAborted(signal)) {
@@ -1680,7 +1687,7 @@ var typewriter = async (text, opts = {}) => {
1680
1687
  break;
1681
1688
  }
1682
1689
  await safeWriteAsync(colorFn ? colorFn(ch) : ch);
1683
- fireFrame(hooks, frame++);
1690
+ fireFrame(hooks, frame2++);
1684
1691
  await sleep(ch === " " ? speed * 0.3 : speed, { signal });
1685
1692
  }
1686
1693
  } finally {
@@ -1851,7 +1858,7 @@ var pulse = async (text, opts = {}) => {
1851
1858
  registerCrashHandlers();
1852
1859
  hideCursorSafe();
1853
1860
  let aborted = false;
1854
- let frame = 0;
1861
+ let frame2 = 0;
1855
1862
  try {
1856
1863
  for (let t = 0; t < cycles; t++) {
1857
1864
  if (isAborted(signal)) {
@@ -1861,7 +1868,7 @@ var pulse = async (text, opts = {}) => {
1861
1868
  await safeWriteAsync(
1862
1869
  cursor.save() + fgRgb(c1.r, c1.g, c1.b) + text + reset() + cursor.restore()
1863
1870
  );
1864
- fireFrame(hooks, frame++);
1871
+ fireFrame(hooks, frame2++);
1865
1872
  await sleep(halfInterval, { signal });
1866
1873
  if (isAborted(signal)) {
1867
1874
  aborted = true;
@@ -1870,7 +1877,7 @@ var pulse = async (text, opts = {}) => {
1870
1877
  await safeWriteAsync(
1871
1878
  cursor.save() + fgRgb(c2.r, c2.g, c2.b) + text + reset() + cursor.restore()
1872
1879
  );
1873
- fireFrame(hooks, frame++);
1880
+ fireFrame(hooks, frame2++);
1874
1881
  await sleep(halfInterval, { signal });
1875
1882
  }
1876
1883
  if (!aborted) {
@@ -3015,7 +3022,7 @@ var spin = (text = "Loading", opts = {}) => {
3015
3022
  }
3016
3023
  };
3017
3024
  }
3018
- let frame = 0;
3025
+ let frame2 = 0;
3019
3026
  let stopped = false;
3020
3027
  let timer = null;
3021
3028
  const animInterval = Math.max(FRAME_MS, safeInterval);
@@ -3024,8 +3031,8 @@ var spin = (text = "Loading", opts = {}) => {
3024
3031
  const render = () => {
3025
3032
  if (stopped) return;
3026
3033
  const elapsed = Date.now() - startTime;
3027
- frame = Math.floor(elapsed / animInterval) % frames2.length;
3028
- const f = frames2[frame] ?? "";
3034
+ frame2 = Math.floor(elapsed / animInterval) % frames2.length;
3035
+ const f = frames2[frame2] ?? "";
3029
3036
  const colored = applyColor(f, hex);
3030
3037
  const line = padToTerminalWidth(`${safePrefix}${colored} ${safeText}${safeSuffix}`);
3031
3038
  const buf = createOutputBuffer().push("\r").push(screen.clearLine()).push(line).toString();
@@ -3238,7 +3245,7 @@ var custom = (frames2, text = "", opts = {}) => {
3238
3245
  }
3239
3246
  registerCrashHandlers2();
3240
3247
  acquireCursor();
3241
- let frame = 0;
3248
+ let frame2 = 0;
3242
3249
  let stopped = false;
3243
3250
  let timer = null;
3244
3251
  const safeInterval = Math.max(FRAME_MS, interval);
@@ -3246,8 +3253,8 @@ var custom = (frames2, text = "", opts = {}) => {
3246
3253
  const render = () => {
3247
3254
  if (stopped) return;
3248
3255
  const elapsed = Date.now() - startTime;
3249
- frame = Math.floor(elapsed / safeInterval) % frames2.length;
3250
- const f = frames2[frame] ?? "";
3256
+ frame2 = Math.floor(elapsed / safeInterval) % frames2.length;
3257
+ const f = frames2[frame2] ?? "";
3251
3258
  write("\r" + screen.clearLine() + applyColor(f, hex) + " " + text);
3252
3259
  };
3253
3260
  render();
@@ -3355,7 +3362,7 @@ var multi = (opts = {}) => {
3355
3362
  registerCrashHandlers2();
3356
3363
  let nextId = 0;
3357
3364
  const items = /* @__PURE__ */ new Map();
3358
- let frame = 0;
3365
+ let frame2 = 0;
3359
3366
  let timer = null;
3360
3367
  let lastLineCount = 0;
3361
3368
  const render = () => {
@@ -3369,13 +3376,13 @@ var multi = (opts = {}) => {
3369
3376
  let glyph;
3370
3377
  if (item.state === "success") glyph = applyColor("\u2713", "#00ff88");
3371
3378
  else if (item.state === "fail") glyph = applyColor("\u2717", "#ff6b6b");
3372
- else glyph = applyColor(frames2[frame % frames2.length] ?? "", item.color ?? null);
3379
+ else glyph = applyColor(frames2[frame2 % frames2.length] ?? "", item.color ?? null);
3373
3380
  const text = item.finalText ?? item.text;
3374
3381
  buf.pushln(padToTerminalWidth(`${glyph} ${text}`));
3375
3382
  }
3376
3383
  write(buf.toString());
3377
3384
  lastLineCount = itemsArr.length;
3378
- frame++;
3385
+ frame2++;
3379
3386
  };
3380
3387
  const start = () => {
3381
3388
  if (timer) return;
@@ -3536,9 +3543,9 @@ var registerCrashHandlers3 = () => {
3536
3543
  if (isTestEnv3()) return;
3537
3544
  installCrashHandlersImpl3();
3538
3545
  };
3539
- var lineCount = (frame) => {
3540
- if (typeof frame !== "string" || frame.length === 0) return 0;
3541
- const normalized = frame.replace(/\r\n/g, "\n").replace(/\r/g, "");
3546
+ var lineCount = (frame2) => {
3547
+ if (typeof frame2 !== "string" || frame2.length === 0) return 0;
3548
+ const normalized = frame2.replace(/\r\n/g, "\n").replace(/\r/g, "");
3542
3549
  return normalized.split("\n").length;
3543
3550
  };
3544
3551
  var clearLines = (n) => {
@@ -3549,7 +3556,7 @@ var clearLines = (n) => {
3549
3556
  }
3550
3557
  };
3551
3558
  var isColorless2 = () => supportsColor() === "none";
3552
- var defaultOnFrame = (frame) => isColorless2() ? stripAnsi(frame) : frame;
3559
+ var defaultOnFrame = (frame2) => isColorless2() ? stripAnsi(frame2) : frame2;
3553
3560
  var play = (frames2, opts = {}) => {
3554
3561
  if (!Array.isArray(frames2)) {
3555
3562
  const resolved = Promise.resolve();
@@ -3610,13 +3617,13 @@ var play = (frames2, opts = {}) => {
3610
3617
  const done = new Promise((r) => {
3611
3618
  resolveDone = r;
3612
3619
  });
3613
- const renderFrame = (frame, idx) => {
3620
+ const renderFrame = (frame2, idx) => {
3614
3621
  if (lastLines > 0) clearLines(lastLines);
3615
3622
  let rendered;
3616
3623
  try {
3617
- rendered = userOnFrame(frame, idx);
3624
+ rendered = userOnFrame(frame2, idx);
3618
3625
  } catch {
3619
- rendered = frame;
3626
+ rendered = frame2;
3620
3627
  }
3621
3628
  const safe = ensureString4(rendered);
3622
3629
  try {
@@ -3745,13 +3752,13 @@ var live = (opts = {}) => {
3745
3752
  let abortHandler = null;
3746
3753
  const render = () => {
3747
3754
  if (lastLines > 0) clearLines(lastLines);
3748
- const frame = isColorless2() ? stripAnsi(currentFrame) : currentFrame;
3755
+ const frame2 = isColorless2() ? stripAnsi(currentFrame) : currentFrame;
3749
3756
  try {
3750
- write(frame);
3757
+ write(frame2);
3751
3758
  } catch {
3752
3759
  }
3753
- lastLines = lineCount(frame);
3754
- if (!frame.endsWith("\n")) writeln();
3760
+ lastLines = lineCount(frame2);
3761
+ if (!frame2.endsWith("\n")) writeln();
3755
3762
  };
3756
3763
  const start = () => {
3757
3764
  if (running) return;
@@ -5608,6 +5615,335 @@ var images = {
5608
5615
  clearAnsiCache
5609
5616
  };
5610
5617
 
5618
+ // src/panels/index.ts
5619
+ var _splitBlock = (block) => {
5620
+ if (typeof block !== "string" || block.length === 0) {
5621
+ return { lines: [""], maxWidth: 0 };
5622
+ }
5623
+ const lines = block.split("\n");
5624
+ let maxWidth = 0;
5625
+ for (const line of lines) {
5626
+ const w = visibleLen(line);
5627
+ if (w > maxWidth) maxWidth = w;
5628
+ }
5629
+ return { lines, maxWidth };
5630
+ };
5631
+ var _padLinesRight = (lines, targetWidth) => {
5632
+ return lines.map((line) => padEnd(line, targetWidth, " "));
5633
+ };
5634
+ var _padLinesAligned = (lines, targetWidth, align) => {
5635
+ return lines.map((line) => {
5636
+ const w = visibleLen(line);
5637
+ const space = Math.max(0, targetWidth - w);
5638
+ if (space === 0) return line;
5639
+ if (align === "end") return " ".repeat(space) + line;
5640
+ if (align === "center") {
5641
+ const left = Math.floor(space / 2);
5642
+ const right = space - left;
5643
+ return " ".repeat(left) + line + " ".repeat(right);
5644
+ }
5645
+ return line + " ".repeat(space);
5646
+ });
5647
+ };
5648
+ var _alignVertical = (lines, targetLines, width, align) => {
5649
+ const current = lines.length;
5650
+ if (current >= targetLines) return lines.slice(0, targetLines);
5651
+ const diff = targetLines - current;
5652
+ const empty = " ".repeat(width);
5653
+ if (align === "end") {
5654
+ return [...Array(diff).fill(empty), ...lines];
5655
+ }
5656
+ if (align === "center") {
5657
+ const above = Math.floor(diff / 2);
5658
+ const below = diff - above;
5659
+ return [...Array(above).fill(empty), ...lines, ...Array(below).fill(empty)];
5660
+ }
5661
+ return [...lines, ...Array(diff).fill(empty)];
5662
+ };
5663
+ var vsplit = (blocks, opts = {}) => {
5664
+ if (!Array.isArray(blocks) || blocks.length === 0) return "";
5665
+ const { gap = 1, align = "start", widths = null } = opts;
5666
+ const safeGap = Math.max(0, Math.floor(gap));
5667
+ const splits = blocks.map((b) => _splitBlock(b));
5668
+ const colWidths = splits.map((s, i) => {
5669
+ if (widths && Array.isArray(widths) && widths[i] != null) {
5670
+ return Math.max(0, Math.floor(widths[i]));
5671
+ }
5672
+ return s.maxWidth;
5673
+ });
5674
+ const targetLines = splits.reduce((m, s) => Math.max(m, s.lines.length), 0);
5675
+ const normalized = splits.map((s, i) => {
5676
+ const w = colWidths[i];
5677
+ const padded = _padLinesRight(s.lines, w);
5678
+ return _alignVertical(padded, targetLines, w, align);
5679
+ });
5680
+ const gapStr = " ".repeat(safeGap);
5681
+ const result = [];
5682
+ for (let r = 0; r < targetLines; r++) {
5683
+ const row = normalized.map((block) => block[r] ?? "").join(gapStr);
5684
+ result.push(row);
5685
+ }
5686
+ return result.join("\n");
5687
+ };
5688
+ var hsplit = (blocks, opts = {}) => {
5689
+ if (!Array.isArray(blocks) || blocks.length === 0) return "";
5690
+ const { gap = 0, align = "start" } = opts;
5691
+ const safeGap = Math.max(0, Math.floor(gap));
5692
+ const splits = blocks.map((b) => _splitBlock(b));
5693
+ const maxWidth = splits.reduce((m, s) => Math.max(m, s.maxWidth), 0);
5694
+ const aligned = splits.map((s) => _padLinesAligned(s.lines, maxWidth, align));
5695
+ const gapLines = safeGap > 0 ? Array(safeGap).fill(" ".repeat(maxWidth)) : [];
5696
+ const parts = [];
5697
+ for (let i = 0; i < aligned.length; i++) {
5698
+ parts.push(...aligned[i]);
5699
+ if (i < aligned.length - 1 && gapLines.length > 0) {
5700
+ parts.push(...gapLines);
5701
+ }
5702
+ }
5703
+ return parts.join("\n");
5704
+ };
5705
+ var center2 = (block, opts) => {
5706
+ if (!opts || typeof opts !== "object") return block;
5707
+ const width = Math.max(0, Math.floor(opts.width ?? 0));
5708
+ if (width === 0) return block;
5709
+ const { lines, maxWidth } = _splitBlock(block);
5710
+ const hCentered = lines.map((line) => {
5711
+ const w = visibleLen(line);
5712
+ const space = Math.max(0, width - w);
5713
+ if (space === 0) return line.slice(0, width);
5714
+ const left = Math.floor(space / 2);
5715
+ const right = space - left;
5716
+ return " ".repeat(left) + line + " ".repeat(right);
5717
+ });
5718
+ if (opts.height != null) {
5719
+ const targetH = Math.max(1, Math.floor(opts.height));
5720
+ return _alignVertical(hCentered, targetH, width, opts.align ?? "center").join("\n");
5721
+ }
5722
+ void maxWidth;
5723
+ return hCentered.join("\n");
5724
+ };
5725
+ var frame = (block, opts = {}) => {
5726
+ const {
5727
+ padding = 0,
5728
+ paddingY,
5729
+ paddingX,
5730
+ topChar = "\u2500",
5731
+ bottomChar,
5732
+ title
5733
+ } = opts;
5734
+ const safePadY = Math.max(0, Math.floor(paddingY ?? padding));
5735
+ const safePadX = Math.max(0, Math.floor(paddingX ?? padding));
5736
+ const safeTop = typeof topChar === "string" && topChar.length > 0 ? topChar.charAt(0) : "\u2500";
5737
+ const safeBot = typeof bottomChar === "string" && bottomChar.length > 0 ? bottomChar.charAt(0) : safeTop;
5738
+ const { lines, maxWidth } = _splitBlock(block);
5739
+ const contentInnerW = maxWidth + 2 * safePadX;
5740
+ let innerW = contentInnerW;
5741
+ let titleStr = "";
5742
+ let titleW = 0;
5743
+ if (typeof title === "string" && title.length > 0) {
5744
+ titleStr = ` ${title} `;
5745
+ titleW = visibleLen(titleStr);
5746
+ const titleNeededW = titleW + 2;
5747
+ if (titleNeededW > innerW) {
5748
+ innerW = titleNeededW;
5749
+ }
5750
+ }
5751
+ let topLine;
5752
+ if (titleStr.length > 0 && titleW < innerW) {
5753
+ const before = Math.floor((innerW - titleW) / 2);
5754
+ const after = innerW - titleW - before;
5755
+ topLine = safeTop.repeat(before) + titleStr + safeTop.repeat(after);
5756
+ } else {
5757
+ topLine = safeTop.repeat(innerW);
5758
+ }
5759
+ const bottomLine = safeBot.repeat(innerW);
5760
+ const padX = " ".repeat(safePadX);
5761
+ const padded = lines.map((line) => {
5762
+ const w = visibleLen(line);
5763
+ const tail = " ".repeat(Math.max(0, innerW - safePadX - w - safePadX));
5764
+ return padX + line + tail + padX;
5765
+ });
5766
+ const blank = " ".repeat(innerW);
5767
+ const out = [];
5768
+ out.push(topLine);
5769
+ for (let i = 0; i < safePadY; i++) out.push(blank);
5770
+ out.push(...padded);
5771
+ for (let i = 0; i < safePadY; i++) out.push(blank);
5772
+ out.push(bottomLine);
5773
+ return out.join("\n");
5774
+ };
5775
+ var panels = {
5776
+ vsplit,
5777
+ hsplit,
5778
+ // v1.3.1
5779
+ center: center2,
5780
+ frame
5781
+ };
5782
+
5783
+ // src/json/index.ts
5784
+ var COLORS = {
5785
+ key: FG.cyan,
5786
+ string: FG.green,
5787
+ number: FG.yellow,
5788
+ boolean: FG.magenta,
5789
+ null: FG.brightBlack,
5790
+ bracket: FG.white,
5791
+ comment: FG.brightBlack
5792
+ };
5793
+ var _c = (text, code, useColor) => useColor ? sgr(code) + text + reset() : text;
5794
+ var _truncString = (s, maxLength) => {
5795
+ if (!Number.isFinite(maxLength) || s.length <= maxLength) return s;
5796
+ if (maxLength <= 3) return s.slice(0, maxLength);
5797
+ return s.slice(0, maxLength - 3) + "...";
5798
+ };
5799
+ var _formatPrimitive = (value, opts) => {
5800
+ const { useColor, maxStringLength } = opts;
5801
+ if (value === null) {
5802
+ return _c("null", COLORS.null, useColor);
5803
+ }
5804
+ if (value === void 0) {
5805
+ return _c("undefined", COLORS.null, useColor);
5806
+ }
5807
+ if (typeof value === "string") {
5808
+ const truncated = _truncString(value, maxStringLength);
5809
+ const quoted = JSON.stringify(truncated);
5810
+ return _c(quoted, COLORS.string, useColor);
5811
+ }
5812
+ if (typeof value === "number") {
5813
+ if (Number.isNaN(value)) return _c("NaN", COLORS.number, useColor);
5814
+ if (!Number.isFinite(value)) {
5815
+ return _c(value > 0 ? "Infinity" : "-Infinity", COLORS.number, useColor);
5816
+ }
5817
+ return _c(String(value), COLORS.number, useColor);
5818
+ }
5819
+ if (typeof value === "boolean") {
5820
+ return _c(String(value), COLORS.boolean, useColor);
5821
+ }
5822
+ if (typeof value === "bigint") {
5823
+ return _c(`${value}n`, COLORS.number, useColor);
5824
+ }
5825
+ if (typeof value === "function") {
5826
+ const name = value.name || "anonymous";
5827
+ return _c(`[Function: ${name}]`, COLORS.comment, useColor);
5828
+ }
5829
+ if (typeof value === "symbol") {
5830
+ return _c(value.toString(), COLORS.comment, useColor);
5831
+ }
5832
+ return _c(String(value), COLORS.comment, useColor);
5833
+ };
5834
+ var _renderValue = (value, depth, config) => {
5835
+ const {
5836
+ indent,
5837
+ maxDepth,
5838
+ maxItems,
5839
+ maxStringLength,
5840
+ useColor,
5841
+ seen,
5842
+ sortKeys,
5843
+ inlineArrayMaxLength
5844
+ } = config;
5845
+ if (value === null || typeof value !== "object") {
5846
+ return _formatPrimitive(value, { useColor, maxStringLength });
5847
+ }
5848
+ if (seen.has(value)) {
5849
+ return _c("[Circular]", COLORS.comment, useColor);
5850
+ }
5851
+ seen.add(value);
5852
+ if (depth >= maxDepth) {
5853
+ if (Array.isArray(value)) {
5854
+ return _c("[", COLORS.bracket, useColor) + _c("...", COLORS.comment, useColor) + _c("]", COLORS.bracket, useColor);
5855
+ }
5856
+ return _c("{", COLORS.bracket, useColor) + _c("...", COLORS.comment, useColor) + _c("}", COLORS.bracket, useColor);
5857
+ }
5858
+ const pad = " ".repeat(indent * (depth + 1));
5859
+ const closePad = " ".repeat(indent * depth);
5860
+ if (Array.isArray(value)) {
5861
+ if (value.length === 0) {
5862
+ return _c("[]", COLORS.bracket, useColor);
5863
+ }
5864
+ if (inlineArrayMaxLength > 0) {
5865
+ const allPrimitive = value.every((v) => v === null || typeof v !== "object");
5866
+ if (allPrimitive) {
5867
+ const displayCount2 = Math.min(value.length, maxItems);
5868
+ const inlineItems = [];
5869
+ for (let i = 0; i < displayCount2; i++) {
5870
+ inlineItems.push(_formatPrimitive(value[i], { useColor, maxStringLength }));
5871
+ }
5872
+ if (value.length > maxItems) {
5873
+ const remaining = value.length - maxItems;
5874
+ inlineItems.push(_c(`... (${remaining} more)`, COLORS.comment, useColor));
5875
+ }
5876
+ const candidate = _c("[", COLORS.bracket, useColor) + inlineItems.join(", ") + _c("]", COLORS.bracket, useColor);
5877
+ const visibleLen2 = candidate.replace(/\x1b\[[0-9;]*m/g, "").length;
5878
+ if (visibleLen2 <= inlineArrayMaxLength) {
5879
+ return candidate;
5880
+ }
5881
+ }
5882
+ }
5883
+ const items = [];
5884
+ const displayCount = Math.min(value.length, maxItems);
5885
+ for (let i = 0; i < displayCount; i++) {
5886
+ const rendered = _renderValue(value[i], depth + 1, config);
5887
+ items.push(pad + rendered);
5888
+ }
5889
+ if (value.length > maxItems) {
5890
+ const remaining = value.length - maxItems;
5891
+ items.push(pad + _c(`... (${remaining} more)`, COLORS.comment, useColor));
5892
+ }
5893
+ return _c("[", COLORS.bracket, useColor) + "\n" + items.join(",\n") + "\n" + closePad + _c("]", COLORS.bracket, useColor);
5894
+ }
5895
+ let keys = Object.keys(value);
5896
+ if (keys.length === 0) {
5897
+ return _c("{}", COLORS.bracket, useColor);
5898
+ }
5899
+ if (sortKeys) {
5900
+ keys = [...keys].sort((a, b) => a.localeCompare(b));
5901
+ }
5902
+ const entries = [];
5903
+ for (const key of keys) {
5904
+ const keyStr = JSON.stringify(key);
5905
+ const renderedKey = _c(keyStr, COLORS.key, useColor);
5906
+ const renderedVal = _renderValue(
5907
+ value[key],
5908
+ depth + 1,
5909
+ config
5910
+ );
5911
+ entries.push(`${pad}${renderedKey}: ${renderedVal}`);
5912
+ }
5913
+ return _c("{", COLORS.bracket, useColor) + "\n" + entries.join(",\n") + "\n" + closePad + _c("}", COLORS.bracket, useColor);
5914
+ };
5915
+ var pretty = (value, opts = {}) => {
5916
+ const {
5917
+ indent = 2,
5918
+ colors = true,
5919
+ maxDepth = Infinity,
5920
+ maxItems = Infinity,
5921
+ maxStringLength = Infinity,
5922
+ // v1.3.1
5923
+ sortKeys = false,
5924
+ inlineArrayMaxLength = 60
5925
+ } = opts;
5926
+ const safeIndent = Math.max(0, Math.floor(Number(indent) || 0));
5927
+ const safeMaxDepth = Number.isFinite(maxDepth) ? Math.max(0, Math.floor(maxDepth)) : Infinity;
5928
+ const safeMaxItems = Number.isFinite(maxItems) ? Math.max(0, Math.floor(maxItems)) : Infinity;
5929
+ const safeMaxStrLen = Number.isFinite(maxStringLength) ? Math.max(0, Math.floor(maxStringLength)) : Infinity;
5930
+ const safeInlineMax = Number.isFinite(inlineArrayMaxLength) ? Math.max(0, Math.floor(inlineArrayMaxLength)) : 60;
5931
+ const useColor = colors && !isNoColor();
5932
+ return _renderValue(value, 0, {
5933
+ indent: safeIndent,
5934
+ maxDepth: safeMaxDepth,
5935
+ maxItems: safeMaxItems,
5936
+ maxStringLength: safeMaxStrLen,
5937
+ useColor,
5938
+ seen: /* @__PURE__ */ new WeakSet(),
5939
+ sortKeys: Boolean(sortKeys),
5940
+ inlineArrayMaxLength: safeInlineMax
5941
+ });
5942
+ };
5943
+ var json = {
5944
+ pretty
5945
+ };
5946
+
5611
5947
  // src/configure.ts
5612
5948
  var DEFAULTS = Object.freeze({
5613
5949
  colorMode: "auto",
@@ -5852,6 +6188,7 @@ var index_default = ansimax;
5852
6188
  canAnimate,
5853
6189
  cancelTerminalFrame,
5854
6190
  center,
6191
+ centerBlock,
5855
6192
  chain,
5856
6193
  charWidth,
5857
6194
  clamp,
@@ -5881,6 +6218,7 @@ var index_default = ansimax;
5881
6218
  findInTree,
5882
6219
  flipHorizontal,
5883
6220
  flipVertical,
6221
+ frame,
5884
6222
  frames,
5885
6223
  fromImage,
5886
6224
  getConfig,
@@ -5896,9 +6234,12 @@ var index_default = ansimax;
5896
6234
  hasFont,
5897
6235
  hexToRgb,
5898
6236
  hideCursor,
6237
+ hsplit,
5899
6238
  images,
5900
6239
  isHexColor,
5901
6240
  isNoColor,
6241
+ json,
6242
+ jsonPretty,
5902
6243
  lerp,
5903
6244
  lerpColor,
5904
6245
  link,
@@ -5916,6 +6257,7 @@ var index_default = ansimax;
5916
6257
  padBoth,
5917
6258
  padEnd,
5918
6259
  padStart,
6260
+ panels,
5919
6261
  parseFiglet,
5920
6262
  pauseListeners,
5921
6263
  presetNames,
@@ -5961,6 +6303,7 @@ var index_default = ansimax;
5961
6303
  trees,
5962
6304
  truncateAnsi,
5963
6305
  visibleLen,
6306
+ vsplit,
5964
6307
  walkTree,
5965
6308
  withConfig,
5966
6309
  wordWrap,