@visulima/ansi 4.0.0-alpha.2 → 4.0.0-alpha.4

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.
Files changed (53) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/alternative-screen.d.ts +74 -0
  3. package/dist/alternative-screen.js +1 -0
  4. package/dist/clear.d.ts +77 -0
  5. package/dist/clear.js +1 -0
  6. package/dist/constants.d.ts +20 -0
  7. package/dist/cursor.d.ts +437 -0
  8. package/dist/cursor.js +1 -0
  9. package/dist/erase.d.ts +206 -0
  10. package/dist/erase.js +1 -0
  11. package/dist/helpers.d.ts +14 -0
  12. package/dist/hyperlink.d.ts +27 -0
  13. package/dist/hyperlink.js +1 -0
  14. package/dist/image.d.ts +73 -0
  15. package/dist/image.js +1 -0
  16. package/dist/index.d.ts +36 -0
  17. package/dist/index.js +1 -0
  18. package/dist/iterm2/iterm2-properties.d.ts +135 -0
  19. package/dist/iterm2/iterm2-sequences.d.ts +96 -0
  20. package/dist/iterm2.d.ts +58 -0
  21. package/dist/iterm2.js +1 -0
  22. package/dist/mode.d.ts +726 -0
  23. package/dist/mode.js +1 -0
  24. package/dist/mouse.d.ts +230 -0
  25. package/dist/mouse.js +1 -0
  26. package/dist/packem_shared/IT2_AUTO-BYrffRAq.js +1 -0
  27. package/dist/packem_shared/ITerm2File-C88DBJC-.js +1 -0
  28. package/dist/packem_shared/constants-D12jy2Zh.js +1 -0
  29. package/dist/packem_shared/cursor-nxpKt8Tn.js +1 -0
  30. package/dist/packem_shared/resetProgressBar-BtBbpWCM.js +1 -0
  31. package/dist/packem_shared/restoreCursor-CHy0jZuu.js +2 -0
  32. package/dist/passthrough.d.ts +77 -0
  33. package/dist/passthrough.js +1 -0
  34. package/dist/progress.d.ts +41 -0
  35. package/dist/reset.d.ts +26 -0
  36. package/dist/reset.js +1 -0
  37. package/dist/screen.d.ts +234 -0
  38. package/dist/screen.js +1 -0
  39. package/dist/scroll.d.ts +67 -0
  40. package/dist/scroll.js +1 -0
  41. package/dist/status.d.ts +524 -0
  42. package/dist/status.js +1 -0
  43. package/dist/strip.d.ts +23 -0
  44. package/dist/strip.js +1 -0
  45. package/dist/termcap.d.ts +38 -0
  46. package/dist/termcap.js +1 -0
  47. package/dist/title.d.ts +185 -0
  48. package/dist/title.js +1 -0
  49. package/dist/window-ops.d.ts +418 -0
  50. package/dist/window-ops.js +1 -0
  51. package/dist/xterm.d.ts +94 -0
  52. package/dist/xterm.js +1 -0
  53. package/package.json +2 -47
