ink-hud 0.1.2 → 0.1.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/dist/index.d.cts CHANGED
@@ -22,7 +22,7 @@ type RenderedLine = Array<{
22
22
  /**
23
23
  * Renderer type
24
24
  */
25
- type RendererType = 'braille' | 'block' | 'ascii';
25
+ type RendererType = 'braille' | 'block';
26
26
  /**
27
27
  * Renderer resolution information
28
28
  * Represents how many pixels each character can display
@@ -152,37 +152,6 @@ declare class BlockRenderer extends Renderer {
152
152
  renderCanvas(pixels: Pixel[][], width: number, height: number): RenderedLine[];
153
153
  }
154
154
 
155
- /**
156
- * ASCII renderer
157
- *
158
- * Implements 1x3 dot matrix rendering using basic ASCII characters
159
- * Simulates subtle height variations using top/middle/bottom character segments
160
- */
161
- declare class AsciiRenderer extends Renderer {
162
- getMetadata(): RendererMetadata;
163
- /**
164
- * Check if the pixel at the specified position is set
165
- */
166
- private isPixelSet;
167
- private getCellPositions;
168
- private getNeighborPosition;
169
- private selectMultiPixelChar;
170
- private selectHorizontalChar;
171
- private selectDiagonalChar;
172
- private selectIsolatedChar;
173
- private selectSinglePixelChar;
174
- /**
175
- * Intelligently select ASCII character
176
- * Select appropriate character based on 1x3 vertical pixels and adjacent column connections
177
- */
178
- private selectAsciiChar;
179
- /**
180
- * Determine the primary color for this character cell
181
- */
182
- private resolveColor;
183
- renderCanvas(pixels: Pixel[][], width: number, height: number): RenderedLine[];
184
- }
185
-
186
155
  /**
187
156
  * Terminal detection type definitions
188
157
  *
@@ -332,6 +301,13 @@ declare class RendererSelector {
332
301
  * @returns Renderer instance
333
302
  */
334
303
  getRenderer(type: RendererType): Renderer;
304
+ /**
305
+ * Check if a renderer type is supported by the current terminal
306
+ * Used internally by InkHudProvider to determine the per-chart renderer
307
+ * @param type - Renderer type
308
+ * @returns Whether the renderer type is supported
309
+ */
310
+ isRendererTypeSupported(type: RendererType): boolean;
335
311
  /**
336
312
  * Check if the renderer meets terminal capability requirements
337
313
  * @param renderer - Renderer instance
@@ -340,12 +316,13 @@ declare class RendererSelector {
340
316
  */
341
317
  private isRendererSupported;
342
318
  /**
343
- * Automatically select the best renderer
319
+ * Automatically select the best renderer from a priority chain.
344
320
  *
345
- * Try in the order of the priority chain, returning the first renderer that meets terminal capability requirements
346
- * If none are satisfied, fallback to ASCII
321
+ * @deprecated Prefer `<InkHudProvider renderers={{ line: 'block' }}>` combined
322
+ * with `useChartRenderer(kind)`. This method remains as a low-level escape
323
+ * hatch for custom renderer selection outside the React component tree.
347
324
  *
348
- * @param preferredChain - Priority chain (default: ['braille', 'block', 'ascii'])
325
+ * @param preferredChain - Priority chain (default: ['braille', 'block'])
349
326
  * @returns Selected renderer instance
350
327
  */
351
328
  selectBest(preferredChain?: RendererType[]): Renderer;
@@ -366,6 +343,25 @@ declare const rendererSelector: RendererSelector;
366
343
  * Provide dependency injection, replacing the global singleton
367
344
  */
368
345
 
346
+ /**
347
+ * Chart types that use the pixel-canvas rendering system
348
+ */
349
+ type ChartKind = 'line' | 'area' | 'bar' | 'pie';
350
+ /**
351
+ * Per-chart-kind renderer assignment
352
+ */
353
+ type ChartRenderers = Record<ChartKind, RendererType>;
354
+ /**
355
+ * Default renderer per chart kind — pre-tuned for best visual output
356
+ *
357
+ * | Chart | Renderer | Reason |
358
+ * |-------|----------|--------|
359
+ * | line | braille | 2×4 sub-pixel grid renders smooth diagonals |
360
+ * | area | braille | Fine-grained fill under curves |
361
+ * | bar | block | 2×2 cells produce clean rectangular bar edges |
362
+ * | pie | block | Solid fills create clean sector boundaries |
363
+ */
364
+ declare const DEFAULT_CHART_RENDERERS: ChartRenderers;
369
365
  /**
370
366
  * InkHud Context value
371
367
  */
@@ -376,8 +372,13 @@ interface InkHudContextValue {
376
372
  getCapabilities: () => TerminalCapabilities;
377
373
  /** Get renderer of specified type */
378
374
  getRenderer: (type: RendererType) => Renderer;
379
- /** Select best renderer */
380
- selectBest: (chain?: RendererType[]) => Renderer;
375
+ /**
376
+ * Get the renderer configured for a specific chart kind.
377
+ * In development mode, emits a one-time console.warn when falling back to
378
+ * BlockRenderer because the configured renderer is not supported by the
379
+ * current terminal. In production, the fallback is silent.
380
+ */
381
+ getRendererFor: (kind: ChartKind) => Renderer;
381
382
  }
382
383
  /**
383
384
  * InkHud Provider Props
@@ -389,20 +390,30 @@ interface InkHudProviderProps {
389
390
  */
390
391
  detector?: TerminalDetector;
391
392
  /**
392
- * Force use of specified renderer
393
- * Override automatic detection for testing or specific scenarios
394
- */
395
- forceRenderer?: RendererType;
393
+ * Override the renderer used for specific chart kinds.
394
+ * Unspecified kinds keep their default (see DEFAULT_CHART_RENDERERS).
395
+ *
396
+ * @example
397
+ * ```tsx
398
+ * // Force all line charts to use block renderer
399
+ * <InkHudProvider renderers={{ line: 'block' }}>
400
+ * <MyApp />
401
+ * </InkHudProvider>
402
+ * ```
403
+ */
404
+ renderers?: Partial<ChartRenderers>;
396
405
  children: React.ReactNode;
397
406
  }
