@visulima/ansi 2.0.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/LICENSE.md +1 -132
  3. package/README.md +226 -226
  4. package/dist/alternative-screen.d.ts +6 -74
  5. package/dist/alternative-screen.js +1 -0
  6. package/dist/clear.d.ts +6 -77
  7. package/dist/clear.js +1 -0
  8. package/dist/cursor.d.ts +48 -429
  9. package/dist/cursor.js +1 -0
  10. package/dist/erase.d.ts +14 -197
  11. package/dist/erase.js +1 -0
  12. package/dist/hyperlink.d.ts +1 -27
  13. package/dist/hyperlink.js +1 -0
  14. package/dist/image.d.ts +7 -69
  15. package/dist/image.js +1 -0
  16. package/dist/index.d.ts +30 -35
  17. package/dist/index.js +1 -0
  18. package/dist/iterm2.d.ts +43 -58
  19. package/dist/iterm2.js +1 -0
  20. package/dist/mode.d.ts +174 -648
  21. package/dist/mode.js +1 -0
  22. package/dist/mouse.d.ts +21 -203
  23. package/dist/mouse.js +1 -0
  24. package/dist/packem_shared/IT2_AUTO-BYrffRAq.js +1 -0
  25. package/dist/packem_shared/ITerm2File-C88DBJC-.js +1 -0
  26. package/dist/packem_shared/constants-D12jy2Zh.js +1 -0
  27. package/dist/packem_shared/cursor-D2UOfUc_.js +1 -0
  28. package/dist/packem_shared/resetProgressBar-BtBbpWCM.js +1 -0
  29. package/dist/packem_shared/restoreCursor-D3XBmqcY.js +2 -0
  30. package/dist/passthrough.d.ts +6 -77
  31. package/dist/passthrough.js +1 -0
  32. package/dist/reset.d.ts +4 -26
  33. package/dist/reset.js +1 -0
  34. package/dist/screen.d.ts +11 -234
  35. package/dist/screen.js +1 -0
  36. package/dist/scroll.d.ts +6 -67
  37. package/dist/scroll.js +1 -0
  38. package/dist/status.d.ts +48 -498
  39. package/dist/status.js +1 -0
  40. package/dist/strip.d.ts +1 -23
  41. package/dist/strip.js +1 -0
  42. package/dist/termcap.d.ts +5 -38
  43. package/dist/termcap.js +1 -0
  44. package/dist/title.d.ts +10 -185
  45. package/dist/title.js +1 -0
  46. package/dist/window-ops.d.ts +24 -396
  47. package/dist/window-ops.js +1 -0
  48. package/dist/xterm.d.ts +12 -94
  49. package/dist/xterm.js +1 -0
  50. package/package.json +45 -230
  51. package/dist/alternative-screen.cjs +0 -17
  52. package/dist/alternative-screen.d.cts +0 -74
  53. package/dist/alternative-screen.d.mts +0 -74
  54. package/dist/alternative-screen.mjs +0 -10
  55. package/dist/clear.cjs +0 -17
  56. package/dist/clear.d.cts +0 -77
  57. package/dist/clear.d.mts +0 -77
  58. package/dist/clear.mjs +0 -10
  59. package/dist/constants.d.cts +0 -20
  60. package/dist/constants.d.mts +0 -20
  61. package/dist/constants.d.ts +0 -20
  62. package/dist/cursor.cjs +0 -41
  63. package/dist/cursor.d.cts +0 -437
  64. package/dist/cursor.d.mts +0 -437
  65. package/dist/cursor.mjs +0 -3
  66. package/dist/erase.cjs +0 -64
  67. package/dist/erase.d.cts +0 -206
  68. package/dist/erase.d.mts +0 -206
  69. package/dist/erase.mjs +0 -49
  70. package/dist/helpers.d.cts +0 -14
  71. package/dist/helpers.d.mts +0 -14
  72. package/dist/helpers.d.ts +0 -14
  73. package/dist/hyperlink.cjs +0 -9
  74. package/dist/hyperlink.d.cts +0 -29
  75. package/dist/hyperlink.d.mts +0 -27
  76. package/dist/hyperlink.mjs +0 -7
  77. package/dist/image.cjs +0 -28
  78. package/dist/image.d.cts +0 -73
  79. package/dist/image.d.mts +0 -73
  80. package/dist/image.mjs +0 -24
  81. package/dist/index.cjs +0 -246
  82. package/dist/index.d.cts +0 -35
  83. package/dist/index.d.mts +0 -35
  84. package/dist/index.mjs +0 -25
  85. package/dist/iterm2/iterm2-properties.d.cts +0 -135
  86. package/dist/iterm2/iterm2-properties.d.mts +0 -135
  87. package/dist/iterm2/iterm2-properties.d.ts +0 -135
  88. package/dist/iterm2/iterm2-sequences.d.cts +0 -96
  89. package/dist/iterm2/iterm2-sequences.d.mts +0 -96
  90. package/dist/iterm2/iterm2-sequences.d.ts +0 -96
  91. package/dist/iterm2.cjs +0 -26
  92. package/dist/iterm2.d.cts +0 -58
  93. package/dist/iterm2.d.mts +0 -58
  94. package/dist/iterm2.mjs +0 -14
  95. package/dist/mode.cjs +0 -388
  96. package/dist/mode.d.cts +0 -657
  97. package/dist/mode.d.mts +0 -657
  98. package/dist/mode.mjs +0 -235
  99. package/dist/mouse.cjs +0 -127
  100. package/dist/mouse.d.cts +0 -230
  101. package/dist/mouse.d.mts +0 -230
  102. package/dist/mouse.mjs +0 -108
  103. package/dist/packem_shared/IT2_AUTO-5vTJQMm6.cjs +0 -15
  104. package/dist/packem_shared/IT2_AUTO-DnfCUXso.mjs +0 -8
  105. package/dist/packem_shared/ITerm2File-BGPqNSjB.cjs +0 -137
  106. package/dist/packem_shared/ITerm2File-DKFkdqdA.mjs +0 -130
  107. package/dist/packem_shared/constants-BK26O-46.cjs +0 -17
  108. package/dist/packem_shared/constants-CE7WkXh_.mjs +0 -9
  109. package/dist/packem_shared/cursor-CQKLCu7U.cjs +0 -105
  110. package/dist/packem_shared/cursor-DhFQcQ9g.mjs +0 -73
  111. package/dist/packem_shared/restoreCursor-C6pNB8UY.mjs +0 -336
  112. package/dist/packem_shared/restoreCursor-DC_ZKZwT.cjs +0 -342
  113. package/dist/passthrough.cjs +0 -38
  114. package/dist/passthrough.d.cts +0 -77
  115. package/dist/passthrough.d.mts +0 -77
  116. package/dist/passthrough.mjs +0 -31
  117. package/dist/reset.cjs +0 -9
  118. package/dist/reset.d.cts +0 -26
  119. package/dist/reset.d.mts +0 -26
  120. package/dist/reset.mjs +0 -4
  121. package/dist/screen.cjs +0 -41
  122. package/dist/screen.d.cts +0 -234
  123. package/dist/screen.d.mts +0 -234
  124. package/dist/screen.mjs +0 -29
  125. package/dist/scroll.cjs +0 -27
  126. package/dist/scroll.d.cts +0 -67
  127. package/dist/scroll.d.mts +0 -67
  128. package/dist/scroll.mjs +0 -20
  129. package/dist/status.cjs +0 -147
  130. package/dist/status.d.cts +0 -501
  131. package/dist/status.d.mts +0 -501
  132. package/dist/status.mjs +0 -104
  133. package/dist/strip.cjs +0 -20
  134. package/dist/strip.d.cts +0 -25
  135. package/dist/strip.d.mts +0 -23
  136. package/dist/strip.mjs +0 -18
  137. package/dist/termcap.cjs +0 -33
  138. package/dist/termcap.d.cts +0 -38
  139. package/dist/termcap.d.mts +0 -38
  140. package/dist/termcap.mjs +0 -27
  141. package/dist/title.cjs +0 -31
  142. package/dist/title.d.cts +0 -185
  143. package/dist/title.d.mts +0 -185
  144. package/dist/title.mjs +0 -20
  145. package/dist/window-ops.cjs +0 -85
  146. package/dist/window-ops.d.cts +0 -418
  147. package/dist/window-ops.d.mts +0 -418
  148. package/dist/window-ops.mjs +0 -63
  149. package/dist/xterm.cjs +0 -48
  150. package/dist/xterm.d.cts +0 -94
  151. package/dist/xterm.d.mts +0 -94
  152. package/dist/xterm.mjs +0 -35