@@ -0,0 +1,206 @@
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
+ */
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
+ */
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
+ */
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
+ */
36
+ ToEnd = 0
37
+ }
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
+ */
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
+ */
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
+ */
89
+ ToEnd = 0
90
+ }
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;
package/dist/erase.js ADDED
@@ -0,0 +1 @@
1
+ var t=Object.defineProperty;var s=(e,n)=>t(e,"name",{value:n,configurable:!0});import{C as c}from"./packem_shared/constants-D12jy2Zh.js";import{u as l,t as E}from"./packem_shared/cursor-nxpKt8Tn.js";var S=Object.defineProperty,a=s((e,n)=>S(e,"name",{value:n,configurable:!0}),"o"),d=(e=>(e[e.EntireScreen=2]="EntireScreen",e[e.EntireScreenAndScrollback=3]="EntireScreenAndScrollback",e[e.ToBeginning=1]="ToBeginning",e[e.ToEnd=0]="ToEnd",e))(d||{});const r=a(e=>{const n=e>=0&&e<=3?e:0;return`${c+(n===0?"":String(n))}J`},"eraseDisplay");var g=(e=>(e[e.EntireLine=2]="EntireLine",e[e.ToBeginning=1]="ToBeginning",e[e.ToEnd=0]="ToEnd",e))(g||{});const o=a(e=>{const n=e>=0&&e<=2?e:0;return`${c+(n===0?"":String(n))}K`},"eraseInLine"),f=r(0),u=o(2),m=o(0),b=o(1),v=a(e=>{if(e<=0)return"";let n="";for(let i=0;i<e;i+=1)n+=u,i<e-1&&(n+=l());return n+=E,n},"eraseLines"),y=r(2),B=r(1),D=r(3);export{d as EraseDisplayMode,g as EraseLineMode,r as eraseDisplay,f as eraseDown,o as eraseInLine,u as eraseLine,m as eraseLineEnd,b as eraseLineStart,v as eraseLines,y as eraseScreen,D as eraseScreenAndScrollback,B as eraseUp};
@@ -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;
@@ -0,0 +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
+ */
26
+ declare const hyperlink: (text: string, url: string) => string;
27
+ export default hyperlink;
@@ -0,0 +1 @@
1
+ var i=Object.defineProperty;var n=(e,a)=>i(e,"name",{value:a,configurable:!0});import{O as o,S as r,B as t}from"./packem_shared/constants-D12jy2Zh.js";var s=Object.defineProperty,f=n((e,a)=>s(e,"name",{value:a,configurable:!0}),"n");const u=f((e,a)=>[o,"8",r,r,a,t,e,o,"8",r,r,t].join(""),"hyperlink");export{u as default};
@@ -0,0 +1,73 @@
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
+ */
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
+ */
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
+ */
29
+ readonly width?: LiteralUnion<"auto", number | string>;
30
+ }
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] : &lt;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/image.js ADDED
@@ -0,0 +1 @@
1
+ var n=Object.defineProperty;var o=(r,e)=>n(r,"name",{value:e,configurable:!0});import{createRequire as a}from"node:module";import{O as l,B as p}from"./packem_shared/constants-D12jy2Zh.js";const c=a(import.meta.url),t=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,u=o(r=>{if(typeof t<"u"&&t.versions&&t.versions.node){const[e,i]=t.versions.node.split(".").map(Number);if(e>22||e===22&&i>=3||e===20&&i>=16)return t.getBuiltinModule(r)}return c(r)},"__cjs_getBuiltinModule"),{Buffer:f}=u("node:buffer");var d=Object.defineProperty,g=o((r,e)=>d(r,"name",{value:e,configurable:!0}),"i");const v=g((r,e={})=>{if(!r)return"";let i=`${l}1337;File=inline=1`;e.width!==void 0&&(i+=`;width=${e.width}`),e.height!==void 0&&(i+=`;height=${e.height}`),e.preserveAspectRatio===!1&&(i+=";preserveAspectRatio=0");const s=f.from(r).toString("base64");return`${i}:${s}${p}`},"image");export{v as image};
@@ -0,0 +1,36 @@
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";
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ import{ALT_SCREEN_OFF as t,ALT_SCREEN_ON as s,alternativeScreenOff as i,alternativeScreenOn as a}from"./alternative-screen.js";import{clearLineAndHomeCursor as d,clearScreenAndHomeCursor as u,clearScreenFromTopLeft as c,resetTerminal as S}from"./clear.js";import{C as M,a as l,b as p,c as m,R as D,x as T,y as E,S as C,d as P,e as A,f as L,g as f,h as y,i as x,j as O,k as b,l as _,m as q,n as I,o as N,p as g,q as w,r as h,s as v,t as U,u as B,v as K,w as W,z as F}from"./packem_shared/cursor-nxpKt8Tn.js";import{eraseDisplay as k,eraseDown as X,eraseInLine as H,eraseLine as Q,eraseLineEnd as V,eraseLineStart as Y,eraseLines as G,eraseScreen as j,eraseScreenAndScrollback as J,eraseUp as Z}from"./erase.js";import{default as ee}from"./hyperlink.js";import{image as oe}from"./image.js";import{iTerm2 as se}from"./iterm2.js";import{BDSM as ae,BiDirectionalSupportMode as ne,BracketedPasteMode as de,DECRPM as ue,DECRQM as ce,DisableModifiersMode as Se,IRM as Re,InBandResizeMode as Me,InsertReplaceMode as le,KAM as pe,KeyboardActionMode as me,LNM as De,LightDarkMode as Te,LineFeedNewLineMode as Ee,LocalEchoMode as Ce,OriginMode as Pe,RM as Ae,RequestBiDirectionalSupportMode as Le,RequestInBandResizeMode as fe,RequestInsertReplaceMode as ye,RequestKeyboardActionMode as xe,RequestLineFeedNewLineMode as Oe,RequestLocalEchoMode as be,RequestSendReceiveMode as _e,RequestUnicodeCoreMode as qe,ResetBiDirectionalSupportMode as Ie,ResetInBandResizeMode as Ne,ResetInsertReplaceMode as ge,ResetKeyboardActionMode as we,ResetLineFeedNewLineMode as he,ResetLocalEchoMode as ve,ResetSendReceiveMode as Ue,ResetUnicodeCoreMode as Be,SGRMouseMode as Ke,SM as We,SRM as Fe,SendFocusEventsMode as ze,SendReceiveMode as ke,SetBiDirectionalSupportMode as Xe,SetInBandResizeMode as He,SetInsertReplaceMode as Qe,SetKeyboardActionMode as Ve,SetLineFeedNewLineMode as Ye,SetLocalEchoMode as Ge,SetSendReceiveMode as je,SetUnicodeCoreMode as Je,TextCursorEnableMode as Ze,UnicodeCoreMode as $e,createAnsiMode as er,createDecMode as rr,isModeNotRecognized as or,isModePermanentlyReset as tr,isModePermanentlySet as sr,isModeReset as ir,isModeSet as ar,reportMode as nr,requestMode as dr,resetMode as ur,setMode as cr}from"./mode.js";import{MouseButton as Rr,disableAnyEventMouse as Mr,disableButtonEventMouse as lr,disableFocusTracking as pr,disableNormalMouse as mr,disableSgrMouse as Dr,disableX10Mouse as Tr,enableAnyEventMouse as Er,enableButtonEventMouse as Cr,enableFocusTracking as Pr,enableNormalMouse as Ar,enableSgrMouse as Lr,enableX10Mouse as fr,encodeMouseButtonByte as yr,mouseSgrSequence as xr,mouseX10Sequence as Or}from"./mouse.js";import{SCREEN_MAX_LEN_DEFAULT as _r,SCREEN_TYPICAL_LIMIT as qr,screenPassthrough as Ir,tmuxPassthrough as Nr}from"./passthrough.js";import{resetProgressBar as wr,setErrorProgressBar as hr,setIndeterminateProgressBar as vr,setProgressBar as Ur,setWarningProgressBar as Br}from"./packem_shared/resetProgressBar-BtBbpWCM.js";import{RESET_INITIAL_STATE as Wr,RIS as Fr}from"./reset.js";import{clearTabStop as kr,deleteCharacter as Xr,deleteLine as Hr,insertCharacter as Qr,insertLine as Vr,repeatPreviousCharacter as Yr,requestPresentationStateReport as Gr,setLeftRightMargins as jr,setTopBottomMargins as Jr}from"./screen.js";import{SCROLL_DOWN_1 as $r,SCROLL_UP_1 as eo,scrollDown as ro,scrollUp as oo}from"./scroll.js";import{CPR as so,DA1 as io,DA2 as ao,DA3 as no,DECXCPR as uo,DSR as co,DSR_KeyboardLanguageDEC as So,DSR_PrinterStatusDEC as Ro,DSR_TerminalStatus as Mo,DSR_UDKStatusDEC as lo,LightDarkReport as po,RequestLightDarkReport as mo,RequestNameVersion as Do,XTVERSION as To,createAnsiStatusReport as Eo,createDecStatusReport as Co,cursorPositionReport as Po,deviceStatusReport as Ao,extendedCursorPositionReport as Lo,reportKeyboardLanguageDEC as fo,reportPrimaryDeviceAttributes as yo,reportPrinterNoPaperDEC as xo,reportPrinterNotReadyDEC as Oo,reportPrinterReadyDEC as bo,reportSecondaryDeviceAttributes as _o,reportTerminalNotOK as qo,reportTerminalOK as Io,reportTertiaryDeviceAttributes as No,reportUDKLockedDEC as go,reportUDKUnlockedDEC as wo,requestCursorPositionReport as ho,requestExtendedCursorPositionReport as vo,requestKeyboardLanguageDEC as Uo,requestPrimaryDeviceAttributes as Bo,requestPrimaryDeviceAttributesParam0 as Ko,requestPrinterStatusDEC as Wo,requestSecondaryDeviceAttributes as Fo,requestSecondaryDeviceAttributesParam0 as zo,requestTerminalStatus as ko,requestTertiaryDeviceAttributes as Xo,requestTertiaryDeviceAttributesParam0 as Ho,requestUDKStatusDEC as Qo}from"./status.js";import{default as Yo}from"./strip.js";import{XTGETTCAP as jo,requestTermcap as Jo,requestTerminfo as Zo}from"./termcap.js";import{decsin as et,decswt as rt,setIconName as ot,setIconNameAndWindowTitle as tt,setIconNameAndWindowTitleWithST as st,setIconNameWithST as it,setWindowTitle as at,setWindowTitleWithST as nt}from"./title.js";import{XTWINOPS as ut,deiconifyWindow as ct,iconifyWindow as St,lowerWindow as Rt,maximizeWindow as Mt,moveWindow as lt,raiseWindow as pt,refreshWindow as mt,reportWindowPosition as Dt,reportWindowState as Tt,requestCellSizePixels as Et,requestTextAreaSizeChars as Ct,requestTextAreaSizePixels as Pt,resizeTextAreaChars as At,resizeTextAreaPixels as Lt,restoreMaximizedWindow as ft,setPageSizeLines as yt,xtermWindowOp as xt}from"./window-ops.js";import{XTMODKEYS as bt,XTQMODKEYS as _t,keyModifierOptions as qt,queryKeyModifierOptions as It,queryModifyOtherKeys as Nt,resetKeyModifierOptions as gt,resetModifyOtherKeys as wt,setKeyModifierOptions as ht,setModifyOtherKeys1 as vt,setModifyOtherKeys2 as Ut}from"./xterm.js";import{IT2_AUTO as Kt,it2Cells as Wt,it2Percent as Ft,it2Pixels as zt}from"./packem_shared/IT2_AUTO-BYrffRAq.js";import{ITerm2File as Xt,ITerm2FileEnd as Ht,ITerm2FilePart as Qt,ITerm2MultipartFileStart as Vt}from"./packem_shared/ITerm2File-C88DBJC-.js";const e="\x07";export{t as ALT_SCREEN_OFF,s as ALT_SCREEN_ON,ae as BDSM,ne as BiDirectionalSupportMode,de as BracketedPasteMode,so as CPR,M as CURSOR_BACKWARD_1,l as CURSOR_DOWN_1,p as CURSOR_FORWARD_1,m as CURSOR_UP_1,io as DA1,ao as DA2,no as DA3,ue as DECRPM,ce as DECRQM,uo as DECXCPR,co as DSR,So as DSR_KeyboardLanguageDEC,Ro as DSR_PrinterStatusDEC,Mo as DSR_TerminalStatus,lo as DSR_UDKStatusDEC,Se as DisableModifiersMode,Re as IRM,Kt as IT2_AUTO,Xt as ITerm2File,Ht as ITerm2FileEnd,Qt as ITerm2FilePart,Vt as ITerm2MultipartFileStart,Me as InBandResizeMode,le as InsertReplaceMode,pe as KAM,me as KeyboardActionMode,De as LNM,Te as LightDarkMode,po as LightDarkReport,Ee as LineFeedNewLineMode,Ce as LocalEchoMode,Rr as MouseButton,Pe as OriginMode,D as REQUEST_CURSOR_POSITION,T as REQUEST_EXTENDED_CURSOR_POSITION,Wr as RESET_INITIAL_STATE,E as RESTORE_CURSOR_DEC,Fr as RIS,Ae as RM,Le as RequestBiDirectionalSupportMode,fe as RequestInBandResizeMode,ye as RequestInsertReplaceMode,xe as RequestKeyboardActionMode,mo as RequestLightDarkReport,Oe as RequestLineFeedNewLineMode,be as RequestLocalEchoMode,Do as RequestNameVersion,_e as RequestSendReceiveMode,qe as RequestUnicodeCoreMode,Ie as ResetBiDirectionalSupportMode,Ne as ResetInBandResizeMode,ge as ResetInsertReplaceMode,we as ResetKeyboardActionMode,he as ResetLineFeedNewLineMode,ve as ResetLocalEchoMode,Ue as ResetSendReceiveMode,Be as ResetUnicodeCoreMode,C as SAVE_CURSOR_DEC,_r as SCREEN_MAX_LEN_DEFAULT,qr as SCREEN_TYPICAL_LIMIT,$r as SCROLL_DOWN_1,eo as SCROLL_UP_1,Ke as SGRMouseMode,We as SM,Fe as SRM,ze as SendFocusEventsMode,ke as SendReceiveMode,Xe as SetBiDirectionalSupportMode,He as SetInBandResizeMode,Qe as SetInsertReplaceMode,Ve as SetKeyboardActionMode,Ye as SetLineFeedNewLineMode,Ge as SetLocalEchoMode,je as SetSendReceiveMode,Je as SetUnicodeCoreMode,Ze as TextCursorEnableMode,$e as UnicodeCoreMode,jo as XTGETTCAP,bt as XTMODKEYS,_t as XTQMODKEYS,To as XTVERSION,ut as XTWINOPS,i as alternativeScreenOff,a as alternativeScreenOn,e as beep,d as clearLineAndHomeCursor,u as clearScreenAndHomeCursor,c as clearScreenFromTopLeft,kr as clearTabStop,er as createAnsiMode,Eo as createAnsiStatusReport,rr as createDecMode,Co as createDecStatusReport,P as cursorBackward,A as cursorBackwardTab,L as cursorDown,f as cursorForward,y as cursorHide,x as cursorHorizontalAbsolute,O as cursorHorizontalForwardTab,b as cursorLeft,_ as cursorMove,q as cursorNextLine,I as cursorPosition,Po as cursorPositionReport,N as cursorPreviousLine,g as cursorRestore,w as cursorSave,h as cursorShow,v as cursorTo,U as cursorToColumn1,B as cursorUp,K as cursorVerticalAbsolute,et as decsin,rt as decswt,ct as deiconifyWindow,Xr as deleteCharacter,Hr as deleteLine,Ao as deviceStatusReport,Mr as disableAnyEventMouse,lr as disableButtonEventMouse,pr as disableFocusTracking,mr as disableNormalMouse,Dr as disableSgrMouse,Tr as disableX10Mouse,Er as enableAnyEventMouse,Cr as enableButtonEventMouse,Pr as enableFocusTracking,Ar as enableNormalMouse,Lr as enableSgrMouse,fr as enableX10Mouse,yr as encodeMouseButtonByte,W as eraseCharacter,k as eraseDisplay,X as eraseDown,H as eraseInLine,Q as eraseLine,V as eraseLineEnd,Y as eraseLineStart,G as eraseLines,j as eraseScreen,J as eraseScreenAndScrollback,Z as eraseUp,Lo as extendedCursorPositionReport,ee as hyperlink,se as iTerm2,St as iconifyWindow,oe as image,Qr as insertCharacter,Vr as insertLine,or as isModeNotRecognized,tr as isModePermanentlyReset,sr as isModePermanentlySet,ir as isModeReset,ar as isModeSet,Wt as it2Cells,Ft as it2Percent,zt as it2Pixels,qt as keyModifierOptions,Rt as lowerWindow,Mt as maximizeWindow,xr as mouseSgrSequence,Or as mouseX10Sequence,lt as moveWindow,It as queryKeyModifierOptions,Nt as queryModifyOtherKeys,pt as raiseWindow,mt as refreshWindow,Yr as repeatPreviousCharacter,fo as reportKeyboardLanguageDEC,nr as reportMode,yo as reportPrimaryDeviceAttributes,xo as reportPrinterNoPaperDEC,Oo as reportPrinterNotReadyDEC,bo as reportPrinterReadyDEC,_o as reportSecondaryDeviceAttributes,qo as reportTerminalNotOK,Io as reportTerminalOK,No as reportTertiaryDeviceAttributes,go as reportUDKLockedDEC,wo as reportUDKUnlockedDEC,Dt as reportWindowPosition,Tt as reportWindowState,Et as requestCellSizePixels,ho as requestCursorPositionReport,vo as requestExtendedCursorPositionReport,Uo as requestKeyboardLanguageDEC,dr as requestMode,Gr as requestPresentationStateReport,Bo as requestPrimaryDeviceAttributes,Ko as requestPrimaryDeviceAttributesParam0,Wo as requestPrinterStatusDEC,Fo as requestSecondaryDeviceAttributes,zo as requestSecondaryDeviceAttributesParam0,Jo as requestTermcap,ko as requestTerminalStatus,Zo as requestTerminfo,Xo as requestTertiaryDeviceAttributes,Ho as requestTertiaryDeviceAttributesParam0,Ct as requestTextAreaSizeChars,Pt as requestTextAreaSizePixels,Qo as requestUDKStatusDEC,gt as resetKeyModifierOptions,ur as resetMode,wt as resetModifyOtherKeys,wr as resetProgressBar,S as resetTerminal,At as resizeTextAreaChars,Lt as resizeTextAreaPixels,ft as restoreMaximizedWindow,Ir as screenPassthrough,ro as scrollDown,oo as scrollUp,F as setCursorStyle,hr as setErrorProgressBar,ot as setIconName,tt as setIconNameAndWindowTitle,st as setIconNameAndWindowTitleWithST,it as setIconNameWithST,vr as setIndeterminateProgressBar,ht as setKeyModifierOptions,jr as setLeftRightMargins,cr as setMode,vt as setModifyOtherKeys1,Ut as setModifyOtherKeys2,yt as setPageSizeLines,Ur as setProgressBar,Jr as setTopBottomMargins,Br as setWarningProgressBar,at as setWindowTitle,nt as setWindowTitleWithST,Yo as strip,Nr as tmuxPassthrough,xt as xtermWindowOp};
@@ -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 ; &lt;payload_string> BEL`.
49
+ * Objects implementing this interface are responsible for generating that `&lt;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
+ }
@@ -0,0 +1,96 @@
1
+ import type { IITerm2Payload, ITerm2FileProperties } from "./iterm2-properties.d.ts";
2
+ /**
3
+ * Represents the payload for a complete iTerm2 file transfer or an inline image display command.
4
+ * This class is used to construct the part of the OSC 1337 sequence that follows `File=`.
5
+ * The generated payload can be either:
6
+ * - `File=[PROPERTIES]:[BASE64_CONTENT]` (for inline content)
7
+ * - `File=[PROPERTIES]` (if content is not provided directly, e.g., for a download announcement)
8
+ *
9
+ * Implements {@link IITerm2Payload} for use with the generic `iTerm2` function.
10
+ * @see {@link ITerm2FileProps} for property details.
11
+ * @see {@link iTerm2} for the function that wraps this payload into a full escape sequence.
12
+ */
13
+ export declare class ITerm2File implements IITerm2Payload {
14
+ private readonly fileProps;
15
+ /**
16
+ * Constructs an `ITerm2File` payload object.
17
+ * @param properties An object containing properties for the file/image, as defined by {@link ITerm2FileProps}.
18
+ * The `name` property within `props` should be pre-Base64 encoded by the caller if it might
19
+ * contain special characters (like `;`, `=`, or non-ASCII characters).
20
+ * If `fileData` is provided, `props.content` will be overridden, and `props.size` will be
21
+ * set from `fileData.byteLength` if not already present in `props`.
22
+ * @param fileData (Optional) A `Uint8Array` containing the raw file data. If provided, this data will be
23
+ * Base64 encoded and used as the `content` of the file transfer. The `size` property
24
+ * will also be automatically set from `fileData.byteLength` if not specified in `props`.
25
+ */
26
+ constructor(properties: ITerm2FileProperties, fileData?: Uint8Array);
27
+ /**
28
+ * Converts the file properties and its content (if any) into the string payload
29
+ * suitable for the iTerm2 `File=` command.
30
+ * @returns The string payload (e.g., `"File=name=...;size=...:BASE64_CONTENT"` or `"File=name=...;size=..."`).
31
+ */
32
+ toString(): string;
33
+ }
34
+ /**
35
+ * Represents the payload for ending an iTerm2 multipart file transfer.
36
+ * This class is used to construct the part of the OSC 1337 sequence that is simply `FileEnd`.
37
+ *
38
+ * Implements {@link IITerm2Payload} for use with the generic `iTerm2` function.
39
+ * @see {@link ITerm2MultipartFileStart} to initiate the transfer.
40
+ * @see {@link ITerm2FilePart} for sending file chunks.
41
+ */
42
+ export declare class ITerm2FileEnd implements IITerm2Payload {
43
+ /**
44
+ * Generates the string payload for the iTerm2 `FileEnd` command.
45
+ * @returns The string `"FileEnd"`.
46
+ */
47
+ toString(): string;
48
+ }
49
+ /**
50
+ * Represents the payload for a part (chunk) of an iTerm2 multipart file transfer.
51
+ * This class is used to construct the part of the OSC 1337 sequence that follows `FilePart=`.
52
+ * The provided chunk must already be Base64 encoded.
53
+ *
54
+ * Implements {@link IITerm2Payload} for use with the generic `iTerm2` function.
55
+ * @see {@link ITerm2MultipartFileStart} to initiate the transfer.
56
+ * @see {@link ITerm2FileEnd} to finalize the transfer.
57
+ */
58
+ export declare class ITerm2FilePart implements IITerm2Payload {
59
+ private readonly base64Chunk;
60
+ /**
61
+ * Constructs an `ITerm2FilePart` payload object.
62
+ * @param base64Chunk A string containing a Base64 encoded chunk of the file data.
63
+ * The caller is responsible for chunking the file and Base64 encoding each chunk.
64
+ */
65
+ constructor(base64Chunk: string);
66
+ /**
67
+ * Converts the Base64 encoded chunk into the string payload suitable for the iTerm2 `FilePart=` command.
68
+ * @returns The string payload (e.g., `"FilePart=U09NRURBVEE="`).
69
+ */
70
+ toString(): string;
71
+ }
72
+ /**
73
+ * Represents the payload for starting an iTerm2 multipart file transfer.
74
+ * This class is used to construct the part of the OSC 1337 sequence that follows `MultipartFile=`.
75
+ * This command initiates a transfer; the actual file data is sent in subsequent `FilePart` commands.
76
+ *
77
+ * Implements {@link IITerm2Payload} for use with the generic `iTerm2` function.
78
+ * @see {@link ITerm2FileProps} for property details (omitting `content`).
79
+ * @see {@link ITerm2FilePart} for sending file chunks.
80
+ * @see {@link ITerm2FileEnd} for finalizing the transfer.
81
+ */
82
+ export declare class ITerm2MultipartFileStart implements IITerm2Payload {
83
+ private readonly properties;
84
+ /**
85
+ * Constructs an `ITerm2MultipartFileStart` payload object.
86
+ * @param properties Properties for the multipart file (e.g., `name`, `size`). Content is not part of this command.
87
+ * The `name` property within `props` should be pre-Base64 encoded by the caller if it might
88
+ * contain special characters.
89
+ */
90
+ constructor(properties: Omit<ITerm2FileProperties, "content">);
91
+ /**
92
+ * Converts the file properties into the string payload suitable for the iTerm2 `MultipartFile=` command.
93
+ * @returns The string payload (e.g., `"MultipartFile=name=...;size=..."`).
94
+ */
95
+ toString(): string;
96
+ }