@jupyter-notebook/application-extension 7.6.1 → 7.7.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +19 -2
- package/lib/settingconnector.d.ts +31 -0
- package/lib/settingconnector.js +97 -0
- package/package.json +16 -14
package/lib/index.js
CHANGED
|
@@ -8,10 +8,11 @@ import { IDocumentManager, renameDialog } from '@jupyterlab/docmanager';
|
|
|
8
8
|
import { DocumentWidget } from '@jupyterlab/docregistry';
|
|
9
9
|
import { IMainMenu } from '@jupyterlab/mainmenu';
|
|
10
10
|
import { ILatexTypesetter, IMarkdownParser, IRenderMimeRegistry, RenderMimeRegistry, standardRendererFactories, } from '@jupyterlab/rendermime';
|
|
11
|
-
import { ISettingRegistry } from '@jupyterlab/settingregistry';
|
|
11
|
+
import { ISettingConnector, ISettingRegistry, } from '@jupyterlab/settingregistry';
|
|
12
12
|
import { ITranslator, nullTranslator } from '@jupyterlab/translation';
|
|
13
13
|
import { NotebookApp, NotebookShell, INotebookShell, SidePanelPalette, INotebookPathOpener, defaultNotebookPathOpener, } from '@jupyter-notebook/application';
|
|
14
14
|
import { jupyterIcon } from '@jupyter-notebook/ui-components';
|
|
15
|
+
import { SettingConnector } from './settingconnector';
|
|
15
16
|
import { PromiseDelegate } from '@lumino/coreutils';
|
|
16
17
|
import { DisposableDelegate, DisposableSet, } from '@lumino/disposable';
|
|
17
18
|
import { Menu, Widget } from '@lumino/widgets';
|
|
@@ -274,7 +275,7 @@ const pages = {
|
|
|
274
275
|
label: trans.__('File Browser'),
|
|
275
276
|
execute: () => {
|
|
276
277
|
if (page === 'tree') {
|
|
277
|
-
app.commands.execute('filebrowser:
|
|
278
|
+
app.commands.execute('filebrowser:open-directory');
|
|
278
279
|
}
|
|
279
280
|
else {
|
|
280
281
|
window.open(URLExt.join(baseUrl, 'tree'));
|
|
@@ -1058,6 +1059,21 @@ const zen = {
|
|
|
1058
1059
|
}
|
|
1059
1060
|
},
|
|
1060
1061
|
};
|
|
1062
|
+
/**
|
|
1063
|
+
* A plugin providing a custom setting connector to override the default
|
|
1064
|
+
* values of some of the JupyterLab plugin settings, for example to open
|
|
1065
|
+
* the help (pager payloads) in the down area by default, like in the
|
|
1066
|
+
* Classic Notebook.
|
|
1067
|
+
*/
|
|
1068
|
+
const settingsConnector = {
|
|
1069
|
+
id: '@jupyter-notebook/application-extension:settings-connector',
|
|
1070
|
+
description: 'Provides a custom setting connector overriding some default setting values.',
|
|
1071
|
+
autoStart: true,
|
|
1072
|
+
provides: ISettingConnector,
|
|
1073
|
+
activate: (app) => {
|
|
1074
|
+
return new SettingConnector(app.serviceManager.settings);
|
|
1075
|
+
},
|
|
1076
|
+
};
|
|
1061
1077
|
/**
|
|
1062
1078
|
* Export the plugins as default.
|
|
1063
1079
|
*/
|
|
@@ -1072,6 +1088,7 @@ const plugins = [
|
|
|
1072
1088
|
pathOpener,
|
|
1073
1089
|
paths,
|
|
1074
1090
|
rendermime,
|
|
1091
|
+
settingsConnector,
|
|
1075
1092
|
shell,
|
|
1076
1093
|
sidePanelVisibility,
|
|
1077
1094
|
shortcuts,
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ISettingConnector, ISettingRegistry } from '@jupyterlab/settingregistry';
|
|
2
|
+
import type { IDataConnector } from '@jupyterlab/statedb';
|
|
3
|
+
import { DataConnector } from '@jupyterlab/statedb';
|
|
4
|
+
/**
|
|
5
|
+
* A data connector for fetching settings.
|
|
6
|
+
*
|
|
7
|
+
* #### Notes
|
|
8
|
+
* This connector is based on the default JupyterLab setting connector,
|
|
9
|
+
* and additionally overrides the default values of some settings.
|
|
10
|
+
*/
|
|
11
|
+
export declare class SettingConnector extends DataConnector<ISettingRegistry.IPlugin, string> implements ISettingConnector {
|
|
12
|
+
constructor(connector: IDataConnector<ISettingRegistry.IPlugin, string>);
|
|
13
|
+
/**
|
|
14
|
+
* Fetch settings for a plugin.
|
|
15
|
+
* @param id - The plugin ID
|
|
16
|
+
*
|
|
17
|
+
* #### Notes
|
|
18
|
+
* The REST API requests are throttled at one request per plugin per 100ms.
|
|
19
|
+
*/
|
|
20
|
+
fetch(id: string): Promise<ISettingRegistry.IPlugin | undefined>;
|
|
21
|
+
list(query: 'ids'): Promise<{
|
|
22
|
+
ids: string[];
|
|
23
|
+
}>;
|
|
24
|
+
list(query: 'active' | 'all'): Promise<{
|
|
25
|
+
ids: string[];
|
|
26
|
+
values: ISettingRegistry.IPlugin[];
|
|
27
|
+
}>;
|
|
28
|
+
save(id: string, raw: string): Promise<void>;
|
|
29
|
+
private _connector;
|
|
30
|
+
private _throttlers;
|
|
31
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// Copyright (c) Jupyter Development Team.
|
|
2
|
+
// Distributed under the terms of the Modified BSD License.
|
|
3
|
+
import { PageConfig } from '@jupyterlab/coreutils';
|
|
4
|
+
import { DataConnector } from '@jupyterlab/statedb';
|
|
5
|
+
import { Throttler } from '@lumino/polling';
|
|
6
|
+
/**
|
|
7
|
+
* The default setting values overridden in Jupyter Notebook, mapping
|
|
8
|
+
* a plugin identifier to the overridden properties.
|
|
9
|
+
*/
|
|
10
|
+
const SETTING_OVERRIDES = {
|
|
11
|
+
// Use a different set of file browser defaults than JupyterLab.
|
|
12
|
+
'@jupyterlab/filebrowser-extension:browser': {
|
|
13
|
+
showFileCheckboxes: true,
|
|
14
|
+
showFileSizeColumn: true,
|
|
15
|
+
singleClickNavigation: true,
|
|
16
|
+
sortNotebooksFirst: true,
|
|
17
|
+
},
|
|
18
|
+
// Open the help (pager payloads) in the down area by default,
|
|
19
|
+
// like in the Classic Notebook.
|
|
20
|
+
'@jupyterlab/notebook-extension:tracker': {
|
|
21
|
+
helpInBottomPanel: true,
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* A data connector for fetching settings.
|
|
26
|
+
*
|
|
27
|
+
* #### Notes
|
|
28
|
+
* This connector is based on the default JupyterLab setting connector,
|
|
29
|
+
* and additionally overrides the default values of some settings.
|
|
30
|
+
*/
|
|
31
|
+
export class SettingConnector extends DataConnector {
|
|
32
|
+
constructor(connector) {
|
|
33
|
+
super();
|
|
34
|
+
this._throttlers = Object.create(null);
|
|
35
|
+
this._connector = connector;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Fetch settings for a plugin.
|
|
39
|
+
* @param id - The plugin ID
|
|
40
|
+
*
|
|
41
|
+
* #### Notes
|
|
42
|
+
* The REST API requests are throttled at one request per plugin per 100ms.
|
|
43
|
+
*/
|
|
44
|
+
fetch(id) {
|
|
45
|
+
const throttlers = this._throttlers;
|
|
46
|
+
if (!(id in throttlers)) {
|
|
47
|
+
throttlers[id] = new Throttler(async () => {
|
|
48
|
+
const plugin = await this._connector.fetch(id);
|
|
49
|
+
return plugin && Private.overrideDefaults(plugin);
|
|
50
|
+
}, 100);
|
|
51
|
+
}
|
|
52
|
+
return throttlers[id].invoke();
|
|
53
|
+
}
|
|
54
|
+
async list(query = 'all') {
|
|
55
|
+
const { isDisabled } = PageConfig.Extension;
|
|
56
|
+
const { ids, values } = await this._connector.list(query === 'ids' ? 'ids' : undefined);
|
|
57
|
+
if (query === 'ids') {
|
|
58
|
+
return { ids };
|
|
59
|
+
}
|
|
60
|
+
if (query === 'all') {
|
|
61
|
+
return { ids, values: values.map(Private.overrideDefaults) };
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
ids: ids.filter((id) => !isDisabled(id)),
|
|
65
|
+
values: values
|
|
66
|
+
.filter(({ id }) => !isDisabled(id))
|
|
67
|
+
.map(Private.overrideDefaults),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
async save(id, raw) {
|
|
71
|
+
await this._connector.save(id, raw);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* A namespace for private module data.
|
|
76
|
+
*/
|
|
77
|
+
var Private;
|
|
78
|
+
(function (Private) {
|
|
79
|
+
/**
|
|
80
|
+
* Override the default values of the plugin settings listed
|
|
81
|
+
* in `SETTING_OVERRIDES`.
|
|
82
|
+
*/
|
|
83
|
+
function overrideDefaults(plugin) {
|
|
84
|
+
const overrides = SETTING_OVERRIDES[plugin.id];
|
|
85
|
+
const properties = plugin.schema.properties;
|
|
86
|
+
if (!overrides || !properties) {
|
|
87
|
+
return plugin;
|
|
88
|
+
}
|
|
89
|
+
for (const [property, value] of Object.entries(overrides)) {
|
|
90
|
+
if (property in properties) {
|
|
91
|
+
properties[property].default = value;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return plugin;
|
|
95
|
+
}
|
|
96
|
+
Private.overrideDefaults = overrideDefaults;
|
|
97
|
+
})(Private || (Private = {}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jupyter-notebook/application-extension",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.7.0-alpha.1",
|
|
4
4
|
"description": "Jupyter Notebook - Application Extension",
|
|
5
5
|
"homepage": "https://github.com/jupyter/notebook",
|
|
6
6
|
"bugs": {
|
|
@@ -38,21 +38,23 @@
|
|
|
38
38
|
"watch": "tsc -b --watch"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@jupyter-notebook/application": "^7.
|
|
42
|
-
"@jupyter-notebook/ui-components": "^7.
|
|
43
|
-
"@jupyterlab/application": "~4.
|
|
44
|
-
"@jupyterlab/apputils": "~4.
|
|
45
|
-
"@jupyterlab/codeeditor": "~4.
|
|
46
|
-
"@jupyterlab/console": "~4.
|
|
47
|
-
"@jupyterlab/coreutils": "~6.
|
|
48
|
-
"@jupyterlab/docmanager": "~4.
|
|
49
|
-
"@jupyterlab/docregistry": "~4.
|
|
50
|
-
"@jupyterlab/mainmenu": "~4.
|
|
51
|
-
"@jupyterlab/rendermime": "~4.
|
|
52
|
-
"@jupyterlab/settingregistry": "~4.
|
|
53
|
-
"@jupyterlab/
|
|
41
|
+
"@jupyter-notebook/application": "^7.7.0-alpha.1",
|
|
42
|
+
"@jupyter-notebook/ui-components": "^7.7.0-alpha.1",
|
|
43
|
+
"@jupyterlab/application": "~4.7.0-alpha.1",
|
|
44
|
+
"@jupyterlab/apputils": "~4.8.0-alpha.1",
|
|
45
|
+
"@jupyterlab/codeeditor": "~4.7.0-alpha.1",
|
|
46
|
+
"@jupyterlab/console": "~4.7.0-alpha.1",
|
|
47
|
+
"@jupyterlab/coreutils": "~6.7.0-alpha.1",
|
|
48
|
+
"@jupyterlab/docmanager": "~4.7.0-alpha.1",
|
|
49
|
+
"@jupyterlab/docregistry": "~4.7.0-alpha.1",
|
|
50
|
+
"@jupyterlab/mainmenu": "~4.7.0-alpha.1",
|
|
51
|
+
"@jupyterlab/rendermime": "~4.7.0-alpha.1",
|
|
52
|
+
"@jupyterlab/settingregistry": "~4.7.0-alpha.1",
|
|
53
|
+
"@jupyterlab/statedb": "~4.7.0-alpha.1",
|
|
54
|
+
"@jupyterlab/translation": "~4.7.0-alpha.1",
|
|
54
55
|
"@lumino/coreutils": "^2.2.2",
|
|
55
56
|
"@lumino/disposable": "^2.1.5",
|
|
57
|
+
"@lumino/polling": "^2.1.5",
|
|
56
58
|
"@lumino/widgets": "^2.7.2"
|
|
57
59
|
},
|
|
58
60
|
"devDependencies": {
|