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