1 | import { ISessionContext } from '@jupyterlab/apputils';
|
2 | import { ITranslator } from '@jupyterlab/translation';
|
3 | import { VDomModel, VDomRenderer } from '@jupyterlab/ui-components';
|
4 | import { Notebook } from './widget';
|
5 | import { NotebookPanel } from './panel';
|
6 | import { ISettingRegistry } from '@jupyterlab/settingregistry';
|
7 | import { Widget } from '@lumino/widgets';
|
8 |
|
9 |
|
10 |
|
11 | export declare function ExecutionIndicatorComponent(props: ExecutionIndicatorComponent.IProps): JSX.Element;
|
12 |
|
13 |
|
14 |
|
15 | declare namespace ExecutionIndicatorComponent {
|
16 | |
17 |
|
18 |
|
19 | interface IProps {
|
20 | |
21 |
|
22 |
|
23 | displayOption: Private.DisplayOption;
|
24 | |
25 |
|
26 |
|
27 | state?: ExecutionIndicator.IExecutionState;
|
28 | |
29 |
|
30 |
|
31 | translator?: ITranslator;
|
32 | }
|
33 | }
|
34 |
|
35 |
|
36 |
|
37 | export declare class ExecutionIndicator extends VDomRenderer<ExecutionIndicator.Model> {
|
38 | |
39 |
|
40 |
|
41 | constructor(translator?: ITranslator, showProgress?: boolean);
|
42 | /**
|
43 | * Render the execution status item.
|
44 | */
|
45 | render(): JSX.Element | null;
|
46 | private translator;
|
47 | }
|
48 | /**
|
49 | * A namespace for ExecutionIndicator statics.
|
50 | */
|
51 | export declare namespace ExecutionIndicator {
|
52 | |
53 |
|
54 |
|
55 | interface IExecutionState {
|
56 | |
57 |
|
58 |
|
59 |
|
60 | executionStatus: string;
|
61 | |
62 |
|
63 |
|
64 | kernelStatus: ISessionContext.KernelDisplayStatus;
|
65 | |
66 |
|
67 |
|
68 | totalTime: number;
|
69 | |
70 |
|
71 |
|
72 |
|
73 | interval: number;
|
74 | |
75 |
|
76 |
|
77 |
|
78 | timeout: number;
|
79 | |
80 |
|
81 |
|
82 |
|
83 | scheduledCell: Set<string>;
|
84 | |
85 |
|
86 |
|
87 |
|
88 | scheduledCellNumber: number;
|
89 | |
90 |
|
91 |
|
92 |
|
93 | needReset: boolean;
|
94 | }
|
95 | |
96 |
|
97 |
|
98 | class Model extends VDomModel {
|
99 | constructor();
|
100 | /**
|
101 | * Attach a notebook with session context to model in order to keep
|
102 | * track of multiple notebooks. If a session context is already
|
103 | * attached, only set current activated notebook to input.
|
104 | *
|
105 | * @param data - The notebook and session context to be attached to model
|
106 | */
|
107 | attachNotebook(data: {
|
108 | content?: Notebook;
|
109 | context?: ISessionContext;
|
110 | } | null): void;
|
111 | /**
|
112 | * The current activated notebook in model.
|
113 | */
|
114 | get currentNotebook(): Notebook | null;
|
115 | /**
|
116 | * The display options for progress bar and elapsed time.
|
117 | */
|
118 | get displayOption(): Private.DisplayOption;
|
119 | /**
|
120 | * Set the display options for progress bar and elapsed time.
|
121 | *
|
122 | * @param options - Options to be used
|
123 | */
|
124 | set displayOption(options: Private.DisplayOption);
|
125 | /**
|
126 | * Get the execution state associated with a notebook.
|
127 | *
|
128 | * @param nb - The notebook used to identify execution
|
129 | * state.
|
130 | *
|
131 | * @returns - The associated execution state.
|
132 | */
|
133 | executionState(nb: Notebook): IExecutionState | undefined;
|
134 | /**
|
135 | * Schedule switch to idle status and clearing of the timer.
|
136 | *
|
137 | * ### Note
|
138 | *
|
139 | * To keep track of cells executed under 1 second,
|
140 | * the execution state is marked as `needReset` 1 second after executing
|
141 | * these cells. This `Timeout` will be cleared if there is any cell
|
142 | * scheduled after that.
|
143 | */
|
144 | private _scheduleSwitchToIdle;
|
145 | /**
|
146 | * The function is called on kernel's idle status message.
|
147 | * It is used to keep track of number of executed
|
148 | * cells or Comm custom messages and the status of kernel.
|
149 | *
|
150 | * @param nb - The notebook which contains the executed code cell.
|
151 | * @param msg_id - The id of message.
|
152 | */
|
153 | private _cellExecutedCallback;
|
154 | /**
|
155 | * The function is called on kernel's restarting status message.
|
156 | * It is used to clear the state tracking the number of executed
|
157 | * cells.
|
158 | *
|
159 | * @param nb - The notebook which contains the executed code cell.
|
160 | */
|
161 | private _restartHandler;
|
162 | /**
|
163 | * This function is called on kernel's `execute_input` message to start
|
164 | * the elapsed time counter.
|
165 | *
|
166 | * @param nb - The notebook which contains the scheduled execution request.
|
167 | */
|
168 | private _startTimer;
|
169 | /**
|
170 | * The function is called on kernel's `execute_request` message or Comm message, it is
|
171 | * used to keep track number of scheduled cell or Comm execution message
|
172 | * and the status of kernel.
|
173 | *
|
174 | * @param nb - The notebook which contains the scheduled code.
|
175 | * cell
|
176 | * @param msg_id - The id of message.
|
177 | */
|
178 | private _cellScheduledCallback;
|
179 | /**
|
180 | * Increment the executed time of input execution state
|
181 | * and emit `stateChanged` signal to re-render the indicator.
|
182 | *
|
183 | * @param data - the state to be updated.
|
184 | */
|
185 | private _tick;
|
186 | /**
|
187 | * Reset the input execution state.
|
188 | *
|
189 | * @param data - the state to be rested.
|
190 | */
|
191 | private _resetTime;
|
192 | get renderFlag(): boolean;
|
193 | updateRenderOption(options: {
|
194 | showOnToolBar: boolean;
|
195 | showProgress: boolean;
|
196 | }): void;
|
197 | /**
|
198 | * The option to show the indicator on status bar or toolbar.
|
199 | */
|
200 | private _displayOption;
|
201 | /**
|
202 | * Current activated notebook.
|
203 | */
|
204 | private _currentNotebook;
|
205 | /**
|
206 | * A weak map to hold execution status of multiple notebooks.
|
207 | */
|
208 | private _notebookExecutionProgress;
|
209 | /**
|
210 | * A flag to show or hide the indicator.
|
211 | */
|
212 | private _renderFlag;
|
213 | }
|
214 | function createExecutionIndicatorItem(panel: NotebookPanel, translator?: ITranslator, loadSettings?: Promise<ISettingRegistry.ISettings>): Widget;
|
215 | function getSettingValue(settings: ISettingRegistry.ISettings): {
|
216 | showOnToolBar: boolean;
|
217 | showProgress: boolean;
|
218 | };
|
219 | }
|
220 |
|
221 |
|
222 |
|
223 | declare namespace Private {
|
224 | type DisplayOption = {
|
225 | |
226 |
|
227 |
|
228 | showOnToolBar: boolean;
|
229 | |
230 |
|
231 |
|
232 |
|
233 | showProgress: boolean;
|
234 | };
|
235 | }
|
236 | export {};
|