UNPKG

3.83 kBTypeScriptView Raw
1import { ITranslator } from '@jupyterlab/translation';
2import { VDomRenderer } from '@jupyterlab/ui-components';
3import { CommandRegistry } from '@lumino/commands';
4import { ReadonlyJSONObject, Token } from '@lumino/coreutils';
5import { IDisposable } from '@lumino/disposable';
6import { Widget } from '@lumino/widgets';
7/**
8 * The launcher token.
9 */
10export declare const ILauncher: Token<ILauncher>;
11/**
12 * The launcher interface.
13 */
14export interface ILauncher {
15 /**
16 * Add a command item to the launcher, and trigger re-render event for parent
17 * widget.
18 *
19 * @param options - The specification options for a launcher item.
20 *
21 * @returns A disposable that will remove the item from Launcher, and trigger
22 * re-render event for parent widget.
23 *
24 */
25 add(options: ILauncher.IItemOptions): IDisposable;
26}
27/**
28 * The namespace for `ILauncher` class statics.
29 */
30export declare namespace ILauncher {
31 /**
32 * An interface for the launcher model
33 */
34 interface IModel extends ILauncher, VDomRenderer.IModel {
35 /**
36 * Return an iterator of launcher items.
37 */
38 items(): IterableIterator<ILauncher.IItemOptions>;
39 }
40 /**
41 * The options used to create a Launcher.
42 */
43 interface IOptions {
44 /**
45 * The model of the launcher.
46 */
47 model: IModel;
48 /**
49 * The cwd of the launcher.
50 */
51 cwd: string;
52 /**
53 * The command registry used by the launcher.
54 */
55 commands: CommandRegistry;
56 /**
57 * The application language translation.
58 */
59 translator?: ITranslator;
60 /**
61 * The callback used when an item is launched.
62 */
63 callback: (widget: Widget) => void;
64 }
65 /**
66 * The options used to create a launcher item.
67 */
68 interface IItemOptions {
69 /**
70 * The command ID for the launcher item.
71 *
72 * #### Notes
73 * If the command's `execute` method returns a `Widget` or
74 * a promise that resolves with a `Widget`, then that widget will
75 * replace the launcher in the same location of the application
76 * shell. If the `execute` method does something else
77 * (i.e., create a modal dialog), then the launcher will not be
78 * disposed.
79 */
80 command: string;
81 /**
82 * The arguments given to the command for
83 * creating the launcher item.
84 *
85 * ### Notes
86 * The launcher will also add the current working
87 * directory of the filebrowser in the `cwd` field
88 * of the args, which a command may use to create
89 * the activity with respect to the right directory.
90 */
91 args?: ReadonlyJSONObject;
92 /**
93 * The category for the launcher item.
94 *
95 * The default value is an empty string.
96 */
97 category?: string;
98 /**
99 * The rank for the launcher item.
100 *
101 * The rank is used when ordering launcher items for display. After grouping
102 * into categories, items are sorted in the following order:
103 * 1. Rank (lower is better)
104 * 3. Display Name (locale order)
105 *
106 * The default rank is `Infinity`.
107 */
108 rank?: number;
109 /**
110 * For items that have a kernel associated with them, the URL of the kernel
111 * icon.
112 *
113 * This is not a CSS class, but the URL that points to the icon in the kernel
114 * spec.
115 */
116 kernelIconUrl?: string;
117 /**
118 * Metadata about the item. This can be used by the launcher to
119 * affect how the item is displayed.
120 */
121 metadata?: ReadonlyJSONObject;
122 }
123}