import { JSONPrimitive, JSONObject } from 'phosphor/lib/algorithm/json'; import { IDisposable } from 'phosphor/lib/core/disposable'; import { ISignal } from 'phosphor/lib/core/signaling'; import * as utils from '../utils'; /** * An interface for a terminal session. */ export interface ITerminalSession extends IDisposable { /** * A signal emitted when a message is received from the server. */ messageReceived: ISignal; /** * Get the name of the terminal session. */ readonly name: string; /** * Send a message to the terminal session. */ send(message: TerminalSession.IMessage): void; /** * Shut down the terminal session. */ shutdown(): Promise; } /** * The namespace for ITerminalSession statics. */ export declare namespace TerminalSession { /** * Create a terminal session or connect to an existing session. * * #### Notes * If the session is already running on the client, the existing * instance will be returned. */ function open(options?: TerminalSession.IOptions): Promise; /** * The options for intializing a terminal session object. */ interface IOptions extends JSONObject { /** * The name of the terminal. */ name?: string; /** * The base url. */ baseUrl?: string; /** * The base websocket url. */ wsUrl?: string; /** * The Ajax settings used for server requests. */ ajaxSettings?: utils.IAjaxSettings; } /** * The server model for a terminal session. */ interface IModel extends JSONObject { /** * The name of the terminal session. */ readonly name: string; } /** * A message from the terminal session. */ interface IMessage extends JSONObject { /** * The type of the message. */ readonly type: MessageType; /** * The content of the message. */ readonly content?: JSONPrimitive[]; } /** * Valid message types for the terminal. */ type MessageType = 'stdout' | 'disconnect' | 'set_size' | 'stdin'; /** * The interface for a terminal manager. */ interface IManager extends IDisposable { /** * A signal emitted when the running terminals change. */ runningChanged: ISignal; /** * Create a new terminal session or connect to an existing session. * * #### Notes * This will emit [[runningChanged]] if the running terminals list * changes. */ create(options?: TerminalSession.IOptions): Promise; /** * Shut down a terminal session by name. * * #### Notes * This will emit [[runningChanged]] if the running terminals list * changes. */ shutdown(name: string): Promise; /** * Get the list of models for the terminals running on the server. */ listRunning(): Promise; } } /** * A terminal session manager. */ export declare class TerminalManager implements TerminalSession.IManager { /** * Construct a new terminal manager. */ constructor(options?: TerminalManager.IOptions); /** * A signal emitted when the running terminals change. */ runningChanged: ISignal; /** * Test whether the terminal manager is disposed. */ readonly isDisposed: boolean; /** * Dispose of the resources used by the manager. */ dispose(): void; /** * Create a new terminal session or connect to an existing session. */ create(options?: TerminalSession.IOptions): Promise; /** * Shut down a terminal session by name. */ shutdown(name: string): Promise; /** * Get the list of models for the terminals running on the server. */ listRunning(): Promise; private _baseUrl; private _wsUrl; private _ajaxSettings; private _running; private _isDisposed; } /** * The namespace for TerminalManager statics. */ export declare namespace TerminalManager { /** * The options used to initialize a terminal manager. */ interface IOptions { /** * The base url. */ baseUrl?: string; /** * The base websocket url. */ wsUrl?: string; /** * The Ajax settings used for server requests. */ ajaxSettings?: utils.IAjaxSettings; } }