@visulima/ansi 1.0.18 → 1.1.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 (130) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/LICENSE.md +76 -74
  3. package/README.md +335 -2
  4. package/dist/alternative-screen.cjs +11 -5
  5. package/dist/alternative-screen.d.cts +74 -4
  6. package/dist/alternative-screen.d.mts +74 -4
  7. package/dist/alternative-screen.d.ts +74 -4
  8. package/dist/alternative-screen.mjs +8 -4
  9. package/dist/clear.cjs +10 -18
  10. package/dist/clear.d.cts +77 -7
  11. package/dist/clear.d.mts +77 -7
  12. package/dist/clear.d.ts +77 -7
  13. package/dist/clear.mjs +8 -15
  14. package/dist/constants.d.cts +20 -0
  15. package/dist/constants.d.mts +20 -0
  16. package/dist/constants.d.ts +20 -0
  17. package/dist/cursor.cjs +19 -2
  18. package/dist/cursor.d.cts +436 -30
  19. package/dist/cursor.d.mts +436 -30
  20. package/dist/cursor.d.ts +436 -30
  21. package/dist/cursor.mjs +2 -2
  22. package/dist/erase.cjs +44 -13
  23. package/dist/erase.d.cts +206 -9
  24. package/dist/erase.d.mts +206 -9
  25. package/dist/erase.d.ts +206 -9
  26. package/dist/erase.mjs +40 -14
  27. package/dist/helpers.d.cts +14 -0
  28. package/dist/helpers.d.mts +14 -0
  29. package/dist/helpers.d.ts +14 -0
  30. package/dist/hyperlink.cjs +9 -0
  31. package/dist/hyperlink.d.cts +29 -0
  32. package/dist/hyperlink.d.mts +27 -0
  33. package/dist/hyperlink.d.ts +29 -0
  34. package/dist/hyperlink.mjs +7 -0
  35. package/dist/image.cjs +12 -5
  36. package/dist/image.d.cts +69 -58
  37. package/dist/image.d.mts +69 -58
  38. package/dist/image.d.ts +69 -58
  39. package/dist/image.mjs +10 -5
  40. package/dist/index.cjs +209 -11
  41. package/dist/index.d.cts +35 -12
  42. package/dist/index.d.mts +35 -12
  43. package/dist/index.d.ts +35 -12
  44. package/dist/index.mjs +20 -7
  45. package/dist/iterm2/iterm2-properties.d.cts +135 -0
  46. package/dist/iterm2/iterm2-properties.d.mts +135 -0
  47. package/dist/iterm2/iterm2-properties.d.ts +135 -0
  48. package/dist/iterm2/iterm2-sequences.d.cts +96 -0
  49. package/dist/iterm2/iterm2-sequences.d.mts +96 -0
  50. package/dist/iterm2/iterm2-sequences.d.ts +96 -0
  51. package/dist/iterm2.cjs +26 -0
  52. package/dist/iterm2.d.cts +58 -0
  53. package/dist/iterm2.d.mts +58 -0
  54. package/dist/iterm2.d.ts +58 -0
  55. package/dist/iterm2.mjs +14 -0
  56. package/dist/mode.cjs +388 -0
  57. package/dist/mode.d.cts +657 -0
  58. package/dist/mode.d.mts +657 -0
  59. package/dist/mode.d.ts +657 -0
  60. package/dist/mode.mjs +235 -0
  61. package/dist/mouse.cjs +127 -0
  62. package/dist/mouse.d.cts +230 -0
  63. package/dist/mouse.d.mts +230 -0
  64. package/dist/mouse.d.ts +230 -0
  65. package/dist/mouse.mjs +108 -0
  66. package/dist/packem_shared/IT2_AUTO-5vTJQMm6.cjs +15 -0
  67. package/dist/packem_shared/IT2_AUTO-DnfCUXso.mjs +8 -0
  68. package/dist/packem_shared/ITerm2File-BGPqNSjB.cjs +137 -0
  69. package/dist/packem_shared/ITerm2File-DKFkdqdA.mjs +130 -0
  70. package/dist/packem_shared/{constants-D8u2npjW.cjs → constants-BK26O-46.cjs} +4 -0
  71. package/dist/packem_shared/constants-CE7WkXh_.mjs +9 -0
  72. package/dist/packem_shared/cursor-CQKLCu7U.cjs +105 -0
  73. package/dist/packem_shared/cursor-DhFQcQ9g.mjs +73 -0
  74. package/dist/passthrough.cjs +38 -0
  75. package/dist/passthrough.d.cts +77 -0
  76. package/dist/passthrough.d.mts +77 -0
  77. package/dist/passthrough.d.ts +77 -0
  78. package/dist/passthrough.mjs +31 -0
  79. package/dist/reset.cjs +9 -0
  80. package/dist/reset.d.cts +26 -0
  81. package/dist/reset.d.mts +26 -0
  82. package/dist/reset.d.ts +26 -0
  83. package/dist/reset.mjs +4 -0
  84. package/dist/screen.cjs +41 -0
  85. package/dist/screen.d.cts +234 -0
  86. package/dist/screen.d.mts +234 -0
  87. package/dist/screen.d.ts +234 -0
  88. package/dist/screen.mjs +29 -0
  89. package/dist/scroll.cjs +17 -3
  90. package/dist/scroll.d.cts +67 -4
  91. package/dist/scroll.d.mts +67 -4
  92. package/dist/scroll.d.ts +67 -4
  93. package/dist/scroll.mjs +16 -4
  94. package/dist/status.cjs +147 -0
  95. package/dist/status.d.cts +501 -0
  96. package/dist/status.d.mts +501 -0
  97. package/dist/status.d.ts +501 -0
  98. package/dist/status.mjs +104 -0
  99. package/dist/strip.d.cts +23 -1
  100. package/dist/strip.d.mts +22 -2
  101. package/dist/strip.d.ts +23 -1
  102. package/dist/termcap.cjs +33 -0
  103. package/dist/termcap.d.cts +38 -0
  104. package/dist/termcap.d.mts +38 -0
  105. package/dist/termcap.d.ts +38 -0
  106. package/dist/termcap.mjs +27 -0
  107. package/dist/title.cjs +31 -0
  108. package/dist/title.d.cts +185 -0
  109. package/dist/title.d.mts +185 -0
  110. package/dist/title.d.ts +185 -0
  111. package/dist/title.mjs +20 -0
  112. package/dist/window-ops.cjs +85 -0
  113. package/dist/window-ops.d.cts +418 -0
  114. package/dist/window-ops.d.mts +418 -0
  115. package/dist/window-ops.d.ts +418 -0
  116. package/dist/window-ops.mjs +63 -0
  117. package/dist/xterm.cjs +48 -0
  118. package/dist/xterm.d.cts +94 -0
  119. package/dist/xterm.d.mts +94 -0
  120. package/dist/xterm.d.ts +94 -0
  121. package/dist/xterm.mjs +35 -0
  122. package/package.json +153 -9
  123. package/dist/link.cjs +0 -9
  124. package/dist/link.d.cts +0 -3
  125. package/dist/link.d.mts +0 -3
  126. package/dist/link.d.ts +0 -3
  127. package/dist/link.mjs +0 -7
  128. package/dist/packem_shared/constants-CqXMfQy0.mjs +0 -7
  129. package/dist/packem_shared/cursor-2tHgT9r6.cjs +0 -57
  130. package/dist/packem_shared/cursor-CDCWqbC9.mjs +0 -42
