/
index.tsx
837 lines (742 loc) · 23.8 KB
/
index.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
import {
IConnectionLost,
ILabShell,
ILabStatus,
ILayoutRestorer,
IRouter,
ConnectionLost,
JupyterFrontEnd,
JupyterFrontEndPlugin,
JupyterLab,
LabShell,
LayoutRestorer,
Router
} from '@jupyterlab/application';
import {
Dialog,
ICommandPalette,
IWindowResolver,
showDialog,
showErrorMessage
} from '@jupyterlab/apputils';
import {
PathExt,
IStateDB,
ISettingRegistry,
URLExt
} from '@jupyterlab/coreutils';
import {
IPropertyInspectorProvider,
SideBarPropertyInspectorProvider
} from '@jupyterlab/property-inspector';
import { each, iter, toArray } from '@lumino/algorithm';
import { PromiseDelegate } from '@lumino/coreutils';
import { DisposableDelegate, DisposableSet } from '@lumino/disposable';
import { Widget, DockLayout } from '@lumino/widgets';
import * as React from 'react';
/**
* The command IDs used by the application plugin.
*/
namespace CommandIDs {
export const activateNextTab: string = 'application:activate-next-tab';
export const activatePreviousTab: string =
'application:activate-previous-tab';
export const close = 'application:close';
export const closeOtherTabs = 'application:close-other-tabs';
export const closeRightTabs = 'application:close-right-tabs';
export const closeAll: string = 'application:close-all';
export const setMode: string = 'application:set-mode';
export const toggleMode: string = 'application:toggle-mode';
export const toggleLeftArea: string = 'application:toggle-left-area';
export const toggleRightArea: string = 'application:toggle-right-area';
export const togglePresentationMode: string =
'application:toggle-presentation-mode';
export const tree: string = 'router:tree';
export const switchSidebar = 'sidebar:switch';
}
/**
* The main extension.
*/
const main: JupyterFrontEndPlugin<void> = {
id: '@jupyterlab/application-extension:main',
requires: [ICommandPalette, IRouter, IWindowResolver],
optional: [IConnectionLost],
activate: (
app: JupyterFrontEnd,
palette: ICommandPalette,
router: IRouter,
resolver: IWindowResolver,
connectionLost: IConnectionLost | undefined
) => {
if (!(app instanceof JupyterLab)) {
throw new Error(`${main.id} must be activated in JupyterLab.`);
}
// Requiring the window resolver guarantees that the application extension
// only loads if there is a viable window name. Otherwise, the application
// will short-circuit and ask the user to navigate away.
const workspace = resolver.name;
console.log(`Starting application in workspace: "${workspace}"`);
// If there were errors registering plugins, tell the user.
if (app.registerPluginErrors.length !== 0) {
const body = (
<pre>{app.registerPluginErrors.map(e => e.message).join('\n')}</pre>
);
void showErrorMessage('Error Registering Plugins', { message: body });
}
addCommands(app, palette);
// If the application shell layout is modified,
// trigger a refresh of the commands.
app.shell.layoutModified.connect(() => {
app.commands.notifyCommandChanged();
});
// when current tab changes, activate the new current tab
// if there isn't an active tab
app.shell.currentChanged.connect((sender, args) => {
if (!app.shell.activeWidget && args.newValue) {
app.shell.activateById(args.newValue.id);
}
});
// If the connection to the server is lost, handle it with the
// connection lost handler.
connectionLost = connectionLost || ConnectionLost;
app.serviceManager.connectionFailure.connect(connectionLost);
const builder = app.serviceManager.builder;
const build = () => {
return builder
.build()
.then(() => {
return showDialog({
title: 'Build Complete',
body: 'Build successfully completed, reload page?',
buttons: [
Dialog.cancelButton(),
Dialog.warnButton({ label: 'Reload' })
]
});
})
.then(result => {
if (result.button.accept) {
router.reload();
}
})
.catch(err => {
void showErrorMessage('Build Failed', {
message: <pre>{err.message}</pre>
});
});
};
if (builder.isAvailable && builder.shouldCheck) {
void builder.getStatus().then(response => {
if (response.status === 'building') {
return build();
}
if (response.status !== 'needed') {
return;
}
const body = (
<div>
JupyterLab build is suggested:
<br />
<pre>{response.message}</pre>
</div>
);
void showDialog({
title: 'Build Recommended',
body,
buttons: [Dialog.cancelButton(), Dialog.okButton({ label: 'Build' })]
}).then(result => (result.button.accept ? build() : undefined));
});
}
const message =
'Are you sure you want to exit JupyterLab?\n' +
'Any unsaved changes will be lost.';
// The spec for the `beforeunload` event is implemented differently by
// the different browser vendors. Consequently, the `event.returnValue`
// attribute needs to set in addition to a return value being returned.
// For more information, see:
// https://developer.mozilla.org/en/docs/Web/Events/beforeunload
window.addEventListener('beforeunload', event => {
if (app.status.isDirty) {
return ((event as any).returnValue = message);
}
});
},
autoStart: true
};
/**
* The default layout restorer provider.
*/
const layout: JupyterFrontEndPlugin<ILayoutRestorer> = {
id: '@jupyterlab/application-extension:layout',
requires: [IStateDB, ILabShell],
activate: (app: JupyterFrontEnd, state: IStateDB, labShell: ILabShell) => {
const first = app.started;
const registry = app.commands;
const restorer = new LayoutRestorer({ connector: state, first, registry });
void restorer.fetch().then(saved => {
labShell.restoreLayout(saved);
labShell.layoutModified.connect(() => {
void restorer.save(labShell.saveLayout());
});
});
return restorer;
},
autoStart: true,
provides: ILayoutRestorer
};
/**
* The default URL router provider.
*/
const router: JupyterFrontEndPlugin<IRouter> = {
id: '@jupyterlab/application-extension:router',
requires: [JupyterFrontEnd.IPaths],
activate: (app: JupyterFrontEnd, paths: JupyterFrontEnd.IPaths) => {
const { commands } = app;
const base = paths.urls.base;
const router = new Router({ base, commands });
void app.started.then(() => {
// Route the very first request on load.
void router.route();
// Route all pop state events.
window.addEventListener('popstate', () => {
void router.route();
});
});
return router;
},
autoStart: true,
provides: IRouter
};
/**
* The default tree route resolver plugin.
*/
const tree: JupyterFrontEndPlugin<JupyterFrontEnd.ITreeResolver> = {
id: '@jupyterlab/application-extension:tree-resolver',
autoStart: true,
requires: [JupyterFrontEnd.IPaths, IRouter, IWindowResolver],
provides: JupyterFrontEnd.ITreeResolver,
activate: (
app: JupyterFrontEnd,
paths: JupyterFrontEnd.IPaths,
router: IRouter,
resolver: IWindowResolver
): JupyterFrontEnd.ITreeResolver => {
const { commands } = app;
const treePattern = new RegExp(`^${paths.urls.tree}([^?]+)`);
const workspacePattern = new RegExp(
`^${paths.urls.workspaces}/[^?/]+/tree/([^?]+)`
);
const set = new DisposableSet();
const delegate = new PromiseDelegate<JupyterFrontEnd.ITreeResolver.Paths>();
set.add(
commands.addCommand(CommandIDs.tree, {
execute: async (args: IRouter.ILocation) => {
if (set.isDisposed) {
return;
}
const treeMatch = args.path.match(treePattern);
const workspaceMatch = args.path.match(workspacePattern);
const match = treeMatch || workspaceMatch;
const file = match ? decodeURI(match[1]) : '';
const workspace = PathExt.basename(resolver.name);
const query = URLExt.queryStringToObject(args.search ?? '');
const browser = query['file-browser-path'] || '';
// Remove the file browser path from the query string.
delete query['file-browser-path'];
// Remove the tree portion of the URL.
const url =
(workspaceMatch
? URLExt.join(paths.urls.workspaces, workspace)
: paths.urls.app) +
URLExt.objectToQueryString(query) +
args.hash;
// Route to the cleaned URL.
router.navigate(url);
// Clean up artifacts immediately upon routing.
set.dispose();
delegate.resolve({ browser, file });
}
})
);
set.add(
router.register({ command: CommandIDs.tree, pattern: treePattern })
);
set.add(
router.register({ command: CommandIDs.tree, pattern: workspacePattern })
);
// If a route is handled by the router without the tree command being
// invoked, resolve to `null` and clean up artifacts.
const listener = () => {
if (set.isDisposed) {
return;
}
set.dispose();
delegate.resolve(null);
};
router.routed.connect(listener);
set.add(
new DisposableDelegate(() => {
router.routed.disconnect(listener);
})
);
return { paths: delegate.promise };
}
};
/**
* The default URL not found extension.
*/
const notfound: JupyterFrontEndPlugin<void> = {
id: '@jupyterlab/application-extension:notfound',
requires: [JupyterFrontEnd.IPaths, IRouter],
activate: (
_: JupyterFrontEnd,
paths: JupyterFrontEnd.IPaths,
router: IRouter
) => {
const bad = paths.urls.notFound;
if (!bad) {
return;
}
const base = router.base;
const message = `
The path: ${bad} was not found. JupyterLab redirected to: ${base}
`;
// Change the URL back to the base application URL.
router.navigate('');
void showErrorMessage('Path Not Found', { message });
},
autoStart: true
};
/**
* Change the favicon changing based on the busy status;
*/
const busy: JupyterFrontEndPlugin<void> = {
id: '@jupyterlab/application-extension:faviconbusy',
requires: [ILabStatus],
activate: async (_: JupyterFrontEnd, status: ILabStatus) => {
status.busySignal.connect((_, isBusy) => {
const favicon = document.querySelector(
`link[rel="icon"]${isBusy ? '.idle.favicon' : '.busy.favicon'}`
) as HTMLLinkElement;
if (!favicon) {
return;
}
const newFavicon = document.querySelector(
`link${isBusy ? '.busy.favicon' : '.idle.favicon'}`
) as HTMLLinkElement;
if (!newFavicon) {
return;
}
// If we have the two icons with the special classes, then toggle them.
if (favicon !== newFavicon) {
favicon.rel = '';
newFavicon.rel = 'icon';
// Firefox doesn't seem to recognize just changing rel, so we also
// reinsert the link into the DOM.
newFavicon.parentNode!.replaceChild(newFavicon, newFavicon);
}
});
},
autoStart: true
};
const SIDEBAR_ID = '@jupyterlab/application-extension:sidebar';
/**
* Keep user settings for where to show the side panels.
*/
const sidebar: JupyterFrontEndPlugin<void> = {
id: SIDEBAR_ID,
activate: (
app: JupyterFrontEnd,
settingRegistry: ISettingRegistry,
labShell: ILabShell
) => {
type overrideMap = { [id: string]: 'left' | 'right' };
let overrides: overrideMap = {};
const handleLayoutOverrides = () => {
each(labShell.widgets('left'), widget => {
if (overrides[widget.id] && overrides[widget.id] === 'right') {
labShell.add(widget, 'right');
}
});
each(labShell.widgets('right'), widget => {
if (overrides[widget.id] && overrides[widget.id] === 'left') {
labShell.add(widget, 'left');
}
});
};
labShell.layoutModified.connect(handleLayoutOverrides);
// Fetch overrides from the settings system.
void Promise.all([settingRegistry.load(SIDEBAR_ID), app.restored]).then(
([settings]) => {
overrides = (settings.get('overrides').composite as overrideMap) || {};
settings.changed.connect(settings => {
overrides =
(settings.get('overrides').composite as overrideMap) || {};
handleLayoutOverrides();
});
}
);
// Add a command to switch a side panels's side
app.commands.addCommand(CommandIDs.switchSidebar, {
label: 'Switch Sidebar Side',
execute: () => {
// First, try to find the correct panel based on the
// application context menu click.
const contextNode: HTMLElement | undefined = app.contextMenuHitTest(
node => !!node.dataset.id
);
let id: string;
let side: 'left' | 'right';
if (contextNode) {
id = contextNode.dataset['id']!;
const leftPanel = document.getElementById('jp-left-stack');
const node = document.getElementById(id);
if (leftPanel && node && leftPanel.contains(node)) {
side = 'right';
} else {
side = 'left';
}
} else {
// Bail if we don't find a sidebar for the widget.
return;
}
// Move the panel to the other side.
const newOverrides = { ...overrides };
newOverrides[id] = side;
return settingRegistry.set(SIDEBAR_ID, 'overrides', newOverrides);
}
});
// Add a context menu item to sidebar tabs.
app.contextMenu.addItem({
command: CommandIDs.switchSidebar,
selector: '.jp-SideBar .p-TabBar-tab',
rank: 500
});
},
requires: [ISettingRegistry, ILabShell],
autoStart: true
};
/**
* Add the main application commands.
*/
function addCommands(app: JupyterLab, palette: ICommandPalette): void {
const { commands, contextMenu, shell } = app;
const category = 'Main Area';
// Returns the widget associated with the most recent contextmenu event.
const contextMenuWidget = (): Widget | null => {
const test = (node: HTMLElement) => !!node.dataset.id;
const node = app.contextMenuHitTest(test);
if (!node) {
// Fall back to active widget if path cannot be obtained from event.
return shell.currentWidget;
}
const matches = toArray(shell.widgets('main')).filter(
widget => widget.id === node.dataset.id
);
if (matches.length < 1) {
return shell.currentWidget;
}
return matches[0];
};
// Closes an array of widgets.
const closeWidgets = (widgets: Array<Widget>): void => {
widgets.forEach(widget => widget.close());
};
// Find the tab area for a widget within a specific dock area.
const findTab = (
area: DockLayout.AreaConfig,
widget: Widget
): DockLayout.ITabAreaConfig | null => {
switch (area.type) {
case 'split-area':
const iterator = iter(area.children);
let tab: DockLayout.ITabAreaConfig | null = null;
let value: DockLayout.AreaConfig | undefined;
do {
value = iterator.next();
if (value) {
tab = findTab(value, widget);
}
} while (!tab && value);
return tab;
case 'tab-area':
const { id } = widget;
return area.widgets.some(widget => widget.id === id) ? area : null;
default:
return null;
}
};
// Find the tab area for a widget within the main dock area.
const tabAreaFor = (widget: Widget): DockLayout.ITabAreaConfig | null => {
const { mainArea } = shell.saveLayout();
if (!mainArea || mainArea.mode !== 'multiple-document') {
return null;
}
let area = mainArea.dock?.main;
if (!area) {
return null;
}
return findTab(area, widget);
};
// Returns an array of all widgets to the right of a widget in a tab area.
const widgetsRightOf = (widget: Widget): Array<Widget> => {
const { id } = widget;
const tabArea = tabAreaFor(widget);
const widgets = tabArea ? tabArea.widgets || [] : [];
const index = widgets.findIndex(widget => widget.id === id);
if (index < 0) {
return [];
}
return widgets.slice(index + 1);
};
commands.addCommand(CommandIDs.activateNextTab, {
label: 'Activate Next Tab',
execute: () => {
shell.activateNextTab();
}
});
palette.addItem({ command: CommandIDs.activateNextTab, category });
commands.addCommand(CommandIDs.activatePreviousTab, {
label: 'Activate Previous Tab',
execute: () => {
shell.activatePreviousTab();
}
});
palette.addItem({ command: CommandIDs.activatePreviousTab, category });
// A CSS selector targeting tabs in the main area. This is a very
// specific selector since we really only want tabs that are
// in the main area, as opposed to those in sidebars, ipywidgets, etc.
const tabSelector =
'#jp-main-dock-panel .p-DockPanel-tabBar.jp-Activity .p-TabBar-tab';
commands.addCommand(CommandIDs.close, {
label: () => 'Close Tab',
isEnabled: () =>
!!shell.currentWidget && !!shell.currentWidget.title.closable,
execute: () => {
if (shell.currentWidget) {
shell.currentWidget.close();
}
}
});
palette.addItem({ command: CommandIDs.close, category });
contextMenu.addItem({
command: CommandIDs.close,
selector: tabSelector,
rank: 4
});
commands.addCommand(CommandIDs.closeAll, {
label: 'Close All Tabs',
execute: () => {
shell.closeAll();
}
});
palette.addItem({ command: CommandIDs.closeAll, category });
commands.addCommand(CommandIDs.closeOtherTabs, {
label: () => `Close All Other Tabs`,
isEnabled: () => {
// Ensure there are at least two widgets.
const iterator = shell.widgets('main');
return !!iterator.next() && !!iterator.next();
},
execute: () => {
const widget = contextMenuWidget();
if (!widget) {
return;
}
const { id } = widget;
const otherWidgets = toArray(shell.widgets('main')).filter(
widget => widget.id !== id
);
closeWidgets(otherWidgets);
}
});
palette.addItem({ command: CommandIDs.closeOtherTabs, category });
contextMenu.addItem({
command: CommandIDs.closeOtherTabs,
selector: tabSelector,
rank: 4
});
commands.addCommand(CommandIDs.closeRightTabs, {
label: () => `Close Tabs to Right`,
isEnabled: () =>
!!contextMenuWidget() && widgetsRightOf(contextMenuWidget()!).length > 0,
execute: () => {
const widget = contextMenuWidget();
if (!widget) {
return;
}
closeWidgets(widgetsRightOf(widget));
}
});
palette.addItem({ command: CommandIDs.closeRightTabs, category });
contextMenu.addItem({
command: CommandIDs.closeRightTabs,
selector: tabSelector,
rank: 5
});
app.commands.addCommand(CommandIDs.toggleLeftArea, {
label: args => 'Show Left Sidebar',
execute: () => {
if (shell.leftCollapsed) {
shell.expandLeft();
} else {
shell.collapseLeft();
if (shell.currentWidget) {
shell.activateById(shell.currentWidget.id);
}
}
},
isToggled: () => !shell.leftCollapsed,
isVisible: () => !shell.isEmpty('left')
});
palette.addItem({ command: CommandIDs.toggleLeftArea, category });
app.commands.addCommand(CommandIDs.toggleRightArea, {
label: args => 'Show Right Sidebar',
execute: () => {
if (shell.rightCollapsed) {
shell.expandRight();
} else {
shell.collapseRight();
if (shell.currentWidget) {
shell.activateById(shell.currentWidget.id);
}
}
},
isToggled: () => !shell.rightCollapsed,
isVisible: () => !shell.isEmpty('right')
});
palette.addItem({ command: CommandIDs.toggleRightArea, category });
app.commands.addCommand(CommandIDs.togglePresentationMode, {
label: args => 'Presentation Mode',
execute: () => {
shell.presentationMode = !shell.presentationMode;
},
isToggled: () => shell.presentationMode,
isVisible: () => true
});
palette.addItem({ command: CommandIDs.togglePresentationMode, category });
app.commands.addCommand(CommandIDs.setMode, {
isVisible: args => {
const mode = args['mode'] as string;
return mode === 'single-document' || mode === 'multiple-document';
},
execute: args => {
const mode = args['mode'] as string;
if (mode === 'single-document' || mode === 'multiple-document') {
shell.mode = mode;
return;
}
throw new Error(`Unsupported application shell mode: ${mode}`);
}
});
app.commands.addCommand(CommandIDs.toggleMode, {
label: 'Single-Document Mode',
isToggled: () => shell.mode === 'single-document',
execute: () => {
const args =
shell.mode === 'multiple-document'
? { mode: 'single-document' }
: { mode: 'multiple-document' };
return app.commands.execute(CommandIDs.setMode, args);
}
});
palette.addItem({ command: CommandIDs.toggleMode, category });
}
/**
* The default JupyterLab application shell.
*/
const shell: JupyterFrontEndPlugin<ILabShell> = {
id: '@jupyterlab/application-extension:shell',
activate: (app: JupyterFrontEnd) => {
if (!(app.shell instanceof LabShell)) {
throw new Error(`${shell.id} did not find a LabShell instance.`);
}
return app.shell;
},
autoStart: true,
provides: ILabShell
};
/**
* The default JupyterLab application status provider.
*/
const status: JupyterFrontEndPlugin<ILabStatus> = {
id: '@jupyterlab/application-extension:status',
activate: (app: JupyterFrontEnd) => {
if (!(app instanceof JupyterLab)) {
throw new Error(`${status.id} must be activated in JupyterLab.`);
}
return app.status;
},
autoStart: true,
provides: ILabStatus
};
/**
* The default JupyterLab application-specific information provider.
*
* #### Notes
* This plugin should only be used by plugins that specifically need to access
* JupyterLab application information, e.g., listing extensions that have been
* loaded or deferred within JupyterLab.
*/
const info: JupyterFrontEndPlugin<JupyterLab.IInfo> = {
id: '@jupyterlab/application-extension:info',
activate: (app: JupyterFrontEnd) => {
if (!(app instanceof JupyterLab)) {
throw new Error(`${info.id} must be activated in JupyterLab.`);
}
return app.info;
},
autoStart: true,
provides: JupyterLab.IInfo
};
/**
* The default JupyterLab paths dictionary provider.
*/
const paths: JupyterFrontEndPlugin<JupyterFrontEnd.IPaths> = {
id: '@jupyterlab/apputils-extension:paths',
activate: (app: JupyterFrontEnd): JupyterFrontEnd.IPaths => {
if (!(app instanceof JupyterLab)) {
throw new Error(`${paths.id} must be activated in JupyterLab.`);
}
return app.paths;
},
autoStart: true,
provides: JupyterFrontEnd.IPaths
};
/**
* The default property inspector provider.
*/
const propertyInspector: JupyterFrontEndPlugin<IPropertyInspectorProvider> = {
id: '@jupyterlab/application-extension:property-inspector',
autoStart: true,
requires: [ILabShell],
provides: IPropertyInspectorProvider,
activate: (app: JupyterFrontEnd, labshell: ILabShell) => {
const widget = new SideBarPropertyInspectorProvider(labshell);
widget.title.iconClass = 'jp-BuildIcon jp-SideBar-tabIcon';
widget.title.caption = 'Property Inspector';
widget.id = 'jp-property-inspector';
labshell.add(widget, 'left');
return widget;
}
};
/**
* Export the plugins as default.
*/
const plugins: JupyterFrontEndPlugin<any>[] = [
main,
layout,
router,
tree,
notfound,
busy,
sidebar,
shell,
status,
info,
paths,
propertyInspector
];
export default plugins;