@visulima/ansi 3.0.5 → 4.0.0-alpha.10

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 (48) hide show
  1. package/CHANGELOG.md +170 -0
  2. package/LICENSE.md +1 -1
  3. package/README.md +32 -14
  4. package/dist/alternative-screen.js +8 -1
  5. package/dist/clear.d.ts +1 -1
  6. package/dist/clear.js +10 -1
  7. package/dist/cursor.d.ts +11 -11
  8. package/dist/cursor.js +3 -1
  9. package/dist/erase.d.ts +22 -22
  10. package/dist/erase.js +47 -1
  11. package/dist/hyperlink.js +5 -1
  12. package/dist/image.js +40 -1
  13. package/dist/index.js +26 -1
  14. package/dist/iterm2/iterm2-properties.d.ts +1 -1
  15. package/dist/iterm2/iterm2-sequences.d.ts +4 -4
  16. package/dist/iterm2.js +12 -1
  17. package/dist/mode.d.ts +11 -11
  18. package/dist/mode.js +245 -1
  19. package/dist/mouse.js +106 -1
  20. package/dist/packem_shared/IT2_AUTO-DyYWsxno.js +6 -0
  21. package/dist/packem_shared/ITerm2File-CUZDBk99.js +137 -0
  22. package/dist/packem_shared/constants-CE7WkXh_.js +9 -0
  23. package/dist/packem_shared/cursor-ChpV7cgs.js +72 -0
  24. package/dist/packem_shared/resetProgressBar-D9r2s7eV.js +18 -0
  25. package/dist/packem_shared/restoreCursor-GfYEeJqN.js +323 -0
  26. package/dist/passthrough.js +29 -1
  27. package/dist/reset.js +4 -1
  28. package/dist/screen.js +27 -1
  29. package/dist/scroll.js +18 -1
  30. package/dist/status.d.ts +6 -5
  31. package/dist/status.js +95 -1
  32. package/dist/strip.d.ts +0 -21
  33. package/dist/strip.js +13 -1
  34. package/dist/termcap.d.ts +1 -1
  35. package/dist/termcap.js +25 -1
  36. package/dist/title.d.ts +32 -34
  37. package/dist/title.js +19 -1
  38. package/dist/window-ops.d.ts +55 -55
  39. package/dist/window-ops.js +61 -1
  40. package/dist/xterm.d.ts +3 -3
  41. package/dist/xterm.js +33 -1
  42. package/package.json +6 -3
  43. package/dist/packem_shared/IT2_AUTO-BYrffRAq.js +0 -1
  44. package/dist/packem_shared/ITerm2File-C88DBJC-.js +0 -1
  45. package/dist/packem_shared/constants-D12jy2Zh.js +0 -1
  46. package/dist/packem_shared/cursor-nxpKt8Tn.js +0 -1
  47. package/dist/packem_shared/resetProgressBar-BtBbpWCM.js +0 -1
  48. package/dist/packem_shared/restoreCursor-CHy0jZuu.js +0 -2
package/dist/iterm2.js CHANGED
@@ -1 +1,12 @@
1
- var i=Object.defineProperty;var r=(t,e)=>i(t,"name",{value:e,configurable:!0});import{O as o,B as m}from"./packem_shared/constants-D12jy2Zh.js";import{IT2_AUTO as I,it2Cells as c,it2Percent as s,it2Pixels as S}from"./packem_shared/IT2_AUTO-BYrffRAq.js";import{ITerm2File as g,ITerm2FileEnd as y,ITerm2FilePart as O,ITerm2MultipartFileStart as P}from"./packem_shared/ITerm2File-C88DBJC-.js";var n=Object.defineProperty,a=r((t,e)=>n(t,"name",{value:e,configurable:!0}),"t");const T=a(t=>{if(!t||typeof t.toString!="function"||t.toString===Object.prototype.toString)throw new Error("Invalid payload: must implement IITerm2Payload with a custom toString method");return`${o}1337;${t.toString()}${m}`},"iTerm2");export{I as IT2_AUTO,g as ITerm2File,y as ITerm2FileEnd,O as ITerm2FilePart,P as ITerm2MultipartFileStart,T as iTerm2,c as it2Cells,s as it2Percent,S as it2Pixels};
1
+ import { O as OSC, B as BEL } from './packem_shared/constants-CE7WkXh_.js';
2
+ export { IT2_AUTO, it2Cells, it2Percent, it2Pixels } from './packem_shared/IT2_AUTO-DyYWsxno.js';
3
+ export { ITerm2File, ITerm2FileEnd, ITerm2FilePart, ITerm2MultipartFileStart } from './packem_shared/ITerm2File-CUZDBk99.js';
4
+
5
+ const iTerm2 = (payload) => {
6
+ if (payload.toString === Object.prototype.toString) {
7
+ throw new Error("Invalid payload: must implement IITerm2Payload with a custom toString method");
8
+ }
9
+ return `${OSC}1337;${payload.toString()}${BEL}`;
10
+ };
11
+
12
+ export { iTerm2 };
package/dist/mode.d.ts CHANGED
@@ -14,25 +14,25 @@ export declare enum ModeSetting {
14
14
  */
15
15
  NotRecognized = 0,
16
16
  /**
17
- * Mode is permanently reset and cannot be changed (e.g., by RM or SM sequences).
18
- * (Parameter `Ps = 4` in DECRPM)
19
- */
20
- PermanentlyReset = 4,
21
- /**
22
- * Mode is permanently set and cannot be changed (e.g., by RM or SM sequences).
23
- * (Parameter `Ps = 3` in DECRPM)
17
+ * Mode is currently set.
18
+ * (Parameter `Ps = 1` in DECRPM)
24
19
  */
25
- PermanentlySet = 3,
20
+ Set = 1,
26
21
  /**
27
22
  * Mode is currently reset (not set).
28
23
  * (Parameter `Ps = 2` in DECRPM)
29
24
  */
30
25
  Reset = 2,
31
26
  /**
32
- * Mode is currently set.
33
- * (Parameter `Ps = 1` in DECRPM)
27
+ * Mode is permanently set and cannot be changed (e.g., by RM or SM sequences).
28
+ * (Parameter `Ps = 3` in DECRPM)
29
+ */
30
+ PermanentlySet = 3,
31
+ /**
32
+ * Mode is permanently reset and cannot be changed (e.g., by RM or SM sequences).
33
+ * (Parameter `Ps = 4` in DECRPM)
34
34
  */
35
- Set = 1
35
+ PermanentlyReset = 4
36
36
  }
