@sayknow-cli/tui 0.3.16 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +184 -18
- 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
|
@@ -1,187 +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 whether the process runs under a terminal multiplexer (tmux, GNU
|
|
27
|
-
* screen, or zellij). Recognizes the same host markers as the renderer's
|
|
28
|
-
* multiplexer predicate in tui.ts so capability selection and viewport-repaint
|
|
29
|
-
* policy agree on what counts as a multiplexed host. Multiplexers intercept
|
|
30
|
-
* graphics escapes and OSC 8 hyperlinks instead of forwarding them to the
|
|
31
|
-
* outer terminal.
|
|
32
|
-
*/
|
|
33
|
-
export declare function isUnderTerminalMultiplexer(env?: NodeJS.ProcessEnv): boolean;
|
|
34
|
-
export interface TerminalGraphicsFallbackOptions {
|
|
35
|
-
/**
|
|
36
|
-
* Permit cursor-neutral image escapes (kitty `a=p,C=1` placements) to render
|
|
37
|
-
* inside this fallback scope. Cursor-advancing protocols (iTerm2/SIXEL)
|
|
38
|
-
* remain suppressed. A nested scope without this option revokes the
|
|
39
|
-
* permission for its own subtree.
|
|
40
|
-
*/
|
|
41
|
-
allowCursorNeutralImages?: boolean;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Synchronously suppress terminal graphics while rendering a text-only surface.
|
|
45
|
-
* Nested scopes remain active until the outermost scope exits.
|
|
46
|
-
*/
|
|
47
|
-
export declare function withTerminalGraphicsFallback<T>(fn: () => T, options?: TerminalGraphicsFallbackOptions): T;
|
|
48
|
-
/** Returns whether terminal graphics are currently suppressed by a render scope. */
|
|
49
|
-
export declare function isTerminalGraphicsFallbackActive(): boolean;
|
|
50
|
-
/**
|
|
51
|
-
* Returns whether cursor-neutral image escapes may render despite an active
|
|
52
|
-
* graphics-fallback scope. True only when every active fallback scope opted in.
|
|
53
|
-
*/
|
|
54
|
-
export declare function isCursorNeutralImagePermittedInFallback(): boolean;
|
|
55
|
-
/**
|
|
56
|
-
* Returns whether PI_FORCE_IMAGE_PROTOCOL explicitly configures the image
|
|
57
|
-
* protocol, including an explicit "off". An explicit configuration is
|
|
58
|
-
* authoritative: runtime capability probes must not override it.
|
|
59
|
-
*/
|
|
60
|
-
export declare function isImageProtocolForced(): boolean;
|
|
61
|
-
/**
|
|
62
|
-
* Returns true when running in Windows Terminal with known SIXEL support.
|
|
63
|
-
*
|
|
64
|
-
* Windows Terminal introduced SIXEL support in preview 1.22.
|
|
65
|
-
*/
|
|
66
|
-
export declare function isWindowsTerminalPreviewSixelSupported(env?: NodeJS.ProcessEnv, platform?: NodeJS.Platform): boolean;
|
|
67
|
-
export declare const TERMINAL_ID: TerminalId;
|
|
68
|
-
export declare const TERMINAL: TerminalInfo;
|
|
69
|
-
type ImageProtocolChangeListener = (imageProtocol: ImageProtocol | null) => void;
|
|
70
|
-
/**
|
|
71
|
-
* Subscribe to runtime image-protocol changes (e.g. the asynchronous sixel
|
|
72
|
-
* capability probe enabling graphics after startup). Returns an unsubscribe
|
|
73
|
-
* function. Listeners fire only on actual changes.
|
|
74
|
-
*/
|
|
75
|
-
export declare function onImageProtocolChanged(listener: ImageProtocolChangeListener): () => void;
|
|
76
|
-
/**
|
|
77
|
-
* Override terminal image protocol at runtime after capability probes complete.
|
|
78
|
-
*/
|
|
79
|
-
export declare function setTerminalImageProtocol(imageProtocol: ImageProtocol | null): void;
|
|
80
|
-
export declare function getTerminalInfo(terminalId: TerminalId): TerminalInfo;
|
|
81
|
-
export interface CellDimensions {
|
|
82
|
-
widthPx: number;
|
|
83
|
-
heightPx: number;
|
|
84
|
-
}
|
|
85
|
-
export interface ImageDimensions {
|
|
86
|
-
widthPx: number;
|
|
87
|
-
heightPx: number;
|
|
88
|
-
}
|
|
89
|
-
export interface ImageRenderOptions {
|
|
90
|
-
maxWidthCells?: number;
|
|
91
|
-
maxHeightCells?: number;
|
|
92
|
-
preserveAspectRatio?: boolean;
|
|
93
|
-
/**
|
|
94
|
-
* Kitty-only: stable placement id (`p=`). Re-emitting the same image id +
|
|
95
|
-
* placement id *replaces* the existing placement instead of stacking a new
|
|
96
|
-
* copy, which makes diff-renderer repaints idempotent. Callers that render
|
|
97
|
-
* a persistent component should allocate one id per component instance.
|
|
98
|
-
*/
|
|
99
|
-
placementId?: number;
|
|
100
|
-
/**
|
|
101
|
-
* Kitty-only: stable image id (`i=`). Defaults to a content hash of the
|
|
102
|
-
* base64 payload ({@link kittyImageId}). Pass a precomputed id to avoid
|
|
103
|
-
* re-hashing large payloads on every render.
|
|
104
|
-
*/
|
|
105
|
-
imageId?: number;
|
|
106
|
-
/**
|
|
107
|
-
* Kitty-only: sink for the out-of-band data transmission (`a=t`) emitted
|
|
108
|
-
* the first time an image id is rendered. Defaults to the process-wide
|
|
109
|
-
* writer configured via {@link setKittyTransmitWriter} (stdout).
|
|
110
|
-
*/
|
|
111
|
-
onTransmit?: (sequence: string) => void;
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Derive a stable 32-bit non-zero kitty image id (`i=`) from image content
|
|
115
|
-
* (FNV-1a over the base64 payload). Identical content maps to the same id, so
|
|
116
|
-
* retransmission replaces the stored image instead of accumulating copies.
|
|
117
|
-
*/
|
|
118
|
-
export declare function kittyImageId(base64Data: string): number;
|
|
119
|
-
export declare function getCellDimensions(): CellDimensions;
|
|
120
|
-
export declare function setCellDimensions(dims: CellDimensions): void;
|
|
121
|
-
export declare function encodeKitty(base64Data: string, options?: {
|
|
122
|
-
columns?: number;
|
|
123
|
-
rows?: number;
|
|
124
|
-
imageId?: number;
|
|
125
|
-
placementId?: number;
|
|
126
|
-
}): string;
|
|
127
|
-
/** Test hook: forget which kitty image ids were transmitted. */
|
|
128
|
-
export declare function resetKittyTransmissions(): void;
|
|
129
|
-
/**
|
|
130
|
-
* Override where out-of-band kitty data transmissions (`a=t`) are written.
|
|
131
|
-
* The default writes directly to stdout: a transmit-only escape is
|
|
132
|
-
* cursor-neutral (it uploads pixel data without drawing anything), so the
|
|
133
|
-
* only ordering requirement is that it reaches the terminal before the
|
|
134
|
-
* placement escape that references it — which the synchronous write during
|
|
135
|
-
* render guarantees. Tests use this to capture transmissions.
|
|
136
|
-
*/
|
|
137
|
-
export declare function setKittyTransmitWriter(writer: (sequence: string) => void): void;
|
|
138
|
-
/**
|
|
139
|
-
* Encode a kitty transmit-only (`a=t`) escape: uploads image data under a
|
|
140
|
-
* stable id without creating a placement. Chunked at 4096 bytes per spec.
|
|
141
|
-
*
|
|
142
|
-
* This is deliberately separate from placement: re-sending data (`a=t`/`a=T`)
|
|
143
|
-
* for an existing image id deletes the image and ALL of its placements, so
|
|
144
|
-
* data must be uploaded exactly once per id and repaints must go through
|
|
145
|
-
* {@link encodeKittyPlacement} only.
|
|
146
|
-
*/
|
|
147
|
-
export declare function encodeKittyTransmit(base64Data: string, imageId: number): string;
|
|
148
|
-
/**
|
|
149
|
-
* Encode a kitty placement-only (`a=p`) escape referencing previously
|
|
150
|
-
* transmitted data. Re-emitting the same i=/p= pair replaces that one
|
|
151
|
-
* placement (never stacks, never touches sibling placements), and C=1
|
|
152
|
-
* keeps the cursor where it is so the escape can be emitted from the
|
|
153
|
-
* component's first row without cursor-up tricks.
|
|
154
|
-
*/
|
|
155
|
-
export declare function encodeKittyPlacement(options: {
|
|
156
|
-
imageId: number;
|
|
157
|
-
placementId: number;
|
|
158
|
-
columns: number;
|
|
159
|
-
rows: number;
|
|
160
|
-
}): string;
|
|
161
|
-
export declare function encodeITerm2(base64Data: string, options?: {
|
|
162
|
-
width?: number | string;
|
|
163
|
-
height?: number | string;
|
|
164
|
-
name?: string;
|
|
165
|
-
preserveAspectRatio?: boolean;
|
|
166
|
-
inline?: boolean;
|
|
167
|
-
}): string;
|
|
168
|
-
export declare function calculateImageRows(imageDimensions: ImageDimensions, targetWidthCells: number, cellDimensions?: CellDimensions): number;
|
|
169
|
-
export declare function getPngDimensions(base64Data: string): ImageDimensions | null;
|
|
170
|
-
export declare function getJpegDimensions(base64Data: string): ImageDimensions | null;
|
|
171
|
-
export declare function getGifDimensions(base64Data: string): ImageDimensions | null;
|
|
172
|
-
export declare function getWebpDimensions(base64Data: string): ImageDimensions | null;
|
|
173
|
-
export declare function getImageDimensions(base64Data: string, mimeType: string): ImageDimensions | null;
|
|
174
|
-
export interface RenderedImage {
|
|
175
|
-
sequence: string;
|
|
176
|
-
rows: number;
|
|
177
|
-
/**
|
|
178
|
-
* True when the escape neither moves the cursor nor carries pixel data
|
|
179
|
-
* (kitty `a=p,C=1` placements). Cursor-neutral sequences can be emitted
|
|
180
|
-
* from the component's first row; cursor-advancing protocols
|
|
181
|
-
* (iTerm2/SIXEL) must draw from the last reserved row instead.
|
|
182
|
-
*/
|
|
183
|
-
cursorNeutral?: boolean;
|
|
184
|
-
}
|
|
185
|
-
export declare function renderImage(base64Data: string, imageDimensions: ImageDimensions, options?: ImageRenderOptions): RenderedImage | null;
|
|
186
|
-
export declare function imageFallback(mimeType: string, dimensions?: ImageDimensions, filename?: string): string;
|
|
187
|
-
export {};
|
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,269 +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
|
-
/** Durable source identifier for a semantically anchored viewport row. */
|
|
61
|
-
export type ViewportAnchorId = string;
|
|
62
|
-
export interface ViewportAnchorRow {
|
|
63
|
-
id: ViewportAnchorId;
|
|
64
|
-
graphemeStart: number;
|
|
65
|
-
graphemeEnd: number;
|
|
66
|
-
cellStart: number;
|
|
67
|
-
cellEnd: number;
|
|
68
|
-
}
|
|
69
|
-
export interface ViewportAnchorRender {
|
|
70
|
-
lines: string[];
|
|
71
|
-
anchors: Array<ViewportAnchorRow | null>;
|
|
72
|
-
}
|
|
73
|
-
export interface ViewportAnchorProvider extends Component {
|
|
74
|
-
renderWithViewportAnchors(width: number): ViewportAnchorRender;
|
|
75
|
-
}
|
|
76
|
-
export interface ViewportAnchorSource {
|
|
77
|
-
id: ViewportAnchorId;
|
|
78
|
-
}
|
|
79
|
-
export interface ViewportAnchorSourceRenderer extends Component {
|
|
80
|
-
renderWithViewportAnchorSource(width: number, source: ViewportAnchorSource): ViewportAnchorRender;
|
|
81
|
-
}
|
|
82
|
-
export declare function isViewportAnchorProvider(component: Component): component is ViewportAnchorProvider;
|
|
83
|
-
export declare function isViewportAnchorSourceRenderer(component: Component): component is ViewportAnchorSourceRenderer;
|
|
84
|
-
export declare function renderComponentWithViewportAnchors(component: Component, width: number): ViewportAnchorRender;
|
|
85
|
-
export declare function renderComponentWithViewportAnchorSource(component: Component, width: number, source: ViewportAnchorSource): ViewportAnchorRender;
|
|
86
|
-
/**
|
|
87
|
-
* Anchor position for overlays
|
|
88
|
-
*/
|
|
89
|
-
export type OverlayAnchor = "center" | "top-left" | "top-right" | "bottom-left" | "bottom-right" | "top-center" | "bottom-center" | "left-center" | "right-center";
|
|
90
|
-
/**
|
|
91
|
-
* Margin configuration for overlays
|
|
92
|
-
*/
|
|
93
|
-
export interface OverlayMargin {
|
|
94
|
-
top?: number;
|
|
95
|
-
right?: number;
|
|
96
|
-
bottom?: number;
|
|
97
|
-
left?: number;
|
|
98
|
-
}
|
|
99
|
-
/** Value that can be absolute (number) or percentage (string like "50%") */
|
|
100
|
-
export type SizeValue = number | `${number}%`;
|
|
101
|
-
/**
|
|
102
|
-
* Startup sixel capability probe policy (pure; exported for tests):
|
|
103
|
-
* - Never probe when PI_FORCE_IMAGE_PROTOCOL is set — an explicit
|
|
104
|
-
* configuration (including "off") is authoritative.
|
|
105
|
-
* - Never probe inside a terminal multiplexer: tmux advertises DA1 ";4"
|
|
106
|
-
* whenever it was compiled with sixel support, regardless of whether the
|
|
107
|
-
* attached client terminal can render sixel, so a positive reply is not
|
|
108
|
-
* end-to-end evidence. Graphics under a multiplexer are strictly opt-in
|
|
109
|
-
* via PI_FORCE_IMAGE_PROTOCOL=sixel.
|
|
110
|
-
* - Probe Windows Terminal (>=1.22 renders sixel but exposes no env marker).
|
|
111
|
-
*/
|
|
112
|
-
export declare function shouldProbeSixelCapability(env?: NodeJS.ProcessEnv, platform?: NodeJS.Platform): boolean;
|
|
113
|
-
/**
|
|
114
|
-
* True when repainting only the live viewport is safer than clearing/replaying
|
|
115
|
-
* the full transcript. Native Windows console hosts are included even when
|
|
116
|
-
* WT_SESSION is absent because PowerShell/ConPTY launch chains can drop terminal
|
|
117
|
-
* identity variables while keeping the same scroll-jump behavior.
|
|
118
|
-
*/
|
|
119
|
-
export declare function shouldUseViewportRepaintForHost(env?: Record<string, string | undefined>, platform?: NodeJS.Platform, options?: {
|
|
120
|
-
includeNativeWindows?: boolean;
|
|
121
|
-
}): boolean;
|
|
122
|
-
/**
|
|
123
|
-
* Options for overlay positioning and sizing.
|
|
124
|
-
* Values can be absolute numbers or percentage strings (e.g., "50%").
|
|
125
|
-
*/
|
|
126
|
-
export interface OverlayOptions {
|
|
127
|
-
/** Width in columns, or percentage of terminal width (e.g., "50%") */
|
|
128
|
-
width?: SizeValue;
|
|
129
|
-
/** Minimum width in columns */
|
|
130
|
-
minWidth?: number;
|
|
131
|
-
/** Maximum height in rows, or percentage of terminal height (e.g., "50%") */
|
|
132
|
-
maxHeight?: SizeValue;
|
|
133
|
-
/** Anchor point for positioning (default: 'center') */
|
|
134
|
-
anchor?: OverlayAnchor;
|
|
135
|
-
/** Horizontal offset from anchor position (positive = right) */
|
|
136
|
-
offsetX?: number;
|
|
137
|
-
/** Vertical offset from anchor position (positive = down) */
|
|
138
|
-
offsetY?: number;
|
|
139
|
-
/** Row position: absolute number, or percentage (e.g., "25%" = 25% from top) */
|
|
140
|
-
row?: SizeValue;
|
|
141
|
-
/** Column position: absolute number, or percentage (e.g., "50%" = centered horizontally) */
|
|
142
|
-
col?: SizeValue;
|
|
143
|
-
/** Margin from terminal edges. Number applies to all sides. */
|
|
144
|
-
margin?: OverlayMargin | number;
|
|
145
|
-
/**
|
|
146
|
-
* Control overlay visibility based on terminal dimensions.
|
|
147
|
-
* If provided, overlay is only rendered when this returns true.
|
|
148
|
-
* Called each render cycle with current terminal dimensions.
|
|
149
|
-
*/
|
|
150
|
-
visible?: (termWidth: number, termHeight: number) => boolean;
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Handle returned by showOverlay for controlling the overlay
|
|
154
|
-
*/
|
|
155
|
-
export interface OverlayHandle {
|
|
156
|
-
/** Permanently remove the overlay (cannot be shown again) */
|
|
157
|
-
hide(): void;
|
|
158
|
-
/** Temporarily hide or show the overlay */
|
|
159
|
-
setHidden(hidden: boolean): void;
|
|
160
|
-
/** Check if overlay is temporarily hidden */
|
|
161
|
-
isHidden(): boolean;
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Container - a component that contains other components
|
|
165
|
-
*/
|
|
166
|
-
export declare class Container implements ViewportAnchorProvider {
|
|
167
|
-
#private;
|
|
168
|
-
children: Component[];
|
|
169
|
-
addChild(component: Component): void;
|
|
170
|
-
removeChild(component: Component): void;
|
|
171
|
-
/** Remove a child without disposing it (for detach-then-readd reuse). */
|
|
172
|
-
detachChild(component: Component): void;
|
|
173
|
-
clear(): void;
|
|
174
|
-
/** Remove all children without disposing them (for detach-then-readd reuse). */
|
|
175
|
-
detachAll(): void;
|
|
176
|
-
/** Registers a direct child as eligible for semantic viewport anchoring. */
|
|
177
|
-
setViewportAnchorSource(component: Component, source: ViewportAnchorSource | null): void;
|
|
178
|
-
dispose(): void;
|
|
179
|
-
invalidate(): void;
|
|
180
|
-
render(width: number): string[];
|
|
181
|
-
renderWithViewportAnchors(width: number): ViewportAnchorRender;
|
|
182
|
-
}
|
|
183
|
-
type TuiRenderCounterSnapshot = {
|
|
184
|
-
debugRedrawEnvReads: number;
|
|
185
|
-
debugRedrawAppendWrites: number;
|
|
186
|
-
differentialGuardVisibleWidthCalls: number;
|
|
187
|
-
};
|
|
188
|
-
/**
|
|
189
|
-
* TUI - Main class for managing terminal UI with differential rendering
|
|
190
|
-
*/
|
|
191
|
-
export declare class TUI extends Container {
|
|
192
|
-
#private;
|
|
193
|
-
terminal: Terminal;
|
|
194
|
-
/** Global callback for debug key (Shift+Ctrl+D). Called before input is forwarded to focused component. */
|
|
195
|
-
onDebug?: () => void;
|
|
196
|
-
static resetRenderCountersForTest(): void;
|
|
197
|
-
static getRenderCountersForTest(): TuiRenderCounterSnapshot;
|
|
198
|
-
overlayStack: {
|
|
199
|
-
component: Component;
|
|
200
|
-
options?: OverlayOptions;
|
|
201
|
-
preFocus: Component | null;
|
|
202
|
-
hidden: boolean;
|
|
203
|
-
}[];
|
|
204
|
-
constructor(terminal: Terminal, showHardwareCursor?: boolean);
|
|
205
|
-
dispose(): void;
|
|
206
|
-
get fullRedraws(): number;
|
|
207
|
-
getShowHardwareCursor(): boolean;
|
|
208
|
-
setShowHardwareCursor(enabled: boolean): void;
|
|
209
|
-
getClearOnShrink(): boolean;
|
|
210
|
-
/**
|
|
211
|
-
* Set whether to trigger full re-render when content shrinks.
|
|
212
|
-
* When true (default), empty rows are cleared when content shrinks.
|
|
213
|
-
* When false, empty rows remain (reduces redraws on slower terminals).
|
|
214
|
-
*/
|
|
215
|
-
setClearOnShrink(enabled: boolean): void;
|
|
216
|
-
setFocus(component: Component | null): void;
|
|
217
|
-
setBottomPinnedComponent(component: Component | null): void;
|
|
218
|
-
/** Register the direct child whose rows are eligible for semantic viewport anchoring. */
|
|
219
|
-
setViewportAnchorComponent(component: Component | null): void;
|
|
220
|
-
/** Clear manual viewport ownership before replacing the transcript identity namespace. */
|
|
221
|
-
resetViewportAnchorIntent(): void;
|
|
222
|
-
/** Allow one semantic-neighbor reconciliation after a definitive same-transcript rebuild. */
|
|
223
|
-
prepareViewportAnchorForTranscriptRebuild(): void;
|
|
224
|
-
scrollViewportPages(direction: -1 | 1): boolean;
|
|
225
|
-
followLiveViewport(): boolean;
|
|
226
|
-
/**
|
|
227
|
-
* Show an overlay component with configurable positioning and sizing.
|
|
228
|
-
* Returns a handle to control the overlay's visibility.
|
|
229
|
-
*/
|
|
230
|
-
showOverlay(component: Component, options?: OverlayOptions): OverlayHandle;
|
|
231
|
-
/** Hide the topmost overlay and restore previous focus. */
|
|
232
|
-
hideOverlay(): void;
|
|
233
|
-
/** Check if there are any visible overlays */
|
|
234
|
-
hasOverlay(): boolean;
|
|
235
|
-
invalidate(): void;
|
|
236
|
-
start(): void;
|
|
237
|
-
get terminalAvailable(): boolean;
|
|
238
|
-
addInputListener(listener: InputListener): () => void;
|
|
239
|
-
removeInputListener(listener: InputListener): void;
|
|
240
|
-
stop(): void;
|
|
241
|
-
/**
|
|
242
|
-
* Viewport-repaint-aware resize render request.
|
|
243
|
-
*
|
|
244
|
-
* A forced full redraw (`requestRender(true)`) resets `#previousWidth`/`#previousHeight`
|
|
245
|
-
* to -1, which makes `#doRender` treat the frame as a width change and fall into the
|
|
246
|
-
* `fullRender` path. In terminal multiplexers that path skips the scrollback-clearing
|
|
247
|
-
* `3J` escape (users navigate scrollback history), so replaying every transcript line
|
|
248
|
-
* piles it back on top of scrollback — the "top of screen scrolls down to the prompt at
|
|
249
|
-
* high speed" resize storm. Windows Terminal/ConPTY can also visibly jump to
|
|
250
|
-
* the transcript top during streaming redraws, so viewport-repaint sessions
|
|
251
|
-
* keep force off and let `#doRender` repaint only the live viewport. Set
|
|
252
|
-
* `PI_TUI_LEGACY_MULTIPLEXER_FULL_RENDER=1` to restore the legacy tmux redraw.
|
|
253
|
-
*/
|
|
254
|
-
requestResizeRender(): void;
|
|
255
|
-
requestRender(force?: boolean, source?: string): void;
|
|
256
|
-
getLineRenderCacheStats(): {
|
|
257
|
-
normalizationSize: number;
|
|
258
|
-
truncationSize: number;
|
|
259
|
-
normalizationLimit: number;
|
|
260
|
-
truncationLimit: number;
|
|
261
|
-
};
|
|
262
|
-
/**
|
|
263
|
-
* Register an emitter whose escape payload is appended to every render
|
|
264
|
-
* write (inside its own synchronized-output block, cursor saved/restored).
|
|
265
|
-
* Used for absolute-positioned overlays such as pixel-image pets that live
|
|
266
|
-
* outside the line-based component model. Return null to emit nothing.
|
|
267
|
-
*/
|
|
268
|
-
setPostRenderEmitter(emitter: (() => string | null) | undefined): void;
|
|
269
|
-
}
|
package/dist/types/utils.d.ts
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { Ellipsis, type ExtractSegmentsResult, type SliceResult } from "@sayknow-cli/natives";
|
|
2
|
-
export { Ellipsis } from "@sayknow-cli/natives";
|
|
3
|
-
export { getDefaultTabWidth, getIndentation } from "@sayknow-cli/utils";
|
|
4
|
-
/** Test-only performance counters for advisory baseline tests. */
|
|
5
|
-
export declare const __textHelperPerfCounters: {
|
|
6
|
-
truncateToWidthCalls: number;
|
|
7
|
-
wrapTextWithAnsiCalls: number;
|
|
8
|
-
truncateLinesToWidthCalls: number;
|
|
9
|
-
visibleWidthsCalls: number;
|
|
10
|
-
reset(): void;
|
|
11
|
-
};
|
|
12
|
-
export declare function invalidateTabWidthCache(): void;
|
|
13
|
-
export declare function isPrintableAscii(text: string): boolean;
|
|
14
|
-
export declare function sliceWithWidth(line: string, startCol: number, length: number, strict?: boolean | null): SliceResult;
|
|
15
|
-
export declare function truncateToWidth(text: string, maxWidth: number, ellipsisKind?: Ellipsis | null, pad?: boolean | null): string;
|
|
16
|
-
export declare function truncateLinesToWidth(lines: readonly string[], maxWidth: number, ellipsisKind?: Ellipsis | null, pad?: boolean | null): string[];
|
|
17
|
-
export declare function wrapTextWithAnsi(text: string, width: number): string[];
|
|
18
|
-
export declare function extractSegments(line: string, beforeEnd: number, afterStart: number, afterLen: number, strictAfter: boolean): ExtractSegmentsResult;
|
|
19
|
-
/**
|
|
20
|
-
* Tab width in columns for `file`, using `process.cwd()` as the project root for relative paths.
|
|
21
|
-
*/
|
|
22
|
-
export declare function getIndentationNoescape(file?: string): number;
|
|
23
|
-
export declare function replaceTabs(text: string, file?: string): string;
|
|
24
|
-
/**
|
|
25
|
-
* Returns a string of n spaces. Uses a pre-allocated buffer for efficiency.
|
|
26
|
-
*/
|
|
27
|
-
export declare function padding(n: number): string;
|
|
28
|
-
/**
|
|
29
|
-
* Get the shared grapheme segmenter instance.
|
|
30
|
-
*/
|
|
31
|
-
export declare function getSegmenter(): Intl.Segmenter;
|
|
32
|
-
export interface ViewportAnchorSpan {
|
|
33
|
-
graphemeStart: number;
|
|
34
|
-
graphemeEnd: number;
|
|
35
|
-
cellStart: number;
|
|
36
|
-
cellEnd: number;
|
|
37
|
-
}
|
|
38
|
-
export interface ViewportAnchorAnnotation {
|
|
39
|
-
text: string;
|
|
40
|
-
nextGrapheme: number;
|
|
41
|
-
nextCell: number;
|
|
42
|
-
token: string;
|
|
43
|
-
}
|
|
44
|
-
export declare const VIEWPORT_ANCHOR_PREFIX = "\u001B_ASKC_ANCHOR:";
|
|
45
|
-
/**
|
|
46
|
-
* Tag every visible grapheme with an APC marker that survives ANSI-aware
|
|
47
|
-
* wrapping. The marker contains source grapheme and monotonic cell offsets.
|
|
48
|
-
*/
|
|
49
|
-
export declare function annotateViewportAnchorGraphemes(text: string, startGrapheme?: number, startCell?: number, token?: `${string}-${string}-${string}-${string}-${string}`): ViewportAnchorAnnotation;
|
|
50
|
-
/** Remove viewport anchor markers and return the exact marked span for each row. */
|
|
51
|
-
export declare function extractViewportAnchorRows(lines: readonly string[], token: string): {
|
|
52
|
-
lines: string[];
|
|
53
|
-
spans: Array<ViewportAnchorSpan | null>;
|
|
54
|
-
};
|
|
55
|
-
export declare function visibleWidthRaw(str: string): number;
|
|
56
|
-
/**
|
|
57
|
-
* Calculate the visible width of a string in terminal columns.
|
|
58
|
-
*/
|
|
59
|
-
export declare function visibleWidth(str: string): number;
|
|
60
|
-
export declare function visibleWidthsNative(lines: readonly string[]): number[];
|
|
61
|
-
export declare function visibleWidths(lines: readonly string[]): number[];
|
|
62
|
-
/**
|
|
63
|
-
* Normalize text for terminal output without changing logical editor content.
|
|
64
|
-
* Some terminals render canonically decomposed Hangul jamo or precomposed
|
|
65
|
-
* Thai/Lao AM vowels inconsistently during differential repaint. Emit a stable
|
|
66
|
-
* terminal form while keeping the component/source strings unchanged.
|
|
67
|
-
*/
|
|
68
|
-
export declare function normalizeTerminalOutput(str: string): string;
|
|
69
|
-
/**
|
|
70
|
-
* Check if a character is whitespace.
|
|
71
|
-
*/
|
|
72
|
-
export declare function isWhitespaceChar(char: string): boolean;
|
|
73
|
-
/**
|
|
74
|
-
* Check if a character is punctuation.
|
|
75
|
-
*/
|
|
76
|
-
export declare function isPunctuationChar(char: string): boolean;
|
|
77
|
-
export type WordNavKind = "whitespace" | "delimiter" | "cjk" | "word" | "other";
|
|
78
|
-
/**
|
|
79
|
-
* Coarse Unicode-aware character classification for word navigation (Option/Alt + Left/Right).
|
|
80
|
-
* This intentionally avoids language-specific word segmentation for predictability across scripts.
|
|
81
|
-
*/
|
|
82
|
-
export declare function getWordNavKind(grapheme: string): WordNavKind;
|
|
83
|
-
export declare function isWordNavJoiner(grapheme: string): boolean;
|
|
84
|
-
/**
|
|
85
|
-
* Move the cursor one "word" to the left using Unicode-aware coarse navigation.
|
|
86
|
-
*
|
|
87
|
-
* Returns a new cursor index in the range [0, text.length].
|
|
88
|
-
*/
|
|
89
|
-
export declare function moveWordLeft(text: string, cursor: number): number;
|
|
90
|
-
/**
|
|
91
|
-
* Move the cursor one "word" to the right using Unicode-aware coarse navigation.
|
|
92
|
-
*
|
|
93
|
-
* Returns a new cursor index in the range [0, text.length].
|
|
94
|
-
*/
|
|
95
|
-
export declare function moveWordRight(text: string, cursor: number): number;
|
|
96
|
-
/**
|
|
97
|
-
* Apply background color to a line, padding to full width.
|
|
98
|
-
*
|
|
99
|
-
* @param line - Line of text (may contain ANSI codes)
|
|
100
|
-
* @param width - Total width to pad to
|
|
101
|
-
* @param bgFn - Background color function
|
|
102
|
-
* @returns Line with background applied and padded to width
|
|
103
|
-
*/
|
|
104
|
-
export declare function applyBackgroundToLine(line: string, width: number, bgFn: (text: string) => string): string;
|
|
105
|
-
/**
|
|
106
|
-
* Extract a range of visible columns from a line. Handles ANSI codes and wide chars.
|
|
107
|
-
*
|
|
108
|
-
* @param strict - If true, exclude wide chars at boundary that would extend past the range
|
|
109
|
-
*/
|
|
110
|
-
export declare function sliceByColumn(line: string, startCol: number, length: number, strict?: boolean): string;
|