@visulima/ansi 2.0.1 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/LICENSE.md +1 -132
  3. package/README.md +226 -226
  4. package/dist/alternative-screen.d.ts +6 -74
  5. package/dist/alternative-screen.js +1 -0
  6. package/dist/clear.d.ts +6 -77
  7. package/dist/clear.js +1 -0
  8. package/dist/cursor.d.ts +48 -429
  9. package/dist/cursor.js +1 -0
  10. package/dist/erase.d.ts +14 -197
  11. package/dist/erase.js +1 -0
  12. package/dist/hyperlink.d.ts +2 -26
  13. package/dist/hyperlink.js +1 -0
  14. package/dist/image.d.ts +7 -69
  15. package/dist/image.js +1 -0
  16. package/dist/index.d.ts +30 -35
  17. package/dist/index.js +1 -0
  18. package/dist/iterm2.d.ts +43 -58
  19. package/dist/iterm2.js +1 -0
  20. package/dist/mode.d.ts +174 -648
  21. package/dist/mode.js +1 -0
  22. package/dist/mouse.d.ts +21 -203
  23. package/dist/mouse.js +1 -0
  24. package/dist/packem_shared/IT2_AUTO-BYrffRAq.js +1 -0
  25. package/dist/packem_shared/ITerm2File-C88DBJC-.js +1 -0
  26. package/dist/packem_shared/constants-D12jy2Zh.js +1 -0
  27. package/dist/packem_shared/cursor-D2UOfUc_.js +1 -0
  28. package/dist/packem_shared/resetProgressBar-BtBbpWCM.js +1 -0
  29. package/dist/packem_shared/restoreCursor-D3XBmqcY.js +2 -0
  30. package/dist/passthrough.d.ts +6 -77
  31. package/dist/passthrough.js +1 -0
  32. package/dist/reset.d.ts +4 -26
  33. package/dist/reset.js +1 -0
  34. package/dist/screen.d.ts +11 -234
  35. package/dist/screen.js +1 -0
  36. package/dist/scroll.d.ts +6 -67
  37. package/dist/scroll.js +1 -0
  38. package/dist/status.d.ts +48 -498
  39. package/dist/status.js +1 -0
  40. package/dist/strip.d.ts +2 -22
  41. package/dist/strip.js +1 -0
  42. package/dist/termcap.d.ts +5 -38
  43. package/dist/termcap.js +1 -0
  44. package/dist/title.d.ts +10 -185
  45. package/dist/title.js +1 -0
  46. package/dist/window-ops.d.ts +24 -396
  47. package/dist/window-ops.js +1 -0
  48. package/dist/xterm.d.ts +12 -94
  49. package/dist/xterm.js +1 -0
  50. package/package.json +45 -230
  51. package/dist/alternative-screen.cjs +0 -17
  52. package/dist/alternative-screen.d.cts +0 -74
  53. package/dist/alternative-screen.d.mts +0 -74
  54. package/dist/alternative-screen.mjs +0 -10
  55. package/dist/clear.cjs +0 -17
  56. package/dist/clear.d.cts +0 -77
  57. package/dist/clear.d.mts +0 -77
  58. package/dist/clear.mjs +0 -10
  59. package/dist/constants.d.cts +0 -20
  60. package/dist/constants.d.mts +0 -20
  61. package/dist/constants.d.ts +0 -20
  62. package/dist/cursor.cjs +0 -41
  63. package/dist/cursor.d.cts +0 -437
  64. package/dist/cursor.d.mts +0 -437
  65. package/dist/cursor.mjs +0 -3
  66. package/dist/erase.cjs +0 -64
  67. package/dist/erase.d.cts +0 -206
  68. package/dist/erase.d.mts +0 -206
  69. package/dist/erase.mjs +0 -49
  70. package/dist/helpers.d.cts +0 -14
  71. package/dist/helpers.d.mts +0 -14
  72. package/dist/helpers.d.ts +0 -14
  73. package/dist/hyperlink.cjs +0 -9
  74. package/dist/hyperlink.d.cts +0 -27
  75. package/dist/hyperlink.d.mts +0 -27
  76. package/dist/hyperlink.mjs +0 -7
  77. package/dist/image.cjs +0 -28
  78. package/dist/image.d.cts +0 -73
  79. package/dist/image.d.mts +0 -73
  80. package/dist/image.mjs +0 -24
  81. package/dist/index.cjs +0 -246
  82. package/dist/index.d.cts +0 -35
  83. package/dist/index.d.mts +0 -35
  84. package/dist/index.mjs +0 -25
  85. package/dist/iterm2/iterm2-properties.d.cts +0 -135
  86. package/dist/iterm2/iterm2-properties.d.mts +0 -135
  87. package/dist/iterm2/iterm2-properties.d.ts +0 -135
  88. package/dist/iterm2/iterm2-sequences.d.cts +0 -96
  89. package/dist/iterm2/iterm2-sequences.d.mts +0 -96
  90. package/dist/iterm2/iterm2-sequences.d.ts +0 -96
  91. package/dist/iterm2.cjs +0 -26
  92. package/dist/iterm2.d.cts +0 -58
  93. package/dist/iterm2.d.mts +0 -58
  94. package/dist/iterm2.mjs +0 -14
  95. package/dist/mode.cjs +0 -388
  96. package/dist/mode.d.cts +0 -657
  97. package/dist/mode.d.mts +0 -657
  98. package/dist/mode.mjs +0 -235
  99. package/dist/mouse.cjs +0 -127
  100. package/dist/mouse.d.cts +0 -230
  101. package/dist/mouse.d.mts +0 -230
  102. package/dist/mouse.mjs +0 -108
  103. package/dist/packem_shared/IT2_AUTO-5vTJQMm6.cjs +0 -15
  104. package/dist/packem_shared/IT2_AUTO-DnfCUXso.mjs +0 -8
  105. package/dist/packem_shared/ITerm2File-BGPqNSjB.cjs +0 -137
  106. package/dist/packem_shared/ITerm2File-DKFkdqdA.mjs +0 -130
  107. package/dist/packem_shared/constants-BK26O-46.cjs +0 -17
  108. package/dist/packem_shared/constants-CE7WkXh_.mjs +0 -9
  109. package/dist/packem_shared/cursor-CQKLCu7U.cjs +0 -105
  110. package/dist/packem_shared/cursor-DhFQcQ9g.mjs +0 -73
  111. package/dist/packem_shared/restoreCursor-C6pNB8UY.mjs +0 -336
  112. package/dist/packem_shared/restoreCursor-DC_ZKZwT.cjs +0 -342
  113. package/dist/passthrough.cjs +0 -38
  114. package/dist/passthrough.d.cts +0 -77
  115. package/dist/passthrough.d.mts +0 -77
  116. package/dist/passthrough.mjs +0 -31
  117. package/dist/reset.cjs +0 -9
  118. package/dist/reset.d.cts +0 -26
  119. package/dist/reset.d.mts +0 -26
  120. package/dist/reset.mjs +0 -4
  121. package/dist/screen.cjs +0 -41
  122. package/dist/screen.d.cts +0 -234
  123. package/dist/screen.d.mts +0 -234
  124. package/dist/screen.mjs +0 -29
  125. package/dist/scroll.cjs +0 -27
  126. package/dist/scroll.d.cts +0 -67
  127. package/dist/scroll.d.mts +0 -67
  128. package/dist/scroll.mjs +0 -20
  129. package/dist/status.cjs +0 -147
  130. package/dist/status.d.cts +0 -501
  131. package/dist/status.d.mts +0 -501
  132. package/dist/status.mjs +0 -104
  133. package/dist/strip.cjs +0 -20
  134. package/dist/strip.d.cts +0 -23
  135. package/dist/strip.d.mts +0 -23
  136. package/dist/strip.mjs +0 -18
  137. package/dist/termcap.cjs +0 -33
  138. package/dist/termcap.d.cts +0 -38
  139. package/dist/termcap.d.mts +0 -38
  140. package/dist/termcap.mjs +0 -27
  141. package/dist/title.cjs +0 -31
  142. package/dist/title.d.cts +0 -185
  143. package/dist/title.d.mts +0 -185
  144. package/dist/title.mjs +0 -20
  145. package/dist/window-ops.cjs +0 -85
  146. package/dist/window-ops.d.cts +0 -418
  147. package/dist/window-ops.d.mts +0 -418
  148. package/dist/window-ops.mjs +0 -63
  149. package/dist/xterm.cjs +0 -48
  150. package/dist/xterm.d.cts +0 -94
  151. package/dist/xterm.d.mts +0 -94
  152. package/dist/xterm.mjs +0 -35
@@ -1,135 +0,0 @@
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
- }
@@ -1,135 +0,0 @@
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
- }
@@ -1,135 +0,0 @@
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
- }
@@ -1,96 +0,0 @@
1
- import type { IITerm2Payload, ITerm2FileProperties } from "./iterm2-properties.d.cts";
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
- }
@@ -1,96 +0,0 @@
1
- import type { IITerm2Payload, ITerm2FileProperties } from "./iterm2-properties.d.mts";
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
- }