398
407
  /**
399
408
  * InkHud Context Provider
400
409
  *
401
- * Encapsulate renderer selection logic, supports dependency injection
410
+ * Encapsulate renderer selection logic, supports dependency injection.
411
+ * Each chart kind ships with a pre-tuned default renderer — no per-component
412
+ * configuration required.
402
413
  *
403
414
  * @example
404
415
  * ```tsx
405
- * // Standard usage (automatic detection)
416
+ * // Standard usage (automatic detection, best renderer per chart)
406
417
  * <InkHudProvider>
407
418
  * <MyApp />
408
419
  * </InkHudProvider>
@@ -412,8 +423,8 @@ interface InkHudProviderProps {
412
423
  * <MyApp />
413
424
  * </InkHudProvider>
414
425
  *
415
- * // Force ASCII renderer
416
- * <InkHudProvider forceRenderer="ascii">
426
+ * // Override renderer for specific charts
427
+ * <InkHudProvider renderers={{ line: 'block', bar: 'braille' }}>
417
428
  * <MyApp />
418
429
  * </InkHudProvider>
419
430
  * ```
@@ -850,6 +861,55 @@ declare function useSmoothArray(targetData: number[], duration?: number, easingF
850
861
  */
851
862
  declare function useThrottle<T>(value: T, fps?: number): T;
852
863
 
