1 | // Copyright (c) Jupyter Development Team.
|
2 | // Distributed under the terms of the Modified BSD License.
|
3 |
|
4 | import { IChangedArgs } from '@jupyterlab/coreutils';
|
5 | import { IRenderMime } from '@jupyterlab/rendermime-interfaces';
|
6 | import { ISettingRegistry } from '@jupyterlab/settingregistry';
|
7 | import { Token } from '@lumino/coreutils';
|
8 | import { IDisposable } from '@lumino/disposable';
|
9 | import { ISignal } from '@lumino/signaling';
|
10 | import { CommandPalette, Widget } from '@lumino/widgets';
|
11 | import { ISessionContext } from './sessioncontext';
|
12 |
|
13 | /**
|
14 | * The command palette token.
|
15 | */
|
16 | export const ICommandPalette = new Token<ICommandPalette>(
|
17 | '@jupyterlab/apputils:ICommandPalette',
|
18 | `A service for the application command palette
|
19 | in the left panel. Use this to add commands to the palette.`
|
20 | );
|
21 |
|
22 | /**
|
23 | * The options for creating a command palette item.
|
24 | */
|
25 | export interface IPaletteItem extends CommandPalette.IItemOptions {}
|
26 |
|
27 | /**
|
28 | * The interface for a Jupyter Lab command palette.
|
29 | */
|
30 | export interface ICommandPalette {
|
31 | /**
|
32 | * The placeholder text of the command palette's search input.
|
33 | */
|
34 | placeholder: string;
|
35 |
|
36 | /**
|
37 | * Activate the command palette for user input.
|
38 | */
|
39 | activate(): void;
|
40 |
|
41 | /**
|
42 | * Add a command item to the command palette.
|
43 | *
|
44 | * @param options - The options for creating the command item.
|
45 | *
|
46 | * @returns A disposable that will remove the item from the palette.
|
47 | */
|
48 | addItem(options: IPaletteItem): IDisposable;
|
49 | }
|
50 |
|
51 | /**
|
52 | * The kernel status indicator model.
|
53 | */
|
54 | export const IKernelStatusModel = new Token<IKernelStatusModel>(
|
55 | '@jupyterlab/apputils:IKernelStatusModel',
|
56 | 'A service to register kernel session provider to the kernel status indicator.'
|
57 | );
|
58 |
|
59 | /**
|
60 | * Kernel status indicator model.
|
61 | */
|
62 | export interface IKernelStatusModel {
|
63 | /**
|
64 | * Add a session context provider.
|
65 | *
|
66 | * A provider will receive the currently active widget and must return the
|
67 | * associated session context if it can or null otherwise.
|
68 | */
|
69 | addSessionProvider: (
|
70 | provider: (widget: Widget | null) => ISessionContext | null
|
71 | ) => void;
|
72 | }
|
73 |
|
74 | /**
|
75 | * An interface for the session context dialogs.
|
76 | */
|
77 | export interface ISessionContextDialogs extends ISessionContext.IDialogs {}
|
78 |
|
79 | /**
|
80 | * The session context dialogs token.
|
81 | */
|
82 | export const ISessionContextDialogs = new Token<ISessionContext.IDialogs>(
|
83 | '@jupyterlab/apputils:ISessionContextDialogs',
|
84 | 'A service for handling the session dialogs.'
|
85 | );
|
86 |
|
87 | /**
|
88 | * The theme manager token.
|
89 | */
|
90 | export const IThemeManager = new Token<IThemeManager>(
|
91 | '@jupyterlab/apputils:IThemeManager',
|
92 | 'A service for the theme manager for the application. This is used primarily in theme extensions to register new themes.'
|
93 | );
|
94 |
|
95 | /**
|
96 | * An interface for a theme manager.
|
97 | */
|
98 | export interface IThemeManager {
|
99 | /**
|
100 | * Get the name of the current theme.
|
101 | */
|
102 | readonly theme: string | null;
|
103 |
|
104 | /**
|
105 | * The names of the registered themes.
|
106 | */
|
107 | readonly themes: ReadonlyArray<string>;
|
108 |
|
109 | /**
|
110 | * A signal fired when the application theme changes.
|
111 | */
|
112 | readonly themeChanged: ISignal<this, IChangedArgs<string, string | null>>;
|
113 |
|
114 | /**
|
115 | * Load a theme CSS file by path.
|
116 | *
|
117 | * @param path - The path of the file to load.
|
118 | */
|
119 | loadCSS(path: string): Promise<void>;
|
120 |
|
121 | /**
|
122 | * Register a theme with the theme manager.
|
123 | *
|
124 | * @param theme - The theme to register.
|
125 | *
|
126 | * @returns A disposable that can be used to unregister the theme.
|
127 | */
|
128 | register(theme: IThemeManager.ITheme): IDisposable;
|
129 |
|
130 | /**
|
131 | * Set the current theme.
|
132 | */
|
133 | setTheme(name: string): Promise<void>;
|
134 |
|
135 | /**
|
136 | * Test whether a given theme is light.
|
137 | */
|
138 | isLight(name: string): boolean;
|
139 |
|
140 | /**
|
141 | * Test whether a given theme styles scrollbars,
|
142 | * and if the user has scrollbar styling enabled.
|
143 | */
|
144 | themeScrollbars(name: string): boolean;
|
145 |
|
146 | /**
|
147 | * Get display name for theme.
|
148 | */
|
149 | getDisplayName(name: string): string;
|
150 | }
|
151 |
|
152 | /**
|
153 | * A namespace for the `IThemeManager` sub-types.
|
154 | */
|
155 | export namespace IThemeManager {
|
156 | /**
|
157 | * An interface for a theme.
|
158 | */
|
159 | export interface ITheme {
|
160 | /**
|
161 | * The unique identifier name of the theme.
|
162 | */
|
163 | name: string;
|
164 |
|
165 | /**
|
166 | * The display name of the theme.
|
167 | */
|
168 | displayName?: string;
|
169 |
|
170 | /**
|
171 | * Whether the theme is light or dark. Downstream authors
|
172 | * of extensions can use this information to customize their
|
173 | * UI depending upon the current theme.
|
174 | */
|
175 | isLight: boolean;
|
176 |
|
177 | /**
|
178 | * Whether the theme includes styling for the scrollbar.
|
179 | * If set to false, this theme will leave the native scrollbar untouched.
|
180 | */
|
181 | themeScrollbars?: boolean;
|
182 |
|
183 | /**
|
184 | * Load the theme.
|
185 | *
|
186 | * @returns A promise that resolves when the theme has loaded.
|
187 | */
|
188 | load(): Promise<void>;
|
189 |
|
190 | /**
|
191 | * Unload the theme.
|
192 | *
|
193 | * @returns A promise that resolves when the theme has unloaded.
|
194 | */
|
195 | unload(): Promise<void>;
|
196 | }
|
197 | }
|
198 |
|
199 | /**
|
200 | * The sanitizer token.
|
201 | */
|
202 | export const ISanitizer = new Token<IRenderMime.ISanitizer>(
|
203 | '@jupyterlab/apputils:ISanitizer',
|
204 | 'A service for sanitizing HTML strings.'
|
205 | );
|
206 |
|
207 | /**
|
208 | * @deprecated since v4 use {@link IRenderMime.ISanitizer}
|
209 | */
|
210 | export type ISanitizer = IRenderMime.ISanitizer;
|
211 |
|
212 | /**
|
213 | * The namespace for `ISanitizer` related interfaces.
|
214 | */
|
215 | export namespace ISanitizer {
|
216 | /**
|
217 | * The options used to sanitize.
|
218 | *
|
219 | * @deprecated in v4 use {@link IRenderMime.ISanitizerOptions}
|
220 | */
|
221 | export type IOptions = IRenderMime.ISanitizerOptions;
|
222 | }
|
223 |
|
224 | /**
|
225 | * The main menu token.
|
226 | */
|
227 | export const ISplashScreen = new Token<ISplashScreen>(
|
228 | '@jupyterlab/apputils:ISplashScreen',
|
229 | `A service for the splash screen for the application.
|
230 | Use this if you want to show the splash screen for your own purposes.`
|
231 | );
|
232 |
|
233 | /**
|
234 | * The interface for an application splash screen.
|
235 | */
|
236 | export interface ISplashScreen {
|
237 | /**
|
238 | * Show the application splash screen.
|
239 | *
|
240 | * @param light - Whether to show the light splash screen or the dark one.
|
241 | *
|
242 | * @returns A disposable used to clear the splash screen.
|
243 | */
|
244 | show(light?: boolean): IDisposable;
|
245 | }
|
246 |
|
247 | /**
|
248 | * The default window resolver token.
|
249 | */
|
250 | export const IWindowResolver = new Token<IWindowResolver>(
|
251 | '@jupyterlab/apputils:IWindowResolver',
|
252 | `A service for a window resolver for the
|
253 | application. JupyterLab workspaces are given a name, which are determined using
|
254 | the window resolver. Require this if you want to use the name of the current workspace.`
|
255 | );
|
256 |
|
257 | /**
|
258 | * The description of a window name resolver.
|
259 | */
|
260 | export interface IWindowResolver {
|
261 | /**
|
262 | * A window name to use as a handle among shared resources.
|
263 | */
|
264 | readonly name: string;
|
265 | }
|
266 |
|
267 | /**
|
268 | * The namespace for `IToolbarWidgetRegistry` related interfaces
|
269 | */
|
270 | export namespace ToolbarRegistry {
|
271 | /**
|
272 | * Interface of item to be inserted in a toolbar
|
273 | */
|
274 | export interface IToolbarItem extends IRenderMime.IToolbarItem {}
|
275 |
|
276 | /**
|
277 | * Interface describing a toolbar item widget
|
278 | */
|
279 | export interface IWidget extends ISettingRegistry.IToolbarItem {}
|
280 |
|
281 | /**
|
282 | * Options to set up the toolbar widget registry
|
283 | */
|
284 | export interface IOptions {
|
285 | /**
|
286 | * Default toolbar widget factory
|
287 | *
|
288 | * The factory is receiving 3 arguments:
|
289 | * @param widgetFactory The widget factory name that creates the toolbar
|
290 | * @param widget The newly widget containing the toolbar
|
291 | * @param toolbarItem The toolbar item definition
|
292 | * @returns The widget to be inserted in the toolbar.
|
293 | */
|
294 | defaultFactory: (
|
295 | widgetFactory: string,
|
296 | widget: Widget,
|
297 | toolbarItem: IWidget
|
298 | ) => Widget;
|
299 | }
|
300 | }
|
301 |
|
302 | /**
|
303 | * Toolbar widget registry interface
|
304 | */
|
305 | export interface IToolbarWidgetRegistry {
|
306 | /**
|
307 | * Add a new toolbar item factory
|
308 | *
|
309 | * @param widgetFactory The widget factory name that creates the toolbar
|
310 | * @param toolbarItemName The unique toolbar item
|
311 | * @param factory The factory function that receives the widget containing the toolbar and returns the toolbar widget.
|
312 | * @returns The previously defined factory
|
313 | */
|
314 | addFactory<T extends Widget = Widget>(
|
315 | widgetFactory: string,
|
316 | toolbarItemName: string,
|
317 | factory: (main: T) => Widget
|
318 | ): ((main: T) => Widget) | undefined;
|
319 |
|
320 | /**
|
321 | * Default toolbar item factory
|
322 | */
|
323 | defaultFactory: (
|
324 | widgetFactory: string,
|
325 | widget: Widget,
|
326 | toolbarItem: ToolbarRegistry.IWidget
|
327 | ) => Widget;
|
328 |
|
329 | /**
|
330 | * Create a toolbar item widget
|
331 | *
|
332 | * @param widgetFactory The widget factory name that creates the toolbar
|
333 | * @param widget The newly widget containing the toolbar
|
334 | * @param toolbarItem The toolbar item definition
|
335 | * @returns The widget to be inserted in the toolbar.
|
336 | */
|
337 | createWidget(
|
338 | widgetFactory: string,
|
339 | widget: Widget,
|
340 | toolbarItem: ToolbarRegistry.IWidget
|
341 | ): Widget;
|
342 |
|
343 | /**
|
344 | * Register a new toolbar item factory
|
345 | *
|
346 | * @param widgetFactory The widget factory name that creates the toolbar
|
347 | * @param toolbarItemName The unique toolbar item
|
348 | * @param factory The factory function that receives the widget containing the toolbar and returns the toolbar widget.
|
349 | * @returns The previously defined factory
|
350 | *
|
351 | * @deprecated since v4 use `addFactory` instead
|
352 | */
|
353 | registerFactory<T extends Widget = Widget>(
|
354 | widgetFactory: string,
|
355 | toolbarItemName: string,
|
356 | factory: (main: T) => Widget
|
357 | ): ((main: T) => Widget) | undefined;
|
358 |
|
359 | /**
|
360 | * A signal emitted when a factory widget has been added.
|
361 | */
|
362 | readonly factoryAdded: ISignal<this, string>;
|
363 | }
|
364 |
|
365 | /**
|
366 | * The toolbar registry token.
|
367 | */
|
368 | export const IToolbarWidgetRegistry = new Token<IToolbarWidgetRegistry>(
|
369 | '@jupyterlab/apputils:IToolbarWidgetRegistry',
|
370 | `A registry for toolbar widgets. Require this
|
371 | if you want to build the toolbar dynamically from a data definition (stored in settings for example).`
|
372 | );
|
373 |
|
\ | No newline at end of file |