@@ -0,0 +1,137 @@
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;
@@ -0,0 +1,130 @@
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 };
@@ -5,9 +5,13 @@ const CSI = `${ESC}[`;
5
5
  const OSC = "\x1B]";
6
6
  const BEL = "\x07";
7
7
  const SEP = ";";
8
+ const DCS = `${ESC}P`;
9
+ const ST = `${ESC}\\`;
8
10
 
9
11
  exports.BEL = BEL;
10
12
  exports.CSI = CSI;
13
+ exports.DCS = DCS;
11
14
  exports.ESC = ESC;
12
15
  exports.OSC = OSC;
13
16
  exports.SEP = SEP;
17
+ exports.ST = ST;
@@ -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,105 @@
1
+ 'use strict';
2
+
3
+ const constants = require('./constants-BK26O-46.cjs');
4
+ require('./restoreCursor-DC_ZKZwT.cjs');
5
+
6
+ const isBrowser = globalThis?.window?.document !== void 0;
7
+ const isTerminalApp = !isBrowser && process.env.TERM_PROGRAM === "Apple_Terminal";
8
+ const isWindows = !isBrowser && (process.platform === "win32" || /^(?:msys|cygwin)$/.test(process.env.OSTYPE));
9
+
10
+ var __defProp = Object.defineProperty;
11
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
12
+ const SAVE_CURSOR_DEC = `${constants.ESC}7`;
13
+ const RESTORE_CURSOR_DEC = `${constants.ESC}8`;
14
+ const CURSOR_UP_1 = `${constants.CSI}A`;
15
+ const CURSOR_DOWN_1 = `${constants.CSI}B`;
16
+ const CURSOR_FORWARD_1 = `${constants.CSI}C`;
17
+ const CURSOR_BACKWARD_1 = `${constants.CSI}D`;
18
+ const REQUEST_CURSOR_POSITION = `${constants.CSI}6n`;
19
+ const REQUEST_EXTENDED_CURSOR_POSITION = `${constants.CSI}?6n`;
20
+ const cursorBackward = /* @__PURE__ */ __name((count = 1) => `${constants.CSI + count}D`, "cursorBackward");
21
+ const cursorDown = /* @__PURE__ */ __name((count = 1) => `${constants.CSI + count}B`, "cursorDown");
22
+ const cursorForward = /* @__PURE__ */ __name((count = 1) => `${constants.CSI + count}C`, "cursorForward");
23
+ const cursorHide = `${constants.CSI}?25l`;
24
+ const cursorToColumn1 = `${constants.CSI}G`;
25
+ const cursorLeft = /* @__PURE__ */ __name((count = 1) => cursorBackward(count), "cursorLeft");
26
+ const cursorHorizontalAbsolute = /* @__PURE__ */ __name((column = 1) => `${constants.CSI + column}G`, "cursorHorizontalAbsolute");
27
+ const cursorMove = /* @__PURE__ */ __name((x, y) => {
28
+ let returnValue = "";
29
+ if (x < 0) {
30
+ returnValue += `${constants.CSI + -x}D`;
31
+ } else if (x > 0) {
32
+ returnValue += `${constants.CSI + x}C`;
33
+ }
34
+ if (y < 0) {
35
+ returnValue += `${constants.CSI + -y}A`;
36
+ } else if (y > 0) {
37
+ returnValue += `${constants.CSI + y}B`;
38
+ }
39
+ return returnValue;
40
+ }, "cursorMove");
41
+ const cursorNextLine = /* @__PURE__ */ __name((count = 1) => `${constants.CSI + count}E`, "cursorNextLine");
42
+ const cursorPreviousLine = /* @__PURE__ */ __name((count = 1) => `${constants.CSI + count}F`, "cursorPreviousLine");
43
+ const cursorRestore = isTerminalApp ? RESTORE_CURSOR_DEC : `${constants.ESC}u`;
44
+ const cursorSave = isTerminalApp ? SAVE_CURSOR_DEC : `${constants.ESC}s`;
45
+ const cursorShow = `${constants.CSI}?25h`;
46
+ const cursorTo = /* @__PURE__ */ __name((x, y) => {
47
+ if (y === void 0) {
48
+ return cursorHorizontalAbsolute(x + 1);
49
+ }
50
+ return `${constants.CSI + (y + 1) + constants.SEP + (x + 1)}H`;
51
+ }, "cursorTo");
52
+ const cursorPosition = /* @__PURE__ */ __name((row, column) => {
53
+ if (column === void 0) {
54
+ return `${constants.CSI + row}H`;
55
+ }
56
+ return `${constants.CSI + row + constants.SEP + column}H`;
57
+ }, "cursorPosition");
58
+ const cursorHorizontalForwardTab = /* @__PURE__ */ __name((count = 1) => `${constants.CSI + count}I`, "cursorHorizontalForwardTab");
59
+ const cursorBackwardTab = /* @__PURE__ */ __name((count = 1) => `${constants.CSI + count}Z`, "cursorBackwardTab");
60
+ const eraseCharacter = /* @__PURE__ */ __name((count = 1) => `${constants.CSI + count}X`, "eraseCharacter");
61
+ const cursorVerticalAbsolute = /* @__PURE__ */ __name((row = 1) => `${constants.CSI + row}d`, "cursorVerticalAbsolute");
62
+ const cursorUp = /* @__PURE__ */ __name((count = 1) => `${constants.CSI + count}A`, "cursorUp");
63
+ var CursorStyle = /* @__PURE__ */ ((CursorStyle2) => {
64
+ CursorStyle2[CursorStyle2["BlinkingBar"] = 5] = "BlinkingBar";
65
+ CursorStyle2[CursorStyle2["BlinkingBlock"] = 1] = "BlinkingBlock";
66
+ CursorStyle2[CursorStyle2["BlinkingUnderline"] = 3] = "BlinkingUnderline";
67
+ CursorStyle2[CursorStyle2["Default"] = 0] = "Default";
68
+ CursorStyle2[CursorStyle2["SteadyBar"] = 6] = "SteadyBar";
69
+ CursorStyle2[CursorStyle2["SteadyBlock"] = 2] = "SteadyBlock";
70
+ CursorStyle2[CursorStyle2["SteadyUnderline"] = 4] = "SteadyUnderline";
71
+ return CursorStyle2;
72
+ })(CursorStyle || {});
73
+ const setCursorStyle = /* @__PURE__ */ __name((style) => `${constants.CSI + style} q`, "setCursorStyle");
74
+
75
+ exports.CURSOR_BACKWARD_1 = CURSOR_BACKWARD_1;
76
+ exports.CURSOR_DOWN_1 = CURSOR_DOWN_1;
77
+ exports.CURSOR_FORWARD_1 = CURSOR_FORWARD_1;
78
+ exports.CURSOR_UP_1 = CURSOR_UP_1;
79
+ exports.CursorStyle = CursorStyle;
80
+ exports.REQUEST_CURSOR_POSITION = REQUEST_CURSOR_POSITION;
81
+ exports.REQUEST_EXTENDED_CURSOR_POSITION = REQUEST_EXTENDED_CURSOR_POSITION;
82
+ exports.RESTORE_CURSOR_DEC = RESTORE_CURSOR_DEC;
83
+ exports.SAVE_CURSOR_DEC = SAVE_CURSOR_DEC;
84
+ exports.cursorBackward = cursorBackward;
85
+ exports.cursorBackwardTab = cursorBackwardTab;
86
+ exports.cursorDown = cursorDown;
87
+ exports.cursorForward = cursorForward;
88
+ exports.cursorHide = cursorHide;
89
+ exports.cursorHorizontalAbsolute = cursorHorizontalAbsolute;
90
+ exports.cursorHorizontalForwardTab = cursorHorizontalForwardTab;
91
+ exports.cursorLeft = cursorLeft;
92
+ exports.cursorMove = cursorMove;
93
+ exports.cursorNextLine = cursorNextLine;
94
+ exports.cursorPosition = cursorPosition;
95
+ exports.cursorPreviousLine = cursorPreviousLine;
96
+ exports.cursorRestore = cursorRestore;
97
+ exports.cursorSave = cursorSave;
98
+ exports.cursorShow = cursorShow;
99
+ exports.cursorTo = cursorTo;
100
+ exports.cursorToColumn1 = cursorToColumn1;
101
+ exports.cursorUp = cursorUp;
102
+ exports.cursorVerticalAbsolute = cursorVerticalAbsolute;
103
+ exports.eraseCharacter = eraseCharacter;
104
+ exports.isWindows = isWindows;
105
+ exports.setCursorStyle = setCursorStyle;
@@ -0,0 +1,73 @@
1
+ import { C as CSI, E as ESC, S as SEP } from './constants-CE7WkXh_.mjs';
2
+ import './restoreCursor-C6pNB8UY.mjs';
3
+
4
+ const isBrowser = globalThis?.window?.document !== void 0;
5
+ const isTerminalApp = !isBrowser && process.env.TERM_PROGRAM === "Apple_Terminal";
6
+ const isWindows = !isBrowser && (process.platform === "win32" || /^(?:msys|cygwin)$/.test(process.env.OSTYPE));
7
+
8
+ var __defProp = Object.defineProperty;
9
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
10
+ const SAVE_CURSOR_DEC = `${ESC}7`;
11
+ const RESTORE_CURSOR_DEC = `${ESC}8`;
12
+ const CURSOR_UP_1 = `${CSI}A`;
13
+ const CURSOR_DOWN_1 = `${CSI}B`;
14
+ const CURSOR_FORWARD_1 = `${CSI}C`;
15
+ const CURSOR_BACKWARD_1 = `${CSI}D`;
16
+ const REQUEST_CURSOR_POSITION = `${CSI}6n`;
17
+ const REQUEST_EXTENDED_CURSOR_POSITION = `${CSI}?6n`;
18
+ const cursorBackward = /* @__PURE__ */ __name((count = 1) => `${CSI + count}D`, "cursorBackward");
19
+ const cursorDown = /* @__PURE__ */ __name((count = 1) => `${CSI + count}B`, "cursorDown");
20
+ const cursorForward = /* @__PURE__ */ __name((count = 1) => `${CSI + count}C`, "cursorForward");
21
+ const cursorHide = `${CSI}?25l`;
22
+ const cursorToColumn1 = `${CSI}G`;
23
+ const cursorLeft = /* @__PURE__ */ __name((count = 1) => cursorBackward(count), "cursorLeft");
24
+ const cursorHorizontalAbsolute = /* @__PURE__ */ __name((column = 1) => `${CSI + column}G`, "cursorHorizontalAbsolute");
25
+ const cursorMove = /* @__PURE__ */ __name((x, y) => {
26
+ let returnValue = "";
27
+ if (x < 0) {
28
+ returnValue += `${CSI + -x}D`;
29
+ } else if (x > 0) {
30
+ returnValue += `${CSI + x}C`;
31
+ }
32
+ if (y < 0) {
33
+ returnValue += `${CSI + -y}A`;
34
+ } else if (y > 0) {
35
+ returnValue += `${CSI + y}B`;
36
+ }
37
+ return returnValue;
38
+ }, "cursorMove");
39
+ const cursorNextLine = /* @__PURE__ */ __name((count = 1) => `${CSI + count}E`, "cursorNextLine");
40
+ const cursorPreviousLine = /* @__PURE__ */ __name((count = 1) => `${CSI + count}F`, "cursorPreviousLine");
41
+ const cursorRestore = isTerminalApp ? RESTORE_CURSOR_DEC : `${ESC}u`;
42
+ const cursorSave = isTerminalApp ? SAVE_CURSOR_DEC : `${ESC}s`;
43
+ const cursorShow = `${CSI}?25h`;
44
+ const cursorTo = /* @__PURE__ */ __name((x, y) => {
45
+ if (y === void 0) {
46
+ return cursorHorizontalAbsolute(x + 1);
47
+ }
48
+ return `${CSI + (y + 1) + SEP + (x + 1)}H`;
49
+ }, "cursorTo");
50
+ const cursorPosition = /* @__PURE__ */ __name((row, column) => {
51
+ if (column === void 0) {
52
+ return `${CSI + row}H`;
53
+ }
54
+ return `${CSI + row + SEP + column}H`;
55
+ }, "cursorPosition");
56
+ const cursorHorizontalForwardTab = /* @__PURE__ */ __name((count = 1) => `${CSI + count}I`, "cursorHorizontalForwardTab");
57
+ const cursorBackwardTab = /* @__PURE__ */ __name((count = 1) => `${CSI + count}Z`, "cursorBackwardTab");
58
+ const eraseCharacter = /* @__PURE__ */ __name((count = 1) => `${CSI + count}X`, "eraseCharacter");
59
+ const cursorVerticalAbsolute = /* @__PURE__ */ __name((row = 1) => `${CSI + row}d`, "cursorVerticalAbsolute");
60
+ const cursorUp = /* @__PURE__ */ __name((count = 1) => `${CSI + count}A`, "cursorUp");
61
+ var CursorStyle = /* @__PURE__ */ ((CursorStyle2) => {
62
+ CursorStyle2[CursorStyle2["BlinkingBar"] = 5] = "BlinkingBar";
63
+ CursorStyle2[CursorStyle2["BlinkingBlock"] = 1] = "BlinkingBlock";
64
+ CursorStyle2[CursorStyle2["BlinkingUnderline"] = 3] = "BlinkingUnderline";
65
+ CursorStyle2[CursorStyle2["Default"] = 0] = "Default";
66
+ CursorStyle2[CursorStyle2["SteadyBar"] = 6] = "SteadyBar";
67
+ CursorStyle2[CursorStyle2["SteadyBlock"] = 2] = "SteadyBlock";
68
+ CursorStyle2[CursorStyle2["SteadyUnderline"] = 4] = "SteadyUnderline";
69
+ return CursorStyle2;
70
+ })(CursorStyle || {});
71
+ const setCursorStyle = /* @__PURE__ */ __name((style) => `${CSI + style} q`, "setCursorStyle");
72
+
73
+ 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, cursorBackward as d, cursorBackwardTab as e, cursorDown as f, cursorForward as g, cursorHide as h, cursorHorizontalAbsolute as i, cursorHorizontalForwardTab as j, cursorLeft as k, cursorMove as l, cursorNextLine as m, cursorPosition as n, cursorPreviousLine as o, cursorRestore as p, cursorSave as q, cursorShow as r, cursorTo as s, cursorToColumn1 as t, cursorUp as u, cursorVerticalAbsolute as v, eraseCharacter as w, REQUEST_EXTENDED_CURSOR_POSITION as x, RESTORE_CURSOR_DEC as y, setCursorStyle as z };
@@ -0,0 +1,38 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
4
+
5
+ const constants = require('./packem_shared/constants-BK26O-46.cjs');
6
+
7
+ var __defProp = Object.defineProperty;
8
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
+ const SCREEN_MAX_LEN_DEFAULT = 0;
10
+ const SCREEN_TYPICAL_LIMIT = 768;
11
+ const screenPassthrough = /* @__PURE__ */ __name((sequence, limit = SCREEN_MAX_LEN_DEFAULT) => {
12
+ let result = constants.DCS;
13
+ if (limit > 0 && sequence.length > limit) {
14
+ for (let index = 0; index < sequence.length; index += limit) {
15
+ const end = Math.min(index + limit, sequence.length);
16
+ result += sequence.slice(index, end);
17
+ if (end < sequence.length) {
18
+ result += constants.ST + constants.DCS;
19
+ }
20
+ }
21
+ } else {
22
+ result += sequence;
23
+ }
24
+ result += constants.ST;
25
+ return result;
26
+ }, "screenPassthrough");
27
+ const tmuxPassthrough = /* @__PURE__ */ __name((sequence) => {
28
+ let escapedSequence = "";
29
+ for (const element of sequence) {
30
+ escapedSequence += element === constants.ESC ? constants.ESC + constants.ESC : element;
31
+ }
32
+ return `${constants.DCS}tmux;${escapedSequence}${constants.ST}`;
33
+ }, "tmuxPassthrough");
34
+
35
+ exports.SCREEN_MAX_LEN_DEFAULT = SCREEN_MAX_LEN_DEFAULT;
36
+ exports.SCREEN_TYPICAL_LIMIT = SCREEN_TYPICAL_LIMIT;
37
+ exports.screenPassthrough = screenPassthrough;
38
+ exports.tmuxPassthrough = tmuxPassthrough;
@@ -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,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;