864
+ interface UseImageProtocolOptions {
865
+ /**
866
+ * 'character' disables image mode entirely; 'image' forces it (no-op when unsupported);
867
+ * 'auto' detects at runtime and falls back to character mode.
868
+ */
869
+ mode: 'auto' | 'image' | 'character';
870
+ /**
871
+ * Number of Kitty placeholder cells (= columns in the Kitty image grid).
872
+ * With trailingSpace=true each cell is 2 terminal cols wide (U+10EEEE + space).
873
+ * With trailingSpace=false each cell is 1 terminal col wide.
874
+ */
875
+ charCols: number;
876
+ /** Number of placeholder rows (= rows in the Kitty image grid). */
877
+ charRows: number;
878
+ /** Pre-built PNG buffer. null suppresses image rendering for this render cycle. */
879
+ pngBuf: Buffer | null;
880
+ /**
881
+ * Append a trailing space after each Kitty placeholder cell.
882
+ * true → 2 terminal cols/cell — use for components whose character mode
883
+ * renders "char + space" per data cell (e.g. Heatmap's "■ ").
884
+ * false → 1 terminal col/cell — use for components with 1-char-per-column
885
+ * layout (e.g. Sparkline).
886
+ * @default true
887
+ */
888
+ trailingSpace?: boolean;
889
+ }
890
+ interface UseImageProtocolResult {
891
+ /** True when image protocol is active and a PNG has been uploaded. */
892
+ useImage: boolean;
893
+ /**
894
+ * One string per charRow to render as <Text> elements (Kitty protocol).
895
+ * null when Kitty is not the active protocol.
896
+ */
897
+ kittyLines: string[] | null;
898
+ /**
899
+ * Width in terminal columns for blank placeholder rows (iTerm2 protocol).
900
+ * null when iTerm2 is not the active protocol.
901
+ * Render charRows blank lines of this width to reserve the image's space.
902
+ */
903
+ iterm2Cols: number | null;
904
+ }
905
+ /**
906
+ * Shared hook for image-mode rendering (Heatmap, Sparkline, …).
907
+ *
908
+ * Handles: protocol detection, stable image ID management, Kitty upload/cleanup
909
+ * effects, iTerm2 cursor-up write, and placeholder data for the calling component.
910
+ */
911
+ declare function useImageProtocol({ mode, charCols, charRows, pngBuf, trailingSpace, }: UseImageProtocolOptions): UseImageProtocolResult;
912
+
853
913
  /**
854
914
  * Common type definitions for Chart components
855
915
  *
@@ -857,27 +917,23 @@ declare function useThrottle<T>(value: T, fps?: number): T;
857
917
  */
858
918
 
859
919
  /**
860
- * Basic chart dimensions and renderer configuration
920
+ * Basic chart dimensions
861
921
  */
862
922
  interface BaseChartProps {
863
923
  /** Chart width (character count) */
864
924
  width?: number;
865
925
  /** Chart height (character rows) */
866
926
  height?: number;
867
- /** Manually specify Renderer type */
868
- renderer?: RendererType;
869
- /** Custom renderer fallback chain */
870
- rendererChain?: RendererType[];
871
927
  /**
872
- * Width offset
873
- * @deprecated Recommend wrapping chart with `<Panel>`, Panel automatically handles border overhead
928
+ * @deprecated Per-chart `renderer` prop has been removed.
929
+ * Configure via `<InkHudProvider renderers={{ line: 'block' }}>` instead.
874
930
  */
875
- widthOffset?: number;
931
+ renderer?: never;
876
932
  /**
877
- * Height offset
878
- * @deprecated Recommend wrapping chart with `<Panel>`, Panel automatically handles border overhead
933
+ * @deprecated Per-chart `rendererChain` prop has been removed.
934
+ * Configure via `<InkHudProvider renderers={{ line: 'block' }}>` instead.
879
935
  */
880
- heightOffset?: number;
936
+ rendererChain?: never;
881
937
  }
882
938
  /**
883
939
  * Legend configuration
@@ -1029,20 +1085,16 @@ interface PieChartProps {
1029
1085
  colors?: string[];
1030
1086
  /** Palette name or custom color array */
1031
1087
  colorPalette?: ColorPalette;
1032
- /** Manually specify renderer type (optional) */
1033
- renderer?: RendererType;
1034
- /** Custom renderer fallback chain (default: ['braille', 'block', 'ascii']) */
1035
- rendererChain?: RendererType[];
1036
1088
  /**
1037
- * Height offset
1038
- * @deprecated Recommend wrapping chart with `<Panel>`, Panel automatically handles border overhead
1089
+ * @deprecated Per-chart `renderer` prop has been removed.
1090
+ * Configure via `<InkHudProvider renderers={{ pie: 'block' }}>` instead.
1039
1091
  */
1040
- heightOffset?: number;
1092
+ renderer?: never;
1041
1093
  /**
1042
- * Width offset
1043
- * @deprecated Recommend wrapping chart with `<Panel>`, Panel automatically handles border overhead
1094
+ * @deprecated Per-chart `rendererChain` prop has been removed.
1095
+ * Configure via `<InkHudProvider renderers={{ pie: 'block' }}>` instead.
1044
1096
  */
