@visulima/ansi 4.0.0-alpha.1 → 4.0.0-alpha.2
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 +16 -0
- package/README.md +32 -14
- package/package.json +9 -7
- package/dist/alternative-screen.d.ts +0 -74
- package/dist/alternative-screen.js +0 -8
- package/dist/clear.d.ts +0 -77
- package/dist/clear.js +0 -16
- package/dist/constants.d.ts +0 -20
- package/dist/cursor.d.ts +0 -437
- package/dist/cursor.js +0 -3
- package/dist/erase.d.ts +0 -206
- package/dist/erase.js +0 -47
- package/dist/helpers.d.ts +0 -14
- package/dist/hyperlink.d.ts +0 -27
- package/dist/hyperlink.js +0 -5
- package/dist/image.d.ts +0 -73
- package/dist/image.js +0 -43
- package/dist/index.d.ts +0 -36
- package/dist/index.js +0 -26
- package/dist/iterm2/iterm2-properties.d.ts +0 -135
- package/dist/iterm2/iterm2-sequences.d.ts +0 -96
- package/dist/iterm2.d.ts +0 -58
- package/dist/iterm2.js +0 -12
- package/dist/mode.d.ts +0 -726
- package/dist/mode.js +0 -245
- package/dist/mouse.d.ts +0 -230
- package/dist/mouse.js +0 -106
- package/dist/packem_shared/IT2_AUTO-BGxGtZAE.js +0 -6
- package/dist/packem_shared/ITerm2File-DzWaT6j3.js +0 -137
- package/dist/packem_shared/constants-CE7WkXh_.js +0 -9
- package/dist/packem_shared/cursor-CHPvxMal.js +0 -71
- package/dist/packem_shared/resetProgressBar-kV21u2hs.js +0 -18
- package/dist/packem_shared/restoreCursor-GfYEeJqN.js +0 -323
- package/dist/passthrough.d.ts +0 -77
- package/dist/passthrough.js +0 -29
- package/dist/progress.d.ts +0 -41
- package/dist/reset.d.ts +0 -26
- package/dist/reset.js +0 -4
- package/dist/screen.d.ts +0 -234
- package/dist/screen.js +0 -27
- package/dist/scroll.d.ts +0 -67
- package/dist/scroll.js +0 -18
- package/dist/status.d.ts +0 -524
- package/dist/status.js +0 -98
- package/dist/strip.d.ts +0 -23
- package/dist/strip.js +0 -12
- package/dist/termcap.d.ts +0 -38
- package/dist/termcap.js +0 -25
- package/dist/title.d.ts +0 -185
- package/dist/title.js +0 -18
- package/dist/window-ops.d.ts +0 -418
- package/dist/window-ops.js +0 -61
- package/dist/xterm.d.ts +0 -94
- package/dist/xterm.js +0 -33
package/dist/erase.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { C as CSI } from './packem_shared/constants-CE7WkXh_.js';
|
|
2
|
-
import { u as cursorUp, t as cursorToColumn1 } from './packem_shared/cursor-CHPvxMal.js';
|
|
3
|
-
|
|
4
|
-
var EraseDisplayMode = /* @__PURE__ */ ((EraseDisplayMode2) => {
|
|
5
|
-
EraseDisplayMode2[EraseDisplayMode2["EntireScreen"] = 2] = "EntireScreen";
|
|
6
|
-
EraseDisplayMode2[EraseDisplayMode2["EntireScreenAndScrollback"] = 3] = "EntireScreenAndScrollback";
|
|
7
|
-
EraseDisplayMode2[EraseDisplayMode2["ToBeginning"] = 1] = "ToBeginning";
|
|
8
|
-
EraseDisplayMode2[EraseDisplayMode2["ToEnd"] = 0] = "ToEnd";
|
|
9
|
-
return EraseDisplayMode2;
|
|
10
|
-
})(EraseDisplayMode || {});
|
|
11
|
-
const eraseDisplay = (mode) => {
|
|
12
|
-
const validMode = mode >= 0 && mode <= 3 ? mode : 0 /* ToEnd */;
|
|
13
|
-
return `${CSI + (validMode === 0 /* ToEnd */ ? "" : String(validMode))}J`;
|
|
14
|
-
};
|
|
15
|
-
var EraseLineMode = /* @__PURE__ */ ((EraseLineMode2) => {
|
|
16
|
-
EraseLineMode2[EraseLineMode2["EntireLine"] = 2] = "EntireLine";
|
|
17
|
-
EraseLineMode2[EraseLineMode2["ToBeginning"] = 1] = "ToBeginning";
|
|
18
|
-
EraseLineMode2[EraseLineMode2["ToEnd"] = 0] = "ToEnd";
|
|
19
|
-
return EraseLineMode2;
|
|
20
|
-
})(EraseLineMode || {});
|
|
21
|
-
const eraseInLine = (mode) => {
|
|
22
|
-
const validMode = mode >= 0 && mode <= 2 ? mode : 0 /* ToEnd */;
|
|
23
|
-
return `${CSI + (validMode === 0 /* ToEnd */ ? "" : String(validMode))}K`;
|
|
24
|
-
};
|
|
25
|
-
const eraseDown = eraseDisplay(0 /* ToEnd */);
|
|
26
|
-
const eraseLine = eraseInLine(2 /* EntireLine */);
|
|
27
|
-
const eraseLineEnd = eraseInLine(0 /* ToEnd */);
|
|
28
|
-
const eraseLineStart = eraseInLine(1 /* ToBeginning */);
|
|
29
|
-
const eraseLines = (count) => {
|
|
30
|
-
if (count <= 0) {
|
|
31
|
-
return "";
|
|
32
|
-
}
|
|
33
|
-
let clear = "";
|
|
34
|
-
for (let index = 0; index < count; index += 1) {
|
|
35
|
-
clear += eraseLine;
|
|
36
|
-
if (index < count - 1) {
|
|
37
|
-
clear += cursorUp();
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
clear += cursorToColumn1;
|
|
41
|
-
return clear;
|
|
42
|
-
};
|
|
43
|
-
const eraseScreen = eraseDisplay(2 /* EntireScreen */);
|
|
44
|
-
const eraseUp = eraseDisplay(1 /* ToBeginning */);
|
|
45
|
-
const eraseScreenAndScrollback = eraseDisplay(3 /* EntireScreenAndScrollback */);
|
|
46
|
-
|
|
47
|
-
export { EraseDisplayMode, EraseLineMode, eraseDisplay, eraseDown, eraseInLine, eraseLine, eraseLineEnd, eraseLineStart, eraseLines, eraseScreen, eraseScreenAndScrollback, eraseUp };
|
package/dist/helpers.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Checks if the current environment is a browser-like environment.
|
|
3
|
-
* It specifically checks for the presence of `globalThis.window.document`.
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Indicates whether the code is running inside Apple's Terminal.app.
|
|
7
|
-
* This is true if not in a browser and the `TERM_PROGRAM` environment variable is "Apple_Terminal".
|
|
8
|
-
*/
|
|
9
|
-
export declare const isTerminalApp: boolean;
|
|
10
|
-
/**
|
|
11
|
-
* Indicates whether the current platform is Windows.
|
|
12
|
-
* This is true if not in a browser and `process.platform` is "win32".
|
|
13
|
-
*/
|
|
14
|
-
export declare const isWindows: boolean;
|
package/dist/hyperlink.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates a clickable hyperlink in the terminal.
|
|
3
|
-
*
|
|
4
|
-
* This function constructs an ANSI escape sequence that, when printed to a compatible terminal,
|
|
5
|
-
* renders as a clickable link. The link's visible text and its target URL are specified
|
|
6
|
-
* by the `text` and `url` parameters, respectively.
|
|
7
|
-
*
|
|
8
|
-
* For information on terminal support for hyperlinks, see this
|
|
9
|
-
* [Gist by Egmont Kob](https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda).
|
|
10
|
-
* To programmatically check for hyperlink support in the current environment,
|
|
11
|
-
* consider using a library like [`supports-hyperlinks`](https://github.com/jamestalmage/supports-hyperlinks).
|
|
12
|
-
* @param text The visible text of the link.
|
|
13
|
-
* @param url The URL the link should point to.
|
|
14
|
-
* @returns A string representing the ANSI escape sequence for the hyperlink.
|
|
15
|
-
* @example
|
|
16
|
-
* ```typescript
|
|
17
|
-
* import { hyperlink } from "@visulima/ansi/hyperlink"; // Adjust import path as needed
|
|
18
|
-
*
|
|
19
|
-
* const aLink = hyperlink("Visulima", "https://www.visulima.com");
|
|
20
|
-
* console.log(`Visit ${aLink} for more information.`);
|
|
21
|
-
* // In a supported terminal, this will output:
|
|
22
|
-
* // Visit Visulima for more information. (where "Visulima" is a clickable link)
|
|
23
|
-
* ```
|
|
24
|
-
* @see {@link https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda} for supported terminals.
|
|
25
|
-
*/
|
|
26
|
-
declare const hyperlink: (text: string, url: string) => string;
|
|
27
|
-
export default hyperlink;
|
package/dist/hyperlink.js
DELETED
package/dist/image.d.ts
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import type { LiteralUnion } from "type-fest";
|
|
2
|
-
/**
|
|
3
|
-
* Options for controlling the display of an inline image in iTerm2.
|
|
4
|
-
*/
|
|
5
|
-
export interface ImageOptions {
|
|
6
|
-
/**
|
|
7
|
-
* The display height of the image. It can be specified as:
|
|
8
|
-
* - A number: Interpreted as the number of character cells (e.g., `10`).
|
|
9
|
-
* - A string with `px`: Interpreted as pixels (e.g., `"100px"`).
|
|
10
|
-
* - A string with `%`: Interpreted as a percentage of the terminal session's height (e.g., `"50%"`).
|
|
11
|
-
* - The string `"auto"`: The image's inherent height will be used, or the terminal will decide.
|
|
12
|
-
*/
|
|
13
|
-
readonly height?: LiteralUnion<"auto", number | string>;
|
|
14
|
-
/**
|
|
15
|
-
* Controls whether the image's aspect ratio is preserved when scaling.
|
|
16
|
-
* - If `true` (default), the aspect ratio is preserved.
|
|
17
|
-
* - If `false`, the image may be stretched to fit the specified width and height.
|
|
18
|
-
* Corresponds to the `preserveAspectRatio` argument in the iTerm2 sequence (`1` for true, `0` for false).
|
|
19
|
-
* @default true
|
|
20
|
-
*/
|
|
21
|
-
readonly preserveAspectRatio?: boolean;
|
|
22
|
-
/**
|
|
23
|
-
* The display width of the image. It can be specified as:
|
|
24
|
-
* - A number: Interpreted as the number of character cells (e.g., `20`).
|
|
25
|
-
* - A string with `px`: Interpreted as pixels (e.g., `"200px"`).
|
|
26
|
-
* - A string with `%`: Interpreted as a percentage of the terminal session's width (e.g., `"75%"`).
|
|
27
|
-
* - The string `"auto"`: The image's inherent width will be used, or the terminal will decide.
|
|
28
|
-
*/
|
|
29
|
-
readonly width?: LiteralUnion<"auto", number | string>;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Generates an ANSI escape sequence for displaying an image inline, primarily for iTerm2.
|
|
33
|
-
*
|
|
34
|
-
* This function constructs a proprietary iTerm2 escape sequence (`OSC 1337 ; File = [arguments] : <base64_data> BEL`)
|
|
35
|
-
* that allows raw image data to be displayed directly in the terminal.
|
|
36
|
-
* @param data The raw image data as a `Uint8Array`. This data will be Base64 encoded.
|
|
37
|
-
* @param options Optional parameters to control how the image is displayed (e.g., width, height, aspect ratio).
|
|
38
|
-
* See {@link ImageOptions}.
|
|
39
|
-
* @returns A string containing the ANSI escape sequence for displaying the image in iTerm2.
|
|
40
|
-
* Returns an empty string if `data` is null or undefined, though TypeScript should prevent this.
|
|
41
|
-
* @example
|
|
42
|
-
* ```typescript
|
|
43
|
-
* import { image } from '@visulima/ansi/image'; // Adjust import path
|
|
44
|
-
* import { promises as fs } from 'fs';
|
|
45
|
-
*
|
|
46
|
-
* async function displayImage() {
|
|
47
|
-
* try {
|
|
48
|
-
* const imageData = await fs.readFile('path/to/your/image.png');
|
|
49
|
-
* const imageSequence = image(new Uint8Array(imageData), {
|
|
50
|
-
* width: 50, // 50 character cells wide
|
|
51
|
-
* height: "auto",
|
|
52
|
-
* preserveAspectRatio: true,
|
|
53
|
-
* });
|
|
54
|
-
* console.log(imageSequence);
|
|
55
|
-
* } catch (error) {
|
|
56
|
-
* console.error("Error reading or displaying image:", error);
|
|
57
|
-
* }
|
|
58
|
-
* }
|
|
59
|
-
*
|
|
60
|
-
* displayImage();
|
|
61
|
-
* ```
|
|
62
|
-
* @remarks
|
|
63
|
-
* - This sequence is specific to iTerm2 and may not work in other terminal emulators.
|
|
64
|
-
* - For Node.js environments, `Buffer.from(data).toString("base64")` is used for Base64 encoding.
|
|
65
|
-
* In browser environments, a polyfill or an alternative method for Base64 encoding `Uint8Array` would be necessary
|
|
66
|
-
* if `Buffer` is not available (e.g., `btoa(String.fromCharCode(...data))` after careful handling of binary data).
|
|
67
|
-
* - The `name` parameter (for filename) is not directly supported by this simplified helper but is part of the
|
|
68
|
-
* full iTerm2 inline image protocol. For more advanced features, consider using the more detailed iTerm2 sequence
|
|
69
|
-
* builders in `iterm2/` files.
|
|
70
|
-
* @see {@link https://iterm2.com/documentation-images.html} iTerm2 Inline Images Protocol.
|
|
71
|
-
* @see {@link ImageOptions}
|
|
72
|
-
*/
|
|
73
|
-
export declare const image: (data: Uint8Array, options?: ImageOptions) => string;
|
package/dist/image.js
DELETED
|
@@ -1,43 +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
|
-
import { O as OSC, B as BEL } from './packem_shared/constants-CE7WkXh_.js';
|
|
24
|
-
|
|
25
|
-
const image = (data, options = {}) => {
|
|
26
|
-
if (!data) {
|
|
27
|
-
return "";
|
|
28
|
-
}
|
|
29
|
-
let returnValue = `${OSC}1337;File=inline=1`;
|
|
30
|
-
if (options.width !== void 0) {
|
|
31
|
-
returnValue += `;width=${options.width}`;
|
|
32
|
-
}
|
|
33
|
-
if (options.height !== void 0) {
|
|
34
|
-
returnValue += `;height=${options.height}`;
|
|
35
|
-
}
|
|
36
|
-
if (options.preserveAspectRatio === false) {
|
|
37
|
-
returnValue += ";preserveAspectRatio=0";
|
|
38
|
-
}
|
|
39
|
-
const base64Data = Buffer.from(data).toString("base64");
|
|
40
|
-
return `${returnValue}:${base64Data}${BEL}`;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export { image };
|
package/dist/index.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Output a beeping sound.
|
|
3
|
-
*/
|
|
4
|
-
export declare const beep = "\u0007";
|
|
5
|
-
export { ALT_SCREEN_OFF, ALT_SCREEN_ON, alternativeScreenOff, alternativeScreenOn } from "./alternative-screen.d.ts";
|
|
6
|
-
export { clearLineAndHomeCursor, clearScreenAndHomeCursor, clearScreenFromTopLeft, resetTerminal } from "./clear.d.ts";
|
|
7
|
-
export type { CursorStyle } from "./cursor.d.ts";
|
|
8
|
-
export { CURSOR_BACKWARD_1, CURSOR_DOWN_1, CURSOR_FORWARD_1, CURSOR_UP_1, cursorBackward, cursorBackwardTab, cursorDown, cursorForward, cursorHide, cursorHorizontalAbsolute, cursorHorizontalForwardTab, cursorLeft, cursorMove, cursorNextLine, cursorPosition, cursorPreviousLine, cursorRestore, // Function
|
|
9
|
-
cursorSave, // Function
|
|
10
|
-
cursorShow, cursorTo, cursorToColumn1, cursorUp, cursorVerticalAbsolute, eraseCharacter, REQUEST_CURSOR_POSITION, REQUEST_EXTENDED_CURSOR_POSITION, RESTORE_CURSOR_DEC, // Constant for ESC 8
|
|
11
|
-
SAVE_CURSOR_DEC, // Constant for ESC 7
|
|
12
|
-
setCursorStyle, } from "./cursor.d.ts";
|
|
13
|
-
export type { EraseDisplayMode, EraseLineMode } from "./erase.d.ts";
|
|
14
|
-
export { eraseDisplay, eraseDown, eraseInLine, eraseLine, eraseLineEnd, eraseLines, eraseLineStart, eraseScreen, eraseScreenAndScrollback, eraseUp, } from "./erase.d.ts";
|
|
15
|
-
export { default as hyperlink } from "./hyperlink.d.ts";
|
|
16
|
-
export type { ImageOptions } from "./image.d.ts";
|
|
17
|
-
export { image } from "./image.d.ts";
|
|
18
|
-
export type { IITerm2Payload, ITerm2FileProperties } from "./iterm2.d.ts";
|
|
19
|
-
export { IT2_AUTO, it2Cells, it2Percent, it2Pixels, iTerm2, ITerm2File, ITerm2FileEnd, ITerm2FilePart, ITerm2MultipartFileStart } from "./iterm2.d.ts";
|
|
20
|
-
export type { AnsiMode, DecMode, Mode, ModeSetting } from "./mode.d.ts";
|
|
21
|
-
export { BDSM, BiDirectionalSupportMode, BracketedPasteMode, createAnsiMode, createDecMode, DECRPM, DECRQM, DisableModifiersMode, InBandResizeMode, InsertReplaceMode, IRM, isModeNotRecognized, isModePermanentlyReset, isModePermanentlySet, isModeReset, isModeSet, KAM, KeyboardActionMode, LightDarkMode, LineFeedNewLineMode, LNM, LocalEchoMode, OriginMode, reportMode, RequestBiDirectionalSupportMode, RequestInBandResizeMode, RequestInsertReplaceMode, RequestKeyboardActionMode, RequestLineFeedNewLineMode, RequestLocalEchoMode, requestMode, RequestSendReceiveMode, RequestUnicodeCoreMode, ResetBiDirectionalSupportMode, ResetInBandResizeMode, ResetInsertReplaceMode, ResetKeyboardActionMode, ResetLineFeedNewLineMode, ResetLocalEchoMode, resetMode, ResetSendReceiveMode, ResetUnicodeCoreMode, RM, SendFocusEventsMode, SendReceiveMode, SetBiDirectionalSupportMode, SetInBandResizeMode, SetInsertReplaceMode, SetKeyboardActionMode, SetLineFeedNewLineMode, SetLocalEchoMode, setMode, SetSendReceiveMode, SetUnicodeCoreMode, SGRMouseMode, SM, SRM, TextCursorEnableMode, UnicodeCoreMode, } from "./mode.d.ts";
|
|
22
|
-
export type { MouseButtonType, MouseModifiers } from "./mouse.d.ts";
|
|
23
|
-
export { disableAnyEventMouse, disableButtonEventMouse, disableFocusTracking, disableNormalMouse, disableSgrMouse, disableX10Mouse, enableAnyEventMouse, enableButtonEventMouse, enableFocusTracking, enableNormalMouse, enableSgrMouse, enableX10Mouse, encodeMouseButtonByte, MouseButton, mouseSgrSequence, mouseX10Sequence, } from "./mouse.d.ts";
|
|
24
|
-
export { SCREEN_MAX_LEN_DEFAULT, SCREEN_TYPICAL_LIMIT, screenPassthrough, tmuxPassthrough } from "./passthrough.d.ts";
|
|
25
|
-
export { resetProgressBar, setErrorProgressBar, setIndeterminateProgressBar, setProgressBar, setWarningProgressBar } from "./progress.d.ts";
|
|
26
|
-
export { RESET_INITIAL_STATE, RIS } from "./reset.d.ts";
|
|
27
|
-
export { clearTabStop, deleteCharacter, deleteLine, insertCharacter, insertLine, repeatPreviousCharacter, requestPresentationStateReport, setLeftRightMargins, setTopBottomMargins, } from "./screen.d.ts";
|
|
28
|
-
export { SCROLL_DOWN_1, SCROLL_UP_1, scrollDown, scrollUp } from "./scroll.d.ts";
|
|
29
|
-
export type { AnsiStatusReport, DecStatusReport, StatusReport } from "./status.d.ts";
|
|
30
|
-
export { CPR, createAnsiStatusReport, createDecStatusReport, cursorPositionReport, DA1, DA2, DA3, DECXCPR, deviceStatusReport, DSR, DSR_KeyboardLanguageDEC, DSR_PrinterStatusDEC, DSR_TerminalStatus, DSR_UDKStatusDEC, extendedCursorPositionReport, LightDarkReport, reportKeyboardLanguageDEC, reportPrimaryDeviceAttributes, reportPrinterNoPaperDEC, reportPrinterNotReadyDEC, reportPrinterReadyDEC, reportSecondaryDeviceAttributes, reportTerminalNotOK, reportTerminalOK, reportTertiaryDeviceAttributes, reportUDKLockedDEC, reportUDKUnlockedDEC, requestCursorPositionReport, requestExtendedCursorPositionReport, requestKeyboardLanguageDEC, RequestLightDarkReport, RequestNameVersion, requestPrimaryDeviceAttributes, requestPrimaryDeviceAttributesParam0, requestPrinterStatusDEC, requestSecondaryDeviceAttributes, requestSecondaryDeviceAttributesParam0, requestTerminalStatus, requestTertiaryDeviceAttributes, requestTertiaryDeviceAttributesParam0, requestUDKStatusDEC, XTVERSION, } from "./status.d.ts";
|
|
31
|
-
export { default as strip } from "./strip.d.ts";
|
|
32
|
-
export { requestTermcap, requestTerminfo, XTGETTCAP } from "./termcap.d.ts";
|
|
33
|
-
export { decsin, decswt, setIconName, setIconNameAndWindowTitle, setIconNameAndWindowTitleWithST, setIconNameWithST, setWindowTitle, setWindowTitleWithST, } from "./title.d.ts";
|
|
34
|
-
export type { XTermWindowOp } from "./window-ops.d.ts";
|
|
35
|
-
export { deiconifyWindow, iconifyWindow, lowerWindow, maximizeWindow, moveWindow, raiseWindow, refreshWindow, reportWindowPosition, reportWindowState, requestCellSizePixels, requestTextAreaSizeChars, requestTextAreaSizePixels, resizeTextAreaChars, resizeTextAreaPixels, restoreMaximizedWindow, setPageSizeLines, xtermWindowOp, XTWINOPS, } from "./window-ops.d.ts";
|
|
36
|
-
export { keyModifierOptions, queryKeyModifierOptions, queryModifyOtherKeys, resetKeyModifierOptions, resetModifyOtherKeys, setKeyModifierOptions, setModifyOtherKeys1, setModifyOtherKeys2, XTMODKEYS, XTQMODKEYS, } from "./xterm.d.ts";
|
package/dist/index.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export { ALT_SCREEN_OFF, ALT_SCREEN_ON, alternativeScreenOff, alternativeScreenOn } from './alternative-screen.js';
|
|
2
|
-
export { clearLineAndHomeCursor, clearScreenAndHomeCursor, clearScreenFromTopLeft, resetTerminal } from './clear.js';
|
|
3
|
-
export { C as CURSOR_BACKWARD_1, a as CURSOR_DOWN_1, b as CURSOR_FORWARD_1, c as CURSOR_UP_1, R as REQUEST_CURSOR_POSITION, x as REQUEST_EXTENDED_CURSOR_POSITION, y as RESTORE_CURSOR_DEC, S as SAVE_CURSOR_DEC, d as cursorBackward, e as cursorBackwardTab, f as cursorDown, g as cursorForward, h as cursorHide, i as cursorHorizontalAbsolute, j as cursorHorizontalForwardTab, k as cursorLeft, l as cursorMove, m as cursorNextLine, n as cursorPosition, o as cursorPreviousLine, p as cursorRestore, q as cursorSave, r as cursorShow, s as cursorTo, t as cursorToColumn1, u as cursorUp, v as cursorVerticalAbsolute, w as eraseCharacter, z as setCursorStyle } from './packem_shared/cursor-CHPvxMal.js';
|
|
4
|
-
export { eraseDisplay, eraseDown, eraseInLine, eraseLine, eraseLineEnd, eraseLineStart, eraseLines, eraseScreen, eraseScreenAndScrollback, eraseUp } from './erase.js';
|
|
5
|
-
export { default as hyperlink } from './hyperlink.js';
|
|
6
|
-
export { image } from './image.js';
|
|
7
|
-
export { iTerm2 } from './iterm2.js';
|
|
8
|
-
export { BDSM, BiDirectionalSupportMode, BracketedPasteMode, DECRPM, DECRQM, DisableModifiersMode, IRM, InBandResizeMode, InsertReplaceMode, KAM, KeyboardActionMode, LNM, LightDarkMode, LineFeedNewLineMode, LocalEchoMode, OriginMode, RM, RequestBiDirectionalSupportMode, RequestInBandResizeMode, RequestInsertReplaceMode, RequestKeyboardActionMode, RequestLineFeedNewLineMode, RequestLocalEchoMode, RequestSendReceiveMode, RequestUnicodeCoreMode, ResetBiDirectionalSupportMode, ResetInBandResizeMode, ResetInsertReplaceMode, ResetKeyboardActionMode, ResetLineFeedNewLineMode, ResetLocalEchoMode, ResetSendReceiveMode, ResetUnicodeCoreMode, SGRMouseMode, SM, SRM, SendFocusEventsMode, SendReceiveMode, SetBiDirectionalSupportMode, SetInBandResizeMode, SetInsertReplaceMode, SetKeyboardActionMode, SetLineFeedNewLineMode, SetLocalEchoMode, SetSendReceiveMode, SetUnicodeCoreMode, TextCursorEnableMode, UnicodeCoreMode, createAnsiMode, createDecMode, isModeNotRecognized, isModePermanentlyReset, isModePermanentlySet, isModeReset, isModeSet, reportMode, requestMode, resetMode, setMode } from './mode.js';
|
|
9
|
-
export { MouseButton, disableAnyEventMouse, disableButtonEventMouse, disableFocusTracking, disableNormalMouse, disableSgrMouse, disableX10Mouse, enableAnyEventMouse, enableButtonEventMouse, enableFocusTracking, enableNormalMouse, enableSgrMouse, enableX10Mouse, encodeMouseButtonByte, mouseSgrSequence, mouseX10Sequence } from './mouse.js';
|
|
10
|
-
export { SCREEN_MAX_LEN_DEFAULT, SCREEN_TYPICAL_LIMIT, screenPassthrough, tmuxPassthrough } from './passthrough.js';
|
|
11
|
-
export { resetProgressBar, setErrorProgressBar, setIndeterminateProgressBar, setProgressBar, setWarningProgressBar } from './packem_shared/resetProgressBar-kV21u2hs.js';
|
|
12
|
-
export { RESET_INITIAL_STATE, RIS } from './reset.js';
|
|
13
|
-
export { clearTabStop, deleteCharacter, deleteLine, insertCharacter, insertLine, repeatPreviousCharacter, requestPresentationStateReport, setLeftRightMargins, setTopBottomMargins } from './screen.js';
|
|
14
|
-
export { SCROLL_DOWN_1, SCROLL_UP_1, scrollDown, scrollUp } from './scroll.js';
|
|
15
|
-
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 } from './status.js';
|
|
16
|
-
export { default as strip } from './strip.js';
|
|
17
|
-
export { XTGETTCAP, requestTermcap, requestTerminfo } from './termcap.js';
|
|
18
|
-
export { decsin, decswt, setIconName, setIconNameAndWindowTitle, setIconNameAndWindowTitleWithST, setIconNameWithST, setWindowTitle, setWindowTitleWithST } from './title.js';
|
|
19
|
-
export { XTWINOPS, deiconifyWindow, iconifyWindow, lowerWindow, maximizeWindow, moveWindow, raiseWindow, refreshWindow, reportWindowPosition, reportWindowState, requestCellSizePixels, requestTextAreaSizeChars, requestTextAreaSizePixels, resizeTextAreaChars, resizeTextAreaPixels, restoreMaximizedWindow, setPageSizeLines, xtermWindowOp } from './window-ops.js';
|
|
20
|
-
export { XTMODKEYS, XTQMODKEYS, keyModifierOptions, queryKeyModifierOptions, queryModifyOtherKeys, resetKeyModifierOptions, resetModifyOtherKeys, setKeyModifierOptions, setModifyOtherKeys1, setModifyOtherKeys2 } from './xterm.js';
|
|
21
|
-
export { IT2_AUTO, it2Cells, it2Percent, it2Pixels } from './packem_shared/IT2_AUTO-BGxGtZAE.js';
|
|
22
|
-
export { ITerm2File, ITerm2FileEnd, ITerm2FilePart, ITerm2MultipartFileStart } from './packem_shared/ITerm2File-DzWaT6j3.js';
|
|
23
|
-
|
|
24
|
-
const beep = "\x07";
|
|
25
|
-
|
|
26
|
-
export { beep };
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import type { LiteralUnion } from "type-fest";
|
|
2
|
-
/**
|
|
3
|
-
* Represents the special string value `'auto'` used for iTerm2 image or file dimensions.
|
|
4
|
-
* When `'auto'` is used for width or height, the terminal (iTerm2) determines the appropriate dimension
|
|
5
|
-
* based on the image's inherent size or other context.
|
|
6
|
-
* @example `width: IT2_AUTO`
|
|
7
|
-
*/
|
|
8
|
-
export declare const IT2_AUTO: string;
|
|
9
|
-
/**
|
|
10
|
-
* Formats a number as a string representing a dimension in character cells for iTerm2.
|
|
11
|
-
* iTerm2 interprets plain numbers for width/height as character cell counts.
|
|
12
|
-
* @param n The number of character cells.
|
|
13
|
-
* @returns A string representation of the number (e.g., `10` becomes `"10"`).
|
|
14
|
-
* @example
|
|
15
|
-
* ```typescript
|
|
16
|
-
* const widthInCells = it2Cells(20); // "20"
|
|
17
|
-
* const sequence = `File=width=${widthInCells}`;
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
export declare const it2Cells: (n: number) => string;
|
|
21
|
-
/**
|
|
22
|
-
* Formats a number as a string representing a dimension in pixels for iTerm2.
|
|
23
|
-
* Appends `px` to the number.
|
|
24
|
-
* @param n The number of pixels.
|
|
25
|
-
* @returns A string representing the dimension in pixels (e.g., `100` becomes `"100px"`).
|
|
26
|
-
* @example
|
|
27
|
-
* ```typescript
|
|
28
|
-
* const heightInPixels = it2Pixels(150);
|
|
29
|
-
* const sequence = `File=height=${heightInPixels}`;
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
|
-
export declare const it2Pixels: (n: number) => string;
|
|
33
|
-
/**
|
|
34
|
-
* Formats a number as a string representing a dimension as a percentage for iTerm2.
|
|
35
|
-
* Appends `%` to the number.
|
|
36
|
-
* @param n The percentage value (e.g., `50` for 50%).
|
|
37
|
-
* @returns A string representing the dimension as a percentage (e.g., `50` becomes `"50%"`).
|
|
38
|
-
* @example
|
|
39
|
-
* ```typescript
|
|
40
|
-
* const widthAsPercentage = it2Percent(75);
|
|
41
|
-
* const sequence = `File=width=${widthAsPercentage}`;
|
|
42
|
-
* ```
|
|
43
|
-
*/
|
|
44
|
-
export declare const it2Percent: (n: number) => string;
|
|
45
|
-
/**
|
|
46
|
-
* Defines the interface for any iTerm2 OSC 1337 payload object.
|
|
47
|
-
*
|
|
48
|
-
* An OSC 1337 sequence has the general form: `OSC 1337 ; <payload_string> BEL`.
|
|
49
|
-
* Objects implementing this interface are responsible for generating that `<payload_string>`
|
|
50
|
-
* via their `toString()` method. This allows for a structured way to build various iTerm2 commands.
|
|
51
|
-
* @see {@link iTerm2} function which consumes objects of this type.
|
|
52
|
-
*/
|
|
53
|
-
export interface IITerm2Payload {
|
|
54
|
-
/**
|
|
55
|
-
* Converts the payload object into its specific string representation required for an iTerm2 OSC 1337 command.
|
|
56
|
-
* For example, for a file transfer, this might return `"File=name=...;size=...:content..."`.
|
|
57
|
-
* @returns The string payload part of the OSC 1337 sequence.
|
|
58
|
-
*/
|
|
59
|
-
toString: () => string;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Defines the properties for an iTerm2 file transfer or inline image display command (`File=...`).
|
|
63
|
-
* These correspond to the key-value pairs used within the `File=` argument of the OSC 1337 sequence.
|
|
64
|
-
* @see {@link https://iterm2.com/documentation-escape-codes.html} iTerm2 Escape Codes (search for `File=`)
|
|
65
|
-
* @see {@link https://iterm2.com/documentation-images.html} iTerm2 Inline Images Protocol
|
|
66
|
-
*/
|
|
67
|
-
export interface ITerm2FileProperties {
|
|
68
|
-
/**
|
|
69
|
-
* The Base64 encoded content of the file or image.
|
|
70
|
-
* This is typically used when `inline=1` is set for images, or for transferring small files directly
|
|
71
|
-
* within the escape sequence. For larger files, multipart transfer is recommended.
|
|
72
|
-
* @remarks The `ITerm2File` class can handle the Base64 encoding of `Uint8Array` data automatically.
|
|
73
|
-
*/
|
|
74
|
-
content?: string;
|
|
75
|
-
/**
|
|
76
|
-
* If `true`, instructs the terminal not to move the cursor after displaying an inline image.
|
|
77
|
-
* Corresponds to `doNotMoveCursor=1` in the sequence.
|
|
78
|
-
* This is a WezTerm extension, also supported by iTerm2 beta/nightly builds as of some versions.
|
|
79
|
-
* @default false (cursor behavior is default terminal behavior)
|
|
80
|
-
*/
|
|
81
|
-
doNotMoveCursor?: boolean;
|
|
82
|
-
/**
|
|
83
|
-
* The display height of the image or file placeholder.
|
|
84
|
-
* Can be:
|
|
85
|
-
* - A number (interpreted as character cells, e.g., `10`).
|
|
86
|
-
* - A string with units: `"Npx"` (N pixels), `"N%"` (N percent of session height).
|
|
87
|
-
* - The string {@link IT2_AUTO} (`"auto"`) for automatic sizing.
|
|
88
|
-
* Use helper functions like {@link it2Cells}, {@link it2Pixels}, {@link it2Percent} for formatting if needed.
|
|
89
|
-
* @example `10`, `"100px"`, `"50%"`, `IT2_AUTO`
|
|
90
|
-
*/
|
|
91
|
-
height?: LiteralUnion<typeof IT2_AUTO, number | string>;
|
|
92
|
-
/**
|
|
93
|
-
* Controls aspect ratio preservation for inline images.
|
|
94
|
-
* - If `true` (or omitted), the aspect ratio *is* preserved (`preserveAspectRatio=1`, which is the default iTerm2 behavior if the param is absent).
|
|
95
|
-
* - If `false`, the aspect ratio is *not* preserved, and the image may stretch (`preserveAspectRatio=0`).
|
|
96
|
-
* @remarks Note the slight inversion: this property `ignoreAspectRatio: true` means `preserveAspectRatio=0` in the sequence.
|
|
97
|
-
* The default iTerm2 behavior *is* to preserve aspect ratio if the `preserveAspectRatio` parameter is not given.
|
|
98
|
-
* So, to *not* preserve, you set this to true to *add* `preserveAspectRatio=0`.
|
|
99
|
-
* If you want to preserve (default), you can omit this or set it to `false`.
|
|
100
|
-
* @default false (meaning aspect ratio is preserved by iTerm2 default unless overridden)
|
|
101
|
-
*/
|
|
102
|
-
ignoreAspectRatio?: boolean;
|
|
103
|
-
/**
|
|
104
|
-
* If `true`, the file (typically an image) should be displayed inline in the terminal.
|
|
105
|
-
* Corresponds to `inline=1` in the sequence.
|
|
106
|
-
* If `false` or omitted, iTerm2 might prompt for download or handle based on file type.
|
|
107
|
-
* @default false
|
|
108
|
-
*/
|
|
109
|
-
inline?: boolean;
|
|
110
|
-
/**
|
|
111
|
-
* The name of the file. This is displayed in UI elements (like a download prompt or image info)
|
|
112
|
-
* and used as the default filename if downloaded.
|
|
113
|
-
* The name **must be Base64 encoded** if it contains special characters (like `;`, `=`, or non-ASCII characters)
|
|
114
|
-
* to ensure correct parsing of the escape sequence by iTerm2.
|
|
115
|
-
* The `ITerm2File` and `ITerm2MultipartFileStart` classes generally expect the name to be pre-encoded if necessary.
|
|
116
|
-
* @example `"bXlmaWxlLnR4dA=="` (Base64 for "myfile.txt")
|
|
117
|
-
*/
|
|
118
|
-
name?: string;
|
|
119
|
-
/**
|
|
120
|
-
* The size of the file in bytes. This is used by iTerm2 for progress indication during downloads
|
|
121
|
-
* or to inform inline display mechanisms.
|
|
122
|
-
* JavaScript `number` type is generally sufficient for typical file sizes (up to `Number.MAX_SAFE_INTEGER`).
|
|
123
|
-
*/
|
|
124
|
-
size?: number;
|
|
125
|
-
/**
|
|
126
|
-
* The display width of the image or file placeholder.
|
|
127
|
-
* Can be:
|
|
128
|
-
* - A number (interpreted as character cells, e.g., `20`).
|
|
129
|
-
* - A string with units: `"Npx"` (N pixels), `"N%"` (N percent of session width).
|
|
130
|
-
* - The string {@link IT2_AUTO} (`"auto"`) for automatic sizing.
|
|
131
|
-
* Use helper functions like {@link it2Cells}, {@link it2Pixels}, {@link it2Percent} for formatting if needed.
|
|
132
|
-
* @example `20`, `"200px"`, `"75%"`, `IT2_AUTO`
|
|
133
|
-
*/
|
|
134
|
-
width?: LiteralUnion<typeof IT2_AUTO, number | string>;
|
|
135
|
-
}
|
|
@@ -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 ITerm2FileProps} for property details.
|
|
11
|
-
* @see {@link 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 ITerm2FileProps}.
|
|
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 ITerm2FileProps} 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
|
-
}
|
package/dist/iterm2.d.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import type { IITerm2Payload } from './iterm2/iterm2-properties.d.ts';
|
|
2
|
-
export type { IITerm2Payload, ITerm2FileProperties } from './iterm2/iterm2-properties.d.ts';
|
|
3
|
-
export { IT2_AUTO, it2Cells, it2Percent, it2Pixels } from './iterm2/iterm2-properties.d.ts';
|
|
4
|
-
export { ITerm2File, ITerm2FileEnd, ITerm2FilePart, ITerm2MultipartFileStart } from './iterm2/iterm2-sequences.d.ts';
|
|
5
|
-
/**
|
|
6
|
-
* Generates a complete iTerm2 proprietary escape sequence (OSC 1337).
|
|
7
|
-
*
|
|
8
|
-
* This function serves as a general-purpose constructor for iTerm2 escape codes.
|
|
9
|
-
* It takes a payload object that conforms to the {@link IITerm2Payload} interface.
|
|
10
|
-
* The `toString()` method of this payload object is responsible for generating the
|
|
11
|
-
* specific command and arguments part of the sequence (e.g., `File=...`, `ShellIntegrationVersion=...`).
|
|
12
|
-
*
|
|
13
|
-
* The overall structure of the generated sequence is: `OSC 1337 ; <PAYLOAD_STRING> BEL`
|
|
14
|
-
* (`OSC` is `\x1b]`, `BEL` is `\x07`).
|
|
15
|
-
* @param payload An object that implements the {@link IITerm2Payload} interface.
|
|
16
|
-
* This object must have a `toString()` method that returns the string representation
|
|
17
|
-
* of the iTerm2 command-specific payload.
|
|
18
|
-
* Examples include instances of `ITerm2File`, `ITerm2MultipartFileStart`, etc.
|
|
19
|
-
* @returns The fully formed ANSI escape sequence for the iTerm2 command.
|
|
20
|
-
* Returns an empty string if the provided `payload` is invalid (e.g., null, undefined,
|
|
21
|
-
* lacks a proper `toString` method, or its `toString` method is the generic `Object.prototype.toString`).
|
|
22
|
-
* @see {@link https://iterm2.com/documentation-escape-codes.html iTerm2 Escape Codes Documentation}
|
|
23
|
-
* for a comprehensive list of supported commands and their payloads.
|
|
24
|
-
* @see {@link IITerm2Payload} for the interface requirement.
|
|
25
|
-
* @see Classes like {@link ITerm2File}, {@link ITerm2MultipartFileStart}, {@link ITerm2FilePart}, {@link ITerm2FileEnd}
|
|
26
|
-
* for concrete examples of payload objects.
|
|
27
|
-
* @example
|
|
28
|
-
* ```typescript
|
|
29
|
-
* import { iTerm2, ITerm2File, ITerm2FileProps } from '@visulima/ansi/iterm2'; // ITerm2FileProps can be used for options
|
|
30
|
-
* import { Buffer } from 'node:buffer';
|
|
31
|
-
*
|
|
32
|
-
* // Example 1: Sending a file inline (like an image)
|
|
33
|
-
* const imageName = "my_image.png";
|
|
34
|
-
* const imageData = Buffer.from("dummyimagecontent"); // Replace with actual Uint8Array image data
|
|
35
|
-
* const imageFileProps: ITerm2FileProps = { // Use ITerm2FileProps for broader options
|
|
36
|
-
* name: Buffer.from(imageName).toString("base64"), // Name should be base64 encoded
|
|
37
|
-
* inline: true,
|
|
38
|
-
* width: "50%",
|
|
39
|
-
* height: "auto",
|
|
40
|
-
* ignoreAspectRatio: false, // Equivalent to preserveAspectRatio: true
|
|
41
|
-
* };
|
|
42
|
-
* const filePayload = new ITerm2File(imageFileProps, imageData);
|
|
43
|
-
* const imageSequence = iTerm2(filePayload);
|
|
44
|
-
* console.log(imageSequence);
|
|
45
|
-
* // Expected output (simplified, actual base64 will be longer):
|
|
46
|
-
* // OSC1337;File=name=bXlfaW1hZ2UucG5n;inline=1;width=50%;height=auto:ZHVtbXlpbWFnZWNvbnRlbnQ=BEL
|
|
47
|
-
* // Note: if ignoreAspectRatio was true, preserveAspectRatio=0 would be in the sequence.
|
|
48
|
-
*
|
|
49
|
-
* // Example 2: A hypothetical simple command (e.g., shell integration handshake)
|
|
50
|
-
* const shellIntegrationPayload: IITerm2Payload = {
|
|
51
|
-
* toString: () => "ShellIntegrationVersion=15;Shell=zsh"
|
|
52
|
-
* };
|
|
53
|
-
* const shellSequence = iTerm2(shellIntegrationPayload);
|
|
54
|
-
* console.log(shellSequence);
|
|
55
|
-
* // Output: OSC1337;ShellIntegrationVersion=15;Shell=zshBEL
|
|
56
|
-
* ```
|
|
57
|
-
*/
|
|
58
|
-
export declare const iTerm2: (payload: IITerm2Payload) => string;
|
package/dist/iterm2.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { O as OSC, B as BEL } from './packem_shared/constants-CE7WkXh_.js';
|
|
2
|
-
export { IT2_AUTO, it2Cells, it2Percent, it2Pixels } from './packem_shared/IT2_AUTO-BGxGtZAE.js';
|
|
3
|
-
export { ITerm2File, ITerm2FileEnd, ITerm2FilePart, ITerm2MultipartFileStart } from './packem_shared/ITerm2File-DzWaT6j3.js';
|
|
4
|
-
|
|
5
|
-
const iTerm2 = (payload) => {
|
|
6
|
-
if (!payload || typeof payload.toString !== "function" || payload.toString === Object.prototype.toString) {
|
|
7
|
-
throw new Error("Invalid payload: must implement IITerm2Payload with a custom toString method");
|
|
8
|
-
}
|
|
9
|
-
return `${OSC}1337;${payload.toString()}${BEL}`;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export { iTerm2 };
|