@@ -1,342 +0,0 @@
1
- 'use strict';
2
-
3
- const process$2 = require('node:process');
4
-
5
- const _interopDefaultCompat = e => e && typeof e === 'object' && 'default' in e ? e.default : e;
6
-
7
- const process__default = /*#__PURE__*/_interopDefaultCompat(process$2);
8
-
9
- var __defProp$2 = Object.defineProperty;
10
- var __name$2 = (target, value) => __defProp$2(target, "name", { value, configurable: true });
11
- const copyProperty = /* @__PURE__ */ __name$2((to, from, property, ignoreNonConfigurable) => {
12
- if (property === "length" || property === "prototype") {
13
- return;
14
- }
15
- if (property === "arguments" || property === "caller") {
16
- return;
17
- }
18
- const toDescriptor = Object.getOwnPropertyDescriptor(to, property);
19
- const fromDescriptor = Object.getOwnPropertyDescriptor(from, property);
20
- if (!canCopyProperty(toDescriptor, fromDescriptor) && ignoreNonConfigurable) {
21
- return;
22
- }
23
- Object.defineProperty(to, property, fromDescriptor);
24
- }, "copyProperty");
25
- const canCopyProperty = /* @__PURE__ */ __name$2(function(toDescriptor, fromDescriptor) {
26
- return toDescriptor === void 0 || toDescriptor.configurable || toDescriptor.writable === fromDescriptor.writable && toDescriptor.enumerable === fromDescriptor.enumerable && toDescriptor.configurable === fromDescriptor.configurable && (toDescriptor.writable || toDescriptor.value === fromDescriptor.value);
27
- }, "canCopyProperty");
28
- const changePrototype = /* @__PURE__ */ __name$2((to, from) => {
29
- const fromPrototype = Object.getPrototypeOf(from);
30
- if (fromPrototype === Object.getPrototypeOf(to)) {
31
- return;
32
- }
33
- Object.setPrototypeOf(to, fromPrototype);
34
- }, "changePrototype");
35
- const wrappedToString = /* @__PURE__ */ __name$2((withName, fromBody) => `/* Wrapped ${withName}*/
36
- ${fromBody}`, "wrappedToString");
37
- const toStringDescriptor = Object.getOwnPropertyDescriptor(Function.prototype, "toString");
38
- const toStringName = Object.getOwnPropertyDescriptor(Function.prototype.toString, "name");
39
- const changeToString = /* @__PURE__ */ __name$2((to, from, name) => {
40
- const withName = name === "" ? "" : `with ${name.trim()}() `;
41
- const newToString = wrappedToString.bind(null, withName, from.toString());
42
- Object.defineProperty(newToString, "name", toStringName);
43
- const { writable, enumerable, configurable } = toStringDescriptor;
44
- Object.defineProperty(to, "toString", { value: newToString, writable, enumerable, configurable });
45
- }, "changeToString");
46
- function mimicFunction(to, from, { ignoreNonConfigurable = false } = {}) {
47
- const { name } = to;
48
- for (const property of Reflect.ownKeys(from)) {
49
- copyProperty(to, from, property, ignoreNonConfigurable);
50
- }
51
- changePrototype(to, from);
52
- changeToString(to, from, name);
53
- return to;
54
- }
55
- __name$2(mimicFunction, "mimicFunction");
56
-
57
- var __defProp$1 = Object.defineProperty;
58
- var __name$1 = (target, value) => __defProp$1(target, "name", { value, configurable: true });
59
- const calledFunctions = /* @__PURE__ */ new WeakMap();
60
- const onetime = /* @__PURE__ */ __name$1((function_, options = {}) => {
61
- if (typeof function_ !== "function") {
62
- throw new TypeError("Expected a function");
63
- }
64
- let returnValue;
65
- let callCount = 0;
66
- const functionName = function_.displayName || function_.name || "<anonymous>";
67
- const onetime2 = /* @__PURE__ */ __name$1(function(...arguments_) {
68
- calledFunctions.set(onetime2, ++callCount);
69
- if (callCount === 1) {
70
- returnValue = function_.apply(this, arguments_);
71
- function_ = void 0;
72
- } else if (options.throw === true) {
73
- throw new Error(`Function \`${functionName}\` can only be called once`);
74
- }
75
- return returnValue;
76
- }, "onetime");
77
- mimicFunction(onetime2, function_);
78
- calledFunctions.set(onetime2, callCount);
79
- return onetime2;
80
- }, "onetime");
81
- onetime.callCount = (function_) => {
82
- if (!calledFunctions.has(function_)) {
83
- throw new Error(`The given function \`${function_.name}\` is not wrapped by the \`onetime\` package`);
84
- }
85
- return calledFunctions.get(function_);
86
- };
87
-
88
- const signals = [];
89
- signals.push("SIGHUP", "SIGINT", "SIGTERM");
90
- if (process.platform !== "win32") {
91
- signals.push(
92
- "SIGALRM",
93
- "SIGABRT",
94
- "SIGVTALRM",
95
- "SIGXCPU",
96
- "SIGXFSZ",
97
- "SIGUSR2",
98
- "SIGTRAP",
99
- "SIGSYS",
100
- "SIGQUIT",
101
- "SIGIOT"
102
- // should detect profiler and enable/disable accordingly.
103
- // see #21
104
- // 'SIGPROF'
105
- );
106
- }
107
- if (process.platform === "linux") {
108
- signals.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT");
109
- }
110
-
111
- var __defProp = Object.defineProperty;
112
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
113
- const processOk = /* @__PURE__ */ __name((process2) => !!process2 && true && typeof process2.removeListener === "function" && typeof process2.emit === "function" && typeof process2.reallyExit === "function" && typeof process2.listeners === "function" && typeof process2.kill === "function" && typeof process2.pid === "number" && typeof process2.on === "function", "processOk");
114
- const kExitEmitter = Symbol.for("signal-exit emitter");
115
- const global = globalThis;
116
- const ObjectDefineProperty = Object.defineProperty.bind(Object);
117
- class Emitter {
118
- static {
119
- __name(this, "Emitter");
120
- }
121
- emitted = {
122
- afterExit: false,
123
- exit: false
124
- };
125
- listeners = {
126
- afterExit: [],
127
- exit: []
128
- };
129
- count = 0;
130
- id = Math.random();
131
- constructor() {
132
- if (global[kExitEmitter]) {
133
- return global[kExitEmitter];
134
- }
135
- ObjectDefineProperty(global, kExitEmitter, {
136
- value: this,
137
- writable: false,
138
- enumerable: false,
139
- configurable: false
140
- });
141
- }
142
- on(ev, fn) {
143
- this.listeners[ev].push(fn);
144
- }
145
- removeListener(ev, fn) {
146
- const list = this.listeners[ev];
147
- const i = list.indexOf(fn);
148
- if (i === -1) {
149
- return;
150
- }
151
- if (i === 0 && list.length === 1) {
152
- list.length = 0;
153
- } else {
154
- list.splice(i, 1);
155
- }
156
- }
157
- emit(ev, code, signal) {
158
- if (this.emitted[ev]) {
159
- return false;
160
- }
161
- this.emitted[ev] = true;
162
- let ret = false;
163
- for (const fn of this.listeners[ev]) {
164
- ret = fn(code, signal) === true || ret;
165
- }
166
- if (ev === "exit") {
167
- ret = this.emit("afterExit", code, signal) || ret;
168
- }
169
- return ret;
170
- }
171
- }
172
- class SignalExitBase {
173
- static {
174
- __name(this, "SignalExitBase");
175
- }
176
- }
177
- const signalExitWrap = /* @__PURE__ */ __name((handler) => {
178
- return {
179
- onExit(cb, opts) {
180
- return handler.onExit(cb, opts);
181
- },
182
- load() {
183
- return handler.load();
184
- },
185
- unload() {
186
- return handler.unload();
187
- }
188
- };
189
- }, "signalExitWrap");
190
- class SignalExitFallback extends SignalExitBase {
191
- static {
192
- __name(this, "SignalExitFallback");
193
- }
194
- onExit() {
195
- return () => {
196
- };
197
- }
198
- load() {
199
- }
200
- unload() {
201
- }
202
- }
203
- class SignalExit extends SignalExitBase {
204
- static {
205
- __name(this, "SignalExit");
206
- }
207
- // "SIGHUP" throws an `ENOSYS` error on Windows,
208
- // so use a supported signal instead
209
- /* c8 ignore start */
210
- #hupSig = process$1.platform === "win32" ? "SIGINT" : "SIGHUP";
211
- /* c8 ignore stop */
212
- #emitter = new Emitter();
213
- #process;
214
- #originalProcessEmit;
215
- #originalProcessReallyExit;
216
- #sigListeners = {};
217
- #loaded = false;
218
- constructor(process2) {
219
- super();
220
- this.#process = process2;
221
- this.#sigListeners = {};
222
- for (const sig of signals) {
223
- this.#sigListeners[sig] = () => {
224
- const listeners = this.#process.listeners(sig);
225
- let { count } = this.#emitter;
226
- const p = process2;
227
- if (typeof p.__signal_exit_emitter__ === "object" && typeof p.__signal_exit_emitter__.count === "number") {
228
- count += p.__signal_exit_emitter__.count;
229
- }
230
- if (listeners.length === count) {
231
- this.unload();
232
- const ret = this.#emitter.emit("exit", null, sig);
233
- const s = sig === "SIGHUP" ? this.#hupSig : sig;
234
- if (!ret)
235
- process2.kill(process2.pid, s);
236
- }
237
- };
238
- }
239
- this.#originalProcessReallyExit = process2.reallyExit;
240
- this.#originalProcessEmit = process2.emit;
241
- }
242
- onExit(cb, opts) {
243
- if (!processOk(this.#process)) {
244
- return () => {
245
- };
246
- }
247
- if (this.#loaded === false) {
248
- this.load();
249
- }
250
- const ev = opts?.alwaysLast ? "afterExit" : "exit";
251
- this.#emitter.on(ev, cb);
252
- return () => {
253
- this.#emitter.removeListener(ev, cb);
254
- if (this.#emitter.listeners["exit"].length === 0 && this.#emitter.listeners["afterExit"].length === 0) {
255
- this.unload();
256
- }
257
- };
258
- }
259
- load() {
260
- if (this.#loaded) {
261
- return;
262
- }
263
- this.#loaded = true;
264
- this.#emitter.count += 1;
265
- for (const sig of signals) {
266
- try {
267
- const fn = this.#sigListeners[sig];
268
- if (fn)
269
- this.#process.on(sig, fn);
270
- } catch (_) {
271
- }
272
- }
273
- this.#process.emit = (ev, ...a) => {
274
- return this.#processEmit(ev, ...a);
275
- };
276
- this.#process.reallyExit = (code) => {
277
- return this.#processReallyExit(code);
278
- };
279
- }
280
- unload() {
281
- if (!this.#loaded) {
282
- return;
283
- }
284
- this.#loaded = false;
285
- signals.forEach((sig) => {
286
- const listener = this.#sigListeners[sig];
287
- if (!listener) {
288
- throw new Error("Listener not defined for signal: " + sig);
289
- }
290
- try {
291
- this.#process.removeListener(sig, listener);
292
- } catch (_) {
293
- }
294
- });
295
- this.#process.emit = this.#originalProcessEmit;
296
- this.#process.reallyExit = this.#originalProcessReallyExit;
297
- this.#emitter.count -= 1;
298
- }
299
- #processReallyExit(code) {
300
- if (!processOk(this.#process)) {
301
- return 0;
302
- }
303
- this.#process.exitCode = code || 0;
304
- this.#emitter.emit("exit", this.#process.exitCode, null);
305
- return this.#originalProcessReallyExit.call(this.#process, this.#process.exitCode);
306
- }
307
- #processEmit(ev, ...args) {
308
- const og = this.#originalProcessEmit;
309
- if (ev === "exit" && processOk(this.#process)) {
310
- if (typeof args[0] === "number") {
311
- this.#process.exitCode = args[0];
312
- }
313
- const ret = og.call(this.#process, ev, ...args);
314
- this.#emitter.emit("exit", this.#process.exitCode, null);
315
- return ret;
316
- } else {
317
- return og.call(this.#process, ev, ...args);
318
- }
319
- }
320
- }
321
- const process$1 = globalThis.process;
322
- const {
323
- /**
324
- * Called when the process is exiting, whether via signal, explicit
325
- * exit, or running out of stuff to do.
326
- *
327
- * If the global process object is not suitable for instrumentation,
328
- * then this will be a no-op.
329
- *
330
- * Returns a function that may be used to unload signal-exit.
331
- */
332
- onExit} = signalExitWrap(processOk(process$1) ? new SignalExit(process$1) : new SignalExitFallback());
333
-
334
- const terminal = process__default.stderr.isTTY ? process__default.stderr : process__default.stdout.isTTY ? process__default.stdout : void 0;
335
- const restoreCursor = terminal ? onetime(() => {
336
- onExit(() => {
337
- terminal.write("\x1B[?25h");
338
- }, { alwaysLast: true });
339
- }) : () => {
340
- };
341
-
342
- module.exports = restoreCursor;
@@ -1,38 +0,0 @@
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;
@@ -1,77 +0,0 @@
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;
@@ -1,77 +0,0 @@
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;
@@ -1,31 +0,0 @@
1
- import { D as DCS, a as ST, E as ESC } from './packem_shared/constants-CE7WkXh_.mjs';
2
-
3
- var __defProp = Object.defineProperty;
4
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
- const SCREEN_MAX_LEN_DEFAULT = 0;
6
- const SCREEN_TYPICAL_LIMIT = 768;
7
- const screenPassthrough = /* @__PURE__ */ __name((sequence, limit = SCREEN_MAX_LEN_DEFAULT) => {
8
- let result = DCS;
9
- if (limit > 0 && sequence.length > limit) {
10
- for (let index = 0; index < sequence.length; index += limit) {
11
- const end = Math.min(index + limit, sequence.length);
12
- result += sequence.slice(index, end);
13
- if (end < sequence.length) {
14
- result += ST + DCS;
15
- }
16
- }
17
- } else {
18
- result += sequence;
19
- }
20
- result += ST;
21
- return result;
22
- }, "screenPassthrough");
23
- const tmuxPassthrough = /* @__PURE__ */ __name((sequence) => {
24
- let escapedSequence = "";
25
- for (const element of sequence) {
26
- escapedSequence += element === ESC ? ESC + ESC : element;
27
- }
28
- return `${DCS}tmux;${escapedSequence}${ST}`;
29
- }, "tmuxPassthrough");
30
-
31
- export { SCREEN_MAX_LEN_DEFAULT, SCREEN_TYPICAL_LIMIT, screenPassthrough, tmuxPassthrough };
package/dist/reset.cjs DELETED
@@ -1,9 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
4
-
5
- const RESET_INITIAL_STATE = "\x1Bc";
6
- const RIS = RESET_INITIAL_STATE;
7
-
8
- exports.RESET_INITIAL_STATE = RESET_INITIAL_STATE;
9
- exports.RIS = RIS;
package/dist/reset.d.cts DELETED
@@ -1,26 +0,0 @@
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.d.mts DELETED
@@ -1,26 +0,0 @@
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.mjs DELETED
@@ -1,4 +0,0 @@
1
- const RESET_INITIAL_STATE = "\x1Bc";
2
- const RIS = RESET_INITIAL_STATE;
3
-
4
- export { RESET_INITIAL_STATE, RIS };
package/dist/screen.cjs DELETED
@@ -1,41 +0,0 @@
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 insertLine = /* @__PURE__ */ __name((count = 1) => `${constants.CSI + (count <= 1 ? "" : count)}L`, "insertLine");
10
- const deleteLine = /* @__PURE__ */ __name((count = 1) => `${constants.CSI + (count <= 1 ? "" : count)}M`, "deleteLine");
11
- const setTopBottomMargins = /* @__PURE__ */ __name((top, bottom) => {
12
- const topString = top && top > 0 ? top.toString() : "";
13
- const bottomString = bottom && bottom > 0 ? bottom.toString() : "";
14
- if (topString === "" && bottomString === "") {
15
- return `${constants.CSI + constants.SEP}r`;
16
- }
17
- return `${constants.CSI + topString + constants.SEP + bottomString}r`;
18
- }, "setTopBottomMargins");
19
- const setLeftRightMargins = /* @__PURE__ */ __name((left, right) => {
20
- const leftString = left && left > 0 ? left.toString() : "";
21
- const rightString = right && right > 0 ? right.toString() : "";
22
- if (leftString === "" && rightString === "") {
23
- return `${constants.CSI + constants.SEP}s`;
24
- }
25
- return `${constants.CSI + leftString + constants.SEP + rightString}s`;
26
- }, "setLeftRightMargins");
27
- const insertCharacter = /* @__PURE__ */ __name((count = 1) => `${constants.CSI + (count <= 1 ? "" : count)}@`, "insertCharacter");
28
- const deleteCharacter = /* @__PURE__ */ __name((count = 1) => `${constants.CSI + (count <= 1 ? "" : count)}P`, "deleteCharacter");
29
- const clearTabStop = /* @__PURE__ */ __name((mode = 0) => `${constants.CSI + mode}g`, "clearTabStop");
30
- const requestPresentationStateReport = /* @__PURE__ */ __name((mode) => `${constants.CSI + mode}$u`, "requestPresentationStateReport");
31
- const repeatPreviousCharacter = /* @__PURE__ */ __name((count = 1) => `${constants.CSI + (count <= 1 ? "" : count)}b`, "repeatPreviousCharacter");
32
-
33
- exports.clearTabStop = clearTabStop;
34
- exports.deleteCharacter = deleteCharacter;
35
- exports.deleteLine = deleteLine;
36
- exports.insertCharacter = insertCharacter;
37
- exports.insertLine = insertLine;
38
- exports.repeatPreviousCharacter = repeatPreviousCharacter;
39
- exports.requestPresentationStateReport = requestPresentationStateReport;
40
- exports.setLeftRightMargins = setLeftRightMargins;
41
- exports.setTopBottomMargins = setTopBottomMargins;