37
37
  /**
38
38
  * Checks if the reported mode setting indicates that the mode is not recognized by the terminal.
package/dist/mode.js CHANGED
@@ -1 +1,245 @@
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};
1
+ import { C as CSI } from './packem_shared/constants-CE7WkXh_.js';
2
+
3
+ class AnsiModeImpl {
4
+ /** The numeric code of the ANSI mode. */
5
+ code;
6
+ /** For ANSI modes, this is always `false`. */
7
+ isDecMode = false;
8
+ /**
9
+ * Creates an instance of an ANSI mode.
10
+ * @param code The numeric code for the ANSI mode.
11
+ */
12
+ constructor(code) {
13
+ this.code = code;
14
+ }
15
+ }
16
+ class DecModeImpl {
17
+ /** The numeric code of the DEC private mode. */
18
+ code;
19
+ /** For DEC private modes, this is always `true`. */
20
+ isDecMode = true;
21
+ /**
22
+ * Creates an instance of a DEC private mode.
23
+ * @param code The numeric code for the DEC mode.
24
+ */
25
+ constructor(code) {
26
+ this.code = code;
27
+ }
28
+ }
29
+ const generateModeSequence = (reset, ...modes) => {
30
+ if (modes.length === 0) {
31
+ return "";
32
+ }
33
+ const command = reset ? "l" : "h";
34
+ if (modes.length === 1) {
35
+ const mode = modes[0];
36
+ let seq = CSI;
37
+ if (mode.isDecMode) {
38
+ seq += "?";
39
+ }
40
+ return seq + String(mode.code) + command;
41
+ }
42
+ const ansiModes = modes.filter((m) => !m.isDecMode).map((m) => m.code);
43
+ const decModes = modes.filter((m) => m.isDecMode).map((m) => m.code);
44
+ let s = "";
45
+ if (ansiModes.length > 0) {
46
+ s += `${CSI}${ansiModes.join(";")}${command}`;
47
+ }
48
+ if (decModes.length > 0) {
49
+ s += `${CSI}?${decModes.join(";")}${command}`;
50
+ }
51
+ return s;
52
+ };
53
+ var ModeSetting = /* @__PURE__ */ ((ModeSetting2) => {
54
+ ModeSetting2[ModeSetting2["NotRecognized"] = 0] = "NotRecognized";
55
+ ModeSetting2[ModeSetting2["Set"] = 1] = "Set";
56
+ ModeSetting2[ModeSetting2["Reset"] = 2] = "Reset";
57
+ ModeSetting2[ModeSetting2["PermanentlySet"] = 3] = "PermanentlySet";
58
+ ModeSetting2[ModeSetting2["PermanentlyReset"] = 4] = "PermanentlyReset";
59
+ return ModeSetting2;
60
+ })(ModeSetting || {});
61
+ const isModeNotRecognized = (m) => m === 0 /* NotRecognized */;
62
+ const isModeSet = (m) => m === 1 /* Set */ || m === 3 /* PermanentlySet */;
63
+ const isModeReset = (m) => m === 2 /* Reset */ || m === 4 /* PermanentlyReset */;
64
+ const isModePermanentlySet = (m) => m === 3 /* PermanentlySet */;
65
+ const isModePermanentlyReset = (m) => m === 4 /* PermanentlyReset */;
66
+ const createAnsiMode = (code) => new AnsiModeImpl(code);
67
+ const createDecMode = (code) => new DecModeImpl(code);
68
+ const setMode = (...modes) => generateModeSequence(false, ...modes);
69
+ const SM = setMode;
70
+ const resetMode = (...modes) => generateModeSequence(true, ...modes);
71
+ const RM = resetMode;
72
+ const requestMode = (mode) => {
73
+ let seq = CSI;
74
+ if (mode.isDecMode) {
75
+ seq += "?";
76
+ }
77
+ return `${seq}${String(mode.code)}$p`;
78
+ };
79
+ const DECRQM = requestMode;
80
+ const reportMode = (mode, value) => {
81
+ let effectiveValue = value;
82
+ if (value < 0 /* NotRecognized */ || value > 4 /* PermanentlyReset */) {
83
+ effectiveValue = 0 /* NotRecognized */;
84
+ }
85
+ let seq = CSI;
86
+ if (mode.isDecMode) {
87
+ seq += "?";
88
+ }
89
+ return `${seq}${String(mode.code)};${String(effectiveValue)}$y`;
90
+ };
91
+ const DECRPM = reportMode;
92
+ const KeyboardActionMode = createAnsiMode(2);
93
+ const KAM = KeyboardActionMode;
94
+ const SetKeyboardActionMode = `${CSI}2h`;
95
+ const ResetKeyboardActionMode = `${CSI}2l`;
96
+ const RequestKeyboardActionMode = `${CSI}2$p`;
97
+ const InsertReplaceMode = createAnsiMode(4);
98
+ const IRM = InsertReplaceMode;
99
+ const SetInsertReplaceMode = `${CSI}4h`;
100
+ const ResetInsertReplaceMode = `${CSI}4l`;
101
+ const RequestInsertReplaceMode = `${CSI}4$p`;
102
+ const BiDirectionalSupportMode = createAnsiMode(8);
103
+ const BDSM = BiDirectionalSupportMode;
104
+ const SetBiDirectionalSupportMode = `${CSI}8h`;
105
+ const ResetBiDirectionalSupportMode = `${CSI}8l`;
106
+ const RequestBiDirectionalSupportMode = `${CSI}8$p`;
107
+ const SendReceiveMode = createAnsiMode(12);
108
+ const LocalEchoMode = SendReceiveMode;
109
+ const SRM = SendReceiveMode;
110
+ const SetSendReceiveMode = `${CSI}12h`;
111
+ const ResetSendReceiveMode = `${CSI}12l`;
112
+ const RequestSendReceiveMode = `${CSI}12$p`;
113
+ const SetLocalEchoMode = SetSendReceiveMode;
114
+ const ResetLocalEchoMode = ResetSendReceiveMode;
115
+ const RequestLocalEchoMode = RequestSendReceiveMode;
116
+ const LineFeedNewLineMode = createAnsiMode(20);
117
+ const LNM = LineFeedNewLineMode;
118
+ const SetLineFeedNewLineMode = `${CSI}20h`;
119
+ const ResetLineFeedNewLineMode = `${CSI}20l`;
120
+ const RequestLineFeedNewLineMode = `${CSI}20$p`;
121
+ const CursorKeysMode = createDecMode(1);
122
+ const DECCKM = CursorKeysMode;
123
+ const SetCursorKeysMode = `${CSI}?1h`;
124
+ const ResetCursorKeysMode = `${CSI}?1l`;
125
+ const RequestCursorKeysMode = `${CSI}?1$p`;
126
+ const OriginMode = createDecMode(6);
127
+ const DECOM = OriginMode;
128
+ const SetOriginMode = `${CSI}?6h`;
129
+ const ResetOriginMode = `${CSI}?6l`;
130
+ const RequestOriginMode = `${CSI}?6$p`;
131
+ const AutoWrapMode = createDecMode(7);
132
+ const DECAWM = AutoWrapMode;
133
+ const SetAutoWrapMode = `${CSI}?7h`;
134
+ const ResetAutoWrapMode = `${CSI}?7l`;
135
+ const RequestAutoWrapMode = `${CSI}?7$p`;
136
+ const X10MouseMode = createDecMode(9);
137
+ const SetX10MouseMode = `${CSI}?9h`;
138
+ const ResetX10MouseMode = `${CSI}?9l`;
139
+ const RequestX10MouseMode = `${CSI}?9$p`;
140
+ const TextCursorEnableMode = createDecMode(25);
141
+ const DECTCEM = TextCursorEnableMode;
142
+ const SetTextCursorEnableMode = `${CSI}?25h`;
143
+ const ResetTextCursorEnableMode = `${CSI}?25l`;
144
+ const RequestTextCursorEnableMode = `${CSI}?25$p`;
145
+ const ShowCursor = SetTextCursorEnableMode;
146
+ const HideCursor = ResetTextCursorEnableMode;
147
+ const NumericKeypadMode = createDecMode(66);
148
+ const DECNKM = NumericKeypadMode;
149
+ const SetNumericKeypadMode = `${CSI}?66h`;
150
+ const ResetNumericKeypadMode = `${CSI}?66l`;
151
+ const RequestNumericKeypadMode = `${CSI}?66$p`;
152
+ const BackarrowKeyMode = createDecMode(67);
153
+ const DECBKM = BackarrowKeyMode;
154
+ const SetBackarrowKeyMode = `${CSI}?67h`;
155
+ const ResetBackarrowKeyMode = `${CSI}?67l`;
156
+ const RequestBackarrowKeyMode = `${CSI}?67$p`;
157
+ const LeftRightMarginMode = createDecMode(69);
158
+ const DECLRMM = LeftRightMarginMode;
159
+ const SetLeftRightMarginMode = `${CSI}?69h`;
160
+ const ResetLeftRightMarginMode = `${CSI}?69l`;
161
+ const RequestLeftRightMarginMode = `${CSI}?69$p`;
162
+ const NormalMouseMode = createDecMode(1e3);
163
+ const SetNormalMouseMode = `${CSI}?1000h`;
164
+ const ResetNormalMouseMode = `${CSI}?1000l`;
165
+ const RequestNormalMouseMode = `${CSI}?1000$p`;
166
+ const HighlightMouseMode = createDecMode(1001);
167
+ const SetHighlightMouseMode = `${CSI}?1001h`;
168
+ const ResetHighlightMouseMode = `${CSI}?1001l`;
169
+ const RequestHighlightMouseMode = `${CSI}?1001$p`;
170
+ const ButtonEventMouseMode = createDecMode(1002);
171
+ const SetButtonEventMouseMode = `${CSI}?1002h`;
172
+ const ResetButtonEventMouseMode = `${CSI}?1002l`;
173
+ const RequestButtonEventMouseMode = `${CSI}?1002$p`;
174
+ const AnyEventMouseMode = createDecMode(1003);
175
+ const SetAnyEventMouseMode = `${CSI}?1003h`;
176
+ const ResetAnyEventMouseMode = `${CSI}?1003l`;
177
+ const RequestAnyEventMouseMode = `${CSI}?1003$p`;
178
+ const FocusEventMode = createDecMode(1004);
179
+ const SetFocusEventMode = `${CSI}?1004h`;
180
+ const ResetFocusEventMode = `${CSI}?1004l`;
181
+ const RequestFocusEventMode = `${CSI}?1004$p`;
182
+ const Utf8ExtMouseMode = createDecMode(1005);
183
+ const SetUtf8ExtMouseMode = `${CSI}?1005h`;
184
+ const ResetUtf8ExtMouseMode = `${CSI}?1005l`;
185
+ const RequestUtf8ExtMouseMode = `${CSI}?1005$p`;
186
+ const SgrExtMouseMode = createDecMode(1006);
187
+ const SetSgrExtMouseMode = `${CSI}?1006h`;
188
+ const ResetSgrExtMouseMode = `${CSI}?1006l`;
189
+ const RequestSgrExtMouseMode = `${CSI}?1006$p`;
190
+ const UrxvtExtMouseMode = createDecMode(1015);
191
+ const SetUrxvtExtMouseMode = `${CSI}?1015h`;
192
+ const ResetUrxvtExtMouseMode = `${CSI}?1015l`;
193
+ const RequestUrxvtExtMouseMode = `${CSI}?1015$p`;
194
+ const SgrPixelExtMouseMode = createDecMode(1016);
195
+ const SetSgrPixelExtMouseMode = `${CSI}?1016h`;
196
+ const ResetSgrPixelExtMouseMode = `${CSI}?1016l`;
197
+ const RequestSgrPixelExtMouseMode = `${CSI}?1016$p`;
198
+ const SGRMouseMode = SgrExtMouseMode;
199
+ const SendFocusEventsMode = FocusEventMode;
200
+ const DisableModifiersMode = createDecMode(1035);
201
+ const SetDisableModifiersMode = `${CSI}?1035h`;
202
+ const ResetDisableModifiersMode = `${CSI}?1035l`;
203
+ const RequestDisableModifiersMode = `${CSI}?1035$p`;
204
+ const AltScreenMode = createDecMode(1047);
205
+ const SetAltScreenMode = `${CSI}?1047h`;
206
+ const ResetAltScreenMode = `${CSI}?1047l`;
207
+ const RequestAltScreenMode = `${CSI}?1047$p`;
208
+ const SaveCursorMode = createDecMode(1048);
209
+ const SetSaveCursorMode = `${CSI}?1048h`;
210
+ const ResetSaveCursorMode = `${CSI}?1048l`;
211
+ const RequestSaveCursorMode = `${CSI}?1048$p`;
212
+ const AltScreenSaveCursorMode = createDecMode(1049);
213
+ const SetAltScreenSaveCursorMode = `${CSI}?1049h`;
214
+ const ResetAltScreenSaveCursorMode = `${CSI}?1049l`;
215
+ const RequestAltScreenSaveCursorMode = `${CSI}?1049$p`;
216
+ const BracketedPasteMode = createDecMode(2004);
217
+ const SetBracketedPasteMode = `${CSI}?2004h`;
218
+ const ResetBracketedPasteMode = `${CSI}?2004l`;
219
+ const RequestBracketedPasteMode = `${CSI}?2004$p`;
220
+ const SynchronizedOutputMode = createDecMode(2026);
221
+ const SetSynchronizedOutputMode = `${CSI}?2026h`;
222
+ const ResetSynchronizedOutputMode = `${CSI}?2026l`;
223
+ const RequestSynchronizedOutputMode = `${CSI}?2026$p`;
224
+ const UnicodeCoreMode = createDecMode(2027);
225
+ const SetUnicodeCoreMode = `${CSI}?2027h`;
226
+ const ResetUnicodeCoreMode = `${CSI}?2027l`;
227
+ const RequestUnicodeCoreMode = `${CSI}?2027$p`;
228
+ const GraphemeClusteringMode = UnicodeCoreMode;
229
+ const SetGraphemeClusteringMode = SetUnicodeCoreMode;
230
+ const ResetGraphemeClusteringMode = ResetUnicodeCoreMode;
231
+ const RequestGraphemeClusteringMode = RequestUnicodeCoreMode;
232
+ const Win32InputMode = createDecMode(9001);
233
+ const SetWin32InputMode = `${CSI}?9001h`;
234
+ const ResetWin32InputMode = `${CSI}?9001l`;
235
+ const RequestWin32InputMode = `${CSI}?9001$p`;
236
+ const LightDarkMode = createDecMode(2031);
237
+ const SetLightDarkMode = `${CSI}?2031h`;
238
+ const ResetLightDarkMode = `${CSI}?2031l`;
239
+ const RequestLightDarkMode = `${CSI}?2031$p`;
240
+ const InBandResizeMode = createDecMode(2048);
241
+ const SetInBandResizeMode = `${CSI}?2048h`;
242
+ const ResetInBandResizeMode = `${CSI}?2048l`;
243
+ const RequestInBandResizeMode = `${CSI}?2048$p`;
244
+
245
+ export { AltScreenMode, AltScreenSaveCursorMode, AnyEventMouseMode, AutoWrapMode, BDSM, BackarrowKeyMode, BiDirectionalSupportMode, BracketedPasteMode, ButtonEventMouseMode, CursorKeysMode, DECAWM, DECBKM, DECCKM, DECLRMM, DECNKM, DECOM, DECRPM, DECRQM, DECTCEM, DisableModifiersMode, FocusEventMode, GraphemeClusteringMode, HideCursor, HighlightMouseMode, IRM, InBandResizeMode, InsertReplaceMode, KAM, KeyboardActionMode, LNM, LeftRightMarginMode, LightDarkMode, LineFeedNewLineMode, LocalEchoMode, ModeSetting, NormalMouseMode, NumericKeypadMode, OriginMode, RM, RequestAltScreenMode, RequestAltScreenSaveCursorMode, RequestAnyEventMouseMode, RequestAutoWrapMode, RequestBackarrowKeyMode, RequestBiDirectionalSupportMode, RequestBracketedPasteMode, RequestButtonEventMouseMode, RequestCursorKeysMode, RequestDisableModifiersMode, RequestFocusEventMode, RequestGraphemeClusteringMode, RequestHighlightMouseMode, RequestInBandResizeMode, RequestInsertReplaceMode, RequestKeyboardActionMode, RequestLeftRightMarginMode, RequestLightDarkMode, RequestLineFeedNewLineMode, RequestLocalEchoMode, RequestNormalMouseMode, RequestNumericKeypadMode, RequestOriginMode, RequestSaveCursorMode, RequestSendReceiveMode, RequestSgrExtMouseMode, RequestSgrPixelExtMouseMode, RequestSynchronizedOutputMode, RequestTextCursorEnableMode, RequestUnicodeCoreMode, RequestUrxvtExtMouseMode, RequestUtf8ExtMouseMode, RequestWin32InputMode, RequestX10MouseMode, ResetAltScreenMode, ResetAltScreenSaveCursorMode, ResetAnyEventMouseMode, ResetAutoWrapMode, ResetBackarrowKeyMode, ResetBiDirectionalSupportMode, ResetBracketedPasteMode, ResetButtonEventMouseMode, ResetCursorKeysMode, ResetDisableModifiersMode, ResetFocusEventMode, ResetGraphemeClusteringMode, ResetHighlightMouseMode, ResetInBandResizeMode, ResetInsertReplaceMode, ResetKeyboardActionMode, ResetLeftRightMarginMode, ResetLightDarkMode, ResetLineFeedNewLineMode, ResetLocalEchoMode, ResetNormalMouseMode, ResetNumericKeypadMode, ResetOriginMode, ResetSaveCursorMode, ResetSendReceiveMode, ResetSgrExtMouseMode, ResetSgrPixelExtMouseMode, ResetSynchronizedOutputMode, ResetTextCursorEnableMode, ResetUnicodeCoreMode, ResetUrxvtExtMouseMode, ResetUtf8ExtMouseMode, ResetWin32InputMode, ResetX10MouseMode, SGRMouseMode, SM, SRM, SaveCursorMode, SendFocusEventsMode, SendReceiveMode, SetAltScreenMode, SetAltScreenSaveCursorMode, SetAnyEventMouseMode, SetAutoWrapMode, SetBackarrowKeyMode, SetBiDirectionalSupportMode, SetBracketedPasteMode, SetButtonEventMouseMode, SetCursorKeysMode, SetDisableModifiersMode, SetFocusEventMode, SetGraphemeClusteringMode, SetHighlightMouseMode, SetInBandResizeMode, SetInsertReplaceMode, SetKeyboardActionMode, SetLeftRightMarginMode, SetLightDarkMode, SetLineFeedNewLineMode, SetLocalEchoMode, SetNormalMouseMode, SetNumericKeypadMode, SetOriginMode, SetSaveCursorMode, SetSendReceiveMode, SetSgrExtMouseMode, SetSgrPixelExtMouseMode, SetSynchronizedOutputMode, SetTextCursorEnableMode, SetUnicodeCoreMode, SetUrxvtExtMouseMode, SetUtf8ExtMouseMode, SetWin32InputMode, SetX10MouseMode, SgrExtMouseMode, SgrPixelExtMouseMode, ShowCursor, SynchronizedOutputMode, TextCursorEnableMode, UnicodeCoreMode, UrxvtExtMouseMode, Utf8ExtMouseMode, Win32InputMode, X10MouseMode, createAnsiMode, createDecMode, isModeNotRecognized, isModePermanentlyReset, isModePermanentlySet, isModeReset, isModeSet, reportMode, requestMode, resetMode, setMode };
package/dist/mouse.js CHANGED
@@ -1 +1,106 @@
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};
1
+ import { E as ESC } from './packem_shared/constants-CE7WkXh_.js';
2
+
3
+ const MOUSE_BIT_SHIFT = 4;
4
+ const MOUSE_BIT_ALT = 8;
5
+ const MOUSE_BIT_CTRL = 16;
6
+ const MOUSE_BIT_MOTION = 32;
7
+ const MOUSE_BIT_WHEEL = 64;
8
+ const MOUSE_BIT_ADDITIONAL = 128;
9
+ const MOUSE_BUTTON_BITS_MASK = 3;
10
+ const X10_MOUSE_OFFSET = 32;
11
+ const MouseButton = {
12
+ BACKWARD: 8,
13
+ BUTTON_1: 1,
14
+ // Left
15
+ BUTTON_2: 2,
16
+ // Middle
17
+ BUTTON_3: 3,
18
+ // Right
19
+ BUTTON_4: 4,
20
+ // Wheel Up
21
+ BUTTON_5: 5,
22
+ // Wheel Down
23
+ BUTTON_6: 6,
24
+ // Wheel Left
25
+ BUTTON_7: 7,
26
+ // Wheel Right
27
+ BUTTON_8: 8,
28
+ // Aux 1 (e.g., Browser Backward)
29
+ BUTTON_9: 9,
30
+ // Aux 2 (e.g., Browser Forward)
31
+ BUTTON_10: 10,
32
+ // Aux 3
33
+ BUTTON_11: 11,
34
+ // Aux 4
35
+ FORWARD: 9,
36
+ // Aliases
37
+ LEFT: 1,
38
+ MIDDLE: 2,
39
+ NONE: 0,
40
+ // Also used for release if no specific button for release
41
+ RELEASE: 0,
42
+ RIGHT: 3,
43
+ WHEEL_DOWN: 5,
44
+ WHEEL_LEFT: 6,
45
+ WHEEL_RIGHT: 7,
46
+ WHEEL_UP: 4
47
+ };
48
+ const encodeMouseButtonByte = (button, motion, modifiers = {}) => {
49
+ let callback;
50
+ if (button === MouseButton.RELEASE) {
51
+ callback = MOUSE_BUTTON_BITS_MASK;
52
+ } else if (button >= MouseButton.LEFT && button <= MouseButton.RIGHT) {
53
+ callback = button - MouseButton.LEFT;
54
+ } else if (button >= MouseButton.WHEEL_UP && button <= MouseButton.WHEEL_RIGHT) {
55
+ callback = button - MouseButton.WHEEL_UP;
56
+ callback |= MOUSE_BIT_WHEEL;
57
+ } else if (button >= MouseButton.BACKWARD && button <= MouseButton.BUTTON_11) {
58
+ callback = button - MouseButton.BACKWARD;
59
+ callback |= MOUSE_BIT_ADDITIONAL;
60
+ } else {
61
+ return 255;
62
+ }
63
+ if (modifiers.shift) {
64
+ callback |= MOUSE_BIT_SHIFT;
65
+ }
66
+ if (modifiers.alt) {
67
+ callback |= MOUSE_BIT_ALT;
68
+ }
69
+ if (modifiers.ctrl) {
70
+ callback |= MOUSE_BIT_CTRL;
71
+ }
72
+ if (motion) {
73
+ callback |= MOUSE_BIT_MOTION;
74
+ }
75
+ return callback;
76
+ };
77
+ const mouseX10Sequence = (callback, x, y) => {
78
+ if (callback === 255) {
79
+ return "";
80
+ }
81
+ const charCallback = String.fromCodePoint(callback + X10_MOUSE_OFFSET);
82
+ const charCx = String.fromCodePoint(x + 1 + X10_MOUSE_OFFSET);
83
+ const charCy = String.fromCodePoint(y + 1 + X10_MOUSE_OFFSET);
84
+ return `${ESC}[M${charCallback}${charCx}${charCy}`;
85
+ };
86
+ const mouseSgrSequence = (callback, x, y, isRelease) => {
87
+ if (callback === 255) {
88
+ return "";
89
+ }
90
+ const finalChar = isRelease ? "m" : "M";
91
+ return `${ESC}[<${String(callback)};${String(x + 1)};${String(y + 1)}${finalChar}`;
92
+ };
93
+ const enableX10Mouse = `${ESC}[?9h`;
94
+ const disableX10Mouse = `${ESC}[?9l`;
95
+ const enableNormalMouse = `${ESC}[?1000h`;
96
+ const disableNormalMouse = `${ESC}[?1000l`;
97
+ const enableButtonEventMouse = `${ESC}[?1002h`;
98
+ const disableButtonEventMouse = `${ESC}[?1002l`;
99
+ const enableAnyEventMouse = `${ESC}[?1003h`;
100
+ const disableAnyEventMouse = `${ESC}[?1003l`;
101
+ const enableSgrMouse = `${ESC}[?1006h`;
102
+ const disableSgrMouse = `${ESC}[?1006l`;
103
+ const enableFocusTracking = `${ESC}[?1004h`;
104
+ const disableFocusTracking = `${ESC}[?1004l`;
105
+
106
+ export { MouseButton, disableAnyEventMouse, disableButtonEventMouse, disableFocusTracking, disableNormalMouse, disableSgrMouse, disableX10Mouse, enableAnyEventMouse, enableButtonEventMouse, enableFocusTracking, enableNormalMouse, enableSgrMouse, enableX10Mouse, encodeMouseButtonByte, mouseSgrSequence, mouseX10Sequence };
@@ -0,0 +1,6 @@
1
+ const IT2_AUTO = "auto";
2
+ const it2Cells = (n) => n.toString();
3
+ const it2Pixels = (n) => `${String(n)}px`;
4
+ const it2Percent = (n) => `${String(n)}%`;
5
+
6
+ export { IT2_AUTO, it2Cells, it2Percent, it2Pixels };
@@ -0,0 +1,137 @@
1
+ import { createRequire as __cjs_createRequire } from "node:module";
2
+
3
+ const __cjs_require = __cjs_createRequire(import.meta.url);
4
+
5
+ const __cjs_getProcess = typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" ? globalThis.process : process;
6
+
7
+ const __cjs_getBuiltinModule = (module) => {
8
+ // Check if we're in Node.js and version supports getBuiltinModule
9
+ if (typeof __cjs_getProcess !== "undefined" && __cjs_getProcess.versions && __cjs_getProcess.versions.node) {
10
+ const [major, minor] = __cjs_getProcess.versions.node.split(".").map(Number);
11
+ // Node.js 20.16.0+ and 22.3.0+
12
+ if (major > 22 || (major === 22 && minor >= 3) || (major === 20 && minor >= 16)) {
13
+ return __cjs_getProcess.getBuiltinModule(module);
14
+ }
15
+ }
16
+ // Fallback to createRequire
17
+ return __cjs_require(module);
18
+ };
19
+
20
+ const {
21
+ Buffer
22
+ } = __cjs_getBuiltinModule("node:buffer");
23
+
24
+ const formatITerm2FileProperties = (properties) => {
25
+ const options = [];
26
+ if (properties.name) {
27
+ options.push(`name=${properties.name}`);
28
+ }
29
+ if (properties.size !== void 0) {
30
+ options.push(`size=${String(properties.size)}`);
31
+ }
32
+ if (properties.width !== void 0) {
33
+ options.push(`width=${properties.width.toString()}`);
34
+ }
35
+ if (properties.height !== void 0) {
36
+ options.push(`height=${properties.height.toString()}`);
37
+ }
38
+ if (properties.ignoreAspectRatio) {
39
+ options.push("preserveAspectRatio=0");
40
+ }
41
+ if (properties.inline) {
42
+ options.push("inline=1");
43
+ }
44
+ if (properties.doNotMoveCursor) {
45
+ options.push("doNotMoveCursor=1");
46
+ }
47
+ return options.join(";");
48
+ };
49
+ class ITerm2File {
50
+ fileProps;
51
+ /**
52
+ * Constructs an `ITerm2File` payload object.
53
+ * @param properties An object containing properties for the file/image, as defined by {@link ITerm2FileProperties}.
54
+ * The `name` property within `props` should be pre-Base64 encoded by the caller if it might
55
+ * contain special characters (like `;`, `=`, or non-ASCII characters).
56
+ * If `fileData` is provided, `props.content` will be overridden, and `props.size` will be
57
+ * set from `fileData.byteLength` if not already present in `props`.
58
+ * @param fileData (Optional) A `Uint8Array` containing the raw file data. If provided, this data will be
59
+ * Base64 encoded and used as the `content` of the file transfer. The `size` property
60
+ * will also be automatically set from `fileData.byteLength` if not specified in `props`.
61
+ */
62
+ constructor(properties, fileData) {
63
+ this.fileProps = { ...properties };
64
+ if (fileData) {
65
+ if (fileData.byteLength > 10 * 1024 * 1024) {
66
+ throw new Error("File size exceeds maximum limit of 10MB");
67
+ }
68
+ this.fileProps.content = Buffer.from(fileData).toString("base64");
69
+ this.fileProps.size ??= fileData.byteLength;
70
+ if (this.fileProps.size !== fileData.byteLength) {
71
+ throw new Error("File size property doesn't match actual data length");
72
+ }
73
+ }
74
+ }
75
+ /**
76
+ * Converts the file properties and its content (if any) into the string payload
77
+ * suitable for the iTerm2 `File=` command.
78
+ * @returns The string payload (e.g., `"File=name=...;size=...:BASE64_CONTENT"` or `"File=name=...;size=..."`).
79
+ */
80
+ toString() {
81
+ let s = "File=";
82
+ s += formatITerm2FileProperties(this.fileProps);
83
+ if (this.fileProps.content !== void 0) {
84
+ s += `:${this.fileProps.content}`;
85
+ }
86
+ return s;
87
+ }
88
+ }
89
+ class ITerm2FileEnd {
90
+ /**
91
+ * Generates the string payload for the iTerm2 `FileEnd` command.
92
+ * @returns The string `"FileEnd"`.
93
+ */
94
+ // eslint-disable-next-line class-methods-use-this
95
+ toString() {
96
+ return "FileEnd";
97
+ }
98
+ }
99
+ class ITerm2FilePart {
100
+ /**
101
+ * Constructs an `ITerm2FilePart` payload object.
102
+ * @param base64Chunk A string containing a Base64 encoded chunk of the file data.
103
+ * The caller is responsible for chunking the file and Base64 encoding each chunk.
104
+ */
105
+ constructor(base64Chunk) {
106
+ this.base64Chunk = base64Chunk;
107
+ }
108
+ base64Chunk;
109
+ /**
110
+ * Converts the Base64 encoded chunk into the string payload suitable for the iTerm2 `FilePart=` command.
111
+ * @returns The string payload (e.g., `"FilePart=U09NRURBVEE="`).
112
+ */
113
+ toString() {
114
+ return `FilePart=${this.base64Chunk}`;
115
+ }
116
+ }
117
+ class ITerm2MultipartFileStart {
118
+ /**
119
+ * Constructs an `ITerm2MultipartFileStart` payload object.
120
+ * @param properties Properties for the multipart file (e.g., `name`, `size`). Content is not part of this command.
121
+ * The `name` property within `props` should be pre-Base64 encoded by the caller if it might
122
+ * contain special characters.
123
+ */
124
+ constructor(properties) {
125
+ this.properties = properties;
126
+ }
127
+ properties;
128
+ /**
129
+ * Converts the file properties into the string payload suitable for the iTerm2 `MultipartFile=` command.
130
+ * @returns The string payload (e.g., `"MultipartFile=name=...;size=..."`).
131
+ */
132
+ toString() {
133
+ return `MultipartFile=${formatITerm2FileProperties(this.properties)}`;
134
+ }
135
+ }
136
+
137
+ export { ITerm2File, ITerm2FileEnd, ITerm2FilePart, ITerm2MultipartFileStart };
@@ -0,0 +1,9 @@
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 };
@@ -0,0 +1,72 @@
1
+ import { C as CSI, E as ESC, S as SEP } from './constants-CE7WkXh_.js';
2
+ import './restoreCursor-GfYEeJqN.js';
3
+
4
+ const isBrowser = typeof globalThis !== "undefined" && typeof globalThis.window === "object" && globalThis.window.document !== void 0;
5
+ const OSTYPE_REGEX = /^(?:msys|cygwin)$/;
6
+ const isTerminalApp = !isBrowser && process.env.TERM_PROGRAM === "Apple_Terminal";
7
+ const isWindows = !isBrowser && (process.platform === "win32" || OSTYPE_REGEX.test(process.env.OSTYPE));
8
+
9
+ const SAVE_CURSOR_DEC = `${ESC}7`;
10
+ const RESTORE_CURSOR_DEC = `${ESC}8`;
11
+ const CURSOR_UP_1 = `${CSI}A`;
12
+ const CURSOR_DOWN_1 = `${CSI}B`;
13
+ const CURSOR_FORWARD_1 = `${CSI}C`;
14
+ const CURSOR_BACKWARD_1 = `${CSI}D`;
15
+ const REQUEST_CURSOR_POSITION = `${CSI}6n`;
16
+ const REQUEST_EXTENDED_CURSOR_POSITION = `${CSI}?6n`;
17
+ const cursorBackward = (count = 1) => `${CSI}${String(count)}D`;
18
+ const cursorDown = (count = 1) => `${CSI}${String(count)}B`;
19
+ const cursorForward = (count = 1) => `${CSI}${String(count)}C`;
20
+ const cursorHide = `${CSI}?25l`;
21
+ const cursorToColumn1 = `${CSI}G`;
22
+ const cursorLeft = (count = 1) => cursorBackward(count);
23
+ const cursorHorizontalAbsolute = (column = 1) => `${CSI}${String(column)}G`;
24
+ const cursorMove = (x, y) => {
25
+ let returnValue = "";
26
+ if (x < 0) {
27
+ returnValue += `${CSI}${String(-x)}D`;
28
+ } else if (x > 0) {
29
+ returnValue += `${CSI}${String(x)}C`;
30
+ }
31
+ if (y < 0) {
32
+ returnValue += `${CSI}${String(-y)}A`;
33
+ } else if (y > 0) {
34
+ returnValue += `${CSI}${String(y)}B`;
35
+ }
36
+ return returnValue;
37
+ };
38
+ const cursorNextLine = (count = 1) => `${CSI}${String(count)}E`;
39
+ const cursorPreviousLine = (count = 1) => `${CSI}${String(count)}F`;
40
+ const cursorRestore = isTerminalApp ? RESTORE_CURSOR_DEC : `${ESC}u`;
41
+ const cursorSave = isTerminalApp ? SAVE_CURSOR_DEC : `${ESC}s`;
42
+ const cursorShow = `${CSI}?25h`;
43
+ const cursorTo = (x, y) => {
44
+ if (y === void 0) {
45
+ return cursorHorizontalAbsolute(x + 1);
46
+ }
47
+ return `${CSI}${String(y + 1)}${SEP}${String(x + 1)}H`;
48
+ };
49
+ const cursorPosition = (row, column) => {
50
+ if (column === void 0) {
51
+ return `${CSI}${String(row)}H`;
52
+ }
53
+ return `${CSI}${String(row)}${SEP}${String(column)}H`;
54
+ };
55
+ const cursorHorizontalForwardTab = (count = 1) => `${CSI}${String(count)}I`;
56
+ const cursorBackwardTab = (count = 1) => `${CSI}${String(count)}Z`;
57
+ const eraseCharacter = (count = 1) => `${CSI}${String(count)}X`;
58
+ const cursorVerticalAbsolute = (row = 1) => `${CSI}${String(row)}d`;
59
+ const cursorUp = (count = 1) => `${CSI}${String(count)}A`;
60
+ var CursorStyle = /* @__PURE__ */ ((CursorStyle2) => {
61
+ CursorStyle2[CursorStyle2["Default"] = 0] = "Default";
62
+ CursorStyle2[CursorStyle2["BlinkingBlock"] = 1] = "BlinkingBlock";
63
+ CursorStyle2[CursorStyle2["SteadyBlock"] = 2] = "SteadyBlock";
64
+ CursorStyle2[CursorStyle2["BlinkingUnderline"] = 3] = "BlinkingUnderline";
65
+ CursorStyle2[CursorStyle2["SteadyUnderline"] = 4] = "SteadyUnderline";
66
+ CursorStyle2[CursorStyle2["BlinkingBar"] = 5] = "BlinkingBar";
67
+ CursorStyle2[CursorStyle2["SteadyBar"] = 6] = "SteadyBar";
68
+ return CursorStyle2;
69
+ })(CursorStyle || {});
70
+ const setCursorStyle = (style) => `${CSI}${String(style)} q`;
71
+
72
+ export { isWindows as A, CursorStyle as B, CURSOR_BACKWARD_1 as C, REQUEST_CURSOR_POSITION as R, SAVE_CURSOR_DEC as S, CURSOR_DOWN_1 as a, CURSOR_FORWARD_1 as b, CURSOR_UP_1 as c, REQUEST_EXTENDED_CURSOR_POSITION as d, RESTORE_CURSOR_DEC as e, cursorBackward as f, cursorBackwardTab as g, cursorDown as h, cursorForward as i, cursorHide as j, cursorHorizontalAbsolute as k, cursorHorizontalForwardTab as l, cursorLeft as m, cursorMove as n, cursorNextLine as o, cursorPosition as p, cursorPreviousLine as q, cursorRestore as r, cursorSave as s, cursorShow as t, cursorTo as u, cursorToColumn1 as v, cursorUp as w, cursorVerticalAbsolute as x, eraseCharacter as y, setCursorStyle as z };