@visulima/ansi 4.0.0-alpha.7 → 4.0.0-alpha.8
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.
- package/CHANGELOG.md +22 -0
- package/dist/alternative-screen.js +8 -1
- package/dist/clear.d.ts +1 -1
- package/dist/clear.js +10 -1
- package/dist/cursor.d.ts +11 -11
- package/dist/cursor.js +3 -1
- package/dist/erase.d.ts +22 -22
- package/dist/erase.js +47 -1
- package/dist/hyperlink.js +5 -1
- package/dist/image.js +40 -1
- package/dist/index.js +26 -1
- package/dist/iterm2/iterm2-properties.d.ts +1 -1
- package/dist/iterm2/iterm2-sequences.d.ts +4 -4
- package/dist/iterm2.js +12 -1
- package/dist/mode.d.ts +11 -11
- package/dist/mode.js +245 -1
- package/dist/mouse.js +106 -1
- package/dist/packem_shared/IT2_AUTO-DyYWsxno.js +6 -0
- package/dist/packem_shared/ITerm2File-CUZDBk99.js +137 -0
- package/dist/packem_shared/constants-CE7WkXh_.js +9 -0
- package/dist/packem_shared/cursor-ChpV7cgs.js +72 -0
- package/dist/packem_shared/resetProgressBar-D9r2s7eV.js +18 -0
- package/dist/packem_shared/restoreCursor-GfYEeJqN.js +323 -0
- package/dist/passthrough.js +29 -1
- package/dist/reset.js +4 -1
- package/dist/screen.js +27 -1
- package/dist/scroll.js +18 -1
- package/dist/status.d.ts +6 -5
- package/dist/status.js +95 -1
- package/dist/strip.d.ts +0 -21
- package/dist/strip.js +13 -1
- package/dist/termcap.d.ts +1 -1
- package/dist/termcap.js +25 -1
- package/dist/title.d.ts +32 -34
- package/dist/title.js +19 -1
- package/dist/window-ops.d.ts +55 -55
- package/dist/window-ops.js +61 -1
- package/dist/xterm.d.ts +3 -3
- package/dist/xterm.js +33 -1
- package/package.json +1 -3
- package/dist/packem_shared/IT2_AUTO-BYrffRAq.js +0 -1
- package/dist/packem_shared/ITerm2File-C88DBJC-.js +0 -1
- package/dist/packem_shared/constants-D12jy2Zh.js +0 -1
- package/dist/packem_shared/cursor-8eSvcJ2I.js +0 -1
- package/dist/packem_shared/resetProgressBar-BtBbpWCM.js +0 -1
- package/dist/packem_shared/restoreCursor-CHy0jZuu.js +0 -2
|
@@ -0,0 +1,323 @@
|
|
|
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 process$2 = __cjs_getProcess;
|
|
8
|
+
|
|
9
|
+
const copyProperty = (to, from, property, ignoreNonConfigurable) => {
|
|
10
|
+
if (property === "length" || property === "prototype") {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
if (property === "arguments" || property === "caller") {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const toDescriptor = Object.getOwnPropertyDescriptor(to, property);
|
|
17
|
+
const fromDescriptor = Object.getOwnPropertyDescriptor(from, property);
|
|
18
|
+
if (!canCopyProperty(toDescriptor, fromDescriptor) && ignoreNonConfigurable) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
Object.defineProperty(to, property, fromDescriptor);
|
|
22
|
+
};
|
|
23
|
+
const canCopyProperty = function(toDescriptor, fromDescriptor) {
|
|
24
|
+
return toDescriptor === void 0 || toDescriptor.configurable || toDescriptor.writable === fromDescriptor.writable && toDescriptor.enumerable === fromDescriptor.enumerable && toDescriptor.configurable === fromDescriptor.configurable && (toDescriptor.writable || toDescriptor.value === fromDescriptor.value);
|
|
25
|
+
};
|
|
26
|
+
const changePrototype = (to, from) => {
|
|
27
|
+
const fromPrototype = Object.getPrototypeOf(from);
|
|
28
|
+
if (fromPrototype === Object.getPrototypeOf(to)) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
Object.setPrototypeOf(to, fromPrototype);
|
|
32
|
+
};
|
|
33
|
+
const wrappedToString = (withName, fromBody) => `/* Wrapped ${withName}*/
|
|
34
|
+
${fromBody}`;
|
|
35
|
+
const toStringDescriptor = Object.getOwnPropertyDescriptor(Function.prototype, "toString");
|
|
36
|
+
const toStringName = Object.getOwnPropertyDescriptor(Function.prototype.toString, "name");
|
|
37
|
+
const changeToString = (to, from, name) => {
|
|
38
|
+
const withName = name === "" ? "" : `with ${name.trim()}() `;
|
|
39
|
+
const newToString = wrappedToString.bind(null, withName, from.toString());
|
|
40
|
+
Object.defineProperty(newToString, "name", toStringName);
|
|
41
|
+
const { writable, enumerable, configurable } = toStringDescriptor;
|
|
42
|
+
Object.defineProperty(to, "toString", { value: newToString, writable, enumerable, configurable });
|
|
43
|
+
};
|
|
44
|
+
function mimicFunction(to, from, { ignoreNonConfigurable = false } = {}) {
|
|
45
|
+
const { name } = to;
|
|
46
|
+
for (const property of Reflect.ownKeys(from)) {
|
|
47
|
+
copyProperty(to, from, property, ignoreNonConfigurable);
|
|
48
|
+
}
|
|
49
|
+
changePrototype(to, from);
|
|
50
|
+
changeToString(to, from, name);
|
|
51
|
+
return to;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const calledFunctions = /* @__PURE__ */ new WeakMap();
|
|
55
|
+
const onetime = (function_, options = {}) => {
|
|
56
|
+
if (typeof function_ !== "function") {
|
|
57
|
+
throw new TypeError("Expected a function");
|
|
58
|
+
}
|
|
59
|
+
let returnValue;
|
|
60
|
+
let callCount = 0;
|
|
61
|
+
const functionName = function_.displayName || function_.name || "<anonymous>";
|
|
62
|
+
const onetime2 = function(...arguments_) {
|
|
63
|
+
calledFunctions.set(onetime2, ++callCount);
|
|
64
|
+
if (callCount === 1) {
|
|
65
|
+
returnValue = function_.apply(this, arguments_);
|
|
66
|
+
function_ = void 0;
|
|
67
|
+
} else if (options.throw === true) {
|
|
68
|
+
throw new Error(`Function \`${functionName}\` can only be called once`);
|
|
69
|
+
}
|
|
70
|
+
return returnValue;
|
|
71
|
+
};
|
|
72
|
+
mimicFunction(onetime2, function_);
|
|
73
|
+
calledFunctions.set(onetime2, callCount);
|
|
74
|
+
return onetime2;
|
|
75
|
+
};
|
|
76
|
+
onetime.callCount = (function_) => {
|
|
77
|
+
if (!calledFunctions.has(function_)) {
|
|
78
|
+
throw new Error(`The given function \`${function_.name}\` is not wrapped by the \`onetime\` package`);
|
|
79
|
+
}
|
|
80
|
+
return calledFunctions.get(function_);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const signals = [];
|
|
84
|
+
signals.push("SIGHUP", "SIGINT", "SIGTERM");
|
|
85
|
+
if (process.platform !== "win32") {
|
|
86
|
+
signals.push(
|
|
87
|
+
"SIGALRM",
|
|
88
|
+
"SIGABRT",
|
|
89
|
+
"SIGVTALRM",
|
|
90
|
+
"SIGXCPU",
|
|
91
|
+
"SIGXFSZ",
|
|
92
|
+
"SIGUSR2",
|
|
93
|
+
"SIGTRAP",
|
|
94
|
+
"SIGSYS",
|
|
95
|
+
"SIGQUIT",
|
|
96
|
+
"SIGIOT"
|
|
97
|
+
// should detect profiler and enable/disable accordingly.
|
|
98
|
+
// see #21
|
|
99
|
+
// 'SIGPROF'
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
if (process.platform === "linux") {
|
|
103
|
+
signals.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT");
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const processOk = (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";
|
|
107
|
+
const kExitEmitter = /* @__PURE__ */ Symbol.for("signal-exit emitter");
|
|
108
|
+
const global = globalThis;
|
|
109
|
+
const ObjectDefineProperty = Object.defineProperty.bind(Object);
|
|
110
|
+
class Emitter {
|
|
111
|
+
emitted = {
|
|
112
|
+
afterExit: false,
|
|
113
|
+
exit: false
|
|
114
|
+
};
|
|
115
|
+
listeners = {
|
|
116
|
+
afterExit: [],
|
|
117
|
+
exit: []
|
|
118
|
+
};
|
|
119
|
+
count = 0;
|
|
120
|
+
id = Math.random();
|
|
121
|
+
constructor() {
|
|
122
|
+
if (global[kExitEmitter]) {
|
|
123
|
+
return global[kExitEmitter];
|
|
124
|
+
}
|
|
125
|
+
ObjectDefineProperty(global, kExitEmitter, {
|
|
126
|
+
value: this,
|
|
127
|
+
writable: false,
|
|
128
|
+
enumerable: false,
|
|
129
|
+
configurable: false
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
on(ev, fn) {
|
|
133
|
+
this.listeners[ev].push(fn);
|
|
134
|
+
}
|
|
135
|
+
removeListener(ev, fn) {
|
|
136
|
+
const list = this.listeners[ev];
|
|
137
|
+
const i = list.indexOf(fn);
|
|
138
|
+
if (i === -1) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
if (i === 0 && list.length === 1) {
|
|
142
|
+
list.length = 0;
|
|
143
|
+
} else {
|
|
144
|
+
list.splice(i, 1);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
emit(ev, code, signal) {
|
|
148
|
+
if (this.emitted[ev]) {
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
this.emitted[ev] = true;
|
|
152
|
+
let ret = false;
|
|
153
|
+
for (const fn of this.listeners[ev]) {
|
|
154
|
+
ret = fn(code, signal) === true || ret;
|
|
155
|
+
}
|
|
156
|
+
if (ev === "exit") {
|
|
157
|
+
ret = this.emit("afterExit", code, signal) || ret;
|
|
158
|
+
}
|
|
159
|
+
return ret;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
class SignalExitBase {
|
|
163
|
+
}
|
|
164
|
+
const signalExitWrap = (handler) => {
|
|
165
|
+
return {
|
|
166
|
+
onExit(cb, opts) {
|
|
167
|
+
return handler.onExit(cb, opts);
|
|
168
|
+
},
|
|
169
|
+
load() {
|
|
170
|
+
return handler.load();
|
|
171
|
+
},
|
|
172
|
+
unload() {
|
|
173
|
+
return handler.unload();
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
};
|
|
177
|
+
class SignalExitFallback extends SignalExitBase {
|
|
178
|
+
onExit() {
|
|
179
|
+
return () => {
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
load() {
|
|
183
|
+
}
|
|
184
|
+
unload() {
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
class SignalExit extends SignalExitBase {
|
|
188
|
+
// "SIGHUP" throws an `ENOSYS` error on Windows,
|
|
189
|
+
// so use a supported signal instead
|
|
190
|
+
/* c8 ignore start */
|
|
191
|
+
#hupSig = process$1.platform === "win32" ? "SIGINT" : "SIGHUP";
|
|
192
|
+
/* c8 ignore stop */
|
|
193
|
+
#emitter = new Emitter();
|
|
194
|
+
#process;
|
|
195
|
+
#originalProcessEmit;
|
|
196
|
+
#originalProcessReallyExit;
|
|
197
|
+
#sigListeners = {};
|
|
198
|
+
#loaded = false;
|
|
199
|
+
constructor(process2) {
|
|
200
|
+
super();
|
|
201
|
+
this.#process = process2;
|
|
202
|
+
this.#sigListeners = {};
|
|
203
|
+
for (const sig of signals) {
|
|
204
|
+
this.#sigListeners[sig] = () => {
|
|
205
|
+
const listeners = this.#process.listeners(sig);
|
|
206
|
+
let { count } = this.#emitter;
|
|
207
|
+
const p = process2;
|
|
208
|
+
if (typeof p.__signal_exit_emitter__ === "object" && typeof p.__signal_exit_emitter__.count === "number") {
|
|
209
|
+
count += p.__signal_exit_emitter__.count;
|
|
210
|
+
}
|
|
211
|
+
if (listeners.length === count) {
|
|
212
|
+
this.unload();
|
|
213
|
+
const ret = this.#emitter.emit("exit", null, sig);
|
|
214
|
+
const s = sig === "SIGHUP" ? this.#hupSig : sig;
|
|
215
|
+
if (!ret)
|
|
216
|
+
process2.kill(process2.pid, s);
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
this.#originalProcessReallyExit = process2.reallyExit;
|
|
221
|
+
this.#originalProcessEmit = process2.emit;
|
|
222
|
+
}
|
|
223
|
+
onExit(cb, opts) {
|
|
224
|
+
if (!processOk(this.#process)) {
|
|
225
|
+
return () => {
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
if (this.#loaded === false) {
|
|
229
|
+
this.load();
|
|
230
|
+
}
|
|
231
|
+
const ev = opts?.alwaysLast ? "afterExit" : "exit";
|
|
232
|
+
this.#emitter.on(ev, cb);
|
|
233
|
+
return () => {
|
|
234
|
+
this.#emitter.removeListener(ev, cb);
|
|
235
|
+
if (this.#emitter.listeners["exit"].length === 0 && this.#emitter.listeners["afterExit"].length === 0) {
|
|
236
|
+
this.unload();
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
load() {
|
|
241
|
+
if (this.#loaded) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
this.#loaded = true;
|
|
245
|
+
this.#emitter.count += 1;
|
|
246
|
+
for (const sig of signals) {
|
|
247
|
+
try {
|
|
248
|
+
const fn = this.#sigListeners[sig];
|
|
249
|
+
if (fn)
|
|
250
|
+
this.#process.on(sig, fn);
|
|
251
|
+
} catch (_) {
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
this.#process.emit = (ev, ...a) => {
|
|
255
|
+
return this.#processEmit(ev, ...a);
|
|
256
|
+
};
|
|
257
|
+
this.#process.reallyExit = (code) => {
|
|
258
|
+
return this.#processReallyExit(code);
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
unload() {
|
|
262
|
+
if (!this.#loaded) {
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
this.#loaded = false;
|
|
266
|
+
signals.forEach((sig) => {
|
|
267
|
+
const listener = this.#sigListeners[sig];
|
|
268
|
+
if (!listener) {
|
|
269
|
+
throw new Error("Listener not defined for signal: " + sig);
|
|
270
|
+
}
|
|
271
|
+
try {
|
|
272
|
+
this.#process.removeListener(sig, listener);
|
|
273
|
+
} catch (_) {
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
this.#process.emit = this.#originalProcessEmit;
|
|
277
|
+
this.#process.reallyExit = this.#originalProcessReallyExit;
|
|
278
|
+
this.#emitter.count -= 1;
|
|
279
|
+
}
|
|
280
|
+
#processReallyExit(code) {
|
|
281
|
+
if (!processOk(this.#process)) {
|
|
282
|
+
return 0;
|
|
283
|
+
}
|
|
284
|
+
this.#process.exitCode = code || 0;
|
|
285
|
+
this.#emitter.emit("exit", this.#process.exitCode, null);
|
|
286
|
+
return this.#originalProcessReallyExit.call(this.#process, this.#process.exitCode);
|
|
287
|
+
}
|
|
288
|
+
#processEmit(ev, ...args) {
|
|
289
|
+
const og = this.#originalProcessEmit;
|
|
290
|
+
if (ev === "exit" && processOk(this.#process)) {
|
|
291
|
+
if (typeof args[0] === "number") {
|
|
292
|
+
this.#process.exitCode = args[0];
|
|
293
|
+
}
|
|
294
|
+
const ret = og.call(this.#process, ev, ...args);
|
|
295
|
+
this.#emitter.emit("exit", this.#process.exitCode, null);
|
|
296
|
+
return ret;
|
|
297
|
+
} else {
|
|
298
|
+
return og.call(this.#process, ev, ...args);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
const process$1 = globalThis.process;
|
|
303
|
+
const {
|
|
304
|
+
/**
|
|
305
|
+
* Called when the process is exiting, whether via signal, explicit
|
|
306
|
+
* exit, or running out of stuff to do.
|
|
307
|
+
*
|
|
308
|
+
* If the global process object is not suitable for instrumentation,
|
|
309
|
+
* then this will be a no-op.
|
|
310
|
+
*
|
|
311
|
+
* Returns a function that may be used to unload signal-exit.
|
|
312
|
+
*/
|
|
313
|
+
onExit} = signalExitWrap(processOk(process$1) ? new SignalExit(process$1) : new SignalExitFallback());
|
|
314
|
+
|
|
315
|
+
const terminal = process$2.stderr.isTTY ? process$2.stderr : process$2.stdout.isTTY ? process$2.stdout : void 0;
|
|
316
|
+
const restoreCursor = terminal ? onetime(() => {
|
|
317
|
+
onExit(() => {
|
|
318
|
+
terminal.write("\x1B[?25h");
|
|
319
|
+
}, { alwaysLast: true });
|
|
320
|
+
}) : () => {
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
export { restoreCursor as default };
|
package/dist/passthrough.js
CHANGED
|
@@ -1 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
import { a as ST, D as DCS, E as ESC } from './packem_shared/constants-CE7WkXh_.js';
|
|
2
|
+
|
|
3
|
+
const SCREEN_MAX_LEN_DEFAULT = 0;
|
|
4
|
+
const SCREEN_TYPICAL_LIMIT = 768;
|
|
5
|
+
const screenPassthrough = (sequence, limit = SCREEN_MAX_LEN_DEFAULT) => {
|
|
6
|
+
let result = DCS;
|
|
7
|
+
if (limit > 0 && sequence.length > limit) {
|
|
8
|
+
for (let index = 0; index < sequence.length; index += limit) {
|
|
9
|
+
const end = Math.min(index + limit, sequence.length);
|
|
10
|
+
result += sequence.slice(index, end);
|
|
11
|
+
if (end < sequence.length) {
|
|
12
|
+
result += ST + DCS;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
} else {
|
|
16
|
+
result += sequence;
|
|
17
|
+
}
|
|
18
|
+
result += ST;
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
const tmuxPassthrough = (sequence) => {
|
|
22
|
+
let escapedSequence = "";
|
|
23
|
+
for (const element of sequence) {
|
|
24
|
+
escapedSequence += element === ESC ? ESC + ESC : element;
|
|
25
|
+
}
|
|
26
|
+
return `${DCS}tmux;${escapedSequence}${ST}`;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export { SCREEN_MAX_LEN_DEFAULT, SCREEN_TYPICAL_LIMIT, screenPassthrough, tmuxPassthrough };
|
package/dist/reset.js
CHANGED
package/dist/screen.js
CHANGED
|
@@ -1 +1,27 @@
|
|
|
1
|
-
|
|
1
|
+
import { C as CSI, S as SEP } from './packem_shared/constants-CE7WkXh_.js';
|
|
2
|
+
|
|
3
|
+
const insertLine = (count = 1) => `${CSI}${count <= 1 ? "" : String(count)}L`;
|
|
4
|
+
const deleteLine = (count = 1) => `${CSI}${count <= 1 ? "" : String(count)}M`;
|
|
5
|
+
const setTopBottomMargins = (top, bottom) => {
|
|
6
|
+
const topString = top && top > 0 ? top.toString() : "";
|
|
7
|
+
const bottomString = bottom && bottom > 0 ? bottom.toString() : "";
|
|
8
|
+
if (topString === "" && bottomString === "") {
|
|
9
|
+
return `${CSI}${SEP}r`;
|
|
10
|
+
}
|
|
11
|
+
return `${CSI}${topString}${SEP}${bottomString}r`;
|
|
12
|
+
};
|
|
13
|
+
const setLeftRightMargins = (left, right) => {
|
|
14
|
+
const leftString = left && left > 0 ? left.toString() : "";
|
|
15
|
+
const rightString = right && right > 0 ? right.toString() : "";
|
|
16
|
+
if (leftString === "" && rightString === "") {
|
|
17
|
+
return `${CSI}${SEP}s`;
|
|
18
|
+
}
|
|
19
|
+
return `${CSI}${leftString}${SEP}${rightString}s`;
|
|
20
|
+
};
|
|
21
|
+
const insertCharacter = (count = 1) => `${CSI}${count <= 1 ? "" : String(count)}@`;
|
|
22
|
+
const deleteCharacter = (count = 1) => `${CSI}${count <= 1 ? "" : String(count)}P`;
|
|
23
|
+
const clearTabStop = (mode = 0) => `${CSI}${String(mode)}g`;
|
|
24
|
+
const requestPresentationStateReport = (mode) => `${CSI}${String(mode)}$u`;
|
|
25
|
+
const repeatPreviousCharacter = (count = 1) => `${CSI}${count <= 1 ? "" : String(count)}b`;
|
|
26
|
+
|
|
27
|
+
export { clearTabStop, deleteCharacter, deleteLine, insertCharacter, insertLine, repeatPreviousCharacter, requestPresentationStateReport, setLeftRightMargins, setTopBottomMargins };
|
package/dist/scroll.js
CHANGED
|
@@ -1 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
import { C as CSI } from './packem_shared/constants-CE7WkXh_.js';
|
|
2
|
+
|
|
3
|
+
const scrollUp = (count = 1) => {
|
|
4
|
+
if (count === 0) {
|
|
5
|
+
return "";
|
|
6
|
+
}
|
|
7
|
+
return `${CSI}${count <= 1 ? "" : String(count)}S`;
|
|
8
|
+
};
|
|
9
|
+
const scrollDown = (count = 1) => {
|
|
10
|
+
if (count === 0) {
|
|
11
|
+
return "";
|
|
12
|
+
}
|
|
13
|
+
return `${CSI}${count <= 1 ? "" : String(count)}T`;
|
|
14
|
+
};
|
|
15
|
+
const SCROLL_UP_1 = `${CSI}S`;
|
|
16
|
+
const SCROLL_DOWN_1 = `${CSI}T`;
|
|
17
|
+
|
|
18
|
+
export { SCROLL_DOWN_1, SCROLL_UP_1, scrollDown, scrollUp };
|
package/dist/status.d.ts
CHANGED
|
@@ -205,8 +205,8 @@ export declare const requestPrimaryDeviceAttributes: string;
|
|
|
205
205
|
export declare const DA1: string;
|
|
206
206
|
/**
|
|
207
207
|
* Generates the response sequence for Primary Device Attributes (DA1).
|
|
208
|
-
* Sequence: `CSI ? Ps ; ... c
|
|
209
|
-
*
|
|
208
|
+
* Sequence: `CSI ? Ps ; ... c`.
|
|
209
|
+
* @remarks
|
|
210
210
|
* Common attributes include:
|
|
211
211
|
* - 1 132 columns
|
|
212
212
|
* - 2 Printer port
|
|
@@ -224,7 +224,7 @@ export declare const DA1: string;
|
|
|
224
224
|
* - 42 ISO Latin-2 character set
|
|
225
225
|
* - 44 PCTerm
|
|
226
226
|
* - 45 Soft key map
|
|
227
|
-
* - 46 ASCII emulation
|
|
227
|
+
* - 46 ASCII emulation.
|
|
228
228
|
* @param attributes Numeric attribute codes.
|
|
229
229
|
* @returns The DA1 response sequence.
|
|
230
230
|
* @example
|
|
@@ -508,8 +508,9 @@ export declare const RequestLightDarkReport: string;
|
|
|
508
508
|
/**
|
|
509
509
|
* Generates a Light/Dark Color Scheme Report sequence.
|
|
510
510
|
* This sequence reports the terminal's operating system light/dark color preference.
|
|
511
|
-
*
|
|
512
|
-
* - `CSI ? 997 ;
|
|
511
|
+
* @remarks
|
|
512
|
+
* - `CSI ? 997 ; 1 n` for dark mode.
|
|
513
|
+
* - `CSI ? 997 ; 2 n` for light mode.
|
|
513
514
|
* @param dark Whether the color scheme is dark mode (true) or light mode (false).
|
|
514
515
|
* @returns The light/dark report sequence string.
|
|
515
516
|
* @see {@link https://contour-terminal.org/vt-extensions/color-palette-update-notifications/}
|
package/dist/status.js
CHANGED
|
@@ -1 +1,95 @@
|
|
|
1
|
-
|
|
1
|
+
import { C as CSI, S as SEP, D as DCS, a as ST } from './packem_shared/constants-CE7WkXh_.js';
|
|
2
|
+
|
|
3
|
+
class AnsiStatusReportImpl {
|
|
4
|
+
constructor(reportCode) {
|
|
5
|
+
this.reportCode = reportCode;
|
|
6
|
+
}
|
|
7
|
+
reportCode;
|
|
8
|
+
isDecReport = false;
|
|
9
|
+
}
|
|
10
|
+
class DecStatusReportImpl {
|
|
11
|
+
constructor(reportCode) {
|
|
12
|
+
this.reportCode = reportCode;
|
|
13
|
+
}
|
|
14
|
+
reportCode;
|
|
15
|
+
isDecReport = true;
|
|
16
|
+
}
|
|
17
|
+
const createAnsiStatusReport = (code) => new AnsiStatusReportImpl(code);
|
|
18
|
+
const createDecStatusReport = (code) => new DecStatusReportImpl(code);
|
|
19
|
+
const deviceStatusReport = (...reports) => {
|
|
20
|
+
if (reports.length === 0) {
|
|
21
|
+
return "";
|
|
22
|
+
}
|
|
23
|
+
const hasDecReport = reports.some((report) => report.isDecReport);
|
|
24
|
+
const reportCodes = reports.map((report) => report.reportCode.toString());
|
|
25
|
+
let seq = CSI;
|
|
26
|
+
if (hasDecReport) {
|
|
27
|
+
seq += "?";
|
|
28
|
+
}
|
|
29
|
+
return `${seq}${reportCodes.join(SEP)}n`;
|
|
30
|
+
};
|
|
31
|
+
const DSR = (report) => deviceStatusReport(report);
|
|
32
|
+
const requestCursorPositionReport = `${CSI}6n`;
|
|
33
|
+
const requestExtendedCursorPositionReport = `${CSI}?6n`;
|
|
34
|
+
const cursorPositionReport = (line, column) => {
|
|
35
|
+
const r = Math.max(1, line);
|
|
36
|
+
const c = Math.max(1, column);
|
|
37
|
+
return `${CSI}${r.toString()}${SEP}${c.toString()}R`;
|
|
38
|
+
};
|
|
39
|
+
const CPR = cursorPositionReport;
|
|
40
|
+
const extendedCursorPositionReport = (line, column, page) => {
|
|
41
|
+
const r = Math.max(1, line);
|
|
42
|
+
const c = Math.max(1, column);
|
|
43
|
+
let seq = `${CSI}?`;
|
|
44
|
+
seq += r.toString() + SEP + c.toString();
|
|
45
|
+
if (page > 0) {
|
|
46
|
+
seq += SEP + page.toString();
|
|
47
|
+
}
|
|
48
|
+
seq += "R";
|
|
49
|
+
return seq;
|
|
50
|
+
};
|
|
51
|
+
const DECXCPR = extendedCursorPositionReport;
|
|
52
|
+
const RequestNameVersion = `${CSI}>0q`;
|
|
53
|
+
const XTVERSION = RequestNameVersion;
|
|
54
|
+
const requestPrimaryDeviceAttributes = `${CSI}c`;
|
|
55
|
+
const DA1 = requestPrimaryDeviceAttributes;
|
|
56
|
+
const reportPrimaryDeviceAttributes = (...attributes) => {
|
|
57
|
+
if (attributes.length === 0) {
|
|
58
|
+
return "";
|
|
59
|
+
}
|
|
60
|
+
return `${CSI}?${attributes.join(SEP)}c`;
|
|
61
|
+
};
|
|
62
|
+
const requestSecondaryDeviceAttributes = `${CSI}>c`;
|
|
63
|
+
const DA2 = requestSecondaryDeviceAttributes;
|
|
64
|
+
const reportSecondaryDeviceAttributes = (version, level, cartridge = 0) => {
|
|
65
|
+
const pv = Math.max(0, version);
|
|
66
|
+
const pl = Math.max(0, level);
|
|
67
|
+
const pc = Math.max(0, cartridge);
|
|
68
|
+
return `${CSI}>${String(pv)}${SEP}${String(pl)}${SEP}${String(pc)}c`;
|
|
69
|
+
};
|
|
70
|
+
const requestTertiaryDeviceAttributes = `${CSI}=c`;
|
|
71
|
+
const DA3 = requestTertiaryDeviceAttributes;
|
|
72
|
+
const reportTertiaryDeviceAttributes = (unitID) => `${DCS}!|${unitID}${ST}`;
|
|
73
|
+
const requestPrimaryDeviceAttributesParam0 = `${CSI}0c`;
|
|
74
|
+
const requestSecondaryDeviceAttributesParam0 = `${CSI}>0c`;
|
|
75
|
+
const requestTertiaryDeviceAttributesParam0 = `${CSI}=0c`;
|
|
76
|
+
const requestTerminalStatus = createAnsiStatusReport(5);
|
|
77
|
+
const DSR_TerminalStatus = deviceStatusReport(requestTerminalStatus);
|
|
78
|
+
const reportTerminalOK = `${CSI}0n`;
|
|
79
|
+
const reportTerminalNotOK = `${CSI}3n`;
|
|
80
|
+
const requestPrinterStatusDEC = createDecStatusReport(15);
|
|
81
|
+
const DSR_PrinterStatusDEC = deviceStatusReport(requestPrinterStatusDEC);
|
|
82
|
+
const reportPrinterReadyDEC = `${CSI}?10n`;
|
|
83
|
+
const reportPrinterNotReadyDEC = `${CSI}?11n`;
|
|
84
|
+
const reportPrinterNoPaperDEC = `${CSI}?13n`;
|
|
85
|
+
const requestUDKStatusDEC = createDecStatusReport(25);
|
|
86
|
+
const DSR_UDKStatusDEC = deviceStatusReport(requestUDKStatusDEC);
|
|
87
|
+
const reportUDKLockedDEC = `${CSI}?20n`;
|
|
88
|
+
const reportUDKUnlockedDEC = `${CSI}?21n`;
|
|
89
|
+
const requestKeyboardLanguageDEC = createDecStatusReport(26);
|
|
90
|
+
const DSR_KeyboardLanguageDEC = deviceStatusReport(requestKeyboardLanguageDEC);
|
|
91
|
+
const reportKeyboardLanguageDEC = (langCode) => `${CSI}?27${SEP}${langCode.toString()}n`;
|
|
92
|
+
const RequestLightDarkReport = `${CSI}?996n`;
|
|
93
|
+
const LightDarkReport = (dark) => `${CSI}?997${SEP}${dark ? "1" : "2"}n`;
|
|
94
|
+
|
|
95
|
+
export { CPR, DA1, DA2, DA3, DECXCPR, DSR, DSR_KeyboardLanguageDEC, DSR_PrinterStatusDEC, DSR_TerminalStatus, DSR_UDKStatusDEC, LightDarkReport, RequestLightDarkReport, RequestNameVersion, XTVERSION, createAnsiStatusReport, createDecStatusReport, cursorPositionReport, deviceStatusReport, extendedCursorPositionReport, reportKeyboardLanguageDEC, reportPrimaryDeviceAttributes, reportPrinterNoPaperDEC, reportPrinterNotReadyDEC, reportPrinterReadyDEC, reportSecondaryDeviceAttributes, reportTerminalNotOK, reportTerminalOK, reportTertiaryDeviceAttributes, reportUDKLockedDEC, reportUDKUnlockedDEC, requestCursorPositionReport, requestExtendedCursorPositionReport, requestKeyboardLanguageDEC, requestPrimaryDeviceAttributes, requestPrimaryDeviceAttributesParam0, requestPrinterStatusDEC, requestSecondaryDeviceAttributes, requestSecondaryDeviceAttributesParam0, requestTerminalStatus, requestTertiaryDeviceAttributes, requestTertiaryDeviceAttributesParam0, requestUDKStatusDEC };
|
package/dist/strip.d.ts
CHANGED
|
@@ -1,23 +1,2 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Removes ANSI escape codes from a string.
|
|
3
|
-
*
|
|
4
|
-
* This function first removes OSC (Operating System Command) sequences like title strings
|
|
5
|
-
* (e.g., `\u001B]0;title\u0007`) and then uses a comprehensive regex (from the `ansi-regex` package)
|
|
6
|
-
* to strip all other ANSI escape codes.
|
|
7
|
-
* @param input The string from which to remove ANSI escape codes.
|
|
8
|
-
* @returns The input string with all ANSI escape codes stripped.
|
|
9
|
-
* @example
|
|
10
|
-
* ```typescript
|
|
11
|
-
* import { strip } from "@visulima/ansi";
|
|
12
|
-
*
|
|
13
|
-
* const textWithAnsi = "\x1b[32mHello, \x1b[1mWorld!\x1b[0m";
|
|
14
|
-
* const strippedText = strip(textWithAnsi);
|
|
15
|
-
* console.log(strippedText); // Output: "Hello, World!"
|
|
16
|
-
*
|
|
17
|
-
* const titleSequence = "\u001B]0;My Window Title\u0007Some content";
|
|
18
|
-
* const strippedTitle = strip(titleSequence);
|
|
19
|
-
* console.log(strippedTitle); // Output: "Some content"
|
|
20
|
-
* ```
|
|
21
|
-
*/
|
|
22
1
|
declare const strip: (input: string) => string;
|
|
23
2
|
export default strip;
|
package/dist/strip.js
CHANGED
|
@@ -1 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
function ansiRegex({ onlyFirst = false } = {}) {
|
|
2
|
+
const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
|
|
3
|
+
const osc = `(?:\\u001B\\][\\s\\S]*?${ST})`;
|
|
4
|
+
const csi = "[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";
|
|
5
|
+
const pattern = `${osc}|${csi}`;
|
|
6
|
+
return new RegExp(pattern, onlyFirst ? void 0 : "g");
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const regex = ansiRegex();
|
|
10
|
+
const OSC_TITLE_REGEX = /\u001B\]0;.*\u0007/;
|
|
11
|
+
const strip = (input) => input.replace(OSC_TITLE_REGEX, "").replace(regex, "");
|
|
12
|
+
|
|
13
|
+
export { strip as default };
|
package/dist/termcap.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Requests Termcap/Terminfo (XTGETTCAP) strings from the terminal.
|
|
3
|
-
* Sequence: DCS + q
|
|
3
|
+
* Sequence: `DCS + q Pt ST`.
|
|
4
4
|
* @param caps A list of termcap/terminfo capability names (e.g., "Co", "li", "cols").
|
|
5
5
|
* @returns The XTGETTCAP sequence string.
|
|
6
6
|
* @see https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Device-Control-Strings-plus-q
|
package/dist/termcap.js
CHANGED
|
@@ -1 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
import { D as DCS, a as ST, S as SEP } from './packem_shared/constants-CE7WkXh_.js';
|
|
2
|
+
|
|
3
|
+
const stringToHex = (input) => {
|
|
4
|
+
let hex = "";
|
|
5
|
+
for (let index = 0; index < input.length; index += 1) {
|
|
6
|
+
const charCode = input.codePointAt(index);
|
|
7
|
+
if (charCode === void 0) {
|
|
8
|
+
continue;
|
|
9
|
+
}
|
|
10
|
+
const byteHex = charCode.toString(16).toUpperCase();
|
|
11
|
+
hex += byteHex.length === 1 ? `0${byteHex}` : byteHex;
|
|
12
|
+
}
|
|
13
|
+
return hex;
|
|
14
|
+
};
|
|
15
|
+
const XTGETTCAP = (...caps) => {
|
|
16
|
+
if (caps.length === 0) {
|
|
17
|
+
return "";
|
|
18
|
+
}
|
|
19
|
+
const hexCaps = caps.map((cap) => stringToHex(cap));
|
|
20
|
+
return `${DCS}+q${hexCaps.join(SEP)}${ST}`;
|
|
21
|
+
};
|
|
22
|
+
const requestTermcap = XTGETTCAP;
|
|
23
|
+
const requestTerminfo = XTGETTCAP;
|
|
24
|
+
|
|
25
|
+
export { XTGETTCAP, requestTermcap, requestTerminfo };
|