@visulima/ansi 4.0.0-alpha.8 → 4.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.
- package/CHANGELOG.md +306 -0
- package/LICENSE.md +0 -20
- package/README.md +41 -10
- package/dist/alternative-screen.d.ts +71 -70
- package/dist/alternative-screen.js +1 -8
- package/dist/background.d.ts +72 -0
- package/dist/background.js +1 -0
- package/dist/charset.d.ts +52 -0
- package/dist/charset.js +1 -0
- package/dist/clear.d.ts +74 -73
- package/dist/clear.js +1 -10
- package/dist/clipboard.d.ts +76 -0
- package/dist/clipboard.js +1 -0
- package/dist/constants.d.ts +18 -10
- package/dist/constants.js +1 -0
- package/dist/cursor.d.ts +421 -406
- package/dist/cursor.js +1 -3
- package/dist/cwd.d.ts +26 -0
- package/dist/cwd.js +1 -0
- package/dist/erase.d.ts +193 -192
- package/dist/erase.js +1 -47
- package/dist/finalterm.d.ts +47 -0
- package/dist/finalterm.js +1 -0
- package/dist/focus.d.ts +20 -0
- package/dist/focus.js +1 -0
- package/dist/hyperlink.d.ts +25 -25
- package/dist/hyperlink.js +1 -5
- package/dist/image.d.ts +70 -70
- package/dist/image.js +1 -40
- package/dist/index.d.ts +38 -35
- package/dist/index.js +1 -26
- package/dist/iterm2.d.ts +285 -58
- package/dist/iterm2.js +1 -12
- package/dist/keypad.d.ts +27 -0
- package/dist/keypad.js +1 -0
- package/dist/kitty-graphics.d.ts +17 -0
- package/dist/kitty-graphics.js +1 -0
- package/dist/mode.d.ts +585 -584
- package/dist/mode.js +1 -245
- package/dist/mouse.d.ts +227 -226
- package/dist/mouse.js +1 -106
- package/dist/notification.d.ts +30 -0
- package/dist/notification.js +1 -0
- package/dist/packem_shared/IT2_AUTO-K3GubKy7.js +1 -0
- package/dist/packem_shared/ITerm2File-BkLc5ipB.js +1 -0
- package/dist/packem_shared/cursor-BXG1O_IE.js +1 -0
- package/dist/packem_shared/restoreCursor-CyaXIMQf.js +2 -0
- package/dist/passthrough.d.ts +74 -73
- package/dist/passthrough.js +1 -29
- package/dist/paste.d.ts +23 -0
- package/dist/paste.js +1 -0
- package/dist/progress.d.ts +37 -36
- package/dist/progress.js +1 -0
- package/dist/reset.d.ts +25 -24
- package/dist/reset.js +1 -4
- package/dist/screen.d.ts +226 -225
- package/dist/screen.js +1 -27
- package/dist/scroll.d.ts +64 -63
- package/dist/scroll.js +1 -18
- package/dist/sixel.d.ts +19 -0
- package/dist/sixel.js +1 -0
- package/dist/status.d.ts +521 -520
- package/dist/status.js +1 -95
- package/dist/strip.d.ts +26 -1
- package/dist/strip.js +1 -13
- package/dist/termcap.d.ts +36 -35
- package/dist/termcap.js +1 -25
- package/dist/title.d.ts +176 -175
- package/dist/title.js +1 -19
- package/dist/urxvt.d.ts +15 -0
- package/dist/urxvt.js +1 -0
- package/dist/window-ops.d.ts +399 -398
- package/dist/window-ops.js +1 -61
- package/dist/xterm.d.ts +167 -84
- package/dist/xterm.js +1 -33
- package/package.json +60 -9
- package/dist/helpers.d.ts +0 -14
- package/dist/iterm2/iterm2-properties.d.ts +0 -135
- package/dist/iterm2/iterm2-sequences.d.ts +0 -96
- package/dist/packem_shared/IT2_AUTO-DyYWsxno.js +0 -6
- package/dist/packem_shared/ITerm2File-CUZDBk99.js +0 -137
- package/dist/packem_shared/constants-CE7WkXh_.js +0 -9
- package/dist/packem_shared/cursor-ChpV7cgs.js +0 -72
- package/dist/packem_shared/resetProgressBar-D9r2s7eV.js +0 -18
- package/dist/packem_shared/restoreCursor-GfYEeJqN.js +0 -323
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import type { IITerm2Payload, ITerm2FileProperties } from "./iterm2-properties.d.ts";
|
|
2
|
-
/**
|
|
3
|
-
* Represents the payload for a complete iTerm2 file transfer or an inline image display command.
|
|
4
|
-
* This class is used to construct the part of the OSC 1337 sequence that follows `File=`.
|
|
5
|
-
* The generated payload can be either:
|
|
6
|
-
* - `File=[PROPERTIES]:[BASE64_CONTENT]` (for inline content)
|
|
7
|
-
* - `File=[PROPERTIES]` (if content is not provided directly, e.g., for a download announcement)
|
|
8
|
-
*
|
|
9
|
-
* Implements {@link IITerm2Payload} for use with the generic `iTerm2` function.
|
|
10
|
-
* @see {@link ITerm2FileProperties} for property details.
|
|
11
|
-
* @see `iTerm2` for the function that wraps this payload into a full escape sequence.
|
|
12
|
-
*/
|
|
13
|
-
export declare class ITerm2File implements IITerm2Payload {
|
|
14
|
-
private readonly fileProps;
|
|
15
|
-
/**
|
|
16
|
-
* Constructs an `ITerm2File` payload object.
|
|
17
|
-
* @param properties An object containing properties for the file/image, as defined by {@link ITerm2FileProperties}.
|
|
18
|
-
* The `name` property within `props` should be pre-Base64 encoded by the caller if it might
|
|
19
|
-
* contain special characters (like `;`, `=`, or non-ASCII characters).
|
|
20
|
-
* If `fileData` is provided, `props.content` will be overridden, and `props.size` will be
|
|
21
|
-
* set from `fileData.byteLength` if not already present in `props`.
|
|
22
|
-
* @param fileData (Optional) A `Uint8Array` containing the raw file data. If provided, this data will be
|
|
23
|
-
* Base64 encoded and used as the `content` of the file transfer. The `size` property
|
|
24
|
-
* will also be automatically set from `fileData.byteLength` if not specified in `props`.
|
|
25
|
-
*/
|
|
26
|
-
constructor(properties: ITerm2FileProperties, fileData?: Uint8Array);
|
|
27
|
-
/**
|
|
28
|
-
* Converts the file properties and its content (if any) into the string payload
|
|
29
|
-
* suitable for the iTerm2 `File=` command.
|
|
30
|
-
* @returns The string payload (e.g., `"File=name=...;size=...:BASE64_CONTENT"` or `"File=name=...;size=..."`).
|
|
31
|
-
*/
|
|
32
|
-
toString(): string;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Represents the payload for ending an iTerm2 multipart file transfer.
|
|
36
|
-
* This class is used to construct the part of the OSC 1337 sequence that is simply `FileEnd`.
|
|
37
|
-
*
|
|
38
|
-
* Implements {@link IITerm2Payload} for use with the generic `iTerm2` function.
|
|
39
|
-
* @see {@link ITerm2MultipartFileStart} to initiate the transfer.
|
|
40
|
-
* @see {@link ITerm2FilePart} for sending file chunks.
|
|
41
|
-
*/
|
|
42
|
-
export declare class ITerm2FileEnd implements IITerm2Payload {
|
|
43
|
-
/**
|
|
44
|
-
* Generates the string payload for the iTerm2 `FileEnd` command.
|
|
45
|
-
* @returns The string `"FileEnd"`.
|
|
46
|
-
*/
|
|
47
|
-
toString(): string;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Represents the payload for a part (chunk) of an iTerm2 multipart file transfer.
|
|
51
|
-
* This class is used to construct the part of the OSC 1337 sequence that follows `FilePart=`.
|
|
52
|
-
* The provided chunk must already be Base64 encoded.
|
|
53
|
-
*
|
|
54
|
-
* Implements {@link IITerm2Payload} for use with the generic `iTerm2` function.
|
|
55
|
-
* @see {@link ITerm2MultipartFileStart} to initiate the transfer.
|
|
56
|
-
* @see {@link ITerm2FileEnd} to finalize the transfer.
|
|
57
|
-
*/
|
|
58
|
-
export declare class ITerm2FilePart implements IITerm2Payload {
|
|
59
|
-
private readonly base64Chunk;
|
|
60
|
-
/**
|
|
61
|
-
* Constructs an `ITerm2FilePart` payload object.
|
|
62
|
-
* @param base64Chunk A string containing a Base64 encoded chunk of the file data.
|
|
63
|
-
* The caller is responsible for chunking the file and Base64 encoding each chunk.
|
|
64
|
-
*/
|
|
65
|
-
constructor(base64Chunk: string);
|
|
66
|
-
/**
|
|
67
|
-
* Converts the Base64 encoded chunk into the string payload suitable for the iTerm2 `FilePart=` command.
|
|
68
|
-
* @returns The string payload (e.g., `"FilePart=U09NRURBVEE="`).
|
|
69
|
-
*/
|
|
70
|
-
toString(): string;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Represents the payload for starting an iTerm2 multipart file transfer.
|
|
74
|
-
* This class is used to construct the part of the OSC 1337 sequence that follows `MultipartFile=`.
|
|
75
|
-
* This command initiates a transfer; the actual file data is sent in subsequent `FilePart` commands.
|
|
76
|
-
*
|
|
77
|
-
* Implements {@link IITerm2Payload} for use with the generic `iTerm2` function.
|
|
78
|
-
* @see {@link ITerm2FileProperties} for property details (omitting `content`).
|
|
79
|
-
* @see {@link ITerm2FilePart} for sending file chunks.
|
|
80
|
-
* @see {@link ITerm2FileEnd} for finalizing the transfer.
|
|
81
|
-
*/
|
|
82
|
-
export declare class ITerm2MultipartFileStart implements IITerm2Payload {
|
|
83
|
-
private readonly properties;
|
|
84
|
-
/**
|
|
85
|
-
* Constructs an `ITerm2MultipartFileStart` payload object.
|
|
86
|
-
* @param properties Properties for the multipart file (e.g., `name`, `size`). Content is not part of this command.
|
|
87
|
-
* The `name` property within `props` should be pre-Base64 encoded by the caller if it might
|
|
88
|
-
* contain special characters.
|
|
89
|
-
*/
|
|
90
|
-
constructor(properties: Omit<ITerm2FileProperties, "content">);
|
|
91
|
-
/**
|
|
92
|
-
* Converts the file properties into the string payload suitable for the iTerm2 `MultipartFile=` command.
|
|
93
|
-
* @returns The string payload (e.g., `"MultipartFile=name=...;size=..."`).
|
|
94
|
-
*/
|
|
95
|
-
toString(): string;
|
|
96
|
-
}
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import { createRequire as __cjs_createRequire } from "node:module";
|
|
2
|
-
|
|
3
|
-
const __cjs_require = __cjs_createRequire(import.meta.url);
|
|
4
|
-
|
|
5
|
-
const __cjs_getProcess = typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" ? globalThis.process : process;
|
|
6
|
-
|
|
7
|
-
const __cjs_getBuiltinModule = (module) => {
|
|
8
|
-
// Check if we're in Node.js and version supports getBuiltinModule
|
|
9
|
-
if (typeof __cjs_getProcess !== "undefined" && __cjs_getProcess.versions && __cjs_getProcess.versions.node) {
|
|
10
|
-
const [major, minor] = __cjs_getProcess.versions.node.split(".").map(Number);
|
|
11
|
-
// Node.js 20.16.0+ and 22.3.0+
|
|
12
|
-
if (major > 22 || (major === 22 && minor >= 3) || (major === 20 && minor >= 16)) {
|
|
13
|
-
return __cjs_getProcess.getBuiltinModule(module);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
// Fallback to createRequire
|
|
17
|
-
return __cjs_require(module);
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const {
|
|
21
|
-
Buffer
|
|
22
|
-
} = __cjs_getBuiltinModule("node:buffer");
|
|
23
|
-
|
|
24
|
-
const formatITerm2FileProperties = (properties) => {
|
|
25
|
-
const options = [];
|
|
26
|
-
if (properties.name) {
|
|
27
|
-
options.push(`name=${properties.name}`);
|
|
28
|
-
}
|
|
29
|
-
if (properties.size !== void 0) {
|
|
30
|
-
options.push(`size=${String(properties.size)}`);
|
|
31
|
-
}
|
|
32
|
-
if (properties.width !== void 0) {
|
|
33
|
-
options.push(`width=${properties.width.toString()}`);
|
|
34
|
-
}
|
|
35
|
-
if (properties.height !== void 0) {
|
|
36
|
-
options.push(`height=${properties.height.toString()}`);
|
|
37
|
-
}
|
|
38
|
-
if (properties.ignoreAspectRatio) {
|
|
39
|
-
options.push("preserveAspectRatio=0");
|
|
40
|
-
}
|
|
41
|
-
if (properties.inline) {
|
|
42
|
-
options.push("inline=1");
|
|
43
|
-
}
|
|
44
|
-
if (properties.doNotMoveCursor) {
|
|
45
|
-
options.push("doNotMoveCursor=1");
|
|
46
|
-
}
|
|
47
|
-
return options.join(";");
|
|
48
|
-
};
|
|
49
|
-
class ITerm2File {
|
|
50
|
-
fileProps;
|
|
51
|
-
/**
|
|
52
|
-
* Constructs an `ITerm2File` payload object.
|
|
53
|
-
* @param properties An object containing properties for the file/image, as defined by {@link ITerm2FileProperties}.
|
|
54
|
-
* The `name` property within `props` should be pre-Base64 encoded by the caller if it might
|
|
55
|
-
* contain special characters (like `;`, `=`, or non-ASCII characters).
|
|
56
|
-
* If `fileData` is provided, `props.content` will be overridden, and `props.size` will be
|
|
57
|
-
* set from `fileData.byteLength` if not already present in `props`.
|
|
58
|
-
* @param fileData (Optional) A `Uint8Array` containing the raw file data. If provided, this data will be
|
|
59
|
-
* Base64 encoded and used as the `content` of the file transfer. The `size` property
|
|
60
|
-
* will also be automatically set from `fileData.byteLength` if not specified in `props`.
|
|
61
|
-
*/
|
|
62
|
-
constructor(properties, fileData) {
|
|
63
|
-
this.fileProps = { ...properties };
|
|
64
|
-
if (fileData) {
|
|
65
|
-
if (fileData.byteLength > 10 * 1024 * 1024) {
|
|
66
|
-
throw new Error("File size exceeds maximum limit of 10MB");
|
|
67
|
-
}
|
|
68
|
-
this.fileProps.content = Buffer.from(fileData).toString("base64");
|
|
69
|
-
this.fileProps.size ??= fileData.byteLength;
|
|
70
|
-
if (this.fileProps.size !== fileData.byteLength) {
|
|
71
|
-
throw new Error("File size property doesn't match actual data length");
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Converts the file properties and its content (if any) into the string payload
|
|
77
|
-
* suitable for the iTerm2 `File=` command.
|
|
78
|
-
* @returns The string payload (e.g., `"File=name=...;size=...:BASE64_CONTENT"` or `"File=name=...;size=..."`).
|
|
79
|
-
*/
|
|
80
|
-
toString() {
|
|
81
|
-
let s = "File=";
|
|
82
|
-
s += formatITerm2FileProperties(this.fileProps);
|
|
83
|
-
if (this.fileProps.content !== void 0) {
|
|
84
|
-
s += `:${this.fileProps.content}`;
|
|
85
|
-
}
|
|
86
|
-
return s;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
class ITerm2FileEnd {
|
|
90
|
-
/**
|
|
91
|
-
* Generates the string payload for the iTerm2 `FileEnd` command.
|
|
92
|
-
* @returns The string `"FileEnd"`.
|
|
93
|
-
*/
|
|
94
|
-
// eslint-disable-next-line class-methods-use-this
|
|
95
|
-
toString() {
|
|
96
|
-
return "FileEnd";
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
class ITerm2FilePart {
|
|
100
|
-
/**
|
|
101
|
-
* Constructs an `ITerm2FilePart` payload object.
|
|
102
|
-
* @param base64Chunk A string containing a Base64 encoded chunk of the file data.
|
|
103
|
-
* The caller is responsible for chunking the file and Base64 encoding each chunk.
|
|
104
|
-
*/
|
|
105
|
-
constructor(base64Chunk) {
|
|
106
|
-
this.base64Chunk = base64Chunk;
|
|
107
|
-
}
|
|
108
|
-
base64Chunk;
|
|
109
|
-
/**
|
|
110
|
-
* Converts the Base64 encoded chunk into the string payload suitable for the iTerm2 `FilePart=` command.
|
|
111
|
-
* @returns The string payload (e.g., `"FilePart=U09NRURBVEE="`).
|
|
112
|
-
*/
|
|
113
|
-
toString() {
|
|
114
|
-
return `FilePart=${this.base64Chunk}`;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
class ITerm2MultipartFileStart {
|
|
118
|
-
/**
|
|
119
|
-
* Constructs an `ITerm2MultipartFileStart` payload object.
|
|
120
|
-
* @param properties Properties for the multipart file (e.g., `name`, `size`). Content is not part of this command.
|
|
121
|
-
* The `name` property within `props` should be pre-Base64 encoded by the caller if it might
|
|
122
|
-
* contain special characters.
|
|
123
|
-
*/
|
|
124
|
-
constructor(properties) {
|
|
125
|
-
this.properties = properties;
|
|
126
|
-
}
|
|
127
|
-
properties;
|
|
128
|
-
/**
|
|
129
|
-
* Converts the file properties into the string payload suitable for the iTerm2 `MultipartFile=` command.
|
|
130
|
-
* @returns The string payload (e.g., `"MultipartFile=name=...;size=..."`).
|
|
131
|
-
*/
|
|
132
|
-
toString() {
|
|
133
|
-
return `MultipartFile=${formatITerm2FileProperties(this.properties)}`;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
export { ITerm2File, ITerm2FileEnd, ITerm2FilePart, ITerm2MultipartFileStart };
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { C as CSI, E as ESC, S as SEP } from './constants-CE7WkXh_.js';
|
|
2
|
-
import './restoreCursor-GfYEeJqN.js';
|
|
3
|
-
|
|
4
|
-
const isBrowser = typeof globalThis !== "undefined" && typeof globalThis.window === "object" && globalThis.window.document !== void 0;
|
|
5
|
-
const OSTYPE_REGEX = /^(?:msys|cygwin)$/;
|
|
6
|
-
const isTerminalApp = !isBrowser && process.env.TERM_PROGRAM === "Apple_Terminal";
|
|
7
|
-
const isWindows = !isBrowser && (process.platform === "win32" || OSTYPE_REGEX.test(process.env.OSTYPE));
|
|
8
|
-
|
|
9
|
-
const SAVE_CURSOR_DEC = `${ESC}7`;
|
|
10
|
-
const RESTORE_CURSOR_DEC = `${ESC}8`;
|
|
11
|
-
const CURSOR_UP_1 = `${CSI}A`;
|
|
12
|
-
const CURSOR_DOWN_1 = `${CSI}B`;
|
|
13
|
-
const CURSOR_FORWARD_1 = `${CSI}C`;
|
|
14
|
-
const CURSOR_BACKWARD_1 = `${CSI}D`;
|
|
15
|
-
const REQUEST_CURSOR_POSITION = `${CSI}6n`;
|
|
16
|
-
const REQUEST_EXTENDED_CURSOR_POSITION = `${CSI}?6n`;
|
|
17
|
-
const cursorBackward = (count = 1) => `${CSI}${String(count)}D`;
|
|
18
|
-
const cursorDown = (count = 1) => `${CSI}${String(count)}B`;
|
|
19
|
-
const cursorForward = (count = 1) => `${CSI}${String(count)}C`;
|
|
20
|
-
const cursorHide = `${CSI}?25l`;
|
|
21
|
-
const cursorToColumn1 = `${CSI}G`;
|
|
22
|
-
const cursorLeft = (count = 1) => cursorBackward(count);
|
|
23
|
-
const cursorHorizontalAbsolute = (column = 1) => `${CSI}${String(column)}G`;
|
|
24
|
-
const cursorMove = (x, y) => {
|
|
25
|
-
let returnValue = "";
|
|
26
|
-
if (x < 0) {
|
|
27
|
-
returnValue += `${CSI}${String(-x)}D`;
|
|
28
|
-
} else if (x > 0) {
|
|
29
|
-
returnValue += `${CSI}${String(x)}C`;
|
|
30
|
-
}
|
|
31
|
-
if (y < 0) {
|
|
32
|
-
returnValue += `${CSI}${String(-y)}A`;
|
|
33
|
-
} else if (y > 0) {
|
|
34
|
-
returnValue += `${CSI}${String(y)}B`;
|
|
35
|
-
}
|
|
36
|
-
return returnValue;
|
|
37
|
-
};
|
|
38
|
-
const cursorNextLine = (count = 1) => `${CSI}${String(count)}E`;
|
|
39
|
-
const cursorPreviousLine = (count = 1) => `${CSI}${String(count)}F`;
|
|
40
|
-
const cursorRestore = isTerminalApp ? RESTORE_CURSOR_DEC : `${ESC}u`;
|
|
41
|
-
const cursorSave = isTerminalApp ? SAVE_CURSOR_DEC : `${ESC}s`;
|
|
42
|
-
const cursorShow = `${CSI}?25h`;
|
|
43
|
-
const cursorTo = (x, y) => {
|
|
44
|
-
if (y === void 0) {
|
|
45
|
-
return cursorHorizontalAbsolute(x + 1);
|
|
46
|
-
}
|
|
47
|
-
return `${CSI}${String(y + 1)}${SEP}${String(x + 1)}H`;
|
|
48
|
-
};
|
|
49
|
-
const cursorPosition = (row, column) => {
|
|
50
|
-
if (column === void 0) {
|
|
51
|
-
return `${CSI}${String(row)}H`;
|
|
52
|
-
}
|
|
53
|
-
return `${CSI}${String(row)}${SEP}${String(column)}H`;
|
|
54
|
-
};
|
|
55
|
-
const cursorHorizontalForwardTab = (count = 1) => `${CSI}${String(count)}I`;
|
|
56
|
-
const cursorBackwardTab = (count = 1) => `${CSI}${String(count)}Z`;
|
|
57
|
-
const eraseCharacter = (count = 1) => `${CSI}${String(count)}X`;
|
|
58
|
-
const cursorVerticalAbsolute = (row = 1) => `${CSI}${String(row)}d`;
|
|
59
|
-
const cursorUp = (count = 1) => `${CSI}${String(count)}A`;
|
|
60
|
-
var CursorStyle = /* @__PURE__ */ ((CursorStyle2) => {
|
|
61
|
-
CursorStyle2[CursorStyle2["Default"] = 0] = "Default";
|
|
62
|
-
CursorStyle2[CursorStyle2["BlinkingBlock"] = 1] = "BlinkingBlock";
|
|
63
|
-
CursorStyle2[CursorStyle2["SteadyBlock"] = 2] = "SteadyBlock";
|
|
64
|
-
CursorStyle2[CursorStyle2["BlinkingUnderline"] = 3] = "BlinkingUnderline";
|
|
65
|
-
CursorStyle2[CursorStyle2["SteadyUnderline"] = 4] = "SteadyUnderline";
|
|
66
|
-
CursorStyle2[CursorStyle2["BlinkingBar"] = 5] = "BlinkingBar";
|
|
67
|
-
CursorStyle2[CursorStyle2["SteadyBar"] = 6] = "SteadyBar";
|
|
68
|
-
return CursorStyle2;
|
|
69
|
-
})(CursorStyle || {});
|
|
70
|
-
const setCursorStyle = (style) => `${CSI}${String(style)} q`;
|
|
71
|
-
|
|
72
|
-
export { isWindows as A, CursorStyle as B, CURSOR_BACKWARD_1 as C, REQUEST_CURSOR_POSITION as R, SAVE_CURSOR_DEC as S, CURSOR_DOWN_1 as a, CURSOR_FORWARD_1 as b, CURSOR_UP_1 as c, REQUEST_EXTENDED_CURSOR_POSITION as d, RESTORE_CURSOR_DEC as e, cursorBackward as f, cursorBackwardTab as g, cursorDown as h, cursorForward as i, cursorHide as j, cursorHorizontalAbsolute as k, cursorHorizontalForwardTab as l, cursorLeft as m, cursorMove as n, cursorNextLine as o, cursorPosition as p, cursorPreviousLine as q, cursorRestore as r, cursorSave as s, cursorShow as t, cursorTo as u, cursorToColumn1 as v, cursorUp as w, cursorVerticalAbsolute as x, eraseCharacter as y, setCursorStyle as z };
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { O as OSC, B as BEL } from './constants-CE7WkXh_.js';
|
|
2
|
-
|
|
3
|
-
const resetProgressBar = `${OSC}9;4;0${BEL}`;
|
|
4
|
-
const setProgressBar = (percentage) => {
|
|
5
|
-
const clamped = Math.min(Math.max(0, percentage), 100);
|
|
6
|
-
return `${OSC}9;4;1;${String(clamped)}${BEL}`;
|
|
7
|
-
};
|
|
8
|
-
const setErrorProgressBar = (percentage) => {
|
|
9
|
-
const clamped = Math.min(Math.max(0, percentage), 100);
|
|
10
|
-
return `${OSC}9;4;2;${String(clamped)}${BEL}`;
|
|
11
|
-
};
|
|
12
|
-
const setIndeterminateProgressBar = `${OSC}9;4;3${BEL}`;
|
|
13
|
-
const setWarningProgressBar = (percentage) => {
|
|
14
|
-
const clamped = Math.min(Math.max(0, percentage), 100);
|
|
15
|
-
return `${OSC}9;4;4;${String(clamped)}${BEL}`;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export { resetProgressBar, setErrorProgressBar, setIndeterminateProgressBar, setProgressBar, setWarningProgressBar };
|
|
@@ -1,323 +0,0 @@
|
|
|
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 };
|