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

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 +12 -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 +1 -46
package/dist/mode.js ADDED
@@ -0,0 +1 @@
1
+ var S=Object.defineProperty;var i=(o,M)=>S(o,"name",{value:M,configurable:!0});import{C as e}from"./packem_shared/constants-D12jy2Zh.js";var p=Object.defineProperty,d=i((o,M)=>p(o,"name",{value:M,configurable:!0}),"s");class h{static{i(this,"g")}static{d(this,"AnsiModeImpl")}code;isDecMode=!1;constructor(M){this.code=M}}class g{static{i(this,"u")}static{d(this,"DecModeImpl")}code;isDecMode=!0;constructor(M){this.code=M}}const R=d((o,...M)=>{if(M.length===0)return"";const r=o?"l":"h";if(M.length===1){const s=M[0];let l=e;return s.isDecMode&&(l+="?"),l+s.code+r}const u=M.filter(s=>!s.isDecMode).map(s=>s.code),a=M.filter(s=>s.isDecMode).map(s=>s.code);let n="";return u.length>0&&(n+=`${e}${u.join(";")}${r}`),a.length>0&&(n+=`${e}?${a.join(";")}${r}`),n},"generateModeSequence");var E=(o=>(o[o.NotRecognized=0]="NotRecognized",o[o.PermanentlyReset=4]="PermanentlyReset",o[o.PermanentlySet=3]="PermanentlySet",o[o.Reset=2]="Reset",o[o.Set=1]="Set",o))(E||{});const Q=d(o=>o===0,"isModeNotRecognized"),J=d(o=>o===1||o===3,"isModeSet"),V=d(o=>o===2||o===4,"isModeReset"),Y=d(o=>o===3,"isModePermanentlySet"),Z=d(o=>o===4,"isModePermanentlyReset"),$=d(o=>new h(o),"createAnsiMode"),t=d(o=>new g(o),"createDecMode"),C=d((...o)=>R(!1,...o),"setMode"),_=C,q=d((...o)=>R(!0,...o),"resetMode"),ee=q,y=d(o=>{let M=e;return o.isDecMode&&(M+="?"),`${M+o.code}$p`},"requestMode"),oe=y,v=d((o,M)=>{let r=M;(M<0||M>4)&&(r=0);let u=e;return o.isDecMode&&(u+="?"),`${u}${o.code};${r}$y`},"reportMode"),te=v,D=$(2),Me=D,de=`${e}2h`,se=`${e}2l`,re=`${e}2$p`,x=$(4),ue=x,$e=`${e}4h`,ie=`${e}4l`,ne=`${e}4$p`,m=$(8),ae=m,le=`${e}8h`,Re=`${e}8l`,ce=`${e}8$p`,c=$(12),Se=c,pe=c,A=`${e}12h`,B=`${e}12l`,L=`${e}12$p`,he=A,ge=B,Ee=L,f=$(20),Ce=f,qe=`${e}20h`,ye=`${e}20l`,ve=`${e}20$p`,K=t(1),De=K,xe=`${e}?1h`,me=`${e}?1l`,Ae=`${e}?1$p`,N=t(6),Be=N,Le=`${e}?6h`,fe=`${e}?6l`,Ke=`${e}?6$p`,P=t(7),Ne=P,Pe=`${e}?7h`,Ie=`${e}?7l`,be=`${e}?7$p`,ke=t(9),ze=`${e}?9h`,Ue=`${e}?9l`,we=`${e}?9$p`,I=t(25),Oe=I,b=`${e}?25h`,k=`${e}?25l`,Fe=`${e}?25$p`,We=b,Ge=k,z=t(66),He=z,Te=`${e}?66h`,Xe=`${e}?66l`,je=`${e}?66$p`,U=t(67),Qe=U,Je=`${e}?67h`,Ve=`${e}?67l`,Ye=`${e}?67$p`,w=t(69),Ze=w,_e=`${e}?69h`,eo=`${e}?69l`,oo=`${e}?69$p`,to=t(1e3),Mo=`${e}?1000h`,so=`${e}?1000l`,ro=`${e}?1000$p`,uo=t(1001),$o=`${e}?1001h`,io=`${e}?1001l`,no=`${e}?1001$p`,ao=t(1002),lo=`${e}?1002h`,Ro=`${e}?1002l`,co=`${e}?1002$p`,So=t(1003),po=`${e}?1003h`,ho=`${e}?1003l`,go=`${e}?1003$p`,O=t(1004),Eo=`${e}?1004h`,Co=`${e}?1004l`,qo=`${e}?1004$p`,yo=t(1005),vo=`${e}?1005h`,Do=`${e}?1005l`,xo=`${e}?1005$p`,F=t(1006),mo=`${e}?1006h`,Ao=`${e}?1006l`,Bo=`${e}?1006$p`,Lo=t(1015),fo=`${e}?1015h`,Ko=`${e}?1015l`,No=`${e}?1015$p`,Po=t(1016),Io=`${e}?1016h`,bo=`${e}?1016l`,ko=`${e}?1016$p`,zo=F,Uo=O,wo=t(1035),Oo=`${e}?1035h`,Fo=`${e}?1035l`,Wo=`${e}?1035$p`,Go=t(1047),Ho=`${e}?1047h`,To=`${e}?1047l`,Xo=`${e}?1047$p`,jo=t(1048),Qo=`${e}?1048h`,Jo=`${e}?1048l`,Vo=`${e}?1048$p`,Yo=t(1049),Zo=`${e}?1049h`,_o=`${e}?1049l`,et=`${e}?1049$p`,ot=t(2004),tt=`${e}?2004h`,Mt=`${e}?2004l`,dt=`${e}?2004$p`,st=t(2026),rt=`${e}?2026h`,ut=`${e}?2026l`,$t=`${e}?2026$p`,W=t(2027),G=`${e}?2027h`,H=`${e}?2027l`,T=`${e}?2027$p`,it=W,nt=G,at=H,lt=T,Rt=t(9001),ct=`${e}?9001h`,St=`${e}?9001l`,pt=`${e}?9001$p`,ht=t(2031),gt=`${e}?2031h`,Et=`${e}?2031l`,Ct=`${e}?2031$p`,qt=t(2048),yt=`${e}?2048h`,vt=`${e}?2048l`,Dt=`${e}?2048$p`;export{Go as AltScreenMode,Yo as AltScreenSaveCursorMode,So as AnyEventMouseMode,P as AutoWrapMode,ae as BDSM,U as BackarrowKeyMode,m as BiDirectionalSupportMode,ot as BracketedPasteMode,ao as ButtonEventMouseMode,K as CursorKeysMode,Ne as DECAWM,Qe as DECBKM,De as DECCKM,Ze as DECLRMM,He as DECNKM,Be as DECOM,te as DECRPM,oe as DECRQM,Oe as DECTCEM,wo as DisableModifiersMode,O as FocusEventMode,it as GraphemeClusteringMode,Ge as HideCursor,uo as HighlightMouseMode,ue as IRM,qt as InBandResizeMode,x as InsertReplaceMode,Me as KAM,D as KeyboardActionMode,Ce as LNM,w as LeftRightMarginMode,ht as LightDarkMode,f as LineFeedNewLineMode,Se as LocalEchoMode,E as ModeSetting,to as NormalMouseMode,z as NumericKeypadMode,N as OriginMode,ee as RM,Xo as RequestAltScreenMode,et as RequestAltScreenSaveCursorMode,go as RequestAnyEventMouseMode,be as RequestAutoWrapMode,Ye as RequestBackarrowKeyMode,ce as RequestBiDirectionalSupportMode,dt as RequestBracketedPasteMode,co as RequestButtonEventMouseMode,Ae as RequestCursorKeysMode,Wo as RequestDisableModifiersMode,qo as RequestFocusEventMode,lt as RequestGraphemeClusteringMode,no as RequestHighlightMouseMode,Dt as RequestInBandResizeMode,ne as RequestInsertReplaceMode,re as RequestKeyboardActionMode,oo as RequestLeftRightMarginMode,Ct as RequestLightDarkMode,ve as RequestLineFeedNewLineMode,Ee as RequestLocalEchoMode,ro as RequestNormalMouseMode,je as RequestNumericKeypadMode,Ke as RequestOriginMode,Vo as RequestSaveCursorMode,L as RequestSendReceiveMode,Bo as RequestSgrExtMouseMode,ko as RequestSgrPixelExtMouseMode,$t as RequestSynchronizedOutputMode,Fe as RequestTextCursorEnableMode,T as RequestUnicodeCoreMode,No as RequestUrxvtExtMouseMode,xo as RequestUtf8ExtMouseMode,pt as RequestWin32InputMode,we as RequestX10MouseMode,To as ResetAltScreenMode,_o as ResetAltScreenSaveCursorMode,ho as ResetAnyEventMouseMode,Ie as ResetAutoWrapMode,Ve as ResetBackarrowKeyMode,Re as ResetBiDirectionalSupportMode,Mt as ResetBracketedPasteMode,Ro as ResetButtonEventMouseMode,me as ResetCursorKeysMode,Fo as ResetDisableModifiersMode,Co as ResetFocusEventMode,at as ResetGraphemeClusteringMode,io as ResetHighlightMouseMode,vt as ResetInBandResizeMode,ie as ResetInsertReplaceMode,se as ResetKeyboardActionMode,eo as ResetLeftRightMarginMode,Et as ResetLightDarkMode,ye as ResetLineFeedNewLineMode,ge as ResetLocalEchoMode,so as ResetNormalMouseMode,Xe as ResetNumericKeypadMode,fe as ResetOriginMode,Jo as ResetSaveCursorMode,B as ResetSendReceiveMode,Ao as ResetSgrExtMouseMode,bo as ResetSgrPixelExtMouseMode,ut as ResetSynchronizedOutputMode,k as ResetTextCursorEnableMode,H as ResetUnicodeCoreMode,Ko as ResetUrxvtExtMouseMode,Do as ResetUtf8ExtMouseMode,St as ResetWin32InputMode,Ue as ResetX10MouseMode,zo as SGRMouseMode,_ as SM,pe as SRM,jo as SaveCursorMode,Uo as SendFocusEventsMode,c as SendReceiveMode,Ho as SetAltScreenMode,Zo as SetAltScreenSaveCursorMode,po as SetAnyEventMouseMode,Pe as SetAutoWrapMode,Je as SetBackarrowKeyMode,le as SetBiDirectionalSupportMode,tt as SetBracketedPasteMode,lo as SetButtonEventMouseMode,xe as SetCursorKeysMode,Oo as SetDisableModifiersMode,Eo as SetFocusEventMode,nt as SetGraphemeClusteringMode,$o as SetHighlightMouseMode,yt as SetInBandResizeMode,$e as SetInsertReplaceMode,de as SetKeyboardActionMode,_e as SetLeftRightMarginMode,gt as SetLightDarkMode,qe as SetLineFeedNewLineMode,he as SetLocalEchoMode,Mo as SetNormalMouseMode,Te as SetNumericKeypadMode,Le as SetOriginMode,Qo as SetSaveCursorMode,A as SetSendReceiveMode,mo as SetSgrExtMouseMode,Io as SetSgrPixelExtMouseMode,rt as SetSynchronizedOutputMode,b as SetTextCursorEnableMode,G as SetUnicodeCoreMode,fo as SetUrxvtExtMouseMode,vo as SetUtf8ExtMouseMode,ct as SetWin32InputMode,ze as SetX10MouseMode,F as SgrExtMouseMode,Po as SgrPixelExtMouseMode,We as ShowCursor,st as SynchronizedOutputMode,I as TextCursorEnableMode,W as UnicodeCoreMode,Lo as UrxvtExtMouseMode,yo as Utf8ExtMouseMode,Rt as Win32InputMode,ke as X10MouseMode,$ as createAnsiMode,t as createDecMode,Q as isModeNotRecognized,Z as isModePermanentlyReset,Y as isModePermanentlySet,V as isModeReset,J as isModeSet,v as reportMode,y as requestMode,q as resetMode,C as setMode};
@@ -0,0 +1,230 @@
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.js ADDED
@@ -0,0 +1 @@
1
+ var a=Object.defineProperty;var l=(e,u)=>a(e,"name",{value:u,configurable:!0});import{E as n}from"./packem_shared/constants-D12jy2Zh.js";var B=Object.defineProperty,E=l((e,u)=>B(e,"name",{value:u,configurable:!0}),"s");const $=4,_=8,c=16,M=32,N=64,O=128,b=3,r=32,t={BACKWARD:8,BUTTON_1:1,BUTTON_2:2,BUTTON_3:3,BUTTON_4:4,BUTTON_5:5,BUTTON_6:6,BUTTON_7:7,BUTTON_8:8,BUTTON_9:9,BUTTON_10:10,BUTTON_11:11,FORWARD:9,LEFT:1,MIDDLE:2,NONE:0,RELEASE:0,RIGHT:3,WHEEL_DOWN:5,WHEEL_LEFT:6,WHEEL_RIGHT:7,WHEEL_UP:4},S=E((e,u,s={})=>{let o;if(e===t.RELEASE)o=b;else if(e>=t.LEFT&&e<=t.RIGHT)o=e-t.LEFT;else if(e>=t.WHEEL_UP&&e<=t.WHEEL_RIGHT)o=e-t.WHEEL_UP,o|=N;else if(e>=t.BACKWARD&&e<=t.BUTTON_11)o=e-t.BACKWARD,o|=O;else return 255;return s.shift&&(o|=$),s.alt&&(o|=_),s.ctrl&&(o|=c),u&&(o|=M),o},"encodeMouseButtonByte"),f=E((e,u,s)=>{if(e===255)return"";const o=String.fromCodePoint(e+r),T=String.fromCodePoint(u+1+r),i=String.fromCodePoint(s+1+r);return`${n}[M${o}${T}${i}`},"mouseX10Sequence"),m=E((e,u,s,o)=>{if(e===255)return"";const T=o?"m":"M";return`${n}[<${e};${u+1};${s+1}${T}`},"mouseSgrSequence"),d=`${n}[?9h`,W=`${n}[?9l`,A=`${n}[?1000h`,H=`${n}[?1000l`,R=`${n}[?1002h`,g=`${n}[?1002l`,h=`${n}[?1003h`,v=`${n}[?1003l`,C=`${n}[?1006h`,D=`${n}[?1006l`,F=`${n}[?1004h`,P=`${n}[?1004l`;export{t as MouseButton,v as disableAnyEventMouse,g as disableButtonEventMouse,P as disableFocusTracking,H as disableNormalMouse,D as disableSgrMouse,W as disableX10Mouse,h as enableAnyEventMouse,R as enableButtonEventMouse,F as enableFocusTracking,A as enableNormalMouse,C as enableSgrMouse,d as enableX10Mouse,S as encodeMouseButtonByte,m as mouseSgrSequence,f as mouseX10Sequence};
@@ -0,0 +1 @@
1
+ var l=Object.defineProperty;var r=(e,t)=>l(e,"name",{value:t,configurable:!0});var n=Object.defineProperty,i=r((e,t)=>n(e,"name",{value:t,configurable:!0}),"e");const o="auto",c=i(e=>e.toString(),"it2Cells"),s=i(e=>`${e}px`,"it2Pixels"),P=i(e=>`${e}%`,"it2Percent");export{o as IT2_AUTO,c as it2Cells,P as it2Percent,s as it2Pixels};
@@ -0,0 +1 @@
1
+ var l=Object.defineProperty;var r=(t,e)=>l(t,"name",{value:e,configurable:!0});import{createRequire as a}from"node:module";const h=a(import.meta.url),s=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,u=r(t=>{if(typeof s<"u"&&s.versions&&s.versions.node){const[e,i]=s.versions.node.split(".").map(Number);if(e>22||e===22&&i>=3||e===20&&i>=16)return s.getBuiltinModule(t)}return h(t)},"__cjs_getBuiltinModule"),{Buffer:c}=u("node:buffer");var p=Object.defineProperty,o=r((t,e)=>p(t,"name",{value:e,configurable:!0}),"t");const n=o(t=>{const e=[];return t.name&&e.push(`name=${t.name}`),t.size!==void 0&&e.push(`size=${t.size}`),t.width!==void 0&&e.push(`width=${t.width.toString()}`),t.height!==void 0&&e.push(`height=${t.height.toString()}`),t.ignoreAspectRatio&&e.push("preserveAspectRatio=0"),t.inline&&e.push("inline=1"),t.doNotMoveCursor&&e.push("doNotMoveCursor=1"),e.join(";")},"formatITerm2FileProperties");class m{static{r(this,"ITerm2File")}static{o(this,"ITerm2File")}fileProps;constructor(e,i){if(this.fileProps={...e},i){if(i.byteLength>10*1024*1024)throw new Error("File size exceeds maximum limit of 10MB");if(this.fileProps.content=c.from(i).toString("base64"),this.fileProps.size===void 0&&(this.fileProps.size=i.byteLength),this.fileProps.size!==i.byteLength)throw new Error("File size property doesn't match actual data length")}}toString(){let e="File=";return e+=n(this.fileProps),this.fileProps.content!==void 0&&(e+=`:${this.fileProps.content}`),e}}class g{static{r(this,"ITerm2FileEnd")}static{o(this,"ITerm2FileEnd")}toString(){return"FileEnd"}}class F{static{r(this,"ITerm2FilePart")}constructor(e){this.base64Chunk=e}static{o(this,"ITerm2FilePart")}toString(){return`FilePart=${this.base64Chunk}`}}class P{static{r(this,"ITerm2MultipartFileStart")}constructor(e){this.properties=e}static{o(this,"ITerm2MultipartFileStart")}toString(){return`MultipartFile=${n(this.properties)}`}}export{m as ITerm2File,g as ITerm2FileEnd,F as ITerm2FilePart,P as ITerm2MultipartFileStart};
@@ -0,0 +1 @@
1
+ const a="\x1B",s="\x1B[",x="\x1B]",B="\x07",S=";",C="\x1BP",E="\x1B\\";export{B,s as C,C as D,a as E,x as O,S,E as a};
@@ -0,0 +1 @@
1
+ var l=Object.defineProperty;var n=(r,o)=>l(r,"name",{value:o,configurable:!0});import{C as s,S as u,E as c}from"./constants-D12jy2Zh.js";import"./restoreCursor-CHy0jZuu.js";const i=globalThis?.window?.document!==void 0,t=!i&&process.env.TERM_PROGRAM==="Apple_Terminal",T=!i&&(process.platform==="win32"||/^(?:msys|cygwin)$/.test(process.env.OSTYPE));var $=Object.defineProperty,a=n((r,o)=>$(r,"name",{value:o,configurable:!0}),"n");const S=`${c}7`,d=`${c}8`,w=`${s}A`,U=`${s}B`,k=`${s}C`,p=`${s}D`,v=`${s}6n`,A=`${s}?6n`,R=a((r=1)=>`${s+r}D`,"cursorBackward"),D=a((r=1)=>`${s+r}B`,"cursorDown"),y=a((r=1)=>`${s+r}C`,"cursorForward"),b=`${s}?25l`,g=`${s}G`,m=a((r=1)=>R(r),"cursorLeft"),C=a((r=1)=>`${s+r}G`,"cursorHorizontalAbsolute"),P=a((r,o)=>{let e="";return r<0?e+=`${s+-r}D`:r>0&&(e+=`${s+r}C`),o<0?e+=`${s+-o}A`:o>0&&(e+=`${s+o}B`),e},"cursorMove"),f=a((r=1)=>`${s+r}E`,"cursorNextLine"),H=a((r=1)=>`${s+r}F`,"cursorPreviousLine"),h=t?d:`${c}u`,F=t?S:`${c}s`,I=`${s}?25h`,L=a((r,o)=>o===void 0?C(r+1):`${s+(o+1)+u+(r+1)}H`,"cursorTo"),N=a((r,o)=>o===void 0?`${s+r}H`:`${s+r+u+o}H`,"cursorPosition"),z=a((r=1)=>`${s+r}I`,"cursorHorizontalForwardTab"),x=a((r=1)=>`${s+r}Z`,"cursorBackwardTab"),M=a((r=1)=>`${s+r}X`,"eraseCharacter"),W=a((r=1)=>`${s+r}d`,"cursorVerticalAbsolute"),G=a((r=1)=>`${s+r}A`,"cursorUp");var B=(r=>(r[r.BlinkingBar=5]="BlinkingBar",r[r.BlinkingBlock=1]="BlinkingBlock",r[r.BlinkingUnderline=3]="BlinkingUnderline",r[r.Default=0]="Default",r[r.SteadyBar=6]="SteadyBar",r[r.SteadyBlock=2]="SteadyBlock",r[r.SteadyUnderline=4]="SteadyUnderline",r))(B||{});const V=a(r=>`${s+r} q`,"setCursorStyle");export{T as A,B,p as C,v as R,S,U as a,k as b,w as c,R as d,x as e,D as f,y as g,b as h,C as i,z as j,m as k,P as l,f as m,N as n,H as o,h as p,F as q,I as r,L as s,g as t,G as u,W as v,M as w,A as x,d as y,V as z};
@@ -0,0 +1 @@
1
+ var o=Object.defineProperty;var n=(r,e)=>o(r,"name",{value:e,configurable:!0});import{O as t,B as s}from"./constants-D12jy2Zh.js";var $=Object.defineProperty,a=n((r,e)=>$(r,"name",{value:e,configurable:!0}),"n");const B=`${t}9;4;0${s}`,i=a(r=>{const e=Math.min(Math.max(0,r),100);return`${t}9;4;1;${e}${s}`},"setProgressBar"),P=a(r=>{const e=Math.min(Math.max(0,r),100);return`${t}9;4;2;${e}${s}`},"setErrorProgressBar"),c=`${t}9;4;3${s}`,h=a(r=>{const e=Math.min(Math.max(0,r),100);return`${t}9;4;4;${e}${s}`},"setWarningProgressBar");export{B as resetProgressBar,P as setErrorProgressBar,c as setIndeterminateProgressBar,i as setProgressBar,h as setWarningProgressBar};
@@ -0,0 +1,2 @@
1
+ var _=Object.defineProperty;var s=(e,t)=>_(e,"name",{value:t,configurable:!0});import{createRequire as E}from"node:module";const B=E(import.meta.url),P=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,f=P;var I=Object.defineProperty,l=s((e,t)=>I(e,"name",{value:t,configurable:!0}),"r$2");const T=l((e,t,i,r)=>{if(i==="length"||i==="prototype"||i==="arguments"||i==="caller")return;const n=Object.getOwnPropertyDescriptor(e,i),o=Object.getOwnPropertyDescriptor(t,i);!v(n,o)&&r||Object.defineProperty(e,i,o)},"copyProperty"),v=l(function(e,t){return e===void 0||e.configurable||e.writable===t.writable&&e.enumerable===t.enumerable&&e.configurable===t.configurable&&(e.writable||e.value===t.value)},"canCopyProperty"),G=l((e,t)=>{const i=Object.getPrototypeOf(t);i!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,i)},"changePrototype"),j=l((e,t)=>`/* Wrapped ${e}*/
2
+ ${t}`,"wrappedToString"),$=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),L=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),R=l((e,t,i)=>{const r=i===""?"":`with ${i.trim()}() `,n=j.bind(null,r,t.toString());Object.defineProperty(n,"name",L);const{writable:o,enumerable:u,configurable:m}=$;Object.defineProperty(e,"toString",{value:n,writable:o,enumerable:u,configurable:m})},"changeToString");function S(e,t,{ignoreNonConfigurable:i=!1}={}){const{name:r}=e;for(const n of Reflect.ownKeys(t))T(e,t,n,i);return G(e,t),R(e,t,r),e}s(S,"P");l(S,"mimicFunction");var C=Object.defineProperty,b=s((e,t)=>C(e,"name",{value:t,configurable:!0}),"a$1");const p=new WeakMap,w=b((e,t={})=>{if(typeof e!="function")throw new TypeError("Expected a function");let i,r=0;const n=e.displayName||e.name||"<anonymous>",o=b(function(...u){if(p.set(o,++r),r===1)i=e.apply(this,u),e=void 0;else if(t.throw===!0)throw new Error(`Function \`${n}\` can only be called once`);return i},"onetime");return S(o,e),p.set(o,r),o},"onetime");w.callCount=e=>{if(!p.has(e))throw new Error(`The given function \`${e.name}\` is not wrapped by the \`onetime\` package`);return p.get(e)};const a=[];a.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&a.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&a.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var F=Object.defineProperty,c=s((e,t)=>F(e,"name",{value:t,configurable:!0}),"r$1");const h=c(e=>!!e&&!0&&typeof e.removeListener=="function"&&typeof e.emit=="function"&&typeof e.reallyExit=="function"&&typeof e.listeners=="function"&&typeof e.kill=="function"&&typeof e.pid=="number"&&typeof e.on=="function","processOk"),d=Symbol.for("signal-exit emitter"),g=globalThis,k=Object.defineProperty.bind(Object);class U{static{s(this,"y")}static{c(this,"Emitter")}emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(g[d])return g[d];k(g,d,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(t,i){this.listeners[t].push(i)}removeListener(t,i){const r=this.listeners[t],n=r.indexOf(i);n!==-1&&(n===0&&r.length===1?r.length=0:r.splice(n,1))}emit(t,i,r){if(this.emitted[t])return!1;this.emitted[t]=!0;let n=!1;for(const o of this.listeners[t])n=o(i,r)===!0||n;return t==="exit"&&(n=this.emit("afterExit",i,r)||n),n}}class O{static{s(this,"c")}static{c(this,"SignalExitBase")}}const M=c(e=>({onExit(t,i){return e.onExit(t,i)},load(){return e.load()},unload(){return e.unload()}}),"signalExitWrap");class A extends O{static{s(this,"_")}static{c(this,"SignalExitFallback")}onExit(){return()=>{}}load(){}unload(){}}class D extends O{static{s(this,"p")}static{c(this,"SignalExit")}#s=y.platform==="win32"?"SIGINT":"SIGHUP";#e=new U;#t;#n;#o;#r={};#i=!1;constructor(t){super(),this.#t=t,this.#r={};for(const i of a)this.#r[i]=()=>{const r=this.#t.listeners(i);let{count:n}=this.#e;const o=t;if(typeof o.__signal_exit_emitter__=="object"&&typeof o.__signal_exit_emitter__.count=="number"&&(n+=o.__signal_exit_emitter__.count),r.length===n){this.unload();const u=this.#e.emit("exit",null,i),m=i==="SIGHUP"?this.#s:i;u||t.kill(t.pid,m)}};this.#o=t.reallyExit,this.#n=t.emit}onExit(t,i){if(!h(this.#t))return()=>{};this.#i===!1&&this.load();const r=i?.alwaysLast?"afterExit":"exit";return this.#e.on(r,t),()=>{this.#e.removeListener(r,t),this.#e.listeners.exit.length===0&&this.#e.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#i){this.#i=!0,this.#e.count+=1;for(const t of a)try{const i=this.#r[t];i&&this.#t.on(t,i)}catch{}this.#t.emit=(t,...i)=>this.#l(t,...i),this.#t.reallyExit=t=>this.#a(t)}}unload(){this.#i&&(this.#i=!1,a.forEach(t=>{const i=this.#r[t];if(!i)throw new Error("Listener not defined for signal: "+t);try{this.#t.removeListener(t,i)}catch{}}),this.#t.emit=this.#n,this.#t.reallyExit=this.#o,this.#e.count-=1)}#a(t){return h(this.#t)?(this.#t.exitCode=t||0,this.#e.emit("exit",this.#t.exitCode,null),this.#o.call(this.#t,this.#t.exitCode)):0}#l(t,...i){const r=this.#n;if(t==="exit"&&h(this.#t)){typeof i[0]=="number"&&(this.#t.exitCode=i[0]);const n=r.call(this.#t,t,...i);return this.#e.emit("exit",this.#t.exitCode,null),n}else return r.call(this.#t,t,...i)}}const y=globalThis.process,{onExit:N}=M(h(y)?new D(y):new A),x=f.stderr.isTTY?f.stderr:f.stdout.isTTY?f.stdout:void 0,H=x?w(()=>{N(()=>{x.write("\x1B[?25h")},{alwaysLast:!0})}):()=>{};export{H as default};
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Default value for the `limit` parameter in {@link screenPassthrough}, indicating no chunking.
3
+ * When this value is used (or any value &lt;= 0), the passthrough sequence is not split into smaller chunks.
4
+ */
5
+ export declare const SCREEN_MAX_LEN_DEFAULT: number;
6
+ /**
7
+ * A typical limit for string sequences in GNU Screen (e.g., 768 bytes).
8
+ * This constant can be used as a practical value for the `limit` parameter in {@link screenPassthrough}
9
+ * to avoid issues with Screen's internal buffers, though the function itself defaults to no limit.
10
+ * It's provided for informational purposes and as a suggested practical chunking limit.
11
+ */
12
+ export declare const SCREEN_TYPICAL_LIMIT: number;
13
+ /**
14
+ * Wraps a given ANSI escape sequence in a DCS (Device Control String) passthrough sequence
15
+ * specifically for GNU Screen. This allows raw escape sequences to be sent to the
16
+ * terminal emulator that is hosting Screen, bypassing Screen's own interpretation.
17
+ *
18
+ * The basic format is: `DCS &lt;data> ST` (where `DCS` is `ESC P` and `ST` is `ESC \`).
19
+ *
20
+ * GNU Screen has limitations on the length of string sequences it can handle (often around 768 bytes).
21
+ * This function can optionally chunk the input `sequence` into smaller parts, each wrapped
22
+ * in its own `DCS...ST` sequence, to work around this limitation.
23
+ * @param sequence The ANSI escape sequence string to be wrapped.
24
+ * @param limit The maximum length for each chunk of the `sequence` before it's wrapped.
25
+ * If `0` or a negative number, the sequence is not chunked. Defaults to {@link SCREEN_MAX_LEN_DEFAULT} (0).
26
+ * Consider using {@link SCREEN_TYPICAL_LIMIT} (768) for practical chunking with Screen.
27
+ * @returns The wrapped string, possibly chunked into multiple `DCS...ST` sequences if `limit` is positive and the `sequence` exceeds it.
28
+ * @see {@link https://www.gnu.org/software/screen/manual/screen.html#String-Escapes} GNU Screen Manual - String Escapes.
29
+ * @example
30
+ * ```typescript
31
+ * import { screenPassthrough, SCREEN_TYPICAL_LIMIT } from \'@visulima/ansi/passthrough\';
32
+ * import { cursorShow, cursorHide } from \'@visulima/ansi/cursor\';
33
+ *
34
+ * const longSequence = cursorHide + "Some very long output..." + cursorShow;
35
+ *
36
+ * // No chunking (default behavior if sequence is short enough or limit is 0)
37
+ * const passthrough1 = screenPassthrough(cursorHide);
38
+ * console.log(JSON.stringify(passthrough1)); // "\u001bP?25l\u001b\\"
39
+ *
40
+ * // With chunking, assuming SCREEN_TYPICAL_LIMIT is small for demonstration
41
+ * const limitedPassthrough = screenPassthrough(longSequence, 10); // Hypothetical small limit
42
+ * // Example output if longSequence was "0123456789abcde" and limit 10:
43
+ * // "\u001bP0123456789\u001b\\\u001bPabcde\u001b\\"
44
+ * console.log(JSON.stringify(limitedPassthrough));
45
+ * ```
46
+ */
47
+ export declare const screenPassthrough: (sequence: string, limit?: number) => string;
48
+ /**
49
+ * Wraps a given ANSI escape sequence in a special DCS (Device Control String) passthrough sequence
50
+ * designed for tmux (Terminal Multiplexer). This allows raw escape sequences to be sent to the
51
+ * terminal emulator hosting tmux, bypassing tmux's own interpretation.
52
+ *
53
+ * The format is: `DCS tmux ; &lt;escaped-data> ST`
54
+ * (where `DCS` is `ESC P`, and `ST` is `ESC \`).
55
+ *
56
+ * The `&lt;escaped-data>` is the original `sequence` with all occurrences of the ESC character (`\u001B`)
57
+ * doubled (i.e., `ESC` becomes `ESC ESC`).
58
+ *
59
+ * **Note:** For this to work, the tmux option `allow-passthrough` must be enabled (`on`) in the tmux configuration.
60
+ * By default, it might be off.
61
+ * @param sequence The ANSI escape sequence string to be wrapped and properly escaped for tmux.
62
+ * @returns The wrapped and escaped string suitable for tmux passthrough.
63
+ * @see {@link https://github.com/tmux/tmux/wiki/FAQ#what-is-the-passthrough-escape-sequence-and-how-do-i-use-it} Tmux FAQ on Passthrough.
64
+ * @example
65
+ * ```typescript
66
+ * import { tmuxPassthrough } from \'@visulima/ansi/passthrough\';
67
+ * import { cursorShow } from \'@visulima/ansi/cursor\';
68
+ *
69
+ * const originalSequence = cursorShow; // e.g., "\u001b[?25h"
70
+ * const passthrough = tmuxPassthrough(originalSequence);
71
+ *
72
+ * // Expected: "\u001bPtmux;\u001b\u001b[?25h\u001b\\"
73
+ * // (ESC P tmux ; ESC ESC [ ? 2 5 h ESC \)
74
+ * console.log(JSON.stringify(passthrough));
75
+ * ```
76
+ */
77
+ export declare const tmuxPassthrough: (sequence: string) => string;
@@ -0,0 +1 @@
1
+ var g=Object.defineProperty;var l=(e,t)=>g(e,"name",{value:t,configurable:!0});import{a as o,D as a,E as n}from"./packem_shared/constants-D12jy2Zh.js";var c=Object.defineProperty,u=l((e,t)=>c(e,"name",{value:t,configurable:!0}),"o");const E=0,i=768,P=u((e,t=E)=>{let r=a;if(t>0&&e.length>t)for(let s=0;s<e.length;s+=t){const h=Math.min(s+t,e.length);r+=e.slice(s,h),h<e.length&&(r+=o+a)}else r+=e;return r+=o,r},"screenPassthrough"),x=u(e=>{let t="";for(const r of e)t+=r===n?n+n:r;return`${a}tmux;${t}${o}`},"tmuxPassthrough");export{E as SCREEN_MAX_LEN_DEFAULT,i as SCREEN_TYPICAL_LIMIT,P as screenPassthrough,x as tmuxPassthrough};
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Resets the progress bar to its default state (hidden).
3
+ *
4
+ * Sequence: `OSC 9 ; 4 ; 0 BEL`
5
+ * @see {@link https://learn.microsoft.com/en-us/windows/terminal/tutorials/progress-bar-sequences}
6
+ */
7
+ export declare const resetProgressBar: string;
8
+ /**
9
+ * Returns a sequence for setting the progress bar to a specific percentage (0-100) in the "default" state.
10
+ *
11
+ * Sequence: `OSC 9 ; 4 ; 1 ; Percentage BEL`
12
+ * @param percentage The progress percentage (0-100, clamped automatically)
13
+ * @returns The progress bar sequence
14
+ * @see {@link https://learn.microsoft.com/en-us/windows/terminal/tutorials/progress-bar-sequences}
15
+ */
16
+ export declare const setProgressBar: (percentage: number) => string;
17
+ /**
18
+ * Returns a sequence for setting the progress bar to a specific percentage (0-100) in the "Error" state.
19
+ *
20
+ * Sequence: `OSC 9 ; 4 ; 2 ; Percentage BEL`
21
+ * @param percentage The progress percentage (0-100, clamped automatically)
22
+ * @returns The error progress bar sequence
23
+ * @see {@link https://learn.microsoft.com/en-us/windows/terminal/tutorials/progress-bar-sequences}
24
+ */
25
+ export declare const setErrorProgressBar: (percentage: number) => string;
26
+ /**
27
+ * Sets the progress bar to the indeterminate state.
28
+ *
29
+ * Sequence: `OSC 9 ; 4 ; 3 BEL`
30
+ * @see {@link https://learn.microsoft.com/en-us/windows/terminal/tutorials/progress-bar-sequences}
31
+ */
32
+ export declare const setIndeterminateProgressBar: string;
33
+ /**
34
+ * Returns a sequence for setting the progress bar to a specific percentage (0-100) in the "Warning" state.
35
+ *
36
+ * Sequence: `OSC 9 ; 4 ; 4 ; Percentage BEL`
37
+ * @param percentage The progress percentage (0-100, clamped automatically)
38
+ * @returns The warning progress bar sequence
39
+ * @see {@link https://learn.microsoft.com/en-us/windows/terminal/tutorials/progress-bar-sequences}
40
+ */
41
+ export declare const setWarningProgressBar: (percentage: number) => string;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * The ANSI escape sequence for Reset Initial State (RIS).
3
+ * This command attempts to reset the terminal to its power-up state or initial configuration.
4
+ * The exact behavior can vary between terminal emulators, but it typically includes:
5
+ * - Resetting graphic rendition (SGR parameters) to default.
6
+ * - Clearing the screen.
7
+ * - Moving the cursor to the top-left (home position).
8
+ * - Resetting character sets.
9
+ * - Resetting tab stops.
10
+ * - Resetting modes (like DECAWM, DECOM) to their defaults.
11
+ *
12
+ * Sequence: `ESC c`
13
+ *
14
+ * This is a more comprehensive reset than `CSI 0 m` (which only resets SGR) or `CSI 2 J` (which only clears the screen).
15
+ * It is often referred to as a "hard reset".
16
+ * @see {@link https://vt100.net/docs/vt510-rm/RIS.html VT510 RIS Documentation}
17
+ * @see {@link https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Reset} Xterm Control Sequences - Reset
18
+ */
19
+ export declare const RESET_INITIAL_STATE: string;
20
+ /**
21
+ * Alias for {@link RESET_INITIAL_STATE} (Reset Initial State).
22
+ *
23
+ * Provides a shorter name for the RIS sequence `ESC c`.
24
+ * @see {@link RESET_INITIAL_STATE}
25
+ */
26
+ export declare const RIS: string;
package/dist/reset.js ADDED
@@ -0,0 +1 @@
1
+ const I="\x1Bc",T="\x1Bc";export{I as RESET_INITIAL_STATE,T as RIS};