@sayknow-cli/tui 0.3.11 → 0.3.13
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/package.json +8 -9
- package/src/components/image.ts +79 -39
- package/src/components/markdown.ts +282 -37
- package/src/components/sayknow-pet.ts +435 -0
- package/src/components/text.ts +60 -36
- package/src/index.ts +1 -0
- package/src/terminal-capabilities.ts +42 -0
- package/src/tui.ts +471 -55
- package/src/utils.ts +144 -8
- 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 -16
- 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 -77
- 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 -13
- 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 -27
- 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 -143
- package/dist/types/terminal.d.ts +0 -90
- package/dist/types/ttyid.d.ts +0 -9
- package/dist/types/tui.d.ts +0 -215
- package/dist/types/utils.d.ts +0 -87
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
|
-
}
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
export declare enum ImageProtocol {
|
|
2
|
-
Kitty = "\u001B_G",
|
|
3
|
-
Iterm2 = "\u001B]1337;File=",
|
|
4
|
-
Sixel = "\u001BPq"
|
|
5
|
-
}
|
|
6
|
-
export declare enum NotifyProtocol {
|
|
7
|
-
Bell = "\u0007",
|
|
8
|
-
Osc99 = "\u001B]99;;",
|
|
9
|
-
Osc9 = "\u001B]9;"
|
|
10
|
-
}
|
|
11
|
-
export type TerminalId = "kitty" | "ghostty" | "wezterm" | "iterm2" | "vscode" | "alacritty" | "base" | "trueColor";
|
|
12
|
-
/** Terminal capability details used for rendering and protocol selection. */
|
|
13
|
-
export declare class TerminalInfo {
|
|
14
|
-
readonly id: TerminalId;
|
|
15
|
-
readonly imageProtocol: ImageProtocol | null;
|
|
16
|
-
readonly trueColor: boolean;
|
|
17
|
-
readonly hyperlinks: boolean;
|
|
18
|
-
readonly notifyProtocol: NotifyProtocol;
|
|
19
|
-
constructor(id: TerminalId, imageProtocol: ImageProtocol | null, trueColor: boolean, hyperlinks: boolean, notifyProtocol?: NotifyProtocol);
|
|
20
|
-
isImageLine(line: string): boolean;
|
|
21
|
-
formatNotification(message: string): string;
|
|
22
|
-
sendNotification(message: string): void;
|
|
23
|
-
}
|
|
24
|
-
export declare function isNotificationSuppressed(): boolean;
|
|
25
|
-
/**
|
|
26
|
-
* Returns true when running in Windows Terminal with known SIXEL support.
|
|
27
|
-
*
|
|
28
|
-
* Windows Terminal introduced SIXEL support in preview 1.22.
|
|
29
|
-
*/
|
|
30
|
-
export declare function isWindowsTerminalPreviewSixelSupported(env?: NodeJS.ProcessEnv, platform?: NodeJS.Platform): boolean;
|
|
31
|
-
export declare const TERMINAL_ID: TerminalId;
|
|
32
|
-
export declare const TERMINAL: TerminalInfo;
|
|
33
|
-
/**
|
|
34
|
-
* Override terminal image protocol at runtime after capability probes complete.
|
|
35
|
-
*/
|
|
36
|
-
export declare function setTerminalImageProtocol(imageProtocol: ImageProtocol | null): void;
|
|
37
|
-
export declare function getTerminalInfo(terminalId: TerminalId): TerminalInfo;
|
|
38
|
-
export interface CellDimensions {
|
|
39
|
-
widthPx: number;
|
|
40
|
-
heightPx: number;
|
|
41
|
-
}
|
|
42
|
-
export interface ImageDimensions {
|
|
43
|
-
widthPx: number;
|
|
44
|
-
heightPx: number;
|
|
45
|
-
}
|
|
46
|
-
export interface ImageRenderOptions {
|
|
47
|
-
maxWidthCells?: number;
|
|
48
|
-
maxHeightCells?: number;
|
|
49
|
-
preserveAspectRatio?: boolean;
|
|
50
|
-
/**
|
|
51
|
-
* Kitty-only: stable placement id (`p=`). Re-emitting the same image id +
|
|
52
|
-
* placement id *replaces* the existing placement instead of stacking a new
|
|
53
|
-
* copy, which makes diff-renderer repaints idempotent. Callers that render
|
|
54
|
-
* a persistent component should allocate one id per component instance.
|
|
55
|
-
*/
|
|
56
|
-
placementId?: number;
|
|
57
|
-
/**
|
|
58
|
-
* Kitty-only: stable image id (`i=`). Defaults to a content hash of the
|
|
59
|
-
* base64 payload ({@link kittyImageId}). Pass a precomputed id to avoid
|
|
60
|
-
* re-hashing large payloads on every render.
|
|
61
|
-
*/
|
|
62
|
-
imageId?: number;
|
|
63
|
-
/**
|
|
64
|
-
* Kitty-only: sink for the out-of-band data transmission (`a=t`) emitted
|
|
65
|
-
* the first time an image id is rendered. Defaults to the process-wide
|
|
66
|
-
* writer configured via {@link setKittyTransmitWriter} (stdout).
|
|
67
|
-
*/
|
|
68
|
-
onTransmit?: (sequence: string) => void;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Derive a stable 32-bit non-zero kitty image id (`i=`) from image content
|
|
72
|
-
* (FNV-1a over the base64 payload). Identical content maps to the same id, so
|
|
73
|
-
* retransmission replaces the stored image instead of accumulating copies.
|
|
74
|
-
*/
|
|
75
|
-
export declare function kittyImageId(base64Data: string): number;
|
|
76
|
-
export declare function getCellDimensions(): CellDimensions;
|
|
77
|
-
export declare function setCellDimensions(dims: CellDimensions): void;
|
|
78
|
-
export declare function encodeKitty(base64Data: string, options?: {
|
|
79
|
-
columns?: number;
|
|
80
|
-
rows?: number;
|
|
81
|
-
imageId?: number;
|
|
82
|
-
placementId?: number;
|
|
83
|
-
}): string;
|
|
84
|
-
/** Test hook: forget which kitty image ids were transmitted. */
|
|
85
|
-
export declare function resetKittyTransmissions(): void;
|
|
86
|
-
/**
|
|
87
|
-
* Override where out-of-band kitty data transmissions (`a=t`) are written.
|
|
88
|
-
* The default writes directly to stdout: a transmit-only escape is
|
|
89
|
-
* cursor-neutral (it uploads pixel data without drawing anything), so the
|
|
90
|
-
* only ordering requirement is that it reaches the terminal before the
|
|
91
|
-
* placement escape that references it — which the synchronous write during
|
|
92
|
-
* render guarantees. Tests use this to capture transmissions.
|
|
93
|
-
*/
|
|
94
|
-
export declare function setKittyTransmitWriter(writer: (sequence: string) => void): void;
|
|
95
|
-
/**
|
|
96
|
-
* Encode a kitty transmit-only (`a=t`) escape: uploads image data under a
|
|
97
|
-
* stable id without creating a placement. Chunked at 4096 bytes per spec.
|
|
98
|
-
*
|
|
99
|
-
* This is deliberately separate from placement: re-sending data (`a=t`/`a=T`)
|
|
100
|
-
* for an existing image id deletes the image and ALL of its placements, so
|
|
101
|
-
* data must be uploaded exactly once per id and repaints must go through
|
|
102
|
-
* {@link encodeKittyPlacement} only.
|
|
103
|
-
*/
|
|
104
|
-
export declare function encodeKittyTransmit(base64Data: string, imageId: number): string;
|
|
105
|
-
/**
|
|
106
|
-
* Encode a kitty placement-only (`a=p`) escape referencing previously
|
|
107
|
-
* transmitted data. Re-emitting the same i=/p= pair replaces that one
|
|
108
|
-
* placement (never stacks, never touches sibling placements), and C=1
|
|
109
|
-
* keeps the cursor where it is so the escape can be emitted from the
|
|
110
|
-
* component's first row without cursor-up tricks.
|
|
111
|
-
*/
|
|
112
|
-
export declare function encodeKittyPlacement(options: {
|
|
113
|
-
imageId: number;
|
|
114
|
-
placementId: number;
|
|
115
|
-
columns: number;
|
|
116
|
-
rows: number;
|
|
117
|
-
}): string;
|
|
118
|
-
export declare function encodeITerm2(base64Data: string, options?: {
|
|
119
|
-
width?: number | string;
|
|
120
|
-
height?: number | string;
|
|
121
|
-
name?: string;
|
|
122
|
-
preserveAspectRatio?: boolean;
|
|
123
|
-
inline?: boolean;
|
|
124
|
-
}): string;
|
|
125
|
-
export declare function calculateImageRows(imageDimensions: ImageDimensions, targetWidthCells: number, cellDimensions?: CellDimensions): number;
|
|
126
|
-
export declare function getPngDimensions(base64Data: string): ImageDimensions | null;
|
|
127
|
-
export declare function getJpegDimensions(base64Data: string): ImageDimensions | null;
|
|
128
|
-
export declare function getGifDimensions(base64Data: string): ImageDimensions | null;
|
|
129
|
-
export declare function getWebpDimensions(base64Data: string): ImageDimensions | null;
|
|
130
|
-
export declare function getImageDimensions(base64Data: string, mimeType: string): ImageDimensions | null;
|
|
131
|
-
export interface RenderedImage {
|
|
132
|
-
sequence: string;
|
|
133
|
-
rows: number;
|
|
134
|
-
/**
|
|
135
|
-
* True when the escape neither moves the cursor nor carries pixel data
|
|
136
|
-
* (kitty `a=p,C=1` placements). Cursor-neutral sequences can be emitted
|
|
137
|
-
* from the component's first row; cursor-advancing protocols
|
|
138
|
-
* (iTerm2/SIXEL) must draw from the last reserved row instead.
|
|
139
|
-
*/
|
|
140
|
-
cursorNeutral?: boolean;
|
|
141
|
-
}
|
|
142
|
-
export declare function renderImage(base64Data: string, imageDimensions: ImageDimensions, options?: ImageRenderOptions): RenderedImage | null;
|
|
143
|
-
export declare function imageFallback(mimeType: string, dimensions?: ImageDimensions, filename?: string): string;
|
package/dist/types/terminal.d.ts
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Whether SKC may reprogram the keyboard with enhanced input protocols
|
|
3
|
-
* (the Kitty keyboard protocol and the xterm modifyOtherKeys fallback).
|
|
4
|
-
*
|
|
5
|
-
* Enabled by default. Set `SKC_TUI_KEYBOARD_PROTOCOL=0` to leave the keyboard in
|
|
6
|
-
* its default mode. Some terminals — notably Android Termius — break IME
|
|
7
|
-
* composition (e.g. Korean/Hangul syllable composition) while these enhanced
|
|
8
|
-
* modes are active, committing every intermediate composing jamo/syllable
|
|
9
|
-
* instead of only the final character. Disabling the protocol restores normal
|
|
10
|
-
* IME behavior, matching how other TUIs that leave the keyboard untouched render
|
|
11
|
-
* Korean correctly.
|
|
12
|
-
*/
|
|
13
|
-
export declare function keyboardEnhancementEnabled(): boolean;
|
|
14
|
-
/** Error codes for terminal/pipe write failures that should never crash the process. */
|
|
15
|
-
export declare function isBenignTerminalWriteError(err: unknown): boolean;
|
|
16
|
-
/**
|
|
17
|
-
* Emergency terminal restore - call this from signal/crash handlers
|
|
18
|
-
* Resets terminal state without requiring access to the ProcessTerminal instance
|
|
19
|
-
*/
|
|
20
|
-
export declare function emergencyTerminalRestore(): void;
|
|
21
|
-
/** Terminal-reported appearance (dark/light mode). */
|
|
22
|
-
export type TerminalAppearance = "dark" | "light";
|
|
23
|
-
export interface Terminal {
|
|
24
|
-
start(onInput: (data: string) => void, onResize: () => void): void;
|
|
25
|
-
stop(): void;
|
|
26
|
-
/**
|
|
27
|
-
* Drain stdin before exiting to prevent Kitty key release events from
|
|
28
|
-
* leaking to the parent shell over slow SSH connections.
|
|
29
|
-
* @param maxMs - Maximum time to drain (default: 1000ms)
|
|
30
|
-
* @param idleMs - Exit early if no input arrives within this time (default: 50ms)
|
|
31
|
-
*/
|
|
32
|
-
drainInput(maxMs?: number, idleMs?: number): Promise<void>;
|
|
33
|
-
write(data: string): void;
|
|
34
|
-
get available(): boolean;
|
|
35
|
-
readonly isProcessTerminal?: boolean;
|
|
36
|
-
get columns(): number;
|
|
37
|
-
get rows(): number;
|
|
38
|
-
get kittyProtocolActive(): boolean;
|
|
39
|
-
moveBy(lines: number): void;
|
|
40
|
-
hideCursor(): void;
|
|
41
|
-
showCursor(): void;
|
|
42
|
-
clearLine(): void;
|
|
43
|
-
clearFromCursor(): void;
|
|
44
|
-
clearScreen(): void;
|
|
45
|
-
setTitle(title: string): void;
|
|
46
|
-
setProgress(active: boolean): void;
|
|
47
|
-
/**
|
|
48
|
-
* Register a callback for terminal appearance (dark/light) changes.
|
|
49
|
-
* Detection uses OSC 11 background color query with Mode 2031 as a change trigger.
|
|
50
|
-
* Fires when the detected appearance changes, including the initial detection.
|
|
51
|
-
*/
|
|
52
|
-
onAppearanceChange(callback: (appearance: TerminalAppearance) => void): void;
|
|
53
|
-
/** The last detected terminal appearance, or undefined if not yet known. */
|
|
54
|
-
get appearance(): TerminalAppearance | undefined;
|
|
55
|
-
}
|
|
56
|
-
interface TerminalSizeStream {
|
|
57
|
-
columns?: number;
|
|
58
|
-
rows?: number;
|
|
59
|
-
getWindowSize?: () => [number, number] | number[];
|
|
60
|
-
}
|
|
61
|
-
export declare function resolveTerminalColumns(stream?: TerminalSizeStream, envColumns?: string | undefined): number;
|
|
62
|
-
export declare function resolveTerminalRows(stream?: TerminalSizeStream, envRows?: string | undefined): number;
|
|
63
|
-
/**
|
|
64
|
-
* Real terminal using process.stdin/stdout
|
|
65
|
-
*/
|
|
66
|
-
export declare class ProcessTerminal implements Terminal {
|
|
67
|
-
#private;
|
|
68
|
-
get isProcessTerminal(): boolean;
|
|
69
|
-
get kittyProtocolActive(): boolean;
|
|
70
|
-
get appearance(): TerminalAppearance | undefined;
|
|
71
|
-
onAppearanceChange(callback: (appearance: TerminalAppearance) => void): void;
|
|
72
|
-
start(onInput: (data: string) => void, onResize: () => void): void;
|
|
73
|
-
drainInput(maxMs?: number, idleMs?: number): Promise<void>;
|
|
74
|
-
stop(): void;
|
|
75
|
-
write(data: string): void;
|
|
76
|
-
/** Invoked by the durable module-level stdout write guard (see installStdoutWriteGuard). */
|
|
77
|
-
markStdoutUnavailable(err: unknown): void;
|
|
78
|
-
get available(): boolean;
|
|
79
|
-
get columns(): number;
|
|
80
|
-
get rows(): number;
|
|
81
|
-
moveBy(lines: number): void;
|
|
82
|
-
hideCursor(): void;
|
|
83
|
-
showCursor(): void;
|
|
84
|
-
clearLine(): void;
|
|
85
|
-
clearFromCursor(): void;
|
|
86
|
-
clearScreen(): void;
|
|
87
|
-
setTitle(title: string): void;
|
|
88
|
-
setProgress(active: boolean): void;
|
|
89
|
-
}
|
|
90
|
-
export {};
|
package/dist/types/ttyid.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/** Resolve the TTY device path for stdin (fd 0) via POSIX `ttyname(3)`. */
|
|
2
|
-
export declare function getTtyPath(): string | null;
|
|
3
|
-
/**
|
|
4
|
-
* Get a stable identifier for the current terminal.
|
|
5
|
-
* Uses the TTY device path (e.g., /dev/pts/3), falling back to environment
|
|
6
|
-
* variables for terminal multiplexers or terminal emulators.
|
|
7
|
-
* Returns null if no terminal can be identified (e.g., piped input).
|
|
8
|
-
*/
|
|
9
|
-
export declare function getTerminalId(): string | null;
|
package/dist/types/tui.d.ts
DELETED
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
import type { Terminal } from "./terminal";
|
|
2
|
-
import { visibleWidth } from "./utils";
|
|
3
|
-
type InputListenerResult = {
|
|
4
|
-
consume?: boolean;
|
|
5
|
-
data?: string;
|
|
6
|
-
} | undefined;
|
|
7
|
-
type InputListener = (data: string) => InputListenerResult;
|
|
8
|
-
/**
|
|
9
|
-
* Component interface - all components must implement this
|
|
10
|
-
*/
|
|
11
|
-
export interface Component {
|
|
12
|
-
/**
|
|
13
|
-
* Render the component to lines for the given viewport width
|
|
14
|
-
* @param width - Current viewport width
|
|
15
|
-
* @returns Array of strings, each representing a line
|
|
16
|
-
*/
|
|
17
|
-
render(width: number): string[];
|
|
18
|
-
/**
|
|
19
|
-
* Optional handler for keyboard input when component has focus
|
|
20
|
-
*/
|
|
21
|
-
handleInput?(data: string): void;
|
|
22
|
-
/**
|
|
23
|
-
* If true, component receives key release events (Kitty protocol).
|
|
24
|
-
* Default is false - release events are filtered out.
|
|
25
|
-
*/
|
|
26
|
-
wantsKeyRelease?: boolean;
|
|
27
|
-
/**
|
|
28
|
-
* Invalidate any cached rendering state.
|
|
29
|
-
* Called when theme changes or when component needs to re-render from scratch.
|
|
30
|
-
*/
|
|
31
|
-
invalidate(): void;
|
|
32
|
-
/**
|
|
33
|
-
* Optional cleanup hook. Called once when the component is permanently
|
|
34
|
-
* removed from the tree via removeChild/clear/dispose. Implementations MUST
|
|
35
|
-
* be idempotent. Components meant to be re-added should be detached, not
|
|
36
|
-
* removed/cleared.
|
|
37
|
-
*/
|
|
38
|
-
dispose?(): void;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Interface for components that can receive focus and display a hardware cursor.
|
|
42
|
-
* When focused, the component should emit CURSOR_MARKER at the cursor position
|
|
43
|
-
* in its render output. TUI will find this marker and position the hardware
|
|
44
|
-
* cursor there for proper IME candidate window positioning.
|
|
45
|
-
*/
|
|
46
|
-
export interface Focusable {
|
|
47
|
-
/** Set by TUI when focus changes. Component should emit CURSOR_MARKER when true. */
|
|
48
|
-
focused: boolean;
|
|
49
|
-
}
|
|
50
|
-
/** Type guard to check if a component implements Focusable */
|
|
51
|
-
export declare function isFocusable(component: Component | null): component is Component & Focusable;
|
|
52
|
-
/**
|
|
53
|
-
* Cursor position marker - APC (Application Program Command) sequence.
|
|
54
|
-
* This is a zero-width escape sequence that terminals ignore.
|
|
55
|
-
* Components emit this at the cursor position when focused.
|
|
56
|
-
* TUI finds and strips this marker, then positions the hardware cursor there.
|
|
57
|
-
*/
|
|
58
|
-
export declare const CURSOR_MARKER = "\u001B_pi:c\u0007";
|
|
59
|
-
export { visibleWidth };
|
|
60
|
-
/**
|
|
61
|
-
* Anchor position for overlays
|
|
62
|
-
*/
|
|
63
|
-
export type OverlayAnchor = "center" | "top-left" | "top-right" | "bottom-left" | "bottom-right" | "top-center" | "bottom-center" | "left-center" | "right-center";
|
|
64
|
-
/**
|
|
65
|
-
* Margin configuration for overlays
|
|
66
|
-
*/
|
|
67
|
-
export interface OverlayMargin {
|
|
68
|
-
top?: number;
|
|
69
|
-
right?: number;
|
|
70
|
-
bottom?: number;
|
|
71
|
-
left?: number;
|
|
72
|
-
}
|
|
73
|
-
/** Value that can be absolute (number) or percentage (string like "50%") */
|
|
74
|
-
export type SizeValue = number | `${number}%`;
|
|
75
|
-
/**
|
|
76
|
-
* True when repainting only the live viewport is safer than clearing/replaying
|
|
77
|
-
* the full transcript. Native Windows console hosts are included even when
|
|
78
|
-
* WT_SESSION is absent because PowerShell/ConPTY launch chains can drop terminal
|
|
79
|
-
* identity variables while keeping the same scroll-jump behavior.
|
|
80
|
-
*/
|
|
81
|
-
export declare function shouldUseViewportRepaintForHost(env?: Record<string, string | undefined>, platform?: NodeJS.Platform, options?: {
|
|
82
|
-
includeNativeWindows?: boolean;
|
|
83
|
-
}): boolean;
|
|
84
|
-
/**
|
|
85
|
-
* Options for overlay positioning and sizing.
|
|
86
|
-
* Values can be absolute numbers or percentage strings (e.g., "50%").
|
|
87
|
-
*/
|
|
88
|
-
export interface OverlayOptions {
|
|
89
|
-
/** Width in columns, or percentage of terminal width (e.g., "50%") */
|
|
90
|
-
width?: SizeValue;
|
|
91
|
-
/** Minimum width in columns */
|
|
92
|
-
minWidth?: number;
|
|
93
|
-
/** Maximum height in rows, or percentage of terminal height (e.g., "50%") */
|
|
94
|
-
maxHeight?: SizeValue;
|
|
95
|
-
/** Anchor point for positioning (default: 'center') */
|
|
96
|
-
anchor?: OverlayAnchor;
|
|
97
|
-
/** Horizontal offset from anchor position (positive = right) */
|
|
98
|
-
offsetX?: number;
|
|
99
|
-
/** Vertical offset from anchor position (positive = down) */
|
|
100
|
-
offsetY?: number;
|
|
101
|
-
/** Row position: absolute number, or percentage (e.g., "25%" = 25% from top) */
|
|
102
|
-
row?: SizeValue;
|
|
103
|
-
/** Column position: absolute number, or percentage (e.g., "50%" = centered horizontally) */
|
|
104
|
-
col?: SizeValue;
|
|
105
|
-
/** Margin from terminal edges. Number applies to all sides. */
|
|
106
|
-
margin?: OverlayMargin | number;
|
|
107
|
-
/**
|
|
108
|
-
* Control overlay visibility based on terminal dimensions.
|
|
109
|
-
* If provided, overlay is only rendered when this returns true.
|
|
110
|
-
* Called each render cycle with current terminal dimensions.
|
|
111
|
-
*/
|
|
112
|
-
visible?: (termWidth: number, termHeight: number) => boolean;
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Handle returned by showOverlay for controlling the overlay
|
|
116
|
-
*/
|
|
117
|
-
export interface OverlayHandle {
|
|
118
|
-
/** Permanently remove the overlay (cannot be shown again) */
|
|
119
|
-
hide(): void;
|
|
120
|
-
/** Temporarily hide or show the overlay */
|
|
121
|
-
setHidden(hidden: boolean): void;
|
|
122
|
-
/** Check if overlay is temporarily hidden */
|
|
123
|
-
isHidden(): boolean;
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Container - a component that contains other components
|
|
127
|
-
*/
|
|
128
|
-
export declare class Container implements Component {
|
|
129
|
-
#private;
|
|
130
|
-
children: Component[];
|
|
131
|
-
addChild(component: Component): void;
|
|
132
|
-
removeChild(component: Component): void;
|
|
133
|
-
/** Remove a child without disposing it (for detach-then-readd reuse). */
|
|
134
|
-
detachChild(component: Component): void;
|
|
135
|
-
clear(): void;
|
|
136
|
-
/** Remove all children without disposing them (for detach-then-readd reuse). */
|
|
137
|
-
detachAll(): void;
|
|
138
|
-
dispose(): void;
|
|
139
|
-
invalidate(): void;
|
|
140
|
-
render(width: number): string[];
|
|
141
|
-
}
|
|
142
|
-
type TuiRenderCounterSnapshot = {
|
|
143
|
-
debugRedrawEnvReads: number;
|
|
144
|
-
debugRedrawAppendWrites: number;
|
|
145
|
-
differentialGuardVisibleWidthCalls: number;
|
|
146
|
-
};
|
|
147
|
-
/**
|
|
148
|
-
* TUI - Main class for managing terminal UI with differential rendering
|
|
149
|
-
*/
|
|
150
|
-
export declare class TUI extends Container {
|
|
151
|
-
#private;
|
|
152
|
-
terminal: Terminal;
|
|
153
|
-
/** Global callback for debug key (Shift+Ctrl+D). Called before input is forwarded to focused component. */
|
|
154
|
-
onDebug?: () => void;
|
|
155
|
-
static resetRenderCountersForTest(): void;
|
|
156
|
-
static getRenderCountersForTest(): TuiRenderCounterSnapshot;
|
|
157
|
-
overlayStack: {
|
|
158
|
-
component: Component;
|
|
159
|
-
options?: OverlayOptions;
|
|
160
|
-
preFocus: Component | null;
|
|
161
|
-
hidden: boolean;
|
|
162
|
-
}[];
|
|
163
|
-
constructor(terminal: Terminal, showHardwareCursor?: boolean);
|
|
164
|
-
dispose(): void;
|
|
165
|
-
get fullRedraws(): number;
|
|
166
|
-
getShowHardwareCursor(): boolean;
|
|
167
|
-
setShowHardwareCursor(enabled: boolean): void;
|
|
168
|
-
getClearOnShrink(): boolean;
|
|
169
|
-
/**
|
|
170
|
-
* Set whether to trigger full re-render when content shrinks.
|
|
171
|
-
* When true (default), empty rows are cleared when content shrinks.
|
|
172
|
-
* When false, empty rows remain (reduces redraws on slower terminals).
|
|
173
|
-
*/
|
|
174
|
-
setClearOnShrink(enabled: boolean): void;
|
|
175
|
-
setFocus(component: Component | null): void;
|
|
176
|
-
setBottomPinnedComponent(component: Component | null): void;
|
|
177
|
-
scrollViewportPages(direction: -1 | 1): boolean;
|
|
178
|
-
followLiveViewport(): boolean;
|
|
179
|
-
/**
|
|
180
|
-
* Show an overlay component with configurable positioning and sizing.
|
|
181
|
-
* Returns a handle to control the overlay's visibility.
|
|
182
|
-
*/
|
|
183
|
-
showOverlay(component: Component, options?: OverlayOptions): OverlayHandle;
|
|
184
|
-
/** Hide the topmost overlay and restore previous focus. */
|
|
185
|
-
hideOverlay(): void;
|
|
186
|
-
/** Check if there are any visible overlays */
|
|
187
|
-
hasOverlay(): boolean;
|
|
188
|
-
invalidate(): void;
|
|
189
|
-
start(): void;
|
|
190
|
-
get terminalAvailable(): boolean;
|
|
191
|
-
addInputListener(listener: InputListener): () => void;
|
|
192
|
-
removeInputListener(listener: InputListener): void;
|
|
193
|
-
stop(): void;
|
|
194
|
-
/**
|
|
195
|
-
* Viewport-repaint-aware resize render request.
|
|
196
|
-
*
|
|
197
|
-
* A forced full redraw (`requestRender(true)`) resets `#previousWidth`/`#previousHeight`
|
|
198
|
-
* to -1, which makes `#doRender` treat the frame as a width change and fall into the
|
|
199
|
-
* `fullRender` path. In terminal multiplexers that path skips the scrollback-clearing
|
|
200
|
-
* `3J` escape (users navigate scrollback history), so replaying every transcript line
|
|
201
|
-
* piles it back on top of scrollback — the "top of screen scrolls down to the prompt at
|
|
202
|
-
* high speed" resize storm. Windows Terminal/ConPTY can also visibly jump to
|
|
203
|
-
* the transcript top during streaming redraws, so viewport-repaint sessions
|
|
204
|
-
* keep force off and let `#doRender` repaint only the live viewport. Set
|
|
205
|
-
* `PI_TUI_LEGACY_MULTIPLEXER_FULL_RENDER=1` to restore the legacy tmux redraw.
|
|
206
|
-
*/
|
|
207
|
-
requestResizeRender(): void;
|
|
208
|
-
requestRender(force?: boolean, source?: string): void;
|
|
209
|
-
getLineRenderCacheStats(): {
|
|
210
|
-
normalizationSize: number;
|
|
211
|
-
truncationSize: number;
|
|
212
|
-
normalizationLimit: number;
|
|
213
|
-
truncationLimit: number;
|
|
214
|
-
};
|
|
215
|
-
}
|