1045
- widthOffset?: number;
1097
+ rendererChain?: never;
1046
1098
  }
1047
1099
  /**
1048
1100
  * PieChart Pie chart component
@@ -1051,25 +1103,57 @@ declare const PieChart: React.FC<PieChartProps>;
1051
1103
 
1052
1104
  /**
1053
1105
  * Sparkline - Mini trend chart component
1106
+ *
1107
+ * Note: Sparkline does NOT consume the InkHudProvider `renderers` configuration.
1108
+ * Its `variant` prop ('block' | 'braille') is independent because Sparkline uses
1109
+ * a static character table (SPARK_LEVELS), not the pixel-canvas pipeline used by
1110
+ * LineChart / AreaChart / BarChart / PieChart. Set `variant` directly on the
1111
+ * component when you need to override the default ('block').
1054
1112
  */
1055
1113
 
1056
1114
  interface SparklineProps {
1057
1115
  /** Array of data points */
1058
1116
  data: number[];
1059
1117
  /**
1060
- * Target width (character count)
1061
- * If number of data points exceeds width, will automatically use LTTB algorithm for downsampling
1062
- * If not provided, width will equal the number of data points
1118
+ * Target width in character columns.
1119
+ * If data.length exceeds width, LTTB downsampling is applied.
1120
+ * Defaults to data.length.
1063
1121
  */
1064
1122
  width?: number;
1065
- /** Minimum value (default: calculation from data) */
1123
+ /** Minimum value (default: derived from data) */
1066
1124
  min?: number;
1067
- /** Maximum value (default: calculation from data) */
1125
+ /** Maximum value (default: derived from data) */
1068
1126
  max?: number;
1069
- /** Color */
1127
+ /** Single solid color for character mode (and image mode when colors is not set) */
1070
1128
  color?: string;
1071
- /** Rendering style (default: 'block') */
1072
- variant?: 'block' | 'braille' | 'ascii';
1129
+ /**
1130
+ * Rendering style for character mode. Ignored in image mode.
1131
+ * @default 'block'
1132
+ */
1133
+ variant?: 'block' | 'braille';
1134
+ /**
1135
+ * Rendering mode.
1136
+ * - 'auto': use image protocol if supported, otherwise character mode
1137
+ * - 'image': force image protocol (no-op if unsupported)
1138
+ * - 'character': always use character mode (block/braille)
1139
+ * @default 'auto'
1140
+ */
1141
+ mode?: 'auto' | 'image' | 'character';
1142
+ /**
1143
+ * Chart height in character rows (image mode only).
1144
+ * @default 1
1145
+ */
1146
+ height?: number;
1147
+ /**
1148
+ * Color gradient for image mode (low → high).
1149
+ * Overrides the `color` prop. Defaults to the theme's heatmapGradient.
1150
+ */
1151
+ colors?: string[];
1152
+ /**
1153
+ * Pixel size per character cell in image mode.
1154
+ * @default 8
1155
+ */
1156
+ cellPx?: number;
1073
1157
  }
1074
1158
  declare const Sparkline: React.FC<SparklineProps>;
1075
1159
 
