@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
package/dist/mouse.d.mts DELETED
@@ -1,230 +0,0 @@
1
- /**
2
- * Defines codes for various mouse buttons and actions.
3
- * These are based on X11 button codes and common terminal mouse reporting extensions.
4
- * @property {number} LEFT - Left mouse button (typically button 1).
5
- * @property {number} MIDDLE - Middle mouse button (typically button 2).
6
- * @property {number} RIGHT - Right mouse button (typically button 3).
7
- * @property {number} NONE - Represents no specific button, often used for release events in some protocols.
8
- * @property {number} RELEASE - Alias for `NONE`, used to signify a button release event.
9
- * @property {number} BUTTON_1 - Alias for `LEFT`.
10
- * @property {number} BUTTON_2 - Alias for `MIDDLE`.
11
- * @property {number} BUTTON_3 - Alias for `RIGHT`.
12
- * @property {number} WHEEL_UP - Mouse wheel scrolled upwards (typically button 4).
13
- * @property {number} WHEEL_DOWN - Mouse wheel scrolled downwards (typically button 5).
14
- * @property {number} WHEEL_LEFT - Mouse wheel scrolled leftwards (typically button 6, less common).
15
- * @property {number} WHEEL_RIGHT - Mouse wheel scrolled rightwards (typically button 7, less common).
16
- * @property {number} BACKWARD - Auxiliary button, often browser "Back" (typically button 8).
17
- * @property {number} FORWARD - Auxiliary button, often browser "Forward" (typically button 9).
18
- * @property {number} BUTTON_4 - Alias for `WHEEL_UP`.
19
- * @property {number} BUTTON_5 - Alias for `WHEEL_DOWN`.
20
- * @property {number} BUTTON_6 - Alias for `WHEEL_LEFT`.
21
- * @property {number} BUTTON_7 - Alias for `WHEEL_RIGHT`.
22
- * @property {number} BUTTON_8 - Alias for `BACKWARD`.
23
- * @property {number} BUTTON_9 - Alias for `FORWARD`.
24
- * @property {number} BUTTON_10 - Auxiliary button 10.
25
- * @property {number} BUTTON_11 - Auxiliary button 11.
26
- * @enum {number}
27
- */
28
- export declare const MouseButton: {
29
- readonly BACKWARD: 8;
30
- readonly BUTTON_1: 1;
31
- readonly BUTTON_2: 2;
32
- readonly BUTTON_3: 3;
33
- readonly BUTTON_4: 4;
34
- readonly BUTTON_5: 5;
35
- readonly BUTTON_6: 6;
36
- readonly BUTTON_7: 7;
37
- readonly BUTTON_8: 8;
38
- readonly BUTTON_9: 9;
39
- readonly BUTTON_10: 10;
40
- readonly BUTTON_11: 11;
41
- readonly FORWARD: 9;
42
- readonly LEFT: 1;
43
- readonly MIDDLE: 2;
44
- readonly NONE: 0;
45
- readonly RELEASE: 0;
46
- readonly RIGHT: 3;
47
- readonly WHEEL_DOWN: 5;
48
- readonly WHEEL_LEFT: 6;
49
- readonly WHEEL_RIGHT: 7;
50
- readonly WHEEL_UP: 4;
51
- };
52
- export type MouseButtonType = (typeof MouseButton)[keyof typeof MouseButton];
53
- /**
54
- * Interface representing modifier keys (Shift, Alt, Ctrl) that might be active during a mouse event.
55
- * @property {boolean} [alt] - `true` if the Alt (or Meta) key was pressed, `false` or `undefined` otherwise.
56
- * @property {boolean} [ctrl] - `true` if the Control key was pressed, `false` or `undefined` otherwise.
57
- * @property {boolean} [shift] - `true` if the Shift key was pressed, `false` or `undefined` otherwise.
58
- */
59
- export interface MouseModifiers {
60
- alt?: boolean;
61
- ctrl?: boolean;
62
- shift?: boolean;
63
- }
64
- /**
65
- * Encodes a mouse button, motion status, and modifiers into a single byte (Cb)
66
- * for use in X10 and SGR mouse tracking protocols.
67
- *
68
- * The encoded byte combines button information, whether it's a motion event,
69
- * and the state of Shift, Alt, and Ctrl keys.
70
- * @param button The {@link MouseButtonType} representing the button pressed or wheel action.
71
- * @param motion `true` if this is a motion event, `false` otherwise.
72
- * @param modifiers An optional {@link MouseModifiers} object indicating active modifier keys.
73
- * @returns The encoded byte (Cb). Returns `0xFF` (255) if the provided `button` is invalid or not recognized.
74
- * @example
75
- * ```typescript
76
- * import { encodeMouseButtonByte, MouseButton, MouseModifiers } from \'@visulima/ansi/mouse\';
77
- *
78
- * // Left button press, no motion, no modifiers
79
- * const cb1 = encodeMouseButtonByte(MouseButton.LEFT, false);
80
- * console.log(cb1); // Output: 0
81
- *
82
- * // Middle button press, with motion, Shift key held
83
- * const cb2 = encodeMouseButtonByte(MouseButton.MIDDLE, true, { shift: true });
84
- * console.log(cb2); // Output: 37 (Middle=1 + Shift=4 + Motion=32)
85
- *
86
- * // Wheel up, no motion, Alt and Ctrl held
87
- * const cb3 = encodeMouseButtonByte(MouseButton.WHEEL_UP, false, { alt: true, ctrl: true });
88
- * console.log(cb3); // Output: 88 (WheelUp=0 + WheelFlag=64 + Alt=8 + Ctrl=16)
89
- *
90
- * // Release event
91
- * const cb4 = encodeMouseButtonByte(MouseButton.RELEASE, false);
92
- * console.log(cb4); // Output: 3
93
- * ```
94
- */
95
- export declare const encodeMouseButtonByte: (button: MouseButtonType, motion: boolean, modifiers?: MouseModifiers) => number;
96
- /**
97
- * Generates an X10 mouse tracking escape sequence.
98
- * Format: `CSI M Cb Cx Cy`
99
- * Where `Cb`, `Cx`, `Cy` are characters derived by adding {@link X10_MOUSE_OFFSET} (32) to the
100
- * encoded button byte, 1-based X coordinate, and 1-based Y coordinate, respectively.
101
- *
102
- * This is an older mouse reporting protocol, primarily reporting button presses.
103
- * @param callback The encoded button byte, typically from {@link encodeMouseButtonByte}.
104
- * @param x The 0-indexed X coordinate of the mouse event.
105
- * @param y The 0-indexed Y coordinate of the mouse event.
106
- * @returns The X10 mouse sequence string. Returns an empty string if `cb` is `0xFF` (invalid).
107
- * @example
108
- * ```typescript
109
- * import { mouseX10Sequence, encodeMouseButtonByte, MouseButton } from \'@visulima/ansi/mouse\';
110
- *
111
- * const cb = encodeMouseButtonByte(MouseButton.LEFT, false);
112
- * const seq = mouseX10Sequence(cb, 10, 20); // Coordinates are 0-indexed
113
- * // Result: "\u001b[M!+5" (Cb=0 -> char 32, Cx=11 -> char 43, Cy=21 -> char 53)
114
- * console.log(seq);
115
- * ```
116
- */
117
- export declare const mouseX10Sequence: (callback: number, x: number, y: number) => string;
118
- /**
119
- * Generates an SGR (Select Graphic Rendition) style mouse tracking escape sequence.
120
- * This is a more modern and robust mouse reporting format.
121
- *
122
- * Format for press/motion: `CSI < Cb ; Px ; Py M`
123
- * Format for release: `CSI < Cb ; Px ; Py m`
124
- *
125
- * `Cb` is the encoded button byte (see {@link encodeMouseButtonByte}).
126
- * `Px` and `Py` are 1-based X and Y coordinates.
127
- * @param callback The encoded button byte from {@link encodeMouseButtonByte}.
128
- * @param x The 0-indexed X coordinate of the mouse event.
129
- * @param y The 0-indexed Y coordinate of the mouse event.
130
- * @param isRelease `true` if this is a button release event (sequence ends with `m`),
131
- * `false` for press or motion events (sequence ends with `M`).
132
- * @returns The SGR mouse sequence string. Returns an empty string if `cb` is `0xFF` (invalid).
133
- * @example
134
- * ```typescript
135
- * import { mouseSgrSequence, encodeMouseButtonByte, MouseButton } from \'@visulima/ansi/mouse\';
136
- *
137
- * // Left button press at (10, 20)
138
- * const cbPress = encodeMouseButtonByte(MouseButton.LEFT, false);
139
- * const seqPress = mouseSgrSequence(cbPress, 10, 20, false);
140
- * console.log(seqPress); // Output: "\u001b[<0;11;21M"
141
- *
142
- * // Left button release at (10, 20)
143
- * const cbRelease = encodeMouseButtonByte(MouseButton.RELEASE, false); // Or use original button with isRelease=true
144
- * const seqRelease = mouseSgrSequence(cbPress, 10, 20, true); // cbPress (0) is fine for release with SGR if button info isn't needed for release
145
- * console.log(seqRelease); // Output: "\u001b[<0;11;21m"
146
- * // If using explicit release button code from encodeMouseButtonByte:
147
- * const cbExplicitRelease = encodeMouseButtonByte(MouseButton.RELEASE, false);
148
- * const seqExplicitRelease = mouseSgrSequence(cbExplicitRelease, 10, 20, true);
149
- * console.log(seqExplicitRelease); // Output: "\u001b[<3;11;21m"
150
- *
151
- * // Motion with middle button and Shift key at (5,5)
152
- * const cbMotion = encodeMouseButtonByte(MouseButton.MIDDLE, true, { shift: true });
153
- * const seqMotion = mouseSgrSequence(cbMotion, 5, 5, false);
154
- * console.log(seqMotion); // Output: "\u001b[<37;6;6M"
155
- * ```
156
- */
157
- export declare const mouseSgrSequence: (callback: number, x: number, y: number, isRelease: boolean) => string;
158
- /**
159
- * Enables X10 compatibility mouse reporting (DECSET 9).
160
- * This is an older protocol that typically reports only button press events.
161
- * The format is `CSI M Cb Cx Cy`.
162
- * @see {@link disableX10Mouse}
163
- * @see {@link mouseX10Sequence}
164
- */
165
- export declare const enableX10Mouse: string;
166
- /**
167
- * Disables X10 compatibility mouse reporting (DECRST 9).
168
- * @see {@link enableX10Mouse}
169
- */
170
- export declare const disableX10Mouse: string;
171
- /**
172
- * Enables Normal Tracking mode, also known as VT200 mouse reporting (DECSET 1000).
173
- * Reports button press and release events.
174
- * Uses X10-style coordinate encoding if SGR mode is not also active.
175
- * @see {@link disableNormalMouse}
176
- */
177
- export declare const enableNormalMouse: string;
178
- /**
179
- * Disables Normal Tracking mode / VT200 mouse reporting (DECRST 1000).
180
- * @see {@link enableNormalMouse}
181
- */
182
- export declare const disableNormalMouse: string;
183
- /**
184
- * Enables Button-Event tracking mouse reporting (DECSET 1002).
185
- * Reports press, release, and mouse motion when a button is held down.
186
- * @see {@link disableButtonEventMouse}
187
- */
188
- export declare const enableButtonEventMouse: string;
189
- /**
190
- * Disables Button-Event tracking mouse reporting (DECRST 1002).
191
- * @see {@link enableButtonEventMouse}
192
- */
193
- export declare const disableButtonEventMouse: string;
194
- /**
195
- * Enables Any-Event mouse reporting (DECSET 1003).
196
- * Reports press, release, and all mouse motion (including hover when no buttons are pressed).
197
- * This is the most comprehensive mouse motion tracking mode (excluding pixel-level reporting).
198
- * @see {@link disableAnyEventMouse}
199
- */
200
- export declare const enableAnyEventMouse: string;
201
- /**
202
- * Disables Any-Event mouse reporting (DECRST 1003).
203
- * @see {@link enableAnyEventMouse}
204
- */
205
- export declare const disableAnyEventMouse: string;
206
- /**
207
- * Enables SGR (Select Graphic Rendition) Extended mouse reporting (DECSET 1006).
208
- * Event data is sent in a more robust format: `CSI < Cb ; Px ; Py M` (press) or `m` (release).
209
- * This mode is generally preferred for new applications due to its clarity and ability
210
- * to handle coordinates larger than 95 without ambiguity with UTF-8 characters.
211
- * @see {@link disableSgrMouse}
212
- * @see {@link mouseSgrSequence}
213
- */
214
- export declare const enableSgrMouse: string;
215
- /**
216
- * Disables SGR Extended mouse reporting (DECRST 1006).
217
- * @see {@link enableSgrMouse}
218
- */
219
- export declare const disableSgrMouse: string;
220
- /**
221
- * Enables FocusIn/FocusOut event reporting (DECSET 1004).
222
- * The terminal will send `CSI I` when it gains focus and `CSI O` when it loses focus.
223
- * @see {@link disableFocusTracking}
224
- */
225
- export declare const enableFocusTracking: string;
226
- /**
227
- * Disables FocusIn/FocusOut event reporting (DECRST 1004).
228
- * @see {@link enableFocusTracking}
229
- */
230
- export declare const disableFocusTracking: string;
package/dist/mouse.mjs DELETED
@@ -1,108 +0,0 @@
1
- import { E as ESC } from './packem_shared/constants-CE7WkXh_.mjs';
2
-
3
- var __defProp = Object.defineProperty;
4
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
- const MOUSE_BIT_SHIFT = 4;
6
- const MOUSE_BIT_ALT = 8;
7
- const MOUSE_BIT_CTRL = 16;
8
- const MOUSE_BIT_MOTION = 32;
9
- const MOUSE_BIT_WHEEL = 64;
10
- const MOUSE_BIT_ADDITIONAL = 128;
11
- const MOUSE_BUTTON_BITS_MASK = 3;
12
- const X10_MOUSE_OFFSET = 32;
13
- const MouseButton = {
14
- BACKWARD: 8,
15
- BUTTON_1: 1,
16
- // Left
17
- BUTTON_2: 2,
18
- // Middle
19
- BUTTON_3: 3,
20
- // Right
21
- BUTTON_4: 4,
22
- // Wheel Up
23
- BUTTON_5: 5,
24
- // Wheel Down
25
- BUTTON_6: 6,
26
- // Wheel Left
27
- BUTTON_7: 7,
28
- // Wheel Right
29
- BUTTON_8: 8,
30
- // Aux 1 (e.g., Browser Backward)
31
- BUTTON_9: 9,
32
- // Aux 2 (e.g., Browser Forward)
33
- BUTTON_10: 10,
34
- // Aux 3
35
- BUTTON_11: 11,
36
- // Aux 4
37
- FORWARD: 9,
38
- // Aliases
39
- LEFT: 1,
40
- MIDDLE: 2,
41
- NONE: 0,
42
- // Also used for release if no specific button for release
43
- RELEASE: 0,
44
- RIGHT: 3,
45
- WHEEL_DOWN: 5,
46
- WHEEL_LEFT: 6,
47
- WHEEL_RIGHT: 7,
48
- WHEEL_UP: 4
49
- };
50
- const encodeMouseButtonByte = /* @__PURE__ */ __name((button, motion, modifiers = {}) => {
51
- let callback;
52
- if (button === MouseButton.RELEASE) {
53
- callback = MOUSE_BUTTON_BITS_MASK;
54
- } else if (button >= MouseButton.LEFT && button <= MouseButton.RIGHT) {
55
- callback = button - MouseButton.LEFT;
56
- } else if (button >= MouseButton.WHEEL_UP && button <= MouseButton.WHEEL_RIGHT) {
57
- callback = button - MouseButton.WHEEL_UP;
58
- callback |= MOUSE_BIT_WHEEL;
59
- } else if (button >= MouseButton.BACKWARD && button <= MouseButton.BUTTON_11) {
60
- callback = button - MouseButton.BACKWARD;
61
- callback |= MOUSE_BIT_ADDITIONAL;
62
- } else {
63
- return 255;
64
- }
65
- if (modifiers.shift) {
66
- callback |= MOUSE_BIT_SHIFT;
67
- }
68
- if (modifiers.alt) {
69
- callback |= MOUSE_BIT_ALT;
70
- }
71
- if (modifiers.ctrl) {
72
- callback |= MOUSE_BIT_CTRL;
73
- }
74
- if (motion) {
75
- callback |= MOUSE_BIT_MOTION;
76
- }
77
- return callback;
78
- }, "encodeMouseButtonByte");
79
- const mouseX10Sequence = /* @__PURE__ */ __name((callback, x, y) => {
80
- if (callback === 255) {
81
- return "";
82
- }
83
- const charCallback = String.fromCodePoint(callback + X10_MOUSE_OFFSET);
84
- const charCx = String.fromCodePoint(x + 1 + X10_MOUSE_OFFSET);
85
- const charCy = String.fromCodePoint(y + 1 + X10_MOUSE_OFFSET);
86
- return `${ESC}[M${charCallback}${charCx}${charCy}`;
87
- }, "mouseX10Sequence");
88
- const mouseSgrSequence = /* @__PURE__ */ __name((callback, x, y, isRelease) => {
89
- if (callback === 255) {
90
- return "";
91
- }
92
- const finalChar = isRelease ? "m" : "M";
93
- return `${ESC}[<${callback};${x + 1};${y + 1}${finalChar}`;
94
- }, "mouseSgrSequence");
95
- const enableX10Mouse = `${ESC}[?9h`;
96
- const disableX10Mouse = `${ESC}[?9l`;
97
- const enableNormalMouse = `${ESC}[?1000h`;
98
- const disableNormalMouse = `${ESC}[?1000l`;
99
- const enableButtonEventMouse = `${ESC}[?1002h`;
100
- const disableButtonEventMouse = `${ESC}[?1002l`;
101
- const enableAnyEventMouse = `${ESC}[?1003h`;
102
- const disableAnyEventMouse = `${ESC}[?1003l`;
103
- const enableSgrMouse = `${ESC}[?1006h`;
104
- const disableSgrMouse = `${ESC}[?1006l`;
105
- const enableFocusTracking = `${ESC}[?1004h`;
106
- const disableFocusTracking = `${ESC}[?1004l`;
107
-
108
- export { MouseButton, disableAnyEventMouse, disableButtonEventMouse, disableFocusTracking, disableNormalMouse, disableSgrMouse, disableX10Mouse, enableAnyEventMouse, enableButtonEventMouse, enableFocusTracking, enableNormalMouse, enableSgrMouse, enableX10Mouse, encodeMouseButtonByte, mouseSgrSequence, mouseX10Sequence };
@@ -1,15 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
4
-
5
- var __defProp = Object.defineProperty;
6
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
- const IT2_AUTO = "auto";
8
- const it2Cells = /* @__PURE__ */ __name((n) => n.toString(), "it2Cells");
9
- const it2Pixels = /* @__PURE__ */ __name((n) => `${n}px`, "it2Pixels");
10
- const it2Percent = /* @__PURE__ */ __name((n) => `${n}%`, "it2Percent");
11
-
12
- exports.IT2_AUTO = IT2_AUTO;
13
- exports.it2Cells = it2Cells;
14
- exports.it2Percent = it2Percent;
15
- exports.it2Pixels = it2Pixels;
@@ -1,8 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- const IT2_AUTO = "auto";
4
- const it2Cells = /* @__PURE__ */ __name((n) => n.toString(), "it2Cells");
5
- const it2Pixels = /* @__PURE__ */ __name((n) => `${n}px`, "it2Pixels");
6
- const it2Percent = /* @__PURE__ */ __name((n) => `${n}%`, "it2Percent");
7
-
8
- export { IT2_AUTO, it2Cells, it2Percent, it2Pixels };
@@ -1,137 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
4
-
5
- const node_buffer = require('node:buffer');
6
-
7
- var __defProp = Object.defineProperty;
8
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
- const formatITerm2FileProperties = /* @__PURE__ */ __name((properties) => {
10
- const options = [];
11
- if (properties.name) {
12
- options.push(`name=${properties.name}`);
13
- }
14
- if (properties.size !== void 0) {
15
- options.push(`size=${properties.size}`);
16
- }
17
- if (properties.width !== void 0) {
18
- options.push(`width=${properties.width.toString()}`);
19
- }
20
- if (properties.height !== void 0) {
21
- options.push(`height=${properties.height.toString()}`);
22
- }
23
- if (properties.ignoreAspectRatio) {
24
- options.push("preserveAspectRatio=0");
25
- }
26
- if (properties.inline) {
27
- options.push("inline=1");
28
- }
29
- if (properties.doNotMoveCursor) {
30
- options.push("doNotMoveCursor=1");
31
- }
32
- return options.join(";");
33
- }, "formatITerm2FileProperties");
34
- class ITerm2File {
35
- static {
36
- __name(this, "ITerm2File");
37
- }
38
- fileProps;
39
- /**
40
- * Constructs an `ITerm2File` payload object.
41
- * @param properties An object containing properties for the file/image, as defined by {@link ITerm2FileProps}.
42
- * The `name` property within `props` should be pre-Base64 encoded by the caller if it might
43
- * contain special characters (like `;`, `=`, or non-ASCII characters).
44
- * If `fileData` is provided, `props.content` will be overridden, and `props.size` will be
45
- * set from `fileData.byteLength` if not already present in `props`.
46
- * @param fileData (Optional) A `Uint8Array` containing the raw file data. If provided, this data will be
47
- * Base64 encoded and used as the `content` of the file transfer. The `size` property
48
- * will also be automatically set from `fileData.byteLength` if not specified in `props`.
49
- */
50
- constructor(properties, fileData) {
51
- this.fileProps = { ...properties };
52
- if (fileData) {
53
- if (fileData.byteLength > 10 * 1024 * 1024) {
54
- throw new Error("File size exceeds maximum limit of 10MB");
55
- }
56
- this.fileProps.content = node_buffer.Buffer.from(fileData).toString("base64");
57
- if (this.fileProps.size === void 0) {
58
- this.fileProps.size = fileData.byteLength;
59
- }
60
- if (this.fileProps.size !== fileData.byteLength) {
61
- throw new Error("File size property doesn't match actual data length");
62
- }
63
- }
64
- }
65
- /**
66
- * Converts the file properties and its content (if any) into the string payload
67
- * suitable for the iTerm2 `File=` command.
68
- * @returns The string payload (e.g., `"File=name=...;size=...:BASE64_CONTENT"` or `"File=name=...;size=..."`).
69
- */
70
- toString() {
71
- let s = "File=";
72
- s += formatITerm2FileProperties(this.fileProps);
73
- if (this.fileProps.content !== void 0) {
74
- s += `:${this.fileProps.content}`;
75
- }
76
- return s;
77
- }
78
- }
79
- class ITerm2FileEnd {
80
- static {
81
- __name(this, "ITerm2FileEnd");
82
- }
83
- /**
84
- * Generates the string payload for the iTerm2 `FileEnd` command.
85
- * @returns The string `"FileEnd"`.
86
- */
87
- // eslint-disable-next-line class-methods-use-this
88
- toString() {
89
- return "FileEnd";
90
- }
91
- }
92
- class ITerm2FilePart {
93
- /**
94
- * Constructs an `ITerm2FilePart` payload object.
95
- * @param base64Chunk A string containing a Base64 encoded chunk of the file data.
96
- * The caller is responsible for chunking the file and Base64 encoding each chunk.
97
- */
98
- constructor(base64Chunk) {
99
- this.base64Chunk = base64Chunk;
100
- }
101
- static {
102
- __name(this, "ITerm2FilePart");
103
- }
104
- /**
105
- * Converts the Base64 encoded chunk into the string payload suitable for the iTerm2 `FilePart=` command.
106
- * @returns The string payload (e.g., `"FilePart=U09NRURBVEE="`).
107
- */
108
- toString() {
109
- return `FilePart=${this.base64Chunk}`;
110
- }
111
- }
112
- class ITerm2MultipartFileStart {
113
- /**
114
- * Constructs an `ITerm2MultipartFileStart` payload object.
115
- * @param properties Properties for the multipart file (e.g., `name`, `size`). Content is not part of this command.
116
- * The `name` property within `props` should be pre-Base64 encoded by the caller if it might
117
- * contain special characters.
118
- */
119
- constructor(properties) {
120
- this.properties = properties;
121
- }
122
- static {
123
- __name(this, "ITerm2MultipartFileStart");
124
- }
125
- /**
126
- * Converts the file properties into the string payload suitable for the iTerm2 `MultipartFile=` command.
127
- * @returns The string payload (e.g., `"MultipartFile=name=...;size=..."`).
128
- */
129
- toString() {
130
- return `MultipartFile=${formatITerm2FileProperties(this.properties)}`;
131
- }
132
- }
133
-
134
- exports.ITerm2File = ITerm2File;
135
- exports.ITerm2FileEnd = ITerm2FileEnd;
136
- exports.ITerm2FilePart = ITerm2FilePart;
137
- exports.ITerm2MultipartFileStart = ITerm2MultipartFileStart;
@@ -1,130 +0,0 @@
1
- import { Buffer } from 'node:buffer';
2
-
3
- var __defProp = Object.defineProperty;
4
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
- const formatITerm2FileProperties = /* @__PURE__ */ __name((properties) => {
6
- const options = [];
7
- if (properties.name) {
8
- options.push(`name=${properties.name}`);
9
- }
10
- if (properties.size !== void 0) {
11
- options.push(`size=${properties.size}`);
12
- }
13
- if (properties.width !== void 0) {
14
- options.push(`width=${properties.width.toString()}`);
15
- }
16
- if (properties.height !== void 0) {
17
- options.push(`height=${properties.height.toString()}`);
18
- }
19
- if (properties.ignoreAspectRatio) {
20
- options.push("preserveAspectRatio=0");
21
- }
22
- if (properties.inline) {
23
- options.push("inline=1");
24
- }
25
- if (properties.doNotMoveCursor) {
26
- options.push("doNotMoveCursor=1");
27
- }
28
- return options.join(";");
29
- }, "formatITerm2FileProperties");
30
- class ITerm2File {
31
- static {
32
- __name(this, "ITerm2File");
33
- }
34
- fileProps;
35
- /**
36
- * Constructs an `ITerm2File` payload object.
37
- * @param properties An object containing properties for the file/image, as defined by {@link ITerm2FileProps}.
38
- * The `name` property within `props` should be pre-Base64 encoded by the caller if it might
39
- * contain special characters (like `;`, `=`, or non-ASCII characters).
40
- * If `fileData` is provided, `props.content` will be overridden, and `props.size` will be
41
- * set from `fileData.byteLength` if not already present in `props`.
42
- * @param fileData (Optional) A `Uint8Array` containing the raw file data. If provided, this data will be
43
- * Base64 encoded and used as the `content` of the file transfer. The `size` property
44
- * will also be automatically set from `fileData.byteLength` if not specified in `props`.
45
- */
46
- constructor(properties, fileData) {
47
- this.fileProps = { ...properties };
48
- if (fileData) {
49
- if (fileData.byteLength > 10 * 1024 * 1024) {
50
- throw new Error("File size exceeds maximum limit of 10MB");
51
- }
52
- this.fileProps.content = Buffer.from(fileData).toString("base64");
53
- if (this.fileProps.size === void 0) {
54
- this.fileProps.size = fileData.byteLength;
55
- }
56
- if (this.fileProps.size !== fileData.byteLength) {
57
- throw new Error("File size property doesn't match actual data length");
58
- }
59
- }
60
- }
61
- /**
62
- * Converts the file properties and its content (if any) into the string payload
63
- * suitable for the iTerm2 `File=` command.
64
- * @returns The string payload (e.g., `"File=name=...;size=...:BASE64_CONTENT"` or `"File=name=...;size=..."`).
65
- */
66
- toString() {
67
- let s = "File=";
68
- s += formatITerm2FileProperties(this.fileProps);
69
- if (this.fileProps.content !== void 0) {
70
- s += `:${this.fileProps.content}`;
71
- }
72
- return s;
73
- }
74
- }
75
- class ITerm2FileEnd {
76
- static {
77
- __name(this, "ITerm2FileEnd");
78
- }
79
- /**
80
- * Generates the string payload for the iTerm2 `FileEnd` command.
81
- * @returns The string `"FileEnd"`.
82
- */
83
- // eslint-disable-next-line class-methods-use-this
84
- toString() {
85
- return "FileEnd";
86
- }
87
- }
88
- class ITerm2FilePart {
89
- /**
90
- * Constructs an `ITerm2FilePart` payload object.
91
- * @param base64Chunk A string containing a Base64 encoded chunk of the file data.
92
- * The caller is responsible for chunking the file and Base64 encoding each chunk.
93
- */
94
- constructor(base64Chunk) {
95
- this.base64Chunk = base64Chunk;
96
- }
97
- static {
98
- __name(this, "ITerm2FilePart");
99
- }
100
- /**
101
- * Converts the Base64 encoded chunk into the string payload suitable for the iTerm2 `FilePart=` command.
102
- * @returns The string payload (e.g., `"FilePart=U09NRURBVEE="`).
103
- */
104
- toString() {
105
- return `FilePart=${this.base64Chunk}`;
106
- }
107
- }
108
- class ITerm2MultipartFileStart {
109
- /**
110
- * Constructs an `ITerm2MultipartFileStart` payload object.
111
- * @param properties Properties for the multipart file (e.g., `name`, `size`). Content is not part of this command.
112
- * The `name` property within `props` should be pre-Base64 encoded by the caller if it might
113
- * contain special characters.
114
- */
115
- constructor(properties) {
116
- this.properties = properties;
117
- }
118
- static {
119
- __name(this, "ITerm2MultipartFileStart");
120
- }
121
- /**
122
- * Converts the file properties into the string payload suitable for the iTerm2 `MultipartFile=` command.
123
- * @returns The string payload (e.g., `"MultipartFile=name=...;size=..."`).
124
- */
125
- toString() {
126
- return `MultipartFile=${formatITerm2FileProperties(this.properties)}`;
127
- }
128
- }
129
-
130
- export { ITerm2File, ITerm2FileEnd, ITerm2FilePart, ITerm2MultipartFileStart };
@@ -1,17 +0,0 @@
1
- 'use strict';
2
-
3
- const ESC = "\x1B";
4
- const CSI = `${ESC}[`;
5
- const OSC = "\x1B]";
6
- const BEL = "\x07";
7
- const SEP = ";";
8
- const DCS = `${ESC}P`;
9
- const ST = `${ESC}\\`;
10
-
11
- exports.BEL = BEL;
12
- exports.CSI = CSI;
13
- exports.DCS = DCS;
14
- exports.ESC = ESC;
15
- exports.OSC = OSC;
16
- exports.SEP = SEP;
17
- exports.ST = ST;
@@ -1,9 +0,0 @@
1
- const ESC = "\x1B";
2
- const CSI = `${ESC}[`;
3
- const OSC = "\x1B]";
4
- const BEL = "\x07";
5
- const SEP = ";";
6
- const DCS = `${ESC}P`;
7
- const ST = `${ESC}\\`;
8
-
9
- export { BEL as B, CSI as C, DCS as D, ESC as E, OSC as O, SEP as S, ST as a };