@sayknow-cli/tui 0.3.15 → 0.4.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/README.md +18 -1
- package/package.json +8 -9
- package/src/autocomplete.ts +31 -1
- package/src/bracketed-paste.ts +106 -29
- package/src/components/editor.ts +81 -37
- package/src/components/input.ts +5 -1
- package/src/components/secret-input.ts +489 -0
- package/src/components/select-list.ts +138 -33
- package/src/index.ts +1 -0
- package/src/keybindings.ts +11 -3
- package/src/stdin-buffer.ts +153 -20
- package/src/terminal.ts +38 -2
- package/src/tui.ts +210 -26
- package/dist/types/animation-scheduler.d.ts +0 -13
- package/dist/types/autocomplete.d.ts +0 -83
- package/dist/types/bracketed-paste.d.ts +0 -26
- package/dist/types/components/box.d.ts +0 -20
- package/dist/types/components/cancellable-loader.d.ts +0 -21
- package/dist/types/components/editor.d.ts +0 -126
- package/dist/types/components/image.d.ts +0 -18
- package/dist/types/components/input.d.ts +0 -16
- package/dist/types/components/loader.d.ts +0 -23
- package/dist/types/components/markdown.d.ts +0 -87
- package/dist/types/components/sayknow-pet.d.ts +0 -128
- package/dist/types/components/select-list.d.ts +0 -46
- package/dist/types/components/settings-list.d.ts +0 -39
- package/dist/types/components/spacer.d.ts +0 -11
- package/dist/types/components/tab-bar.d.ts +0 -56
- package/dist/types/components/text.d.ts +0 -22
- package/dist/types/components/truncated-text.d.ts +0 -10
- package/dist/types/editor-component.d.ts +0 -36
- package/dist/types/fuzzy.d.ts +0 -15
- package/dist/types/index.d.ts +0 -28
- package/dist/types/keybindings.d.ts +0 -201
- package/dist/types/keys.d.ts +0 -208
- package/dist/types/kill-ring.d.ts +0 -27
- package/dist/types/metrics.d.ts +0 -85
- package/dist/types/stdin-buffer.d.ts +0 -50
- package/dist/types/symbols.d.ts +0 -23
- package/dist/types/terminal-capabilities.d.ts +0 -187
- package/dist/types/terminal.d.ts +0 -90
- package/dist/types/ttyid.d.ts +0 -9
- package/dist/types/tui.d.ts +0 -269
- package/dist/types/utils.d.ts +0 -110
package/dist/types/index.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export * from "./animation-scheduler";
|
|
2
|
-
export * from "./autocomplete";
|
|
3
|
-
export * from "./components/box";
|
|
4
|
-
export * from "./components/cancellable-loader";
|
|
5
|
-
export * from "./components/editor";
|
|
6
|
-
export * from "./components/image";
|
|
7
|
-
export * from "./components/input";
|
|
8
|
-
export * from "./components/loader";
|
|
9
|
-
export * from "./components/markdown";
|
|
10
|
-
export * from "./components/sayknow-pet";
|
|
11
|
-
export * from "./components/select-list";
|
|
12
|
-
export * from "./components/settings-list";
|
|
13
|
-
export * from "./components/spacer";
|
|
14
|
-
export * from "./components/tab-bar";
|
|
15
|
-
export * from "./components/text";
|
|
16
|
-
export * from "./components/truncated-text";
|
|
17
|
-
export type * from "./editor-component";
|
|
18
|
-
export * from "./fuzzy";
|
|
19
|
-
export * from "./keybindings";
|
|
20
|
-
export * from "./keys";
|
|
21
|
-
export * from "./metrics";
|
|
22
|
-
export * from "./stdin-buffer";
|
|
23
|
-
export type * from "./symbols";
|
|
24
|
-
export * from "./terminal";
|
|
25
|
-
export * from "./terminal-capabilities";
|
|
26
|
-
export * from "./ttyid";
|
|
27
|
-
export * from "./tui";
|
|
28
|
-
export * from "./utils";
|
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
import { type KeyId } from "./keys";
|
|
2
|
-
/**
|
|
3
|
-
* Global keybinding registry.
|
|
4
|
-
* Downstream packages can add keybindings via declaration merging.
|
|
5
|
-
*/
|
|
6
|
-
export interface Keybindings {
|
|
7
|
-
"tui.editor.cursorUp": true;
|
|
8
|
-
"tui.editor.cursorDown": true;
|
|
9
|
-
"tui.editor.cursorLeft": true;
|
|
10
|
-
"tui.editor.cursorRight": true;
|
|
11
|
-
"tui.editor.cursorWordLeft": true;
|
|
12
|
-
"tui.editor.cursorWordRight": true;
|
|
13
|
-
"tui.editor.cursorLineStart": true;
|
|
14
|
-
"tui.editor.cursorLineEnd": true;
|
|
15
|
-
"tui.editor.jumpForward": true;
|
|
16
|
-
"tui.editor.jumpBackward": true;
|
|
17
|
-
"tui.editor.pageUp": true;
|
|
18
|
-
"tui.editor.pageDown": true;
|
|
19
|
-
"tui.editor.deleteCharBackward": true;
|
|
20
|
-
"tui.editor.deleteCharForward": true;
|
|
21
|
-
"tui.editor.deleteWordBackward": true;
|
|
22
|
-
"tui.editor.deleteWordForward": true;
|
|
23
|
-
"tui.editor.deleteToLineStart": true;
|
|
24
|
-
"tui.editor.deleteToLineEnd": true;
|
|
25
|
-
"tui.editor.yank": true;
|
|
26
|
-
"tui.editor.yankPop": true;
|
|
27
|
-
"tui.editor.undo": true;
|
|
28
|
-
"tui.input.newLine": true;
|
|
29
|
-
"tui.input.submit": true;
|
|
30
|
-
"tui.input.tab": true;
|
|
31
|
-
"tui.input.copy": true;
|
|
32
|
-
"tui.select.up": true;
|
|
33
|
-
"tui.select.down": true;
|
|
34
|
-
"tui.select.pageUp": true;
|
|
35
|
-
"tui.select.pageDown": true;
|
|
36
|
-
"tui.select.confirm": true;
|
|
37
|
-
"tui.select.cancel": true;
|
|
38
|
-
"tui.global.debug": true;
|
|
39
|
-
}
|
|
40
|
-
export type Keybinding = keyof Keybindings;
|
|
41
|
-
export type { KeyId };
|
|
42
|
-
export interface KeybindingDefinition {
|
|
43
|
-
defaultKeys: KeyId | KeyId[];
|
|
44
|
-
description?: string;
|
|
45
|
-
}
|
|
46
|
-
export type KeybindingDefinitions = Record<string, KeybindingDefinition>;
|
|
47
|
-
export type KeybindingsConfig = Record<string, KeyId | KeyId[] | undefined>;
|
|
48
|
-
export declare const TUI_KEYBINDINGS: {
|
|
49
|
-
readonly "tui.editor.cursorUp": {
|
|
50
|
-
readonly defaultKeys: "up";
|
|
51
|
-
readonly description: "Move cursor up";
|
|
52
|
-
};
|
|
53
|
-
readonly "tui.editor.cursorDown": {
|
|
54
|
-
readonly defaultKeys: "down";
|
|
55
|
-
readonly description: "Move cursor down";
|
|
56
|
-
};
|
|
57
|
-
readonly "tui.editor.cursorLeft": {
|
|
58
|
-
readonly defaultKeys: ["left", "ctrl+b"];
|
|
59
|
-
readonly description: "Move cursor left";
|
|
60
|
-
};
|
|
61
|
-
readonly "tui.editor.cursorRight": {
|
|
62
|
-
readonly defaultKeys: ["right", "ctrl+f"];
|
|
63
|
-
readonly description: "Move cursor right";
|
|
64
|
-
};
|
|
65
|
-
readonly "tui.editor.cursorWordLeft": {
|
|
66
|
-
readonly defaultKeys: ["alt+left", "ctrl+left", "alt+b"];
|
|
67
|
-
readonly description: "Move cursor word left";
|
|
68
|
-
};
|
|
69
|
-
readonly "tui.editor.cursorWordRight": {
|
|
70
|
-
readonly defaultKeys: ["alt+right", "ctrl+right", "alt+f"];
|
|
71
|
-
readonly description: "Move cursor word right";
|
|
72
|
-
};
|
|
73
|
-
readonly "tui.editor.cursorLineStart": {
|
|
74
|
-
readonly defaultKeys: ["home", "ctrl+a"];
|
|
75
|
-
readonly description: "Move to line start";
|
|
76
|
-
};
|
|
77
|
-
readonly "tui.editor.cursorLineEnd": {
|
|
78
|
-
readonly defaultKeys: ["end", "ctrl+e"];
|
|
79
|
-
readonly description: "Move to line end";
|
|
80
|
-
};
|
|
81
|
-
readonly "tui.editor.jumpForward": {
|
|
82
|
-
readonly defaultKeys: "ctrl+]";
|
|
83
|
-
readonly description: "Jump forward to character";
|
|
84
|
-
};
|
|
85
|
-
readonly "tui.editor.jumpBackward": {
|
|
86
|
-
readonly defaultKeys: "ctrl+alt+]";
|
|
87
|
-
readonly description: "Jump backward to character";
|
|
88
|
-
};
|
|
89
|
-
readonly "tui.editor.pageUp": {
|
|
90
|
-
readonly defaultKeys: "pageUp";
|
|
91
|
-
readonly description: "Page up";
|
|
92
|
-
};
|
|
93
|
-
readonly "tui.editor.pageDown": {
|
|
94
|
-
readonly defaultKeys: "pageDown";
|
|
95
|
-
readonly description: "Page down";
|
|
96
|
-
};
|
|
97
|
-
readonly "tui.editor.deleteCharBackward": {
|
|
98
|
-
readonly defaultKeys: "backspace";
|
|
99
|
-
readonly description: "Delete character backward";
|
|
100
|
-
};
|
|
101
|
-
readonly "tui.editor.deleteCharForward": {
|
|
102
|
-
readonly defaultKeys: ["delete", "ctrl+d"];
|
|
103
|
-
readonly description: "Delete character forward";
|
|
104
|
-
};
|
|
105
|
-
readonly "tui.editor.deleteWordBackward": {
|
|
106
|
-
readonly defaultKeys: ["ctrl+w", "alt+backspace", "ctrl+backspace"];
|
|
107
|
-
readonly description: "Delete word backward";
|
|
108
|
-
};
|
|
109
|
-
readonly "tui.editor.deleteWordForward": {
|
|
110
|
-
readonly defaultKeys: ["alt+delete", "alt+d"];
|
|
111
|
-
readonly description: "Delete word forward";
|
|
112
|
-
};
|
|
113
|
-
readonly "tui.editor.deleteToLineStart": {
|
|
114
|
-
readonly defaultKeys: "ctrl+u";
|
|
115
|
-
readonly description: "Delete to line start";
|
|
116
|
-
};
|
|
117
|
-
readonly "tui.editor.deleteToLineEnd": {
|
|
118
|
-
readonly defaultKeys: "ctrl+k";
|
|
119
|
-
readonly description: "Delete to line end";
|
|
120
|
-
};
|
|
121
|
-
readonly "tui.editor.yank": {
|
|
122
|
-
readonly defaultKeys: "ctrl+y";
|
|
123
|
-
readonly description: "Yank";
|
|
124
|
-
};
|
|
125
|
-
readonly "tui.editor.yankPop": {
|
|
126
|
-
readonly defaultKeys: "alt+y";
|
|
127
|
-
readonly description: "Yank pop";
|
|
128
|
-
};
|
|
129
|
-
readonly "tui.editor.undo": {
|
|
130
|
-
readonly defaultKeys: ["ctrl+-", "ctrl+_"];
|
|
131
|
-
readonly description: "Undo";
|
|
132
|
-
};
|
|
133
|
-
readonly "tui.input.newLine": {
|
|
134
|
-
readonly defaultKeys: "shift+enter";
|
|
135
|
-
readonly description: "Insert newline";
|
|
136
|
-
};
|
|
137
|
-
readonly "tui.input.submit": {
|
|
138
|
-
readonly defaultKeys: "enter";
|
|
139
|
-
readonly description: "Submit input";
|
|
140
|
-
};
|
|
141
|
-
readonly "tui.input.tab": {
|
|
142
|
-
readonly defaultKeys: "tab";
|
|
143
|
-
readonly description: "Tab / autocomplete";
|
|
144
|
-
};
|
|
145
|
-
readonly "tui.input.copy": {
|
|
146
|
-
readonly defaultKeys: "ctrl+c";
|
|
147
|
-
readonly description: "Copy selection";
|
|
148
|
-
};
|
|
149
|
-
readonly "tui.select.up": {
|
|
150
|
-
readonly defaultKeys: "up";
|
|
151
|
-
readonly description: "Move selection up";
|
|
152
|
-
};
|
|
153
|
-
readonly "tui.select.down": {
|
|
154
|
-
readonly defaultKeys: "down";
|
|
155
|
-
readonly description: "Move selection down";
|
|
156
|
-
};
|
|
157
|
-
readonly "tui.select.pageUp": {
|
|
158
|
-
readonly defaultKeys: "pageUp";
|
|
159
|
-
readonly description: "Selection page up";
|
|
160
|
-
};
|
|
161
|
-
readonly "tui.select.pageDown": {
|
|
162
|
-
readonly defaultKeys: "pageDown";
|
|
163
|
-
readonly description: "Selection page down";
|
|
164
|
-
};
|
|
165
|
-
readonly "tui.select.confirm": {
|
|
166
|
-
readonly defaultKeys: "enter";
|
|
167
|
-
readonly description: "Confirm selection";
|
|
168
|
-
};
|
|
169
|
-
readonly "tui.select.cancel": {
|
|
170
|
-
readonly defaultKeys: ["escape", "ctrl+c"];
|
|
171
|
-
readonly description: "Cancel selection";
|
|
172
|
-
};
|
|
173
|
-
readonly "tui.global.debug": {
|
|
174
|
-
readonly defaultKeys: "shift+ctrl+d";
|
|
175
|
-
readonly description: "Toggle debug overlay";
|
|
176
|
-
};
|
|
177
|
-
};
|
|
178
|
-
export interface KeybindingConflict {
|
|
179
|
-
key: KeyId;
|
|
180
|
-
keybindings: string[];
|
|
181
|
-
}
|
|
182
|
-
export declare class KeybindingsManager {
|
|
183
|
-
#private;
|
|
184
|
-
constructor(definitions: KeybindingDefinitions, userBindings?: KeybindingsConfig);
|
|
185
|
-
matches(data: string, keybinding: Keybinding): boolean;
|
|
186
|
-
getKeys(keybinding: Keybinding): KeyId[];
|
|
187
|
-
getDefinition(keybinding: Keybinding): KeybindingDefinition;
|
|
188
|
-
getConflicts(): KeybindingConflict[];
|
|
189
|
-
setUserBindings(userBindings: KeybindingsConfig): void;
|
|
190
|
-
getUserBindings(): KeybindingsConfig;
|
|
191
|
-
getResolvedBindings(): KeybindingsConfig;
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* Detect default-key collisions across the registry: keys whose default
|
|
195
|
-
* binding is claimed by more than one action. Cross-context collisions are
|
|
196
|
-
* often intentional (the dispatch context disambiguates them), so this is a
|
|
197
|
-
* diagnostics aid for auditing the surface, not an error by itself.
|
|
198
|
-
*/
|
|
199
|
-
export declare function detectDefaultKeyCollisions(definitions: KeybindingDefinitions): KeybindingConflict[];
|
|
200
|
-
export declare function setKeybindings(keybindings: KeybindingsManager): void;
|
|
201
|
-
export declare function getKeybindings(): KeybindingsManager;
|
package/dist/types/keys.d.ts
DELETED
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Keyboard input handling for terminal applications.
|
|
3
|
-
*
|
|
4
|
-
* Supports both legacy terminal sequences and Kitty keyboard protocol.
|
|
5
|
-
* See: https://sw.kovidgoyal.net/kitty/keyboard-protocol/
|
|
6
|
-
* Reference: https://github.com/sst/opentui/blob/7da92b4088aebfe27b9f691c04163a48821e49fd/packages/core/src/lib/parse.keypress.ts
|
|
7
|
-
*
|
|
8
|
-
* Symbol keys are also supported, however some ctrl+symbol combos
|
|
9
|
-
* overlap with ASCII codes, e.g. ctrl+[ = ESC.
|
|
10
|
-
* See: https://sw.kovidgoyal.net/kitty/keyboard-protocol/#legacy-ctrl-mapping-of-ascii-keys
|
|
11
|
-
* Those can still be * used for ctrl+shift combos
|
|
12
|
-
*
|
|
13
|
-
* API:
|
|
14
|
-
* - matchesKey(data, keyId) - Check if input matches a key identifier
|
|
15
|
-
* - parseKey(data) - Parse input and return the key identifier
|
|
16
|
-
* - Key - Helper object for creating typed key identifiers
|
|
17
|
-
* - setKittyProtocolActive(active) - Set global Kitty protocol state
|
|
18
|
-
* - isKittyProtocolActive() - Query global Kitty protocol state
|
|
19
|
-
*/
|
|
20
|
-
import type { KeyEventType } from "@sayknow-cli/natives";
|
|
21
|
-
declare function isWindowsTerminalSession(): boolean;
|
|
22
|
-
/**
|
|
23
|
-
* Raw 0x08 (BS) is ambiguous in legacy terminals.
|
|
24
|
-
*
|
|
25
|
-
* - Windows Terminal uses it for Ctrl+Backspace.
|
|
26
|
-
* - Some legacy terminals and tmux setups send it for plain Backspace.
|
|
27
|
-
*
|
|
28
|
-
* Prefer explicit Kitty / CSI-u / modifyOtherKeys sequences whenever they are
|
|
29
|
-
* available. Fall back to a Windows Terminal heuristic only for raw BS bytes.
|
|
30
|
-
*/
|
|
31
|
-
declare function matchesRawBackspace(data: string, expectedModifier: number): boolean;
|
|
32
|
-
export { isWindowsTerminalSession, matchesRawBackspace };
|
|
33
|
-
/**
|
|
34
|
-
* Set the global Kitty keyboard protocol state.
|
|
35
|
-
* Called by ProcessTerminal after detecting protocol support.
|
|
36
|
-
*/
|
|
37
|
-
export declare function setKittyProtocolActive(active: boolean): void;
|
|
38
|
-
/**
|
|
39
|
-
* Query whether Kitty keyboard protocol is currently active.
|
|
40
|
-
*/
|
|
41
|
-
export declare function isKittyProtocolActive(): boolean;
|
|
42
|
-
type Letter = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z";
|
|
43
|
-
type Digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9";
|
|
44
|
-
type SymbolKey = "`" | "-" | "=" | "[" | "]" | "\\" | ";" | "'" | "," | "." | "/" | "!" | "@" | "#" | "$" | "%" | "^" | "&" | "*" | "(" | ")" | "_" | "+" | "|" | "~" | "{" | "}" | ":" | "<" | ">" | "?";
|
|
45
|
-
type SpecialKey = "escape" | "esc" | "enter" | "return" | "tab" | "space" | "backspace" | "delete" | "insert" | "clear" | "home" | "end" | "pageUp" | "pageDown" | "up" | "down" | "left" | "right" | "f1" | "f2" | "f3" | "f4" | "f5" | "f6" | "f7" | "f8" | "f9" | "f10" | "f11" | "f12";
|
|
46
|
-
type BaseKey = Letter | Digit | SymbolKey | SpecialKey;
|
|
47
|
-
type ModifierName = "ctrl" | "shift" | "alt" | "super";
|
|
48
|
-
type ModifiedKeyId<Key extends string, RemainingModifiers extends ModifierName = ModifierName> = {
|
|
49
|
-
[M in RemainingModifiers]: `${M}+${Key}` | `${M}+${ModifiedKeyId<Key, Exclude<RemainingModifiers, M>>}`;
|
|
50
|
-
}[RemainingModifiers];
|
|
51
|
-
/**
|
|
52
|
-
* Union type of all valid key identifiers.
|
|
53
|
-
* Provides autocomplete and catches typos at compile time.
|
|
54
|
-
*/
|
|
55
|
-
export type KeyId = BaseKey | ModifiedKeyId<BaseKey>;
|
|
56
|
-
/**
|
|
57
|
-
* Typed helper for constructing key identifiers with autocomplete.
|
|
58
|
-
*
|
|
59
|
-
* The runtime values are just the canonical key-name strings (so `Key.enter`
|
|
60
|
-
* is literally `"enter"`); the value of `Key` over a bag of magic strings is
|
|
61
|
-
* that each property is typed to the exact `KeyId` literal it produces and the
|
|
62
|
-
* modifier methods return precisely-typed concatenations (e.g. `Key.ctrl("c")`
|
|
63
|
-
* is `"ctrl+c"`, not just `string`). This mirrors the upstream
|
|
64
|
-
* `@mariozechner/pi-tui` `Key` export verbatim so plugins built against any
|
|
65
|
-
* scope alias (`@mariozechner`, `@earendil-works`, `@sayknow-cli`) keep working
|
|
66
|
-
* once the specifier shim remaps them to this package.
|
|
67
|
-
*/
|
|
68
|
-
export declare const Key: {
|
|
69
|
-
readonly escape: "escape";
|
|
70
|
-
readonly esc: "esc";
|
|
71
|
-
readonly enter: "enter";
|
|
72
|
-
readonly return: "return";
|
|
73
|
-
readonly tab: "tab";
|
|
74
|
-
readonly space: "space";
|
|
75
|
-
readonly backspace: "backspace";
|
|
76
|
-
readonly delete: "delete";
|
|
77
|
-
readonly insert: "insert";
|
|
78
|
-
readonly clear: "clear";
|
|
79
|
-
readonly home: "home";
|
|
80
|
-
readonly end: "end";
|
|
81
|
-
readonly pageUp: "pageUp";
|
|
82
|
-
readonly pageDown: "pageDown";
|
|
83
|
-
readonly up: "up";
|
|
84
|
-
readonly down: "down";
|
|
85
|
-
readonly left: "left";
|
|
86
|
-
readonly right: "right";
|
|
87
|
-
readonly f1: "f1";
|
|
88
|
-
readonly f2: "f2";
|
|
89
|
-
readonly f3: "f3";
|
|
90
|
-
readonly f4: "f4";
|
|
91
|
-
readonly f5: "f5";
|
|
92
|
-
readonly f6: "f6";
|
|
93
|
-
readonly f7: "f7";
|
|
94
|
-
readonly f8: "f8";
|
|
95
|
-
readonly f9: "f9";
|
|
96
|
-
readonly f10: "f10";
|
|
97
|
-
readonly f11: "f11";
|
|
98
|
-
readonly f12: "f12";
|
|
99
|
-
readonly backtick: "`";
|
|
100
|
-
readonly hyphen: "-";
|
|
101
|
-
readonly equals: "=";
|
|
102
|
-
readonly leftbracket: "[";
|
|
103
|
-
readonly rightbracket: "]";
|
|
104
|
-
readonly backslash: "\\";
|
|
105
|
-
readonly semicolon: ";";
|
|
106
|
-
readonly quote: "'";
|
|
107
|
-
readonly comma: ",";
|
|
108
|
-
readonly period: ".";
|
|
109
|
-
readonly slash: "/";
|
|
110
|
-
readonly exclamation: "!";
|
|
111
|
-
readonly at: "@";
|
|
112
|
-
readonly hash: "#";
|
|
113
|
-
readonly dollar: "$";
|
|
114
|
-
readonly percent: "%";
|
|
115
|
-
readonly caret: "^";
|
|
116
|
-
readonly ampersand: "&";
|
|
117
|
-
readonly asterisk: "*";
|
|
118
|
-
readonly leftparen: "(";
|
|
119
|
-
readonly rightparen: ")";
|
|
120
|
-
readonly underscore: "_";
|
|
121
|
-
readonly plus: "+";
|
|
122
|
-
readonly pipe: "|";
|
|
123
|
-
readonly tilde: "~";
|
|
124
|
-
readonly leftbrace: "{";
|
|
125
|
-
readonly rightbrace: "}";
|
|
126
|
-
readonly colon: ":";
|
|
127
|
-
readonly lessthan: "<";
|
|
128
|
-
readonly greaterthan: ">";
|
|
129
|
-
readonly question: "?";
|
|
130
|
-
readonly ctrl: <K extends BaseKey>(key: K) => `ctrl+${K}`;
|
|
131
|
-
readonly shift: <K extends BaseKey>(key: K) => `shift+${K}`;
|
|
132
|
-
readonly alt: <K extends BaseKey>(key: K) => `alt+${K}`;
|
|
133
|
-
readonly super: <K extends BaseKey>(key: K) => `super+${K}`;
|
|
134
|
-
readonly ctrlShift: <K extends BaseKey>(key: K) => `ctrl+shift+${K}`;
|
|
135
|
-
readonly shiftCtrl: <K extends BaseKey>(key: K) => `shift+ctrl+${K}`;
|
|
136
|
-
readonly ctrlAlt: <K extends BaseKey>(key: K) => `ctrl+alt+${K}`;
|
|
137
|
-
readonly altCtrl: <K extends BaseKey>(key: K) => `alt+ctrl+${K}`;
|
|
138
|
-
readonly shiftAlt: <K extends BaseKey>(key: K) => `shift+alt+${K}`;
|
|
139
|
-
readonly altShift: <K extends BaseKey>(key: K) => `alt+shift+${K}`;
|
|
140
|
-
readonly ctrlSuper: <K extends BaseKey>(key: K) => `ctrl+super+${K}`;
|
|
141
|
-
readonly superCtrl: <K extends BaseKey>(key: K) => `super+ctrl+${K}`;
|
|
142
|
-
readonly shiftSuper: <K extends BaseKey>(key: K) => `shift+super+${K}`;
|
|
143
|
-
readonly superShift: <K extends BaseKey>(key: K) => `super+shift+${K}`;
|
|
144
|
-
readonly altSuper: <K extends BaseKey>(key: K) => `alt+super+${K}`;
|
|
145
|
-
readonly superAlt: <K extends BaseKey>(key: K) => `super+alt+${K}`;
|
|
146
|
-
readonly ctrlShiftAlt: <K extends BaseKey>(key: K) => `ctrl+shift+alt+${K}`;
|
|
147
|
-
readonly ctrlShiftSuper: <K extends BaseKey>(key: K) => `ctrl+shift+super+${K}`;
|
|
148
|
-
};
|
|
149
|
-
interface ParsedKittySequence {
|
|
150
|
-
codepoint: number;
|
|
151
|
-
shiftedKey?: number;
|
|
152
|
-
baseLayoutKey?: number;
|
|
153
|
-
modifier: number;
|
|
154
|
-
eventType?: KeyEventType;
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Check if the input is a key release event.
|
|
158
|
-
* Only meaningful when Kitty keyboard protocol with flag 2 is active.
|
|
159
|
-
* Returns false if Kitty protocol is not active.
|
|
160
|
-
*/
|
|
161
|
-
export declare function isKeyRelease(data: string): boolean;
|
|
162
|
-
/**
|
|
163
|
-
* Check if the input is a key repeat event.
|
|
164
|
-
* Only meaningful when Kitty keyboard protocol with flag 2 is active.
|
|
165
|
-
* Returns false if Kitty protocol is not active.
|
|
166
|
-
*/
|
|
167
|
-
export declare function isKeyRepeat(data: string): boolean;
|
|
168
|
-
export declare function parseKittySequence(data: string): ParsedKittySequence | null;
|
|
169
|
-
/**
|
|
170
|
-
* Extract printable text from raw terminal input.
|
|
171
|
-
*
|
|
172
|
-
* Handles Kitty CSI-u text-producing keys so text-entry components can treat
|
|
173
|
-
* keypad digits, keypad operators, and shifted symbols the same as direct character input.
|
|
174
|
-
*/
|
|
175
|
-
export declare function extractPrintableText(data: string): string | undefined;
|
|
176
|
-
/**
|
|
177
|
-
* Decode terminal input into the printable character it represents.
|
|
178
|
-
*
|
|
179
|
-
* Tries Kitty CSI-u first, then falls back to xterm modifyOtherKeys. Returns
|
|
180
|
-
* undefined for control sequences and modifier-only events.
|
|
181
|
-
*/
|
|
182
|
-
export declare function decodePrintableKey(data: string): string | undefined;
|
|
183
|
-
/**
|
|
184
|
-
* Match input data against a key identifier string.
|
|
185
|
-
*
|
|
186
|
-
* Supported key identifiers:
|
|
187
|
-
* - Single keys: "escape", "tab", "enter", "backspace", "delete", "home", "end", "space"
|
|
188
|
-
* - Arrow keys: "up", "down", "left", "right"
|
|
189
|
-
* - Ctrl combinations: "ctrl+c", "ctrl+z", etc.
|
|
190
|
-
* - Shift combinations: "shift+tab", "shift+enter"
|
|
191
|
-
* - Alt combinations: "alt+enter", "alt+backspace"
|
|
192
|
-
* - Combined modifiers: "shift+ctrl+p", "ctrl+alt+x"
|
|
193
|
-
*
|
|
194
|
-
* Use the Key helper for autocomplete: Key.ctrl("c"), Key.escape, Key.ctrlShift("p")
|
|
195
|
-
*
|
|
196
|
-
* @param data - Raw input data from terminal
|
|
197
|
-
* @param keyId - Key identifier (e.g., "ctrl+c", "escape", Key.ctrl("c"))
|
|
198
|
-
*/
|
|
199
|
-
export declare function matchesKey(data: string, keyId: KeyId): boolean;
|
|
200
|
-
/**
|
|
201
|
-
* Parse terminal input and return a normalized key identifier.
|
|
202
|
-
*
|
|
203
|
-
* Returns key names like "escape", "ctrl+c", "shift+tab", "alt+enter".
|
|
204
|
-
* Returns undefined if the input is not a recognized key sequence.
|
|
205
|
-
*
|
|
206
|
-
* @param data - Raw input data from terminal
|
|
207
|
-
*/
|
|
208
|
-
export declare function parseKey(data: string): string | undefined;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Ring buffer for Emacs-style kill/yank operations.
|
|
3
|
-
*
|
|
4
|
-
* Tracks killed (deleted) text entries. Consecutive kills can accumulate
|
|
5
|
-
* into a single entry. Supports yank (paste most recent) and yank-pop
|
|
6
|
-
* (cycle through older entries).
|
|
7
|
-
*/
|
|
8
|
-
export declare class KillRing {
|
|
9
|
-
#private;
|
|
10
|
-
/**
|
|
11
|
-
* Add text to the kill ring.
|
|
12
|
-
*
|
|
13
|
-
* @param text - The killed text to add
|
|
14
|
-
* @param opts - Push options
|
|
15
|
-
* @param opts.prepend - If accumulating, prepend (backward deletion) or append (forward deletion)
|
|
16
|
-
* @param opts.accumulate - Merge with the most recent entry instead of creating a new one
|
|
17
|
-
*/
|
|
18
|
-
push(text: string, opts: {
|
|
19
|
-
prepend: boolean;
|
|
20
|
-
accumulate?: boolean;
|
|
21
|
-
}): void;
|
|
22
|
-
/** Get most recent entry without modifying the ring. */
|
|
23
|
-
peek(): string | undefined;
|
|
24
|
-
/** Move last entry to front (for yank-pop cycling). */
|
|
25
|
-
rotate(): void;
|
|
26
|
-
get length(): number;
|
|
27
|
-
}
|
package/dist/types/metrics.d.ts
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
/** Number of consecutive unexpected full redraws that constitute a "storm". */
|
|
2
|
-
export declare const REPAINT_STORM_THRESHOLD = 3;
|
|
3
|
-
/** Hard cap on retained metric label keys; overflow is aggregated under `other`. */
|
|
4
|
-
export declare const MAX_LABEL_MAP_ENTRIES = 128;
|
|
5
|
-
export interface DurationStats {
|
|
6
|
-
count: number;
|
|
7
|
-
meanMs: number;
|
|
8
|
-
p50Ms: number;
|
|
9
|
-
p95Ms: number;
|
|
10
|
-
p99Ms: number;
|
|
11
|
-
maxMs: number;
|
|
12
|
-
}
|
|
13
|
-
export interface RssStats {
|
|
14
|
-
samples: number;
|
|
15
|
-
baselineBytes: number | null;
|
|
16
|
-
lastBytes: number | null;
|
|
17
|
-
peakBytes: number;
|
|
18
|
-
growthBytes: number;
|
|
19
|
-
/** RSS sampled after the run + a forced GC (informational). */
|
|
20
|
-
returnBytes: number | null;
|
|
21
|
-
/** Heap used at baseline and after the run + forced GC (reclaimable signal). */
|
|
22
|
-
heapBaselineBytes: number | null;
|
|
23
|
-
heapReturnBytes: number | null;
|
|
24
|
-
/** (heapReturn - heapBaseline) / heapBaseline; <= tolerance means heap returned. */
|
|
25
|
-
returnWithinBaselineFraction: number | null;
|
|
26
|
-
}
|
|
27
|
-
export interface HelperStat {
|
|
28
|
-
count: number;
|
|
29
|
-
totalMs: number;
|
|
30
|
-
meanMs: number;
|
|
31
|
-
}
|
|
32
|
-
export interface LineCountGauge {
|
|
33
|
-
last: number;
|
|
34
|
-
max: number;
|
|
35
|
-
}
|
|
36
|
-
export interface RenderMetricsSnapshot {
|
|
37
|
-
enabled: boolean;
|
|
38
|
-
renderCount: number;
|
|
39
|
-
renderDurations: DurationStats;
|
|
40
|
-
durationsTruncated: boolean;
|
|
41
|
-
requestSources: Record<string, number>;
|
|
42
|
-
fullRedrawCount: number;
|
|
43
|
-
fullRedrawCauses: Record<string, number>;
|
|
44
|
-
repaintStorms: number;
|
|
45
|
-
maxConsecutiveFullRedraws: number;
|
|
46
|
-
rss: RssStats;
|
|
47
|
-
ownerGauges: Record<string, number>;
|
|
48
|
-
timerGauges: Record<string, number>;
|
|
49
|
-
helperStats: Record<string, HelperStat>;
|
|
50
|
-
lineCounts: Record<string, LineCountGauge>;
|
|
51
|
-
}
|
|
52
|
-
export declare class RenderMetrics {
|
|
53
|
-
#private;
|
|
54
|
-
constructor(enabled?: boolean);
|
|
55
|
-
get enabled(): boolean;
|
|
56
|
-
enable(): void;
|
|
57
|
-
disable(): void;
|
|
58
|
-
/** Reset all collected data (keeps the enabled state). */
|
|
59
|
-
reset(): void;
|
|
60
|
-
/** High-resolution clock for timing render passes. Returns 0 when disabled. */
|
|
61
|
-
now(): number;
|
|
62
|
-
/** Record that a render was requested, attributed to a caller source. */
|
|
63
|
-
recordRequest(source?: string): void;
|
|
64
|
-
/** Record one completed `#doRender` pass duration (ms). */
|
|
65
|
-
recordRender(durationMs: number): void;
|
|
66
|
-
/** Record a full-redraw event and classify its cause for storm detection. */
|
|
67
|
-
recordFullRedraw(cause: string): void;
|
|
68
|
-
/** Sample current RSS. Records baseline on first sample, tracks peak/last. */
|
|
69
|
-
sampleRss(): number;
|
|
70
|
-
setOwnerGauge(name: string, value: number): void;
|
|
71
|
-
setTimerGauge(name: string, value: number): void;
|
|
72
|
-
/** Accumulate timing/count for a named render helper (e.g. "renderTree"). */
|
|
73
|
-
recordHelper(name: string, durationMs: number): void;
|
|
74
|
-
/** Record a per-render line-count gauge (e.g. "rendered", "normalized", "diffed"). */
|
|
75
|
-
recordLineCount(name: string, value: number): void;
|
|
76
|
-
/**
|
|
77
|
-
* Force a GC when the runtime exposes one and sample RSS as the post-run
|
|
78
|
-
* "return" value used by the memory-leak gate. Callers should drop large
|
|
79
|
-
* references before calling so reclaimable memory is actually freed.
|
|
80
|
-
*/
|
|
81
|
-
sampleReturn(): number;
|
|
82
|
-
snapshot(): RenderMetricsSnapshot;
|
|
83
|
-
}
|
|
84
|
-
/** Shared metrics instance used by the TUI render loop. */
|
|
85
|
-
export declare const renderMetrics: RenderMetrics;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* StdinBuffer buffers input and emits complete sequences.
|
|
3
|
-
*
|
|
4
|
-
* This is necessary because stdin data events can arrive in partial chunks,
|
|
5
|
-
* especially for escape sequences like mouse events. Without buffering,
|
|
6
|
-
* partial sequences can be misinterpreted as regular keypresses.
|
|
7
|
-
*
|
|
8
|
-
* For example, the mouse SGR sequence `\x1b[<35;20;5m` might arrive as:
|
|
9
|
-
* - Event 1: `\x1b`
|
|
10
|
-
* - Event 2: `[<35`
|
|
11
|
-
* - Event 3: `;20;5m`
|
|
12
|
-
*
|
|
13
|
-
* The buffer accumulates these until a complete sequence is detected.
|
|
14
|
-
* Call the `process()` method to feed input data.
|
|
15
|
-
*
|
|
16
|
-
* Based on code from OpenTUI (https://github.com/anomalyco/opentui)
|
|
17
|
-
* MIT License - Copyright (c) 2025 opentui
|
|
18
|
-
*/
|
|
19
|
-
import { EventEmitter } from "events";
|
|
20
|
-
export type StdinBufferOptions = {
|
|
21
|
-
/**
|
|
22
|
-
* Maximum time to wait for sequence completion (default: 10ms)
|
|
23
|
-
* After this time, the buffer is flushed even if incomplete
|
|
24
|
-
*/
|
|
25
|
-
timeout?: number;
|
|
26
|
-
};
|
|
27
|
-
export type StdinBufferEventMap = {
|
|
28
|
-
data: [string];
|
|
29
|
-
paste: [string];
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* Buffers stdin input and emits complete sequences via the 'data' event.
|
|
33
|
-
* Handles partial escape sequences that arrive across multiple chunks.
|
|
34
|
-
*
|
|
35
|
-
* StdinBuffer is the single raw-stdin decoding boundary: raw terminal bytes
|
|
36
|
-
* enter via `process()` and decoded string events leave via the 'data' and
|
|
37
|
-
* 'paste' events. UTF-8 is decoded exactly once here (using a persistent
|
|
38
|
-
* StringDecoder) so multi-byte characters split across chunk boundaries are
|
|
39
|
-
* reassembled rather than corrupted into U+FFFD. All downstream parsing
|
|
40
|
-
* (escape sequences, bracketed paste, Kitty/CSI, OSC/DA1) operates on strings.
|
|
41
|
-
*/
|
|
42
|
-
export declare class StdinBuffer extends EventEmitter<StdinBufferEventMap> {
|
|
43
|
-
#private;
|
|
44
|
-
constructor(options?: StdinBufferOptions);
|
|
45
|
-
process(data: string | Buffer): void;
|
|
46
|
-
flush(): string[];
|
|
47
|
-
clear(): void;
|
|
48
|
-
getBuffer(): string;
|
|
49
|
-
destroy(): void;
|
|
50
|
-
}
|
package/dist/types/symbols.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export interface BoxSymbols {
|
|
2
|
-
topLeft: string;
|
|
3
|
-
topRight: string;
|
|
4
|
-
bottomLeft: string;
|
|
5
|
-
bottomRight: string;
|
|
6
|
-
horizontal: string;
|
|
7
|
-
vertical: string;
|
|
8
|
-
teeDown: string;
|
|
9
|
-
teeUp: string;
|
|
10
|
-
teeLeft: string;
|
|
11
|
-
teeRight: string;
|
|
12
|
-
cross: string;
|
|
13
|
-
}
|
|
14
|
-
export interface SymbolTheme {
|
|
15
|
-
cursor: string;
|
|
16
|
-
inputCursor: string;
|
|
17
|
-
boxRound: Omit<BoxSymbols, "teeDown" | "teeUp" | "teeLeft" | "teeRight" | "cross">;
|
|
18
|
-
boxSharp: BoxSymbols;
|
|
19
|
-
table: BoxSymbols;
|
|
20
|
-
quoteBorder: string;
|
|
21
|
-
hrChar: string;
|
|
22
|
-
spinnerFrames: string[];
|
|
23
|
-
}
|