UNPKG

@visulima/ansi

Version:

ANSI escape codes for some terminal swag.

97 lines (96 loc) 4.93 kB
import type { IITerm2Payload, ITerm2FileProperties } from "./iterm2-properties.d.cts"; /** * Represents the payload for a complete iTerm2 file transfer or an inline image display command. * This class is used to construct the part of the OSC 1337 sequence that follows `File=`. * The generated payload can be either: * - `File=[PROPERTIES]:[BASE64_CONTENT]` (for inline content) * - `File=[PROPERTIES]` (if content is not provided directly, e.g., for a download announcement) * * Implements {@link IITerm2Payload} for use with the generic `iTerm2` function. * @see {@link ITerm2FileProps} for property details. * @see {@link iTerm2} for the function that wraps this payload into a full escape sequence. */ export declare class ITerm2File implements IITerm2Payload { private readonly fileProps; /** * Constructs an `ITerm2File` payload object. * @param properties An object containing properties for the file/image, as defined by {@link ITerm2FileProps}. * The `name` property within `props` should be pre-Base64 encoded by the caller if it might * contain special characters (like `;`, `=`, or non-ASCII characters). * If `fileData` is provided, `props.content` will be overridden, and `props.size` will be * set from `fileData.byteLength` if not already present in `props`. * @param fileData (Optional) A `Uint8Array` containing the raw file data. If provided, this data will be * Base64 encoded and used as the `content` of the file transfer. The `size` property * will also be automatically set from `fileData.byteLength` if not specified in `props`. */ constructor(properties: ITerm2FileProperties, fileData?: Uint8Array); /** * Converts the file properties and its content (if any) into the string payload * suitable for the iTerm2 `File=` command. * @returns The string payload (e.g., `"File=name=...;size=...:BASE64_CONTENT"` or `"File=name=...;size=..."`). */ toString(): string; } /** * Represents the payload for ending an iTerm2 multipart file transfer. * This class is used to construct the part of the OSC 1337 sequence that is simply `FileEnd`. * * Implements {@link IITerm2Payload} for use with the generic `iTerm2` function. * @see {@link ITerm2MultipartFileStart} to initiate the transfer. * @see {@link ITerm2FilePart} for sending file chunks. */ export declare class ITerm2FileEnd implements IITerm2Payload { /** * Generates the string payload for the iTerm2 `FileEnd` command. * @returns The string `"FileEnd"`. */ toString(): string; } /** * Represents the payload for a part (chunk) of an iTerm2 multipart file transfer. * This class is used to construct the part of the OSC 1337 sequence that follows `FilePart=`. * The provided chunk must already be Base64 encoded. * * Implements {@link IITerm2Payload} for use with the generic `iTerm2` function. * @see {@link ITerm2MultipartFileStart} to initiate the transfer. * @see {@link ITerm2FileEnd} to finalize the transfer. */ export declare class ITerm2FilePart implements IITerm2Payload { private readonly base64Chunk; /** * Constructs an `ITerm2FilePart` payload object. * @param base64Chunk A string containing a Base64 encoded chunk of the file data. * The caller is responsible for chunking the file and Base64 encoding each chunk. */ constructor(base64Chunk: string); /** * Converts the Base64 encoded chunk into the string payload suitable for the iTerm2 `FilePart=` command. * @returns The string payload (e.g., `"FilePart=U09NRURBVEE="`). */ toString(): string; } /** * Represents the payload for starting an iTerm2 multipart file transfer. * This class is used to construct the part of the OSC 1337 sequence that follows `MultipartFile=`. * This command initiates a transfer; the actual file data is sent in subsequent `FilePart` commands. * * Implements {@link IITerm2Payload} for use with the generic `iTerm2` function. * @see {@link ITerm2FileProps} for property details (omitting `content`). * @see {@link ITerm2FilePart} for sending file chunks. * @see {@link ITerm2FileEnd} for finalizing the transfer. */ export declare class ITerm2MultipartFileStart implements IITerm2Payload { private readonly properties; /** * Constructs an `ITerm2MultipartFileStart` payload object. * @param properties Properties for the multipart file (e.g., `name`, `size`). Content is not part of this command. * The `name` property within `props` should be pre-Base64 encoded by the caller if it might * contain special characters. */ constructor(properties: Omit<ITerm2FileProperties, "content">); /** * Converts the file properties into the string payload suitable for the iTerm2 `MultipartFile=` command. * @returns The string payload (e.g., `"MultipartFile=name=...;size=..."`). */ toString(): string; }