@visulima/ansi 3.0.3 → 3.0.5
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/CHANGELOG.md +30 -0
- package/LICENSE.md +3 -0
- package/dist/alternative-screen.d.ts +74 -6
- package/dist/clear.d.ts +77 -6
- package/dist/constants.d.ts +20 -0
- package/dist/cursor.d.ts +429 -48
- package/dist/erase.d.ts +197 -14
- package/dist/helpers.d.ts +14 -0
- package/dist/hyperlink.d.ts +26 -2
- package/dist/image.d.ts +69 -7
- package/dist/index.d.ts +36 -30
- package/dist/iterm2/iterm2-properties.d.ts +135 -0
- package/dist/iterm2/iterm2-sequences.d.ts +96 -0
- package/dist/iterm2.d.ts +58 -43
- package/dist/mode.d.ts +717 -174
- package/dist/mouse.d.ts +203 -21
- package/dist/passthrough.d.ts +77 -6
- package/dist/progress.d.ts +41 -0
- package/dist/reset.d.ts +26 -4
- package/dist/screen.d.ts +234 -11
- package/dist/scroll.d.ts +67 -6
- package/dist/status.d.ts +521 -48
- package/dist/strip.d.ts +22 -2
- package/dist/termcap.d.ts +38 -5
- package/dist/title.d.ts +185 -10
- package/dist/window-ops.d.ts +396 -24
- package/dist/xterm.d.ts +94 -12
- package/package.json +1 -4
package/dist/erase.d.ts
CHANGED
|
@@ -1,23 +1,206 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Defines the modes for erasing parts of the display using the ED (Erase in Display) sequence.
|
|
3
|
+
* The ED sequence is `CSI Ps J`, where `Ps` is one of these mode values.
|
|
4
|
+
* @see {@link eraseDisplay} for the function that generates ED sequences.
|
|
5
|
+
* @see {@link https://vt100.net/docs/vt510-rm/ED.html} VT510 Erase in Display (ED) documentation.
|
|
6
|
+
* @enum {number}
|
|
7
|
+
*/
|
|
8
|
+
export declare enum EraseDisplayMode {
|
|
9
|
+
/**
|
|
10
|
+
* Clears the entire screen. The cursor position usually does not change, but this can be
|
|
11
|
+
* terminal-dependent. Some terminals might move the cursor to the home position (top-left).
|
|
12
|
+
* This corresponds to `Ps=2` in `CSI Ps J`.
|
|
13
|
+
* Sequence: `CSI 2J`.
|
|
14
|
+
*/
|
|
2
15
|
EntireScreen = 2,
|
|
16
|
+
/**
|
|
17
|
+
* Clears the entire screen and, on supported terminals (like XTerm and derivatives),
|
|
18
|
+
* also deletes all lines saved in the scrollback buffer.
|
|
19
|
+
* This corresponds to `Ps=3` in `CSI Ps J` (an XTerm extension, widely adopted).
|
|
20
|
+
* Sequence: `CSI 3J`.
|
|
21
|
+
* @remarks This mode is particularly useful for a more complete "reset" of the terminal view.
|
|
22
|
+
*/
|
|
3
23
|
EntireScreenAndScrollback = 3,
|
|
24
|
+
/**
|
|
25
|
+
* Clears from the beginning of the screen to the current cursor position (inclusive).
|
|
26
|
+
* This corresponds to `Ps=1` in `CSI Ps J`.
|
|
27
|
+
* Sequence: `CSI 1J`.
|
|
28
|
+
*/
|
|
4
29
|
ToBeginning = 1,
|
|
30
|
+
/**
|
|
31
|
+
* Clears from the current cursor position to the end of the screen (inclusive).
|
|
32
|
+
* If the cursor is at the top-left, this clears the entire screen.
|
|
33
|
+
* This corresponds to `Ps=0` (or `Ps` omitted) in `CSI Ps J`.
|
|
34
|
+
* Sequence: `CSI J` or `CSI 0J`.
|
|
35
|
+
*/
|
|
5
36
|
ToEnd = 0
|
|
6
37
|
}
|
|
7
|
-
|
|
8
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Generates an ANSI escape sequence to erase parts of the display (ED - Erase in Display).
|
|
40
|
+
* The specific sequence is `CSI <mode>J`, where `<mode>` is a parameter from {@link EraseDisplayMode}.
|
|
41
|
+
*
|
|
42
|
+
* - If `mode` is `EraseDisplayMode.ToEnd` (or `0`), the sequence can be shortened to `CSI J`.
|
|
43
|
+
* - The function validates the input `mode`. If an invalid number is provided, it defaults to `EraseDisplayMode.ToEnd`.
|
|
44
|
+
* @param mode The erase mode, specified as a value from `EraseDisplayMode` or its corresponding number (0, 1, 2, 3).
|
|
45
|
+
* @returns The ANSI escape sequence string for erasing in display.
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* import { eraseDisplay, EraseDisplayMode } from '@visulima/ansi/erase';
|
|
49
|
+
*
|
|
50
|
+
* // Erase from cursor to end of screen
|
|
51
|
+
* process.stdout.write(eraseDisplay(EraseDisplayMode.ToEnd)); // or eraseDisplay(0)
|
|
52
|
+
*
|
|
53
|
+
* // Erase entire screen
|
|
54
|
+
* process.stdout.write(eraseDisplay(EraseDisplayMode.EntireScreen)); // or eraseDisplay(2)
|
|
55
|
+
*
|
|
56
|
+
* // Erase entire screen and scrollback buffer
|
|
57
|
+
* process.stdout.write(eraseDisplay(EraseDisplayMode.EntireScreenAndScrollback)); // or eraseDisplay(3)
|
|
58
|
+
* ```
|
|
59
|
+
* @see {@link EraseDisplayMode}
|
|
60
|
+
* @see {@link https://vt100.net/docs/vt510-rm/ED.html} VT510 Erase in Display (ED) documentation.
|
|
61
|
+
*/
|
|
62
|
+
export declare const eraseDisplay: (mode: EraseDisplayMode | 0 | 1 | 2 | 3) => string;
|
|
63
|
+
/**
|
|
64
|
+
* Defines the modes for erasing parts of the current line using the EL (Erase in Line) sequence.
|
|
65
|
+
* The EL sequence is `CSI Ps K`, where `Ps` is one of these mode values.
|
|
66
|
+
* The cursor position is NOT affected by EL sequences.
|
|
67
|
+
* @see {@link eraseInLine} for the function that generates EL sequences.
|
|
68
|
+
* @see {@link https://vt100.net/docs/vt510-rm/EL.html} VT510 Erase in Line (EL) documentation.
|
|
69
|
+
* @enum {number}
|
|
70
|
+
*/
|
|
71
|
+
export declare enum EraseLineMode {
|
|
72
|
+
/**
|
|
73
|
+
* Clears the entire current line.
|
|
74
|
+
* This corresponds to `Ps=2` in `CSI Ps K`.
|
|
75
|
+
* Sequence: `CSI 2K`.
|
|
76
|
+
*/
|
|
9
77
|
EntireLine = 2,
|
|
78
|
+
/**
|
|
79
|
+
* Clears from the beginning of the line to the current cursor position (inclusive).
|
|
80
|
+
* This corresponds to `Ps=1` in `CSI Ps K`.
|
|
81
|
+
* Sequence: `CSI 1K`.
|
|
82
|
+
*/
|
|
10
83
|
ToBeginning = 1,
|
|
84
|
+
/**
|
|
85
|
+
* Clears from the current cursor position to the end of the line (inclusive).
|
|
86
|
+
* This corresponds to `Ps=0` (or `Ps` omitted) in `CSI Ps K`.
|
|
87
|
+
* Sequence: `CSI K` or `CSI 0K`.
|
|
88
|
+
*/
|
|
11
89
|
ToEnd = 0
|
|
12
90
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
91
|
+
/**
|
|
92
|
+
* Generates an ANSI escape sequence to erase parts of the current line (EL - Erase in Line).
|
|
93
|
+
* The specific sequence is `CSI <mode>K`, where `<mode>` is a parameter from {@link EraseLineMode}.
|
|
94
|
+
* The cursor position is NOT changed by this sequence.
|
|
95
|
+
*
|
|
96
|
+
* - If `mode` is `EraseLineMode.ToEnd` (or `0`), the sequence can be shortened to `CSI K`.
|
|
97
|
+
* - The function validates the input `mode`. If an invalid number is provided, it defaults to `EraseLineMode.ToEnd`.
|
|
98
|
+
* @param mode The erase mode, specified as a value from `EraseLineMode` or its corresponding number (0, 1, 2).
|
|
99
|
+
* @returns The ANSI escape sequence string for erasing in line.
|
|
100
|
+
* @example
|
|
101
|
+
* ```typescript
|
|
102
|
+
* import { eraseInLine, EraseLineMode } from '@visulima/ansi/erase';
|
|
103
|
+
*
|
|
104
|
+
* // Erase from cursor to end of line
|
|
105
|
+
* process.stdout.write(eraseInLine(EraseLineMode.ToEnd)); // or eraseInLine(0)
|
|
106
|
+
*
|
|
107
|
+
* // Erase entire current line
|
|
108
|
+
* process.stdout.write(eraseInLine(EraseLineMode.EntireLine)); // or eraseInLine(2)
|
|
109
|
+
* ```
|
|
110
|
+
* @see {@link EraseLineMode}
|
|
111
|
+
* @see {@link https://vt100.net/docs/vt510-rm/EL.html} VT510 Erase in Line (EL) documentation.
|
|
112
|
+
*/
|
|
113
|
+
export declare const eraseInLine: (mode: EraseLineMode | 0 | 1 | 2) => string;
|
|
114
|
+
/**
|
|
115
|
+
* Erases the screen from the current cursor position down to the bottom of the screen (inclusive).
|
|
116
|
+
* This is a convenience constant for `eraseDisplay(EraseDisplayMode.ToEnd)`.
|
|
117
|
+
* Sequence: `CSI J` (or `CSI 0J`).
|
|
118
|
+
* @returns The ANSI escape sequence `CSI J`.
|
|
119
|
+
* @see {@link eraseDisplay}
|
|
120
|
+
* @see {@link EraseDisplayMode.ToEnd}
|
|
121
|
+
*/
|
|
122
|
+
export declare const eraseDown: string;
|
|
123
|
+
/**
|
|
124
|
+
* Erases the entire current line. The cursor position does not change.
|
|
125
|
+
* This is a convenience constant for `eraseInLine(EraseLineMode.EntireLine)`.
|
|
126
|
+
* Sequence: `CSI 2K`.
|
|
127
|
+
* @returns The ANSI escape sequence `CSI 2K`.
|
|
128
|
+
* @see {@link eraseInLine}
|
|
129
|
+
* @see {@link EraseLineMode.EntireLine}
|
|
130
|
+
*/
|
|
131
|
+
export declare const eraseLine: string;
|
|
132
|
+
/**
|
|
133
|
+
* Erases from the current cursor position to the end of the current line (inclusive).
|
|
134
|
+
* The cursor position does not change.
|
|
135
|
+
* This is a convenience constant for `eraseInLine(EraseLineMode.ToEnd)`.
|
|
136
|
+
* Sequence: `CSI K` (or `CSI 0K`).
|
|
137
|
+
* @returns The ANSI escape sequence `CSI K`.
|
|
138
|
+
* @see {@link eraseInLine}
|
|
139
|
+
* @see {@link EraseLineMode.ToEnd}
|
|
140
|
+
*/
|
|
141
|
+
export declare const eraseLineEnd: string;
|
|
142
|
+
/**
|
|
143
|
+
* Erases from the current cursor position to the beginning of the current line (inclusive).
|
|
144
|
+
* The cursor position does not change.
|
|
145
|
+
* This is a convenience constant for `eraseInLine(EraseLineMode.ToBeginning)`.
|
|
146
|
+
* Sequence: `CSI 1K`.
|
|
147
|
+
* @returns The ANSI escape sequence `CSI 1K`.
|
|
148
|
+
* @see {@link eraseInLine}
|
|
149
|
+
* @see {@link EraseLineMode.ToBeginning}
|
|
150
|
+
*/
|
|
151
|
+
export declare const eraseLineStart: string;
|
|
152
|
+
/**
|
|
153
|
+
* Erases a specified number of lines, starting from the current line and moving upwards,
|
|
154
|
+
* then moves the cursor to the beginning of the topmost erased line (which becomes the new current line).
|
|
155
|
+
*
|
|
156
|
+
* This is a custom helper function, not a single standard ANSI/VT sequence. It combines
|
|
157
|
+
* multiple sequences: {@link eraseLine} to clear each line, {@link cursorUp} to move to the line above,
|
|
158
|
+
* and finally {@link cursorToColumn1} to position the cursor at the start of the resulting current line.
|
|
159
|
+
* @param count The total number of lines to erase. This includes the current line and `count-1` lines above it.
|
|
160
|
+
* If `count` is 0 or negative, an empty string is returned (no operation).
|
|
161
|
+
* @returns A string of concatenated ANSI escape sequences to perform the operation.
|
|
162
|
+
* @example
|
|
163
|
+
* ```typescript
|
|
164
|
+
* import { eraseLines } from '@visulima/ansi/erase';
|
|
165
|
+
*
|
|
166
|
+
* // To erase the current line and the 2 lines above it (total 3 lines):
|
|
167
|
+
* process.stdout.write(eraseLines(3));
|
|
168
|
+
* // Conceptual sequence of operations:
|
|
169
|
+
* // 1. Erase current line
|
|
170
|
+
* // 2. Cursor up
|
|
171
|
+
* // 3. Erase current line (which was the line above the original)
|
|
172
|
+
* // 4. Cursor up
|
|
173
|
+
* // 5. Erase current line (which was two lines above the original)
|
|
174
|
+
* // 6. Cursor to column 1 (on this topmost erased line)
|
|
175
|
+
* ```
|
|
176
|
+
*/
|
|
177
|
+
export declare const eraseLines: (count: number) => string;
|
|
178
|
+
/**
|
|
179
|
+
* Erases the entire screen. The cursor position usually does not change, though this can be terminal-dependent.
|
|
180
|
+
* This is a convenience constant for `eraseDisplay(EraseDisplayMode.EntireScreen)`.
|
|
181
|
+
* Sequence: `CSI 2J`.
|
|
182
|
+
* @returns The ANSI escape sequence `CSI 2J`.
|
|
183
|
+
* @see {@link eraseDisplay}
|
|
184
|
+
* @see {@link EraseDisplayMode.EntireScreen}
|
|
185
|
+
*/
|
|
186
|
+
export declare const eraseScreen: string;
|
|
187
|
+
/**
|
|
188
|
+
* Erases the screen from the current cursor position up to the top of the screen (inclusive).
|
|
189
|
+
* This is a convenience constant for `eraseDisplay(EraseDisplayMode.ToBeginning)`.
|
|
190
|
+
* Sequence: `CSI 1J`.
|
|
191
|
+
* @returns The ANSI escape sequence `CSI 1J`.
|
|
192
|
+
* @see {@link eraseDisplay}
|
|
193
|
+
* @see {@link EraseDisplayMode.ToBeginning}
|
|
194
|
+
*/
|
|
195
|
+
export declare const eraseUp: string;
|
|
196
|
+
/**
|
|
197
|
+
* Erases the entire screen and, on supported terminals (like XTerm and derivatives),
|
|
198
|
+
* also deletes all lines saved in the scrollback buffer.
|
|
199
|
+
* This is a convenience constant for `eraseDisplay(EraseDisplayMode.EntireScreenAndScrollback)`.
|
|
200
|
+
* Sequence: `CSI 3J` (an XTerm extension, widely adopted).
|
|
201
|
+
* @returns The ANSI escape sequence `CSI 3J`.
|
|
202
|
+
* @remarks This mode is particularly useful for a more complete "reset" of the terminal view.
|
|
203
|
+
* @see {@link eraseDisplay}
|
|
204
|
+
* @see {@link EraseDisplayMode.EntireScreenAndScrollback}
|
|
205
|
+
*/
|
|
206
|
+
export declare const eraseScreenAndScrollback: string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if the current environment is a browser-like environment.
|
|
3
|
+
* It specifically checks for the presence of `globalThis.window.document`.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Indicates whether the code is running inside Apple's Terminal.app.
|
|
7
|
+
* This is true if not in a browser and the `TERM_PROGRAM` environment variable is "Apple_Terminal".
|
|
8
|
+
*/
|
|
9
|
+
export declare const isTerminalApp: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Indicates whether the current platform is Windows.
|
|
12
|
+
* This is true if not in a browser and `process.platform` is "win32".
|
|
13
|
+
*/
|
|
14
|
+
export declare const isWindows: boolean;
|
package/dist/hyperlink.d.ts
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a clickable hyperlink in the terminal.
|
|
3
|
+
*
|
|
4
|
+
* This function constructs an ANSI escape sequence that, when printed to a compatible terminal,
|
|
5
|
+
* renders as a clickable link. The link's visible text and its target URL are specified
|
|
6
|
+
* by the `text` and `url` parameters, respectively.
|
|
7
|
+
*
|
|
8
|
+
* For information on terminal support for hyperlinks, see this
|
|
9
|
+
* [Gist by Egmont Kob](https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda).
|
|
10
|
+
* To programmatically check for hyperlink support in the current environment,
|
|
11
|
+
* consider using a library like [`supports-hyperlinks`](https://github.com/jamestalmage/supports-hyperlinks).
|
|
12
|
+
* @param text The visible text of the link.
|
|
13
|
+
* @param url The URL the link should point to.
|
|
14
|
+
* @returns A string representing the ANSI escape sequence for the hyperlink.
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* import { hyperlink } from "@visulima/ansi/hyperlink"; // Adjust import path as needed
|
|
18
|
+
*
|
|
19
|
+
* const aLink = hyperlink("Visulima", "https://www.visulima.com");
|
|
20
|
+
* console.log(`Visit ${aLink} for more information.`);
|
|
21
|
+
* // In a supported terminal, this will output:
|
|
22
|
+
* // Visit Visulima for more information. (where "Visulima" is a clickable link)
|
|
23
|
+
* ```
|
|
24
|
+
* @see {@link https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda} for supported terminals.
|
|
25
|
+
*/
|
|
1
26
|
declare const hyperlink: (text: string, url: string) => string;
|
|
2
|
-
|
|
3
|
-
export { hyperlink as default };
|
|
27
|
+
export default hyperlink;
|
package/dist/image.d.ts
CHANGED
|
@@ -1,11 +1,73 @@
|
|
|
1
|
-
import { LiteralUnion } from
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import type { LiteralUnion } from "type-fest";
|
|
2
|
+
/**
|
|
3
|
+
* Options for controlling the display of an inline image in iTerm2.
|
|
4
|
+
*/
|
|
5
|
+
export interface ImageOptions {
|
|
6
|
+
/**
|
|
7
|
+
* The display height of the image. It can be specified as:
|
|
8
|
+
* - A number: Interpreted as the number of character cells (e.g., `10`).
|
|
9
|
+
* - A string with `px`: Interpreted as pixels (e.g., `"100px"`).
|
|
10
|
+
* - A string with `%`: Interpreted as a percentage of the terminal session's height (e.g., `"50%"`).
|
|
11
|
+
* - The string `"auto"`: The image's inherent height will be used, or the terminal will decide.
|
|
12
|
+
*/
|
|
4
13
|
readonly height?: LiteralUnion<"auto", number | string>;
|
|
14
|
+
/**
|
|
15
|
+
* Controls whether the image's aspect ratio is preserved when scaling.
|
|
16
|
+
* - If `true` (default), the aspect ratio is preserved.
|
|
17
|
+
* - If `false`, the image may be stretched to fit the specified width and height.
|
|
18
|
+
* Corresponds to the `preserveAspectRatio` argument in the iTerm2 sequence (`1` for true, `0` for false).
|
|
19
|
+
* @default true
|
|
20
|
+
*/
|
|
5
21
|
readonly preserveAspectRatio?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* The display width of the image. It can be specified as:
|
|
24
|
+
* - A number: Interpreted as the number of character cells (e.g., `20`).
|
|
25
|
+
* - A string with `px`: Interpreted as pixels (e.g., `"200px"`).
|
|
26
|
+
* - A string with `%`: Interpreted as a percentage of the terminal session's width (e.g., `"75%"`).
|
|
27
|
+
* - The string `"auto"`: The image's inherent width will be used, or the terminal will decide.
|
|
28
|
+
*/
|
|
6
29
|
readonly width?: LiteralUnion<"auto", number | string>;
|
|
7
30
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Generates an ANSI escape sequence for displaying an image inline, primarily for iTerm2.
|
|
33
|
+
*
|
|
34
|
+
* This function constructs a proprietary iTerm2 escape sequence (`OSC 1337 ; File = [arguments] : <base64_data> BEL`)
|
|
35
|
+
* that allows raw image data to be displayed directly in the terminal.
|
|
36
|
+
* @param data The raw image data as a `Uint8Array`. This data will be Base64 encoded.
|
|
37
|
+
* @param options Optional parameters to control how the image is displayed (e.g., width, height, aspect ratio).
|
|
38
|
+
* See {@link ImageOptions}.
|
|
39
|
+
* @returns A string containing the ANSI escape sequence for displaying the image in iTerm2.
|
|
40
|
+
* Returns an empty string if `data` is null or undefined, though TypeScript should prevent this.
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* import { image } from '@visulima/ansi/image'; // Adjust import path
|
|
44
|
+
* import { promises as fs } from 'fs';
|
|
45
|
+
*
|
|
46
|
+
* async function displayImage() {
|
|
47
|
+
* try {
|
|
48
|
+
* const imageData = await fs.readFile('path/to/your/image.png');
|
|
49
|
+
* const imageSequence = image(new Uint8Array(imageData), {
|
|
50
|
+
* width: 50, // 50 character cells wide
|
|
51
|
+
* height: "auto",
|
|
52
|
+
* preserveAspectRatio: true,
|
|
53
|
+
* });
|
|
54
|
+
* console.log(imageSequence);
|
|
55
|
+
* } catch (error) {
|
|
56
|
+
* console.error("Error reading or displaying image:", error);
|
|
57
|
+
* }
|
|
58
|
+
* }
|
|
59
|
+
*
|
|
60
|
+
* displayImage();
|
|
61
|
+
* ```
|
|
62
|
+
* @remarks
|
|
63
|
+
* - This sequence is specific to iTerm2 and may not work in other terminal emulators.
|
|
64
|
+
* - For Node.js environments, `Buffer.from(data).toString("base64")` is used for Base64 encoding.
|
|
65
|
+
* In browser environments, a polyfill or an alternative method for Base64 encoding `Uint8Array` would be necessary
|
|
66
|
+
* if `Buffer` is not available (e.g., `btoa(String.fromCharCode(...data))` after careful handling of binary data).
|
|
67
|
+
* - The `name` parameter (for filename) is not directly supported by this simplified helper but is part of the
|
|
68
|
+
* full iTerm2 inline image protocol. For more advanced features, consider using the more detailed iTerm2 sequence
|
|
69
|
+
* builders in `iterm2/` files.
|
|
70
|
+
* @see {@link https://iterm2.com/documentation-images.html} iTerm2 Inline Images Protocol.
|
|
71
|
+
* @see {@link ImageOptions}
|
|
72
|
+
*/
|
|
73
|
+
export declare const image: (data: Uint8Array, options?: ImageOptions) => string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,30 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
15
|
-
export { default as
|
|
16
|
-
export {
|
|
17
|
-
export {
|
|
18
|
-
export {
|
|
19
|
-
export {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
export {
|
|
1
|
+
/**
|
|
2
|
+
* Output a beeping sound.
|
|
3
|
+
*/
|
|
4
|
+
export declare const beep = "\u0007";
|
|
5
|
+
export { ALT_SCREEN_OFF, ALT_SCREEN_ON, alternativeScreenOff, alternativeScreenOn } from "./alternative-screen.d.ts";
|
|
6
|
+
export { clearLineAndHomeCursor, clearScreenAndHomeCursor, clearScreenFromTopLeft, resetTerminal } from "./clear.d.ts";
|
|
7
|
+
export type { CursorStyle } from "./cursor.d.ts";
|
|
8
|
+
export { CURSOR_BACKWARD_1, CURSOR_DOWN_1, CURSOR_FORWARD_1, CURSOR_UP_1, cursorBackward, cursorBackwardTab, cursorDown, cursorForward, cursorHide, cursorHorizontalAbsolute, cursorHorizontalForwardTab, cursorLeft, cursorMove, cursorNextLine, cursorPosition, cursorPreviousLine, cursorRestore, // Function
|
|
9
|
+
cursorSave, // Function
|
|
10
|
+
cursorShow, cursorTo, cursorToColumn1, cursorUp, cursorVerticalAbsolute, eraseCharacter, REQUEST_CURSOR_POSITION, REQUEST_EXTENDED_CURSOR_POSITION, RESTORE_CURSOR_DEC, // Constant for ESC 8
|
|
11
|
+
SAVE_CURSOR_DEC, // Constant for ESC 7
|
|
12
|
+
setCursorStyle, } from "./cursor.d.ts";
|
|
13
|
+
export type { EraseDisplayMode, EraseLineMode } from "./erase.d.ts";
|
|
14
|
+
export { eraseDisplay, eraseDown, eraseInLine, eraseLine, eraseLineEnd, eraseLines, eraseLineStart, eraseScreen, eraseScreenAndScrollback, eraseUp, } from "./erase.d.ts";
|
|
15
|
+
export { default as hyperlink } from "./hyperlink.d.ts";
|
|
16
|
+
export type { ImageOptions } from "./image.d.ts";
|
|
17
|
+
export { image } from "./image.d.ts";
|
|
18
|
+
export type { IITerm2Payload, ITerm2FileProperties } from "./iterm2.d.ts";
|
|
19
|
+
export { IT2_AUTO, it2Cells, it2Percent, it2Pixels, iTerm2, ITerm2File, ITerm2FileEnd, ITerm2FilePart, ITerm2MultipartFileStart } from "./iterm2.d.ts";
|
|
20
|
+
export type { AnsiMode, DecMode, Mode, ModeSetting } from "./mode.d.ts";
|
|
21
|
+
export { BDSM, BiDirectionalSupportMode, BracketedPasteMode, createAnsiMode, createDecMode, DECRPM, DECRQM, DisableModifiersMode, InBandResizeMode, InsertReplaceMode, IRM, isModeNotRecognized, isModePermanentlyReset, isModePermanentlySet, isModeReset, isModeSet, KAM, KeyboardActionMode, LightDarkMode, LineFeedNewLineMode, LNM, LocalEchoMode, OriginMode, reportMode, RequestBiDirectionalSupportMode, RequestInBandResizeMode, RequestInsertReplaceMode, RequestKeyboardActionMode, RequestLineFeedNewLineMode, RequestLocalEchoMode, requestMode, RequestSendReceiveMode, RequestUnicodeCoreMode, ResetBiDirectionalSupportMode, ResetInBandResizeMode, ResetInsertReplaceMode, ResetKeyboardActionMode, ResetLineFeedNewLineMode, ResetLocalEchoMode, resetMode, ResetSendReceiveMode, ResetUnicodeCoreMode, RM, SendFocusEventsMode, SendReceiveMode, SetBiDirectionalSupportMode, SetInBandResizeMode, SetInsertReplaceMode, SetKeyboardActionMode, SetLineFeedNewLineMode, SetLocalEchoMode, setMode, SetSendReceiveMode, SetUnicodeCoreMode, SGRMouseMode, SM, SRM, TextCursorEnableMode, UnicodeCoreMode, } from "./mode.d.ts";
|
|
22
|
+
export type { MouseButtonType, MouseModifiers } from "./mouse.d.ts";
|
|
23
|
+
export { disableAnyEventMouse, disableButtonEventMouse, disableFocusTracking, disableNormalMouse, disableSgrMouse, disableX10Mouse, enableAnyEventMouse, enableButtonEventMouse, enableFocusTracking, enableNormalMouse, enableSgrMouse, enableX10Mouse, encodeMouseButtonByte, MouseButton, mouseSgrSequence, mouseX10Sequence, } from "./mouse.d.ts";
|
|
24
|
+
export { SCREEN_MAX_LEN_DEFAULT, SCREEN_TYPICAL_LIMIT, screenPassthrough, tmuxPassthrough } from "./passthrough.d.ts";
|
|
25
|
+
export { resetProgressBar, setErrorProgressBar, setIndeterminateProgressBar, setProgressBar, setWarningProgressBar } from "./progress.d.ts";
|
|
26
|
+
export { RESET_INITIAL_STATE, RIS } from "./reset.d.ts";
|
|
27
|
+
export { clearTabStop, deleteCharacter, deleteLine, insertCharacter, insertLine, repeatPreviousCharacter, requestPresentationStateReport, setLeftRightMargins, setTopBottomMargins, } from "./screen.d.ts";
|
|
28
|
+
export { SCROLL_DOWN_1, SCROLL_UP_1, scrollDown, scrollUp } from "./scroll.d.ts";
|
|
29
|
+
export type { AnsiStatusReport, DecStatusReport, StatusReport } from "./status.d.ts";
|
|
30
|
+
export { CPR, createAnsiStatusReport, createDecStatusReport, cursorPositionReport, DA1, DA2, DA3, DECXCPR, deviceStatusReport, DSR, DSR_KeyboardLanguageDEC, DSR_PrinterStatusDEC, DSR_TerminalStatus, DSR_UDKStatusDEC, extendedCursorPositionReport, LightDarkReport, reportKeyboardLanguageDEC, reportPrimaryDeviceAttributes, reportPrinterNoPaperDEC, reportPrinterNotReadyDEC, reportPrinterReadyDEC, reportSecondaryDeviceAttributes, reportTerminalNotOK, reportTerminalOK, reportTertiaryDeviceAttributes, reportUDKLockedDEC, reportUDKUnlockedDEC, requestCursorPositionReport, requestExtendedCursorPositionReport, requestKeyboardLanguageDEC, RequestLightDarkReport, RequestNameVersion, requestPrimaryDeviceAttributes, requestPrimaryDeviceAttributesParam0, requestPrinterStatusDEC, requestSecondaryDeviceAttributes, requestSecondaryDeviceAttributesParam0, requestTerminalStatus, requestTertiaryDeviceAttributes, requestTertiaryDeviceAttributesParam0, requestUDKStatusDEC, XTVERSION, } from "./status.d.ts";
|
|
31
|
+
export { default as strip } from "./strip.d.ts";
|
|
32
|
+
export { requestTermcap, requestTerminfo, XTGETTCAP } from "./termcap.d.ts";
|
|
33
|
+
export { decsin, decswt, setIconName, setIconNameAndWindowTitle, setIconNameAndWindowTitleWithST, setIconNameWithST, setWindowTitle, setWindowTitleWithST, } from "./title.d.ts";
|
|
34
|
+
export type { XTermWindowOp } from "./window-ops.d.ts";
|
|
35
|
+
export { deiconifyWindow, iconifyWindow, lowerWindow, maximizeWindow, moveWindow, raiseWindow, refreshWindow, reportWindowPosition, reportWindowState, requestCellSizePixels, requestTextAreaSizeChars, requestTextAreaSizePixels, resizeTextAreaChars, resizeTextAreaPixels, restoreMaximizedWindow, setPageSizeLines, xtermWindowOp, XTWINOPS, } from "./window-ops.d.ts";
|
|
36
|
+
export { keyModifierOptions, queryKeyModifierOptions, queryModifyOtherKeys, resetKeyModifierOptions, resetModifyOtherKeys, setKeyModifierOptions, setModifyOtherKeys1, setModifyOtherKeys2, XTMODKEYS, XTQMODKEYS, } from "./xterm.d.ts";
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import type { LiteralUnion } from "type-fest";
|
|
2
|
+
/**
|
|
3
|
+
* Represents the special string value `'auto'` used for iTerm2 image or file dimensions.
|
|
4
|
+
* When `'auto'` is used for width or height, the terminal (iTerm2) determines the appropriate dimension
|
|
5
|
+
* based on the image's inherent size or other context.
|
|
6
|
+
* @example `width: IT2_AUTO`
|
|
7
|
+
*/
|
|
8
|
+
export declare const IT2_AUTO: string;
|
|
9
|
+
/**
|
|
10
|
+
* Formats a number as a string representing a dimension in character cells for iTerm2.
|
|
11
|
+
* iTerm2 interprets plain numbers for width/height as character cell counts.
|
|
12
|
+
* @param n The number of character cells.
|
|
13
|
+
* @returns A string representation of the number (e.g., `10` becomes `"10"`).
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const widthInCells = it2Cells(20); // "20"
|
|
17
|
+
* const sequence = `File=width=${widthInCells}`;
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare const it2Cells: (n: number) => string;
|
|
21
|
+
/**
|
|
22
|
+
* Formats a number as a string representing a dimension in pixels for iTerm2.
|
|
23
|
+
* Appends `px` to the number.
|
|
24
|
+
* @param n The number of pixels.
|
|
25
|
+
* @returns A string representing the dimension in pixels (e.g., `100` becomes `"100px"`).
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* const heightInPixels = it2Pixels(150);
|
|
29
|
+
* const sequence = `File=height=${heightInPixels}`;
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare const it2Pixels: (n: number) => string;
|
|
33
|
+
/**
|
|
34
|
+
* Formats a number as a string representing a dimension as a percentage for iTerm2.
|
|
35
|
+
* Appends `%` to the number.
|
|
36
|
+
* @param n The percentage value (e.g., `50` for 50%).
|
|
37
|
+
* @returns A string representing the dimension as a percentage (e.g., `50` becomes `"50%"`).
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* const widthAsPercentage = it2Percent(75);
|
|
41
|
+
* const sequence = `File=width=${widthAsPercentage}`;
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare const it2Percent: (n: number) => string;
|
|
45
|
+
/**
|
|
46
|
+
* Defines the interface for any iTerm2 OSC 1337 payload object.
|
|
47
|
+
*
|
|
48
|
+
* An OSC 1337 sequence has the general form: `OSC 1337 ; <payload_string> BEL`.
|
|
49
|
+
* Objects implementing this interface are responsible for generating that `<payload_string>`
|
|
50
|
+
* via their `toString()` method. This allows for a structured way to build various iTerm2 commands.
|
|
51
|
+
* @see {@link iTerm2} function which consumes objects of this type.
|
|
52
|
+
*/
|
|
53
|
+
export interface IITerm2Payload {
|
|
54
|
+
/**
|
|
55
|
+
* Converts the payload object into its specific string representation required for an iTerm2 OSC 1337 command.
|
|
56
|
+
* For example, for a file transfer, this might return `"File=name=...;size=...:content..."`.
|
|
57
|
+
* @returns The string payload part of the OSC 1337 sequence.
|
|
58
|
+
*/
|
|
59
|
+
toString: () => string;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Defines the properties for an iTerm2 file transfer or inline image display command (`File=...`).
|
|
63
|
+
* These correspond to the key-value pairs used within the `File=` argument of the OSC 1337 sequence.
|
|
64
|
+
* @see {@link https://iterm2.com/documentation-escape-codes.html} iTerm2 Escape Codes (search for `File=`)
|
|
65
|
+
* @see {@link https://iterm2.com/documentation-images.html} iTerm2 Inline Images Protocol
|
|
66
|
+
*/
|
|
67
|
+
export interface ITerm2FileProperties {
|
|
68
|
+
/**
|
|
69
|
+
* The Base64 encoded content of the file or image.
|
|
70
|
+
* This is typically used when `inline=1` is set for images, or for transferring small files directly
|
|
71
|
+
* within the escape sequence. For larger files, multipart transfer is recommended.
|
|
72
|
+
* @remarks The `ITerm2File` class can handle the Base64 encoding of `Uint8Array` data automatically.
|
|
73
|
+
*/
|
|
74
|
+
content?: string;
|
|
75
|
+
/**
|
|
76
|
+
* If `true`, instructs the terminal not to move the cursor after displaying an inline image.
|
|
77
|
+
* Corresponds to `doNotMoveCursor=1` in the sequence.
|
|
78
|
+
* This is a WezTerm extension, also supported by iTerm2 beta/nightly builds as of some versions.
|
|
79
|
+
* @default false (cursor behavior is default terminal behavior)
|
|
80
|
+
*/
|
|
81
|
+
doNotMoveCursor?: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* The display height of the image or file placeholder.
|
|
84
|
+
* Can be:
|
|
85
|
+
* - A number (interpreted as character cells, e.g., `10`).
|
|
86
|
+
* - A string with units: `"Npx"` (N pixels), `"N%"` (N percent of session height).
|
|
87
|
+
* - The string {@link IT2_AUTO} (`"auto"`) for automatic sizing.
|
|
88
|
+
* Use helper functions like {@link it2Cells}, {@link it2Pixels}, {@link it2Percent} for formatting if needed.
|
|
89
|
+
* @example `10`, `"100px"`, `"50%"`, `IT2_AUTO`
|
|
90
|
+
*/
|
|
91
|
+
height?: LiteralUnion<typeof IT2_AUTO, number | string>;
|
|
92
|
+
/**
|
|
93
|
+
* Controls aspect ratio preservation for inline images.
|
|
94
|
+
* - If `true` (or omitted), the aspect ratio *is* preserved (`preserveAspectRatio=1`, which is the default iTerm2 behavior if the param is absent).
|
|
95
|
+
* - If `false`, the aspect ratio is *not* preserved, and the image may stretch (`preserveAspectRatio=0`).
|
|
96
|
+
* @remarks Note the slight inversion: this property `ignoreAspectRatio: true` means `preserveAspectRatio=0` in the sequence.
|
|
97
|
+
* The default iTerm2 behavior *is* to preserve aspect ratio if the `preserveAspectRatio` parameter is not given.
|
|
98
|
+
* So, to *not* preserve, you set this to true to *add* `preserveAspectRatio=0`.
|
|
99
|
+
* If you want to preserve (default), you can omit this or set it to `false`.
|
|
100
|
+
* @default false (meaning aspect ratio is preserved by iTerm2 default unless overridden)
|
|
101
|
+
*/
|
|
102
|
+
ignoreAspectRatio?: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* If `true`, the file (typically an image) should be displayed inline in the terminal.
|
|
105
|
+
* Corresponds to `inline=1` in the sequence.
|
|
106
|
+
* If `false` or omitted, iTerm2 might prompt for download or handle based on file type.
|
|
107
|
+
* @default false
|
|
108
|
+
*/
|
|
109
|
+
inline?: boolean;
|
|
110
|
+
/**
|
|
111
|
+
* The name of the file. This is displayed in UI elements (like a download prompt or image info)
|
|
112
|
+
* and used as the default filename if downloaded.
|
|
113
|
+
* The name **must be Base64 encoded** if it contains special characters (like `;`, `=`, or non-ASCII characters)
|
|
114
|
+
* to ensure correct parsing of the escape sequence by iTerm2.
|
|
115
|
+
* The `ITerm2File` and `ITerm2MultipartFileStart` classes generally expect the name to be pre-encoded if necessary.
|
|
116
|
+
* @example `"bXlmaWxlLnR4dA=="` (Base64 for "myfile.txt")
|
|
117
|
+
*/
|
|
118
|
+
name?: string;
|
|
119
|
+
/**
|
|
120
|
+
* The size of the file in bytes. This is used by iTerm2 for progress indication during downloads
|
|
121
|
+
* or to inform inline display mechanisms.
|
|
122
|
+
* JavaScript `number` type is generally sufficient for typical file sizes (up to `Number.MAX_SAFE_INTEGER`).
|
|
123
|
+
*/
|
|
124
|
+
size?: number;
|
|
125
|
+
/**
|
|
126
|
+
* The display width of the image or file placeholder.
|
|
127
|
+
* Can be:
|
|
128
|
+
* - A number (interpreted as character cells, e.g., `20`).
|
|
129
|
+
* - A string with units: `"Npx"` (N pixels), `"N%"` (N percent of session width).
|
|
130
|
+
* - The string {@link IT2_AUTO} (`"auto"`) for automatic sizing.
|
|
131
|
+
* Use helper functions like {@link it2Cells}, {@link it2Pixels}, {@link it2Percent} for formatting if needed.
|
|
132
|
+
* @example `20`, `"200px"`, `"75%"`, `IT2_AUTO`
|
|
133
|
+
*/
|
|
134
|
+
width?: LiteralUnion<typeof IT2_AUTO, number | string>;
|
|
135
|
+
}
|