@@ -1299,18 +1383,11 @@ interface GaugeProps {
1299
1383
  */
1300
1384
  showPercent?: boolean;
1301
1385
  /**
1302
- * Rendering style
1303
- * - 'unicode': Use Unicode block characters (█░)
1304
- * - 'ascii': Use ASCII characters (#-)
1305
- * @default 'unicode'
1306
- */
1307
- variant?: 'unicode' | 'ascii';
1308
- /**
1309
- * Custom fill character (overrides variant setting)
1386
+ * Custom fill character
1310
1387
  */
1311
1388
  fillChar?: string;
1312
1389
  /**
1313
- * Custom unfilled character (overrides variant setting)
1390
+ * Custom unfilled character
1314
1391
  */
1315
1392
  emptyChar?: string;
1316
1393
  /**
@@ -1322,27 +1399,32 @@ interface GaugeProps {
1322
1399
  * Gauge - Gauge/progress bar component
1323
1400
  *
1324
1401
  * Display progress or load of a single metric.
1325
- * Style examples:
1326
- * - unicode: [██████░░░░] 60%
1327
- * - ascii: [######----] 60%
1402
+ * Example: [██████░░░░] 60%
1328
1403
  */
1329
1404
  declare const Gauge: React.FC<GaugeProps>;
1330
1405
 
1331
1406
  /**
1332
1407
  * Multi-Style Big Fonts for BigNumber Component
1333
1408
  *
1334
- * Supports three rendering styles:
1409
+ * Supports two rendering styles:
1335
1410
  * - block: Unicode Block Elements (█▀▄)
1336
1411
  * - braille: Braille patterns (⠿)
1337
- * - ascii: Pure ASCII characters
1338
1412
  */
1339
- type FontStyle = 'block' | 'braille' | 'ascii';
1413
+ type FontStyle = 'block' | 'braille';
1340
1414
 
1341
1415
  interface BigNumberProps {
1342
1416
  /**
1343
- * Main value
1417
+ * Main value — should contain only supported characters: 0-9 . , % + -
1344
1418
  */
1345
1419
  value: string | number;
1420
+ /**
1421
+ * Small text rendered to the left of the big value (e.g. "$")
1422
+ */
1423
+ prefix?: string;
1424
+ /**
1425
+ * Small text rendered to the right of the big value (e.g. "ms", "k", "%")
1426
+ */
1427
+ suffix?: string;
1346
1428
  /**
1347
1429
  * Subtitle/label
1348
1430
  */
@@ -1360,18 +1442,10 @@ interface BigNumberProps {
1360
1442
  * Trend label (e.g., "12%")
1361
1443
  */
1362
1444
  trendLabel?: string;
1363
- /**
1364
- * Trend arrow style
1365
- * - 'unicode': Use Unicode arrows
1366
- * - 'ascii': Use ASCII characters
1367
- * @default 'unicode'
1368
- */
1369
- variant?: 'unicode' | 'ascii';
1370
1445
  /**
1371
1446
  * Large font style
1372
1447
  * - 'block': Block Elements characters (default)
1373
1448
  * - 'braille': Braille Dot Matrix characters
1374
- * - 'ascii': Pure ASCII characters
1375
1449
  * @default 'block'
1376
1450
  */
1377
1451
  fontStyle?: FontStyle;
@@ -1389,31 +1463,28 @@ interface BigNumberProps {
1389
1463
  declare const BigNumber: React.FC<BigNumberProps>;
1390
1464
 
1391
1465
  interface HeatmapProps {
1392
- /**
1393
- * Data matrix (2D array)
1394
- * e.g. rows x cols
1395
- */
1466
+ /** Data matrix (2D array), rows × cols */
1396
1467
  data: number[][];
1397
1468
  /**
1398
- * Color gradient (from low to high)
1399
- * Defaults to theme's heatmapGradient
1469
+ * Color gradient (from low to high).
1470
+ * Defaults to theme's heatmapGradient.
1400
1471
  */
1401
1472
  colors?: string[];
1473
+ /** Custom character for character mode (defaults to Unicode block ■) */
1474
+ char?: string;
1402
1475
  /**
1403
- * Empty/zero value color (if not handled in gradient)
1404
- */
1405
- emptyColor?: string;
1406
- /**
1407
- * Rendering style
1408
- * - 'unicode': Use Unicode Blocks character (■)
1409
- * - 'ascii': Use ASCII characters (#)
1410
- * @default 'unicode'
1476
+ * Rendering mode.
1477
+ * - 'auto': use image protocol if supported, otherwise character mode
1478
+ * - 'image': force image protocol (no-op if unsupported)
1479
+ * - 'character': always use unicode block characters
1480
+ * @default 'auto'
1411
1481
  */
1412
- variant?: 'unicode' | 'ascii';
1482
+ mode?: 'auto' | 'image' | 'character';
1413
1483
  /**
1414
- * Custom character (overrides variant setting)
1484
+ * Pixel size of each data cell in image mode.
1485
+ * @default 8
1415
1486
  */
1416
- char?: string;
1487
+ cellPx?: number;
1417
1488
  }
1418
1489
  declare const Heatmap: React.FC<HeatmapProps>;
1419
1490
 
@@ -1526,19 +1597,12 @@ interface PulseBarProps {
1526
1597
  /**
1527
1598
  * Ping history entries
1528
1599
  */
1529
- records: PingRecord[];
1600
+ records?: PingRecord[];
1530
1601
  /**
1531
1602
  * Maximum number of bars to display
1532
1603
  * @default 30
1533
1604
  */
1534
1605
  maxBars?: number;
1535
- /**
1536
- * Render style
1537
- * - 'unicode': use Unicode characters
1538
- * - 'ascii': use ASCII characters
1539
- * @default 'unicode'
1540
- */
1541
- variant?: 'unicode' | 'ascii';
1542
1606
  /**
1543
1607
  * Custom colors
1544
1608
  */
@@ -1558,4 +1622,165 @@ interface PulseBarProps {
1558
1622
  */
1559
1623
  declare const PulseBar: React.FC<PulseBarProps>;
1560
1624
 
1561
- export { AreaChart, type AreaChartProps, AsciiRenderer, Axis, type AxisProps, BarChart, type BarChartProps, BigNumber, type BigNumberProps, BlockRenderer, BrailleRenderer, type EasingFunction, type EnvironmentInfo, Gauge, type GaugeProps, Grid, GridItem, type GridItemProps, type GridProps, Heatmap, type HeatmapProps, type InkHudContextValue, InkHudProvider, type InkHudProviderProps, Legend, type LegendItem, type LegendProps, LineChart, type LineChartProps, LogStream, type LogStreamProps, ONE_DARK_THEME, Panel, type PanelProps, PieChart, type PieChartDataItem, type PieChartProps, type PingRecord, type PingStatus, PulseBar, type PulseBarProps, Renderer, type RendererMetadata, type RendererResolution, RendererSelector, type RendererType, type SemanticColors, Sparkline, type SparklineProps, Table, type TableColumn, type TableProps, type TerminalCapabilities, TerminalDetector, type Theme, ThemeProvider, arcPoints, assignColors, averageDownsampling, clamp, colorToChalk, createGradient, degreesToRadians, distanceBetweenPoints, easeInCubic, easeInOutQuad, easeLinear, easeOutCubic, fixedIntervalDownsampling, linearScale, lttb, midpointCircle, minMaxDownsampling, normalize, pointOnArc, radiansToDegrees, rendererSelector, scaleToRange, terminalDetector, useInkHud, useRendererSelector, useSemanticColors, useSmooth, useSmoothArray, useTheme, useThrottle };
1625
+ /**
1626
+ * ink-hud visual symbol constants
1627
+ *
1628
+ * Centralised character table — grouped by purpose, not Unicode block.
1629
+ * Components import from here instead of hard-coding characters inline.
1630
+ * All entries are `as const` — stable references safe to use in object keys.
1631
+ */
1632
+ /** Trend direction arrows (BigNumber, Table) */
1633
+ declare const TREND: {
1634
+ readonly up: "▲";
1635
+ readonly down: "▼";
1636
+ readonly neutral: "─";
1637
+ };
1638
+ /** Legend dot marker (PieChart, Legend, chart core) */
1639
+ declare const LEGEND: {
1640
+ readonly dot: "●";
1641
+ };
1642
+ /** Filled / empty bar characters (Gauge) */
1643
+ declare const BAR: {
1644
+ readonly fill: "█";
1645
+ readonly empty: "░";
1646
+ };
1647
+ /** Default character for heatmap cells in character mode */
1648
+ declare const HEATMAP: {
1649
+ readonly default: "■";
1650
+ };
1651
+ /** Rounded-box border characters (PulseBar) */
1652
+ declare const BORDER_ROUNDED: {
1653
+ readonly topLeft: "╭";
1654
+ readonly topRight: "╮";
1655
+ readonly bottomLeft: "╰";
1656
+ readonly bottomRight: "╯";
1657
+ readonly horizontal: "─";
1658
+ readonly vertical: "│";
1659
+ readonly bar: "▌";
1660
+ };
1661
+ /** Multi-level bar characters for Sparkline character mode */
1662
+ declare const SPARK_LEVELS: {
1663
+ readonly block: readonly [" ", "▂", "▃", "▄", "▅", "▆", "▇", "█"];
1664
+ readonly braille: readonly ["⠀", "⡀", "⣀", "⣄", "⣤", "⣦", "⣶", "⣷", "⣿"];
1665
+ };
1666
+
1667
+ /**
1668
+ * Terminal image protocol capability detection
1669
+ */
1670
+ type ImageProtocol = 'kitty' | 'iterm2' | null;
1671
+ /**
1672
+ * Detect which image protocol (if any) the current terminal supports.
1673
+ *
1674
+ * Priority: Kitty Graphics > iTerm2 Inline Images
1675
+ * Users can override by setting INKHU_IMAGE_PROTOCOL=kitty|iterm2|none
1676
+ */
1677
+ declare function detectImageProtocol(env?: NodeJS.ProcessEnv): ImageProtocol;
1678
+
1679
+ /**
1680
+ * Minimal RGB PNG encoder — no dependencies (uses Node.js built-in zlib).
1681
+ */
1682
+ /**
1683
+ * Encode a grid of RGB pixels into a minimal PNG buffer.
1684
+ *
1685
+ * @param pixels - Row-major grid: pixels[row][col] = [r, g, b]
1686
+ */
1687
+ declare function createRgbPng(pixels: [number, number, number][][]): Buffer;
1688
+ /**
1689
+ * Convert a hex colour string (#rrggbb or rrggbb) to [r, g, b].
1690
+ */
1691
+ declare function hexToRgb(hex: string): [number, number, number];
1692
+
1693
+ /**
1694
+ * Kitty Graphics Protocol encoder
1695
+ *
1696
+ * Spec: https://sw.kovidgoyal.net/kitty/graphics-protocol/
1697
+ */
1698
+ /**
1699
+ * Encode a PNG buffer as a Kitty Graphics upload sequence (Unicode Placeholder mode).
1700
+ *
1701
+ * Unlike `encodeKitty` (a=T, immediate display), this stores the image under a
1702
+ * numeric ID without rendering it. The caller must then write placeholder characters
1703
+ * to select which cells display the image (see `encodeKittyPlaceholders`).
1704
+ *
1705
+ * Upload params:
1706
+ * a=T — transmit
1707
+ * U=1 — Unicode Placeholder virtual placement
1708
+ * i= — image ID (1–4294967295)
1709
+ * f=100 — PNG format
1710
+ * q=2 — quiet (suppress OK/error response)
1711
+ * c=, r= — nominal cell dimensions (informational for the terminal)
1712
+ */
1713
+ declare function encodeKittyUpload(pngBuffer: Buffer, cols: number, rows: number, imageId: number): string;
1714
+ /**
1715
+ * Build placeholder character rows for a previously-uploaded Kitty image.
1716
+ *
1717
+ * Each cell is represented by:
1718
+ * - fg color encoding the image ID: ESC[38;2;R;G;Bm
1719
+ * - U+10EEEE (Kitty placeholder, string-width=1)
1720
+ * - DIACRITICS[row] (zero-width combining mark)
1721
+ * - DIACRITICS[col] (zero-width combining mark)
1722
+ * - U+0020 (trailing space) — only when trailingSpace=true (default)
1723
+ *
1724
+ * trailingSpace=true → each cell = 2 terminal columns (Heatmap, 1 char + 1 space layout)
1725
+ * trailingSpace=false → each cell = 1 terminal column (Sparkline, 1 char per column layout)
1726
+ *
1727
+ * Returns a string with `rows` lines separated by '\n' (no trailing newline).
1728
+ */
1729
+ declare function encodeKittyPlaceholders(cols: number, rows: number, imageId: number, options?: {
1730
+ trailingSpace?: boolean;
1731
+ }): string;
1732
+ /**
1733
+ * Delete a previously-uploaded Kitty image by ID.
1734
+ * Write this to stdout when the component unmounts to free terminal memory.
1735
+ */
1736
+ declare function encodeKittyDelete(imageId: number): string;
1737
+ /**
1738
+ * Encode a PNG buffer as a Kitty sequence that transmits and displays immediately
1739
+ * (legacy / PoC mode, no image ID). Use `encodeKittyUpload` + `encodeKittyPlaceholders`
1740
+ * for ink integration instead.
1741
+ */
1742
+ declare function encodeKitty(pngBuffer: Buffer, cols: number, rows: number): string;
1743
+
1744
+ /**
1745
+ * iTerm2 Inline Images Protocol encoder
1746
+ *
1747
+ * Encodes a PNG buffer as an OSC 1337 escape sequence for iTerm2.
1748
+ *
1749
+ * Spec: https://iterm2.com/documentation-images.html
1750
+ */
1751
+ /**
1752
+ * Encode a PNG buffer as an iTerm2 inline image escape sequence.
1753
+ *
1754
+ * @param pngBuffer - Raw PNG data
1755
+ * @param cols - Desired display width in character columns (optional)
1756
+ */
1757
+ declare function encodeIterm2(pngBuffer: Buffer, cols?: number): string;
1758
+
1759
+ /**
1760
+ * Shared pixel-grid drawing utilities for image-mode chart components.
1761
+ * All functions produce RGB[][], ready to pass to createRgbPng().
1762
+ */
1763
+ type RGB = [number, number, number];
1764
+ /**
1765
+ * Returns a function that maps a normalized value [0, 1] to an RGB color
1766
+ * by interpolating through the provided color stops (256-step palette).
1767
+ */
1768
+ declare function gradientColorFn(colors: string[]): (normalized: number) => RGB;
1769
+ /**
1770
+ * Build an RGB pixel grid for a sparkline area chart.
1771
+ *
1772
+ * Each data value is linearly interpolated across pixel columns.
1773
+ * The line is drawn 2 px thick; the area below is filled with a darkened version
1774
+ * of the line color. bgColor fills everything above the line.
1775
+ *
1776
+ * @param data - Processed (downsampled) data points
1777
+ * @param widthPx - Pixel width of the output image
1778
+ * @param heightPx - Pixel height of the output image
1779
+ * @param min - Data minimum (for normalization)
1780
+ * @param max - Data maximum (for normalization)
1781
+ * @param colorFn - Maps normalized value → RGB (use gradientColorFn)
1782
+ * @param bgColor - Background color (default: near-black)
1783
+ */
1784
+ declare function buildSparklinePixelGrid(data: number[], widthPx: number, heightPx: number, min: number, max: number, colorFn: (normalized: number) => RGB, bgColor?: RGB): RGB[][];
1785
+
1786
+ export { AreaChart, type AreaChartProps, Axis, type AxisProps, BAR, BORDER_ROUNDED, BarChart, type BarChartProps, BigNumber, type BigNumberProps, BlockRenderer, BrailleRenderer, type ChartKind, type ChartRenderers, DEFAULT_CHART_RENDERERS, type EasingFunction, type EnvironmentInfo, Gauge, type GaugeProps, Grid, GridItem, type GridItemProps, type GridProps, HEATMAP, Heatmap, type HeatmapProps, type ImageProtocol, type InkHudContextValue, InkHudProvider, type InkHudProviderProps, LEGEND, Legend, type LegendItem, type LegendProps, LineChart, type LineChartProps, LogStream, type LogStreamProps, ONE_DARK_THEME, Panel, type PanelProps, PieChart, type PieChartDataItem, type PieChartProps, type PingRecord, type PingStatus, PulseBar, type PulseBarProps, Renderer, type RendererMetadata, type RendererResolution, RendererSelector, type RendererType, SPARK_LEVELS, type SemanticColors, Sparkline, type SparklineProps, TREND, Table, type TableColumn, type TableProps, type TerminalCapabilities, TerminalDetector, type Theme, ThemeProvider, type UseImageProtocolOptions, type UseImageProtocolResult, arcPoints, assignColors, averageDownsampling, buildSparklinePixelGrid, clamp, colorToChalk, createGradient, createRgbPng, degreesToRadians, detectImageProtocol, distanceBetweenPoints, easeInCubic, easeInOutQuad, easeLinear, easeOutCubic, encodeIterm2, encodeKitty, encodeKittyDelete, encodeKittyPlaceholders, encodeKittyUpload, fixedIntervalDownsampling, gradientColorFn, hexToRgb, linearScale, lttb, midpointCircle, minMaxDownsampling, normalize, pointOnArc, radiansToDegrees, rendererSelector, scaleToRange, terminalDetector, useImageProtocol, useInkHud, useRendererSelector, useSemanticColors, useSmooth, useSmoothArray, useTheme, useThrottle };