UNPKG

@karinjs/node-pty

Version:

Use vite+tsup to recompile node-pty into esm, which is smaller in size.

149 lines (144 loc) 4.77 kB
/** * Copyright (c) 2016, Daniel Imms (MIT License). * Copyright (c) 2018, Microsoft Corporation (MIT License). */ interface IProcessEnv { [key: string]: string | undefined; } interface ITerminal { /** * Gets the name of the process. */ process: string; /** * Gets the process ID. */ pid: number; /** * Writes data to the socket. * @param data The data to write. */ write(data: string): void; /** * Resize the pty. * @param cols The number of columns. * @param rows The number of rows. */ resize(cols: number, rows: number): void; /** * Clears the pty's internal representation of its buffer. This is a no-op * unless on Windows/ConPTY. */ clear(): void; /** * Close, kill and destroy the socket. */ destroy(): void; /** * Kill the pty. * @param signal The signal to send, by default this is SIGHUP. This is not * supported on Windows. */ kill(signal?: string): void; /** * Set the pty socket encoding. */ setEncoding(encoding: string | null): void; /** * Resume the pty socket. */ resume(): void; /** * Pause the pty socket. */ pause(): void; /** * Alias for ITerminal.on(eventName, listener). */ addListener(eventName: string, listener: (...args: any[]) => any): void; /** * Adds the listener function to the end of the listeners array for the event * named eventName. * @param eventName The event name. * @param listener The callback function */ on(eventName: string, listener: (...args: any[]) => any): void; /** * Returns a copy of the array of listeners for the event named eventName. */ listeners(eventName: string): Function[]; /** * Removes the specified listener from the listener array for the event named * eventName. */ removeListener(eventName: string, listener: (...args: any[]) => any): void; /** * Removes all listeners, or those of the specified eventName. */ removeAllListeners(eventName: string): void; /** * Adds a one time listener function for the event named eventName. The next * time eventName is triggered, this listener is removed and then invoked. */ once(eventName: string, listener: (...args: any[]) => any): void; } interface IBasePtyForkOptions { name?: string; cols?: number; rows?: number; cwd?: string; env?: IProcessEnv; encoding?: string | null; handleFlowControl?: boolean; flowControlPause?: string; flowControlResume?: string; } interface IPtyForkOptions extends IBasePtyForkOptions { uid?: number; gid?: number; } interface IWindowsPtyForkOptions extends IBasePtyForkOptions { useConpty?: boolean; useConptyDll?: boolean; conptyInheritCursor?: boolean; } interface IPtyOpenOptions { cols?: number; rows?: number; encoding?: string | null; } /** * Copyright (c) 2017, Daniel Imms (MIT License). * Copyright (c) 2018, Microsoft Corporation (MIT License). */ type ArgvOrCommandLine = string[] | string; /** * Copyright (c) 2012-2015, Christopher Jeffrey, Peter Sunde (MIT License) * Copyright (c) 2016, Daniel Imms (MIT License). * Copyright (c) 2018, Microsoft Corporation (MIT License). */ /** * Forks a process as a pseudoterminal. * @param file The file to launch. * @param args The file's arguments as argv (string[]) or in a pre-escaped * CommandLine format (string). Note that the CommandLine option is only * available on Windows and is expected to be escaped properly. * @param options The options of the terminal. * @throws When the file passed to spawn with does not exists. * @see CommandLineToArgvW https://msdn.microsoft.com/en-us/library/windows/desktop/bb776391(v=vs.85).aspx * @see Parsing C++ Comamnd-Line Arguments https://msdn.microsoft.com/en-us/library/17w5ykft.aspx * @see GetCommandLine https://msdn.microsoft.com/en-us/library/windows/desktop/ms683156.aspx */ declare function spawn(file?: string, args?: ArgvOrCommandLine, opt?: IPtyForkOptions | IWindowsPtyForkOptions): ITerminal; /** @deprecated */ declare function fork(file?: string, args?: ArgvOrCommandLine, opt?: IPtyForkOptions | IWindowsPtyForkOptions): ITerminal; /** @deprecated */ declare function createTerminal(file?: string, args?: ArgvOrCommandLine, opt?: IPtyForkOptions | IWindowsPtyForkOptions): ITerminal; declare function open(options: IPtyOpenOptions): ITerminal; /** * Expose the native API when not Windows, note that this is not public API and * could be removed at any time. */ declare const native: any; export { createTerminal, fork, native, open, spawn }; export type IPty = ITerminal