@termuijs/core 0.1.1 → 0.1.3
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/LICENSE +21 -0
- package/README.md +28 -27
- package/dist/index.cjs +402 -34
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +299 -1
- package/dist/index.d.ts +299 -1
- package/dist/index.js +380 -34
- package/dist/index.js.map +1 -1
- package/package.json +7 -2
package/dist/index.d.cts
CHANGED
|
@@ -88,6 +88,11 @@ declare class Terminal {
|
|
|
88
88
|
private _resizeHandlers;
|
|
89
89
|
private _cleanupHandlers;
|
|
90
90
|
private _originalRawMode;
|
|
91
|
+
private _resizeHandler;
|
|
92
|
+
private _exitHandler;
|
|
93
|
+
private _sigintHandler;
|
|
94
|
+
private _sigtermHandler;
|
|
95
|
+
private _restored;
|
|
91
96
|
constructor(options?: TerminalOptions);
|
|
92
97
|
/** Current terminal width in columns */
|
|
93
98
|
get cols(): number;
|
|
@@ -109,6 +114,7 @@ declare class Terminal {
|
|
|
109
114
|
onResize(handler: (cols: number, rows: number) => void): () => void;
|
|
110
115
|
/**
|
|
111
116
|
* Restore terminal to its original state.
|
|
117
|
+
* Removes all process signal handlers to prevent leaks.
|
|
112
118
|
* Called automatically on SIGINT, SIGTERM, process exit.
|
|
113
119
|
*/
|
|
114
120
|
restore(): void;
|
|
@@ -693,6 +699,52 @@ declare function createLayoutNode(id: string, style: Style, children?: LayoutNod
|
|
|
693
699
|
*/
|
|
694
700
|
declare function computeLayout(root: LayoutNode, containerWidth: number, containerHeight: number): void;
|
|
695
701
|
|
|
702
|
+
type Constraint = {
|
|
703
|
+
type: 'length';
|
|
704
|
+
value: number;
|
|
705
|
+
} | {
|
|
706
|
+
type: 'percentage';
|
|
707
|
+
value: number;
|
|
708
|
+
} | {
|
|
709
|
+
type: 'ratio';
|
|
710
|
+
num: number;
|
|
711
|
+
den: number;
|
|
712
|
+
} | {
|
|
713
|
+
type: 'min';
|
|
714
|
+
value: number;
|
|
715
|
+
} | {
|
|
716
|
+
type: 'max';
|
|
717
|
+
value: number;
|
|
718
|
+
} | {
|
|
719
|
+
type: 'fill';
|
|
720
|
+
weight: number;
|
|
721
|
+
};
|
|
722
|
+
/** Exactly n cells. */
|
|
723
|
+
declare const length: (n: number) => Constraint;
|
|
724
|
+
/** n% of available space. */
|
|
725
|
+
declare const percentage: (n: number) => Constraint;
|
|
726
|
+
/** num/den of available space. */
|
|
727
|
+
declare const ratio: (num: number, den: number) => Constraint;
|
|
728
|
+
/** At least n cells. */
|
|
729
|
+
declare const min: (n: number) => Constraint;
|
|
730
|
+
/** At most n cells. */
|
|
731
|
+
declare const max: (n: number) => Constraint;
|
|
732
|
+
/** Fill remaining space with the given weight. Default weight: 1. */
|
|
733
|
+
declare const fill: (weight?: number) => Constraint;
|
|
734
|
+
/**
|
|
735
|
+
* Split a rectangle into sub-rectangles using constraints.
|
|
736
|
+
*
|
|
737
|
+
* Example:
|
|
738
|
+
* ```ts
|
|
739
|
+
* const [header, body, footer] = splitRect(
|
|
740
|
+
* area,
|
|
741
|
+
* [length(3), fill(), length(1)],
|
|
742
|
+
* 'vertical',
|
|
743
|
+
* );
|
|
744
|
+
* ```
|
|
745
|
+
*/
|
|
746
|
+
declare function splitRect(rect: Rect, constraints: Constraint[], direction?: 'horizontal' | 'vertical', gap?: number): Rect[];
|
|
747
|
+
|
|
696
748
|
/**
|
|
697
749
|
* Strongly-typed event emitter using TypeScript generics.
|
|
698
750
|
* Supports `on`, `off`, `once`, `emit` with type-safe event maps.
|
|
@@ -839,6 +891,250 @@ declare class FocusManager {
|
|
|
839
891
|
private _changeFocus;
|
|
840
892
|
}
|
|
841
893
|
|
|
894
|
+
interface BorderSet {
|
|
895
|
+
topLeft: string;
|
|
896
|
+
topRight: string;
|
|
897
|
+
bottomLeft: string;
|
|
898
|
+
bottomRight: string;
|
|
899
|
+
horizontal: string;
|
|
900
|
+
vertical: string;
|
|
901
|
+
cross: string;
|
|
902
|
+
}
|
|
903
|
+
declare const BorderSets: {
|
|
904
|
+
readonly PLAIN: {
|
|
905
|
+
readonly topLeft: "┌";
|
|
906
|
+
readonly topRight: "┐";
|
|
907
|
+
readonly bottomLeft: "└";
|
|
908
|
+
readonly bottomRight: "┘";
|
|
909
|
+
readonly horizontal: "─";
|
|
910
|
+
readonly vertical: "│";
|
|
911
|
+
readonly cross: "┼";
|
|
912
|
+
};
|
|
913
|
+
readonly ROUNDED: {
|
|
914
|
+
readonly topLeft: "╭";
|
|
915
|
+
readonly topRight: "╮";
|
|
916
|
+
readonly bottomLeft: "╰";
|
|
917
|
+
readonly bottomRight: "╯";
|
|
918
|
+
readonly horizontal: "─";
|
|
919
|
+
readonly vertical: "│";
|
|
920
|
+
readonly cross: "┼";
|
|
921
|
+
};
|
|
922
|
+
readonly DOUBLE: {
|
|
923
|
+
readonly topLeft: "╔";
|
|
924
|
+
readonly topRight: "╗";
|
|
925
|
+
readonly bottomLeft: "╚";
|
|
926
|
+
readonly bottomRight: "╝";
|
|
927
|
+
readonly horizontal: "═";
|
|
928
|
+
readonly vertical: "║";
|
|
929
|
+
readonly cross: "╬";
|
|
930
|
+
};
|
|
931
|
+
readonly THICK: {
|
|
932
|
+
readonly topLeft: "┏";
|
|
933
|
+
readonly topRight: "┓";
|
|
934
|
+
readonly bottomLeft: "┗";
|
|
935
|
+
readonly bottomRight: "┛";
|
|
936
|
+
readonly horizontal: "━";
|
|
937
|
+
readonly vertical: "┃";
|
|
938
|
+
readonly cross: "╋";
|
|
939
|
+
};
|
|
940
|
+
readonly QUADRANT_INSIDE: {
|
|
941
|
+
readonly topLeft: "▗";
|
|
942
|
+
readonly topRight: "▖";
|
|
943
|
+
readonly bottomLeft: "▝";
|
|
944
|
+
readonly bottomRight: "▘";
|
|
945
|
+
readonly horizontal: "▀";
|
|
946
|
+
readonly vertical: "▐";
|
|
947
|
+
readonly cross: "█";
|
|
948
|
+
};
|
|
949
|
+
readonly QUADRANT_OUTSIDE: {
|
|
950
|
+
readonly topLeft: "▛";
|
|
951
|
+
readonly topRight: "▜";
|
|
952
|
+
readonly bottomLeft: "▙";
|
|
953
|
+
readonly bottomRight: "▟";
|
|
954
|
+
readonly horizontal: "▀";
|
|
955
|
+
readonly vertical: "▌";
|
|
956
|
+
readonly cross: "█";
|
|
957
|
+
};
|
|
958
|
+
readonly EMPTY: {
|
|
959
|
+
readonly topLeft: " ";
|
|
960
|
+
readonly topRight: " ";
|
|
961
|
+
readonly bottomLeft: " ";
|
|
962
|
+
readonly bottomRight: " ";
|
|
963
|
+
readonly horizontal: " ";
|
|
964
|
+
readonly vertical: " ";
|
|
965
|
+
readonly cross: " ";
|
|
966
|
+
};
|
|
967
|
+
};
|
|
968
|
+
interface BarSet {
|
|
969
|
+
full: string;
|
|
970
|
+
sevenEighths: string;
|
|
971
|
+
threeQuarters: string;
|
|
972
|
+
fiveEighths: string;
|
|
973
|
+
half: string;
|
|
974
|
+
threeEighths: string;
|
|
975
|
+
oneQuarter: string;
|
|
976
|
+
oneEighth: string;
|
|
977
|
+
empty: string;
|
|
978
|
+
}
|
|
979
|
+
/**
|
|
980
|
+
* Vertical bar symbols: bottom-up block characters ▁▂▃▄▅▆▇█
|
|
981
|
+
* 9 levels (including empty) for sub-cell precision.
|
|
982
|
+
*/
|
|
983
|
+
declare const BarSets: {
|
|
984
|
+
readonly NINE_LEVELS: {
|
|
985
|
+
readonly full: "█";
|
|
986
|
+
readonly sevenEighths: "▇";
|
|
987
|
+
readonly threeQuarters: "▆";
|
|
988
|
+
readonly fiveEighths: "▅";
|
|
989
|
+
readonly half: "▄";
|
|
990
|
+
readonly threeEighths: "▃";
|
|
991
|
+
readonly oneQuarter: "▂";
|
|
992
|
+
readonly oneEighth: "▁";
|
|
993
|
+
readonly empty: " ";
|
|
994
|
+
};
|
|
995
|
+
readonly THREE_LEVELS: {
|
|
996
|
+
readonly full: "█";
|
|
997
|
+
readonly sevenEighths: "░";
|
|
998
|
+
readonly threeQuarters: "░";
|
|
999
|
+
readonly fiveEighths: "░";
|
|
1000
|
+
readonly half: "▄";
|
|
1001
|
+
readonly threeEighths: "░";
|
|
1002
|
+
readonly oneQuarter: "░";
|
|
1003
|
+
readonly oneEighth: "░";
|
|
1004
|
+
readonly empty: " ";
|
|
1005
|
+
};
|
|
1006
|
+
readonly ASCII: {
|
|
1007
|
+
readonly full: "#";
|
|
1008
|
+
readonly sevenEighths: "#";
|
|
1009
|
+
readonly threeQuarters: "#";
|
|
1010
|
+
readonly fiveEighths: "#";
|
|
1011
|
+
readonly half: "#";
|
|
1012
|
+
readonly threeEighths: "-";
|
|
1013
|
+
readonly oneQuarter: "-";
|
|
1014
|
+
readonly oneEighth: "-";
|
|
1015
|
+
readonly empty: " ";
|
|
1016
|
+
};
|
|
1017
|
+
};
|
|
1018
|
+
/** Ordered vertical bar symbols from empty to full (9 levels). */
|
|
1019
|
+
declare const VERTICAL_BAR_SYMBOLS: readonly string[];
|
|
1020
|
+
/** Ordered horizontal bar symbols from empty to full (9 levels). */
|
|
1021
|
+
declare const HORIZONTAL_BAR_SYMBOLS: readonly string[];
|
|
1022
|
+
interface ScrollbarSet {
|
|
1023
|
+
track: string;
|
|
1024
|
+
thumb: string;
|
|
1025
|
+
begin: string;
|
|
1026
|
+
end: string;
|
|
1027
|
+
}
|
|
1028
|
+
declare const ScrollbarSets: {
|
|
1029
|
+
readonly VERTICAL: {
|
|
1030
|
+
readonly track: "│";
|
|
1031
|
+
readonly thumb: "█";
|
|
1032
|
+
readonly begin: "↑";
|
|
1033
|
+
readonly end: "↓";
|
|
1034
|
+
};
|
|
1035
|
+
readonly HORIZONTAL: {
|
|
1036
|
+
readonly track: "─";
|
|
1037
|
+
readonly thumb: "█";
|
|
1038
|
+
readonly begin: "←";
|
|
1039
|
+
readonly end: "→";
|
|
1040
|
+
};
|
|
1041
|
+
readonly DOUBLE_VERTICAL: {
|
|
1042
|
+
readonly track: "║";
|
|
1043
|
+
readonly thumb: "▐";
|
|
1044
|
+
readonly begin: "▲";
|
|
1045
|
+
readonly end: "▼";
|
|
1046
|
+
};
|
|
1047
|
+
readonly DOUBLE_HORIZONTAL: {
|
|
1048
|
+
readonly track: "═";
|
|
1049
|
+
readonly thumb: "▌";
|
|
1050
|
+
readonly begin: "◄";
|
|
1051
|
+
readonly end: "►";
|
|
1052
|
+
};
|
|
1053
|
+
};
|
|
1054
|
+
interface LineSet {
|
|
1055
|
+
horizontal: string;
|
|
1056
|
+
vertical: string;
|
|
1057
|
+
cross: string;
|
|
1058
|
+
}
|
|
1059
|
+
declare const LineSets: {
|
|
1060
|
+
readonly NORMAL: {
|
|
1061
|
+
readonly horizontal: "─";
|
|
1062
|
+
readonly vertical: "│";
|
|
1063
|
+
readonly cross: "┼";
|
|
1064
|
+
};
|
|
1065
|
+
readonly THICK: {
|
|
1066
|
+
readonly horizontal: "━";
|
|
1067
|
+
readonly vertical: "┃";
|
|
1068
|
+
readonly cross: "╋";
|
|
1069
|
+
};
|
|
1070
|
+
readonly DOUBLE: {
|
|
1071
|
+
readonly horizontal: "═";
|
|
1072
|
+
readonly vertical: "║";
|
|
1073
|
+
readonly cross: "╬";
|
|
1074
|
+
};
|
|
1075
|
+
};
|
|
1076
|
+
declare const Shade: {
|
|
1077
|
+
readonly FULL: "█";
|
|
1078
|
+
readonly DARK: "▓";
|
|
1079
|
+
readonly MEDIUM: "▒";
|
|
1080
|
+
readonly LIGHT: "░";
|
|
1081
|
+
readonly EMPTY: " ";
|
|
1082
|
+
};
|
|
1083
|
+
/** Unicode braille range offset (U+2800). */
|
|
1084
|
+
declare const BRAILLE_OFFSET = 10240;
|
|
1085
|
+
/**
|
|
1086
|
+
* Braille dot bit positions.
|
|
1087
|
+
* Each row is [leftBit, rightBit] for a 2-wide, 4-tall braille cell.
|
|
1088
|
+
*/
|
|
1089
|
+
declare const BRAILLE_DOTS: readonly (readonly [number, number])[];
|
|
1090
|
+
|
|
1091
|
+
/**
|
|
1092
|
+
* In-memory grid that captures rendered output.
|
|
1093
|
+
* Use `createTestScreen()` to create one, render widgets into it,
|
|
1094
|
+
* then call `testScreenToString()` to get a plain-text snapshot.
|
|
1095
|
+
*/
|
|
1096
|
+
interface TestScreen {
|
|
1097
|
+
readonly width: number;
|
|
1098
|
+
readonly height: number;
|
|
1099
|
+
cells: Cell[][];
|
|
1100
|
+
}
|
|
1101
|
+
/**
|
|
1102
|
+
* Create an in-memory test screen of the given dimensions.
|
|
1103
|
+
* Every cell starts as empty (space character, default colors).
|
|
1104
|
+
*/
|
|
1105
|
+
declare function createTestScreen(width: number, height: number): TestScreen;
|
|
1106
|
+
/**
|
|
1107
|
+
* Set a cell in the test screen at (x, y).
|
|
1108
|
+
* Out-of-bounds writes are silently ignored.
|
|
1109
|
+
*/
|
|
1110
|
+
declare function testScreenSetCell(screen: TestScreen, x: number, y: number, cell: Cell): void;
|
|
1111
|
+
/**
|
|
1112
|
+
* Get the cell at (x, y) in the test screen.
|
|
1113
|
+
* Returns undefined for out-of-bounds coordinates.
|
|
1114
|
+
*/
|
|
1115
|
+
declare function testScreenGetCell(screen: TestScreen, x: number, y: number): Cell | undefined;
|
|
1116
|
+
/**
|
|
1117
|
+
* Convert the test screen to a plain-text string.
|
|
1118
|
+
* Each row becomes a line. Trailing spaces on each line are preserved.
|
|
1119
|
+
*
|
|
1120
|
+
* Example output:
|
|
1121
|
+
* ```
|
|
1122
|
+
* ┌Hello──┐
|
|
1123
|
+
* │World │
|
|
1124
|
+
* └───────┘
|
|
1125
|
+
* ```
|
|
1126
|
+
*/
|
|
1127
|
+
declare function testScreenToString(screen: TestScreen): string;
|
|
1128
|
+
/**
|
|
1129
|
+
* Clear the test screen, resetting all cells to empty.
|
|
1130
|
+
*/
|
|
1131
|
+
declare function testScreenClear(screen: TestScreen): void;
|
|
1132
|
+
/**
|
|
1133
|
+
* Write a string into the test screen starting at (x, y).
|
|
1134
|
+
* Characters that fall outside the screen bounds are clipped.
|
|
1135
|
+
*/
|
|
1136
|
+
declare function testScreenSetString(screen: TestScreen, x: number, y: number, str: string): void;
|
|
1137
|
+
|
|
842
1138
|
interface AppOptions extends TerminalOptions {
|
|
843
1139
|
/** Frames per second for the render loop */
|
|
844
1140
|
fps?: number;
|
|
@@ -848,6 +1144,8 @@ interface AppOptions extends TerminalOptions {
|
|
|
848
1144
|
mouse?: boolean;
|
|
849
1145
|
/** Force fallback (static) rendering */
|
|
850
1146
|
forceFallback?: boolean;
|
|
1147
|
+
/** Skip fallback detection — always run interactively. Default: false */
|
|
1148
|
+
skipFallback?: boolean;
|
|
851
1149
|
/** Title to set on the terminal window */
|
|
852
1150
|
title?: string;
|
|
853
1151
|
}
|
|
@@ -1078,4 +1376,4 @@ declare namespace ansi {
|
|
|
1078
1376
|
export { ansi_CSI as CSI, ansi_ESC as ESC, ansi_OSC as OSC, ansi_beginSyncUpdate as beginSyncUpdate, ansi_blink as blink, ansi_bold as bold, ansi_clearDown as clearDown, ansi_clearLine as clearLine, ansi_clearLineToEnd as clearLineToEnd, ansi_clearLineToStart as clearLineToStart, ansi_clearScreen as clearScreen, ansi_clearUp as clearUp, ansi_dim as dim, ansi_disableBracketedPaste as disableBracketedPaste, ansi_disableMouse as disableMouse, ansi_enableBracketedPaste as enableBracketedPaste, ansi_enableMouse as enableMouse, ansi_endSyncUpdate as endSyncUpdate, ansi_enterAltScreen as enterAltScreen, ansi_exitAltScreen as exitAltScreen, ansi_hideCursor as hideCursor, ansi_inverse as inverse, ansi_italic as italic, ansi_moveDown as moveDown, ansi_moveLeft as moveLeft, ansi_moveRight as moveRight, ansi_moveTo as moveTo, ansi_moveUp as moveUp, ansi_reset as reset, ansi_resetBlink as resetBlink, ansi_resetBold as resetBold, ansi_resetDim as resetDim, ansi_resetInverse as resetInverse, ansi_resetItalic as resetItalic, ansi_resetScrollRegion as resetScrollRegion, ansi_resetStrikethrough as resetStrikethrough, ansi_resetUnderline as resetUnderline, ansi_restoreCursorPosition as restoreCursorPosition, ansi_saveCursorPosition as saveCursorPosition, ansi_setScrollRegion as setScrollRegion, ansi_setTitle as setTitle, ansi_showCursor as showCursor, ansi_strikethrough as strikethrough, ansi_underline as underline };
|
|
1079
1377
|
}
|
|
1080
1378
|
|
|
1081
|
-
export { App, type AppOptions, BORDER_CHARS, type BorderChars, type BorderStyle, CTRL_KEYS, type Cell, type Color, ColorDepth, ESCAPE_SEQUENCES, type Edges, EventEmitter, type EventMap, type FocusEvent, FocusManager, type Focusable, InputParser, type KeyEvent, type Layer, LayerManager, type LayoutNode, type MouseEvent, type NamedColor, type Rect, Renderer, type ResizeEvent, type RootWidget, SPECIAL_KEYS, Screen, type Size, type Style, Terminal, type TerminalOptions, ansi, borderSize, cellsEqual, colorToAnsiBg, colorToAnsiFg, colorToRgb, computeLayout, containsPoint, createKeyEvent, createLayoutNode, defaultStyle, detectColorDepth, emptyCell, emptyRect, getBorderChars, intersectRect, isMouseSequence, mergeStyles, normalizeEdges, parseColor, parseMouseEvent, renderFallback, shouldUseFallback, shrinkRect, stringWidth, stripAnsi, styleToCellAttrs, truncate, unionRect, wordWrap };
|
|
1379
|
+
export { App, type AppOptions, BORDER_CHARS, BRAILLE_DOTS, BRAILLE_OFFSET, type BarSet, BarSets, type BorderChars, type BorderSet, BorderSets, type BorderStyle, CTRL_KEYS, type Cell, type Color, ColorDepth, type Constraint, ESCAPE_SEQUENCES, type Edges, EventEmitter, type EventMap, type FocusEvent, FocusManager, type Focusable, HORIZONTAL_BAR_SYMBOLS, InputParser, type KeyEvent, type Layer, LayerManager, type LayoutNode, type LineSet, LineSets, type MouseEvent, type NamedColor, type Rect, Renderer, type ResizeEvent, type RootWidget, SPECIAL_KEYS, Screen, type ScrollbarSet, ScrollbarSets, Shade, type Size, type Style, Terminal, type TerminalOptions, type TestScreen, VERTICAL_BAR_SYMBOLS, ansi, borderSize, cellsEqual, colorToAnsiBg, colorToAnsiFg, colorToRgb, computeLayout, containsPoint, createKeyEvent, createLayoutNode, createTestScreen, defaultStyle, detectColorDepth, emptyCell, emptyRect, fill, getBorderChars, intersectRect, isMouseSequence, length, max, mergeStyles, min, normalizeEdges, parseColor, parseMouseEvent, percentage, ratio, renderFallback, shouldUseFallback, shrinkRect, splitRect, stringWidth, stripAnsi, styleToCellAttrs, testScreenClear, testScreenGetCell, testScreenSetCell, testScreenSetString, testScreenToString, truncate, unionRect, wordWrap };
|
package/dist/index.d.ts
CHANGED
|
@@ -88,6 +88,11 @@ declare class Terminal {
|
|
|
88
88
|
private _resizeHandlers;
|
|
89
89
|
private _cleanupHandlers;
|
|
90
90
|
private _originalRawMode;
|
|
91
|
+
private _resizeHandler;
|
|
92
|
+
private _exitHandler;
|
|
93
|
+
private _sigintHandler;
|
|
94
|
+
private _sigtermHandler;
|
|
95
|
+
private _restored;
|
|
91
96
|
constructor(options?: TerminalOptions);
|
|
92
97
|
/** Current terminal width in columns */
|
|
93
98
|
get cols(): number;
|
|
@@ -109,6 +114,7 @@ declare class Terminal {
|
|
|
109
114
|
onResize(handler: (cols: number, rows: number) => void): () => void;
|
|
110
115
|
/**
|
|
111
116
|
* Restore terminal to its original state.
|
|
117
|
+
* Removes all process signal handlers to prevent leaks.
|
|
112
118
|
* Called automatically on SIGINT, SIGTERM, process exit.
|
|
113
119
|
*/
|
|
114
120
|
restore(): void;
|
|
@@ -693,6 +699,52 @@ declare function createLayoutNode(id: string, style: Style, children?: LayoutNod
|
|
|
693
699
|
*/
|
|
694
700
|
declare function computeLayout(root: LayoutNode, containerWidth: number, containerHeight: number): void;
|
|
695
701
|
|
|
702
|
+
type Constraint = {
|
|
703
|
+
type: 'length';
|
|
704
|
+
value: number;
|
|
705
|
+
} | {
|
|
706
|
+
type: 'percentage';
|
|
707
|
+
value: number;
|
|
708
|
+
} | {
|
|
709
|
+
type: 'ratio';
|
|
710
|
+
num: number;
|
|
711
|
+
den: number;
|
|
712
|
+
} | {
|
|
713
|
+
type: 'min';
|
|
714
|
+
value: number;
|
|
715
|
+
} | {
|
|
716
|
+
type: 'max';
|
|
717
|
+
value: number;
|
|
718
|
+
} | {
|
|
719
|
+
type: 'fill';
|
|
720
|
+
weight: number;
|
|
721
|
+
};
|
|
722
|
+
/** Exactly n cells. */
|
|
723
|
+
declare const length: (n: number) => Constraint;
|
|
724
|
+
/** n% of available space. */
|
|
725
|
+
declare const percentage: (n: number) => Constraint;
|
|
726
|
+
/** num/den of available space. */
|
|
727
|
+
declare const ratio: (num: number, den: number) => Constraint;
|
|
728
|
+
/** At least n cells. */
|
|
729
|
+
declare const min: (n: number) => Constraint;
|
|
730
|
+
/** At most n cells. */
|
|
731
|
+
declare const max: (n: number) => Constraint;
|
|
732
|
+
/** Fill remaining space with the given weight. Default weight: 1. */
|
|
733
|
+
declare const fill: (weight?: number) => Constraint;
|
|
734
|
+
/**
|
|
735
|
+
* Split a rectangle into sub-rectangles using constraints.
|
|
736
|
+
*
|
|
737
|
+
* Example:
|
|
738
|
+
* ```ts
|
|
739
|
+
* const [header, body, footer] = splitRect(
|
|
740
|
+
* area,
|
|
741
|
+
* [length(3), fill(), length(1)],
|
|
742
|
+
* 'vertical',
|
|
743
|
+
* );
|
|
744
|
+
* ```
|
|
745
|
+
*/
|
|
746
|
+
declare function splitRect(rect: Rect, constraints: Constraint[], direction?: 'horizontal' | 'vertical', gap?: number): Rect[];
|
|
747
|
+
|
|
696
748
|
/**
|
|
697
749
|
* Strongly-typed event emitter using TypeScript generics.
|
|
698
750
|
* Supports `on`, `off`, `once`, `emit` with type-safe event maps.
|
|
@@ -839,6 +891,250 @@ declare class FocusManager {
|
|
|
839
891
|
private _changeFocus;
|
|
840
892
|
}
|
|
841
893
|
|
|
894
|
+
interface BorderSet {
|
|
895
|
+
topLeft: string;
|
|
896
|
+
topRight: string;
|
|
897
|
+
bottomLeft: string;
|
|
898
|
+
bottomRight: string;
|
|
899
|
+
horizontal: string;
|
|
900
|
+
vertical: string;
|
|
901
|
+
cross: string;
|
|
902
|
+
}
|
|
903
|
+
declare const BorderSets: {
|
|
904
|
+
readonly PLAIN: {
|
|
905
|
+
readonly topLeft: "┌";
|
|
906
|
+
readonly topRight: "┐";
|
|
907
|
+
readonly bottomLeft: "└";
|
|
908
|
+
readonly bottomRight: "┘";
|
|
909
|
+
readonly horizontal: "─";
|
|
910
|
+
readonly vertical: "│";
|
|
911
|
+
readonly cross: "┼";
|
|
912
|
+
};
|
|
913
|
+
readonly ROUNDED: {
|
|
914
|
+
readonly topLeft: "╭";
|
|
915
|
+
readonly topRight: "╮";
|
|
916
|
+
readonly bottomLeft: "╰";
|
|
917
|
+
readonly bottomRight: "╯";
|
|
918
|
+
readonly horizontal: "─";
|
|
919
|
+
readonly vertical: "│";
|
|
920
|
+
readonly cross: "┼";
|
|
921
|
+
};
|
|
922
|
+
readonly DOUBLE: {
|
|
923
|
+
readonly topLeft: "╔";
|
|
924
|
+
readonly topRight: "╗";
|
|
925
|
+
readonly bottomLeft: "╚";
|
|
926
|
+
readonly bottomRight: "╝";
|
|
927
|
+
readonly horizontal: "═";
|
|
928
|
+
readonly vertical: "║";
|
|
929
|
+
readonly cross: "╬";
|
|
930
|
+
};
|
|
931
|
+
readonly THICK: {
|
|
932
|
+
readonly topLeft: "┏";
|
|
933
|
+
readonly topRight: "┓";
|
|
934
|
+
readonly bottomLeft: "┗";
|
|
935
|
+
readonly bottomRight: "┛";
|
|
936
|
+
readonly horizontal: "━";
|
|
937
|
+
readonly vertical: "┃";
|
|
938
|
+
readonly cross: "╋";
|
|
939
|
+
};
|
|
940
|
+
readonly QUADRANT_INSIDE: {
|
|
941
|
+
readonly topLeft: "▗";
|
|
942
|
+
readonly topRight: "▖";
|
|
943
|
+
readonly bottomLeft: "▝";
|
|
944
|
+
readonly bottomRight: "▘";
|
|
945
|
+
readonly horizontal: "▀";
|
|
946
|
+
readonly vertical: "▐";
|
|
947
|
+
readonly cross: "█";
|
|
948
|
+
};
|
|
949
|
+
readonly QUADRANT_OUTSIDE: {
|
|
950
|
+
readonly topLeft: "▛";
|
|
951
|
+
readonly topRight: "▜";
|
|
952
|
+
readonly bottomLeft: "▙";
|
|
953
|
+
readonly bottomRight: "▟";
|
|
954
|
+
readonly horizontal: "▀";
|
|
955
|
+
readonly vertical: "▌";
|
|
956
|
+
readonly cross: "█";
|
|
957
|
+
};
|
|
958
|
+
readonly EMPTY: {
|
|
959
|
+
readonly topLeft: " ";
|
|
960
|
+
readonly topRight: " ";
|
|
961
|
+
readonly bottomLeft: " ";
|
|
962
|
+
readonly bottomRight: " ";
|
|
963
|
+
readonly horizontal: " ";
|
|
964
|
+
readonly vertical: " ";
|
|
965
|
+
readonly cross: " ";
|
|
966
|
+
};
|
|
967
|
+
};
|
|
968
|
+
interface BarSet {
|
|
969
|
+
full: string;
|
|
970
|
+
sevenEighths: string;
|
|
971
|
+
threeQuarters: string;
|
|
972
|
+
fiveEighths: string;
|
|
973
|
+
half: string;
|
|
974
|
+
threeEighths: string;
|
|
975
|
+
oneQuarter: string;
|
|
976
|
+
oneEighth: string;
|
|
977
|
+
empty: string;
|
|
978
|
+
}
|
|
979
|
+
/**
|
|
980
|
+
* Vertical bar symbols: bottom-up block characters ▁▂▃▄▅▆▇█
|
|
981
|
+
* 9 levels (including empty) for sub-cell precision.
|
|
982
|
+
*/
|
|
983
|
+
declare const BarSets: {
|
|
984
|
+
readonly NINE_LEVELS: {
|
|
985
|
+
readonly full: "█";
|
|
986
|
+
readonly sevenEighths: "▇";
|
|
987
|
+
readonly threeQuarters: "▆";
|
|
988
|
+
readonly fiveEighths: "▅";
|
|
989
|
+
readonly half: "▄";
|
|
990
|
+
readonly threeEighths: "▃";
|
|
991
|
+
readonly oneQuarter: "▂";
|
|
992
|
+
readonly oneEighth: "▁";
|
|
993
|
+
readonly empty: " ";
|
|
994
|
+
};
|
|
995
|
+
readonly THREE_LEVELS: {
|
|
996
|
+
readonly full: "█";
|
|
997
|
+
readonly sevenEighths: "░";
|
|
998
|
+
readonly threeQuarters: "░";
|
|
999
|
+
readonly fiveEighths: "░";
|
|
1000
|
+
readonly half: "▄";
|
|
1001
|
+
readonly threeEighths: "░";
|
|
1002
|
+
readonly oneQuarter: "░";
|
|
1003
|
+
readonly oneEighth: "░";
|
|
1004
|
+
readonly empty: " ";
|
|
1005
|
+
};
|
|
1006
|
+
readonly ASCII: {
|
|
1007
|
+
readonly full: "#";
|
|
1008
|
+
readonly sevenEighths: "#";
|
|
1009
|
+
readonly threeQuarters: "#";
|
|
1010
|
+
readonly fiveEighths: "#";
|
|
1011
|
+
readonly half: "#";
|
|
1012
|
+
readonly threeEighths: "-";
|
|
1013
|
+
readonly oneQuarter: "-";
|
|
1014
|
+
readonly oneEighth: "-";
|
|
1015
|
+
readonly empty: " ";
|
|
1016
|
+
};
|
|
1017
|
+
};
|
|
1018
|
+
/** Ordered vertical bar symbols from empty to full (9 levels). */
|
|
1019
|
+
declare const VERTICAL_BAR_SYMBOLS: readonly string[];
|
|
1020
|
+
/** Ordered horizontal bar symbols from empty to full (9 levels). */
|
|
1021
|
+
declare const HORIZONTAL_BAR_SYMBOLS: readonly string[];
|
|
1022
|
+
interface ScrollbarSet {
|
|
1023
|
+
track: string;
|
|
1024
|
+
thumb: string;
|
|
1025
|
+
begin: string;
|
|
1026
|
+
end: string;
|
|
1027
|
+
}
|
|
1028
|
+
declare const ScrollbarSets: {
|
|
1029
|
+
readonly VERTICAL: {
|
|
1030
|
+
readonly track: "│";
|
|
1031
|
+
readonly thumb: "█";
|
|
1032
|
+
readonly begin: "↑";
|
|
1033
|
+
readonly end: "↓";
|
|
1034
|
+
};
|
|
1035
|
+
readonly HORIZONTAL: {
|
|
1036
|
+
readonly track: "─";
|
|
1037
|
+
readonly thumb: "█";
|
|
1038
|
+
readonly begin: "←";
|
|
1039
|
+
readonly end: "→";
|
|
1040
|
+
};
|
|
1041
|
+
readonly DOUBLE_VERTICAL: {
|
|
1042
|
+
readonly track: "║";
|
|
1043
|
+
readonly thumb: "▐";
|
|
1044
|
+
readonly begin: "▲";
|
|
1045
|
+
readonly end: "▼";
|
|
1046
|
+
};
|
|
1047
|
+
readonly DOUBLE_HORIZONTAL: {
|
|
1048
|
+
readonly track: "═";
|
|
1049
|
+
readonly thumb: "▌";
|
|
1050
|
+
readonly begin: "◄";
|
|
1051
|
+
readonly end: "►";
|
|
1052
|
+
};
|
|
1053
|
+
};
|
|
1054
|
+
interface LineSet {
|
|
1055
|
+
horizontal: string;
|
|
1056
|
+
vertical: string;
|
|
1057
|
+
cross: string;
|
|
1058
|
+
}
|
|
1059
|
+
declare const LineSets: {
|
|
1060
|
+
readonly NORMAL: {
|
|
1061
|
+
readonly horizontal: "─";
|
|
1062
|
+
readonly vertical: "│";
|
|
1063
|
+
readonly cross: "┼";
|
|
1064
|
+
};
|
|
1065
|
+
readonly THICK: {
|
|
1066
|
+
readonly horizontal: "━";
|
|
1067
|
+
readonly vertical: "┃";
|
|
1068
|
+
readonly cross: "╋";
|
|
1069
|
+
};
|
|
1070
|
+
readonly DOUBLE: {
|
|
1071
|
+
readonly horizontal: "═";
|
|
1072
|
+
readonly vertical: "║";
|
|
1073
|
+
readonly cross: "╬";
|
|
1074
|
+
};
|
|
1075
|
+
};
|
|
1076
|
+
declare const Shade: {
|
|
1077
|
+
readonly FULL: "█";
|
|
1078
|
+
readonly DARK: "▓";
|
|
1079
|
+
readonly MEDIUM: "▒";
|
|
1080
|
+
readonly LIGHT: "░";
|
|
1081
|
+
readonly EMPTY: " ";
|
|
1082
|
+
};
|
|
1083
|
+
/** Unicode braille range offset (U+2800). */
|
|
1084
|
+
declare const BRAILLE_OFFSET = 10240;
|
|
1085
|
+
/**
|
|
1086
|
+
* Braille dot bit positions.
|
|
1087
|
+
* Each row is [leftBit, rightBit] for a 2-wide, 4-tall braille cell.
|
|
1088
|
+
*/
|
|
1089
|
+
declare const BRAILLE_DOTS: readonly (readonly [number, number])[];
|
|
1090
|
+
|
|
1091
|
+
/**
|
|
1092
|
+
* In-memory grid that captures rendered output.
|
|
1093
|
+
* Use `createTestScreen()` to create one, render widgets into it,
|
|
1094
|
+
* then call `testScreenToString()` to get a plain-text snapshot.
|
|
1095
|
+
*/
|
|
1096
|
+
interface TestScreen {
|
|
1097
|
+
readonly width: number;
|
|
1098
|
+
readonly height: number;
|
|
1099
|
+
cells: Cell[][];
|
|
1100
|
+
}
|
|
1101
|
+
/**
|
|
1102
|
+
* Create an in-memory test screen of the given dimensions.
|
|
1103
|
+
* Every cell starts as empty (space character, default colors).
|
|
1104
|
+
*/
|
|
1105
|
+
declare function createTestScreen(width: number, height: number): TestScreen;
|
|
1106
|
+
/**
|
|
1107
|
+
* Set a cell in the test screen at (x, y).
|
|
1108
|
+
* Out-of-bounds writes are silently ignored.
|
|
1109
|
+
*/
|
|
1110
|
+
declare function testScreenSetCell(screen: TestScreen, x: number, y: number, cell: Cell): void;
|
|
1111
|
+
/**
|
|
1112
|
+
* Get the cell at (x, y) in the test screen.
|
|
1113
|
+
* Returns undefined for out-of-bounds coordinates.
|
|
1114
|
+
*/
|
|
1115
|
+
declare function testScreenGetCell(screen: TestScreen, x: number, y: number): Cell | undefined;
|
|
1116
|
+
/**
|
|
1117
|
+
* Convert the test screen to a plain-text string.
|
|
1118
|
+
* Each row becomes a line. Trailing spaces on each line are preserved.
|
|
1119
|
+
*
|
|
1120
|
+
* Example output:
|
|
1121
|
+
* ```
|
|
1122
|
+
* ┌Hello──┐
|
|
1123
|
+
* │World │
|
|
1124
|
+
* └───────┘
|
|
1125
|
+
* ```
|
|
1126
|
+
*/
|
|
1127
|
+
declare function testScreenToString(screen: TestScreen): string;
|
|
1128
|
+
/**
|
|
1129
|
+
* Clear the test screen, resetting all cells to empty.
|
|
1130
|
+
*/
|
|
1131
|
+
declare function testScreenClear(screen: TestScreen): void;
|
|
1132
|
+
/**
|
|
1133
|
+
* Write a string into the test screen starting at (x, y).
|
|
1134
|
+
* Characters that fall outside the screen bounds are clipped.
|
|
1135
|
+
*/
|
|
1136
|
+
declare function testScreenSetString(screen: TestScreen, x: number, y: number, str: string): void;
|
|
1137
|
+
|
|
842
1138
|
interface AppOptions extends TerminalOptions {
|
|
843
1139
|
/** Frames per second for the render loop */
|
|
844
1140
|
fps?: number;
|
|
@@ -848,6 +1144,8 @@ interface AppOptions extends TerminalOptions {
|
|
|
848
1144
|
mouse?: boolean;
|
|
849
1145
|
/** Force fallback (static) rendering */
|
|
850
1146
|
forceFallback?: boolean;
|
|
1147
|
+
/** Skip fallback detection — always run interactively. Default: false */
|
|
1148
|
+
skipFallback?: boolean;
|
|
851
1149
|
/** Title to set on the terminal window */
|
|
852
1150
|
title?: string;
|
|
853
1151
|
}
|
|
@@ -1078,4 +1376,4 @@ declare namespace ansi {
|
|
|
1078
1376
|
export { ansi_CSI as CSI, ansi_ESC as ESC, ansi_OSC as OSC, ansi_beginSyncUpdate as beginSyncUpdate, ansi_blink as blink, ansi_bold as bold, ansi_clearDown as clearDown, ansi_clearLine as clearLine, ansi_clearLineToEnd as clearLineToEnd, ansi_clearLineToStart as clearLineToStart, ansi_clearScreen as clearScreen, ansi_clearUp as clearUp, ansi_dim as dim, ansi_disableBracketedPaste as disableBracketedPaste, ansi_disableMouse as disableMouse, ansi_enableBracketedPaste as enableBracketedPaste, ansi_enableMouse as enableMouse, ansi_endSyncUpdate as endSyncUpdate, ansi_enterAltScreen as enterAltScreen, ansi_exitAltScreen as exitAltScreen, ansi_hideCursor as hideCursor, ansi_inverse as inverse, ansi_italic as italic, ansi_moveDown as moveDown, ansi_moveLeft as moveLeft, ansi_moveRight as moveRight, ansi_moveTo as moveTo, ansi_moveUp as moveUp, ansi_reset as reset, ansi_resetBlink as resetBlink, ansi_resetBold as resetBold, ansi_resetDim as resetDim, ansi_resetInverse as resetInverse, ansi_resetItalic as resetItalic, ansi_resetScrollRegion as resetScrollRegion, ansi_resetStrikethrough as resetStrikethrough, ansi_resetUnderline as resetUnderline, ansi_restoreCursorPosition as restoreCursorPosition, ansi_saveCursorPosition as saveCursorPosition, ansi_setScrollRegion as setScrollRegion, ansi_setTitle as setTitle, ansi_showCursor as showCursor, ansi_strikethrough as strikethrough, ansi_underline as underline };
|
|
1079
1377
|
}
|
|
1080
1378
|
|
|
1081
|
-
export { App, type AppOptions, BORDER_CHARS, type BorderChars, type BorderStyle, CTRL_KEYS, type Cell, type Color, ColorDepth, ESCAPE_SEQUENCES, type Edges, EventEmitter, type EventMap, type FocusEvent, FocusManager, type Focusable, InputParser, type KeyEvent, type Layer, LayerManager, type LayoutNode, type MouseEvent, type NamedColor, type Rect, Renderer, type ResizeEvent, type RootWidget, SPECIAL_KEYS, Screen, type Size, type Style, Terminal, type TerminalOptions, ansi, borderSize, cellsEqual, colorToAnsiBg, colorToAnsiFg, colorToRgb, computeLayout, containsPoint, createKeyEvent, createLayoutNode, defaultStyle, detectColorDepth, emptyCell, emptyRect, getBorderChars, intersectRect, isMouseSequence, mergeStyles, normalizeEdges, parseColor, parseMouseEvent, renderFallback, shouldUseFallback, shrinkRect, stringWidth, stripAnsi, styleToCellAttrs, truncate, unionRect, wordWrap };
|
|
1379
|
+
export { App, type AppOptions, BORDER_CHARS, BRAILLE_DOTS, BRAILLE_OFFSET, type BarSet, BarSets, type BorderChars, type BorderSet, BorderSets, type BorderStyle, CTRL_KEYS, type Cell, type Color, ColorDepth, type Constraint, ESCAPE_SEQUENCES, type Edges, EventEmitter, type EventMap, type FocusEvent, FocusManager, type Focusable, HORIZONTAL_BAR_SYMBOLS, InputParser, type KeyEvent, type Layer, LayerManager, type LayoutNode, type LineSet, LineSets, type MouseEvent, type NamedColor, type Rect, Renderer, type ResizeEvent, type RootWidget, SPECIAL_KEYS, Screen, type ScrollbarSet, ScrollbarSets, Shade, type Size, type Style, Terminal, type TerminalOptions, type TestScreen, VERTICAL_BAR_SYMBOLS, ansi, borderSize, cellsEqual, colorToAnsiBg, colorToAnsiFg, colorToRgb, computeLayout, containsPoint, createKeyEvent, createLayoutNode, createTestScreen, defaultStyle, detectColorDepth, emptyCell, emptyRect, fill, getBorderChars, intersectRect, isMouseSequence, length, max, mergeStyles, min, normalizeEdges, parseColor, parseMouseEvent, percentage, ratio, renderFallback, shouldUseFallback, shrinkRect, splitRect, stringWidth, stripAnsi, styleToCellAttrs, testScreenClear, testScreenGetCell, testScreenSetCell, testScreenSetString, testScreenToString, truncate, unionRect, wordWrap };
|