UNPKG

4.61 kBTypeScriptView Raw
1import { Poll } from '@lumino/polling';
2import { ISignal } from '@lumino/signaling';
3import { ServerConnection } from '..';
4import * as Terminal from './terminal';
5import { BaseManager } from '../basemanager';
6/**
7 * A terminal session manager.
8 */
9export declare class TerminalManager extends BaseManager implements Terminal.IManager {
10 /**
11 * Construct a new terminal manager.
12 */
13 constructor(options?: TerminalManager.IOptions);
14 /**
15 * The server settings of the manager.
16 */
17 readonly serverSettings: ServerConnection.ISettings;
18 /**
19 * Test whether the manager is ready.
20 */
21 get isReady(): boolean;
22 /**
23 * A promise that fulfills when the manager is ready.
24 */
25 get ready(): Promise<void>;
26 /**
27 * A signal emitted when the running terminals change.
28 */
29 get runningChanged(): ISignal<this, Terminal.IModel[]>;
30 /**
31 * A signal emitted when there is a connection failure.
32 */
33 get connectionFailure(): ISignal<this, Error>;
34 /**
35 * Dispose of the resources used by the manager.
36 */
37 dispose(): void;
38 /**
39 * Whether the terminal service is available.
40 */
41 isAvailable(): boolean;
42 connectTo(options: Omit<Terminal.ITerminalConnection.IOptions, 'serverSettings'>): Terminal.ITerminalConnection;
43 /**
44 * Create an iterator over the most recent running terminals.
45 *
46 * @returns A new iterator over the running terminals.
47 */
48 running(): IterableIterator<Terminal.IModel>;
49 /**
50 * Force a refresh of the running terminals.
51 *
52 * @returns A promise that with the list of running terminals.
53 *
54 * #### Notes
55 * This is intended to be called only in response to a user action,
56 * since the manager maintains its internal state.
57 */
58 refreshRunning(): Promise<void>;
59 /**
60 * Create a new terminal session.
61 *
62 * @param options - The options used to create the terminal.
63 *
64 * @returns A promise that resolves with the terminal connection instance.
65 *
66 * #### Notes
67 * The manager `serverSettings` will be used unless overridden in the
68 * options.
69 */
70 startNew(options?: Terminal.ITerminal.IOptions): Promise<Terminal.ITerminalConnection>;
71 /**
72 * Shut down a terminal session by name.
73 */
74 shutdown(name: string): Promise<void>;
75 /**
76 * Shut down all terminal sessions.
77 *
78 * @returns A promise that resolves when all of the sessions are shut down.
79 */
80 shutdownAll(): Promise<void>;
81 /**
82 * Execute a request to the server to poll running terminals and update state.
83 */
84 protected requestRunning(): Promise<void>;
85 /**
86 * Handle a session starting.
87 */
88 private _onStarted;
89 /**
90 * Handle a session terminating.
91 */
92 private _onDisposed;
93 private _isReady;
94 private _names;
95 private get _models();
96 private _pollModels;
97 private _terminalConnections;
98 private _ready;
99 private _runningChanged;
100 private _connectionFailure;
101}
102/**
103 * The namespace for TerminalManager statics.
104 */
105export declare namespace TerminalManager {
106 /**
107 * The options used to initialize a terminal manager.
108 */
109 interface IOptions extends BaseManager.IOptions {
110 /**
111 * When the manager stops polling the API. Defaults to `when-hidden`.
112 */
113 standby?: Poll.Standby | (() => boolean | Poll.Standby);
114 }
115 /**
116 * A no-op terminal manager to be used when starting terminals is not supported.
117 */
118 class NoopManager extends TerminalManager {
119 /**
120 * Whether the manager is active.
121 */
122 get isActive(): boolean;
123 /**
124 * Used for testing.
125 */
126 get parentReady(): Promise<void>;
127 /**
128 * A promise that fulfills when the manager is ready (never).
129 */
130 get ready(): Promise<void>;
131 /**
132 * Create a new terminal session - throw an error since it is not supported.
133 *
134 */
135 startNew(options?: Terminal.ITerminal.IOptions): Promise<Terminal.ITerminalConnection>;
136 connectTo(options: Omit<Terminal.ITerminalConnection.IOptions, 'serverSettings'>): Terminal.ITerminalConnection;
137 /**
138 * Shut down a session by id - throw an error since it is not supported.
139 */
140 shutdown(id: string): Promise<void>;
141 /**
142 * Execute a request to the server to poll running sessions and update state.
143 */
144 protected requestRunning(): Promise<void>;
145 private _readyPromise;
146 }
147}
148
\No newline at end of file