@jupyterlite/apputils-extension 0.6.0-alpha.10

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.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ import { JupyterFrontEndPlugin } from '@jupyterlab/application';
2
+ import { IPluginManager } from '@jupyterlab/pluginmanager';
3
+ /**
4
+ * A plugin for managing the status of other plugins.
5
+ */
6
+ export declare const pluginManagerPlugin: JupyterFrontEndPlugin<IPluginManager>;
7
+ declare const plugins: JupyterFrontEndPlugin<any>[];
8
+ export default plugins;
package/lib/index.js ADDED
@@ -0,0 +1,120 @@
1
+ // Copyright (c) Jupyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+ import { JupyterLab, } from '@jupyterlab/application';
4
+ import { ILicensesClient, ICommandPalette, MainAreaWidget, WidgetTracker, } from '@jupyterlab/apputils';
5
+ import { IPluginManager, Plugins } from '@jupyterlab/pluginmanager';
6
+ import { ITranslator, ITranslatorConnector, nullTranslator, } from '@jupyterlab/translation';
7
+ import { extensionIcon } from '@jupyterlab/ui-components';
8
+ import { LiteLicensesClient, LitePluginListModel, LiteTranslatorConnector, } from '@jupyterlite/apputils';
9
+ /**
10
+ * The command IDs used by the apputils extension.
11
+ */
12
+ var CommandIDs;
13
+ (function (CommandIDs) {
14
+ /**
15
+ * The command ID for opening the plugin manager.
16
+ */
17
+ CommandIDs.openPluginManager = 'apputils:open-plugin-manager';
18
+ })(CommandIDs || (CommandIDs = {}));
19
+ /**
20
+ * The client for fetching licenses data.
21
+ */
22
+ const licensesClient = {
23
+ id: '@jupyterlite/application-extension:licenses-client',
24
+ autoStart: true,
25
+ provides: ILicensesClient,
26
+ activate: (app) => {
27
+ return new LiteLicensesClient();
28
+ },
29
+ };
30
+ /**
31
+ * A plugin for managing the status of other plugins.
32
+ */
33
+ export const pluginManagerPlugin = {
34
+ id: '@jupyterlite/application-extension:plugin-manager',
35
+ description: 'Plugin manager viewer',
36
+ autoStart: true,
37
+ optional: [JupyterLab.IInfo, ITranslator, ICommandPalette],
38
+ provides: IPluginManager,
39
+ activate: (app, info, translator, palette) => {
40
+ var _a;
41
+ const availablePlugins = (_a = info === null || info === void 0 ? void 0 : info.availablePlugins) !== null && _a !== void 0 ? _a : [];
42
+ if (availablePlugins.length === 0) {
43
+ return {
44
+ open: async () => {
45
+ // eslint-disable-next-line no-console
46
+ console.info('The application does not contain information about plugins');
47
+ },
48
+ };
49
+ }
50
+ const { commands, serviceManager, shell } = app;
51
+ translator = translator !== null && translator !== void 0 ? translator : nullTranslator;
52
+ const trans = translator.load('jupyterlab');
53
+ const category = trans.__('Plugin Manager');
54
+ const widgetLabel = trans.__('Advanced Plugin Manager');
55
+ const namespace = 'plugin-manager';
56
+ const tracker = new WidgetTracker({
57
+ namespace: namespace,
58
+ });
59
+ function createWidget(args) {
60
+ const model = new LitePluginListModel({
61
+ ...args,
62
+ pluginData: {
63
+ availablePlugins,
64
+ },
65
+ serverSettings: serviceManager.serverSettings,
66
+ extraLockedPlugins: [pluginManagerPlugin.id],
67
+ translator: translator !== null && translator !== void 0 ? translator : nullTranslator,
68
+ });
69
+ const content = new Plugins({
70
+ model,
71
+ translator: translator !== null && translator !== void 0 ? translator : nullTranslator,
72
+ });
73
+ content.title.label = widgetLabel;
74
+ content.title.icon = extensionIcon;
75
+ content.title.caption = trans.__('Plugin Manager');
76
+ const main = new MainAreaWidget({ content, reveal: model.ready });
77
+ return main;
78
+ }
79
+ commands.addCommand(CommandIDs.openPluginManager, {
80
+ label: widgetLabel,
81
+ execute: (args) => {
82
+ const main = createWidget(args);
83
+ shell.add(main, 'main', { type: 'Plugins' });
84
+ // add to tracker so it can be restored, and update when choices change
85
+ void tracker.add(main);
86
+ main.content.model.trackerDataChanged.connect(() => {
87
+ void tracker.save(main);
88
+ });
89
+ return main;
90
+ },
91
+ });
92
+ if (palette) {
93
+ palette.addItem({ command: CommandIDs.openPluginManager, category });
94
+ }
95
+ return {
96
+ open: () => {
97
+ return app.commands.execute(CommandIDs.openPluginManager);
98
+ },
99
+ };
100
+ },
101
+ };
102
+ /**
103
+ * The main translator connector plugin.
104
+ */
105
+ const translatorConnector = {
106
+ id: '@jupyterlite/application-extension:translator-connector',
107
+ description: 'Provides the application translation connector.',
108
+ autoStart: true,
109
+ provides: ITranslatorConnector,
110
+ activate: (app) => {
111
+ return new LiteTranslatorConnector();
112
+ },
113
+ };
114
+ const plugins = [
115
+ licensesClient,
116
+ pluginManagerPlugin,
117
+ translatorConnector,
118
+ ];
119
+ export default plugins;
120
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAE3D,OAAO,EAGL,UAAU,GACX,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,eAAe,EACf,eAAe,EACf,cAAc,EACd,aAAa,GACd,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,cAAc,EAAmB,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAErF,OAAO,EACL,WAAW,EACX,oBAAoB,EACpB,cAAc,GACf,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,uBAAuB,CAAC;AAE/B;;GAEG;AACH,IAAU,UAAU,CAKnB;AALD,WAAU,UAAU;IAClB;;OAEG;IACU,4BAAiB,GAAG,8BAA8B,CAAC;AAClE,CAAC,EALS,UAAU,KAAV,UAAU,QAKnB;AAED;;GAEG;AACH,MAAM,cAAc,GAA2C;IAC7D,EAAE,EAAE,oDAAoD;IACxD,SAAS,EAAE,IAAI;IACf,QAAQ,EAAE,eAAe;IACzB,QAAQ,EAAE,CAAC,GAAoB,EAAmB,EAAE;QAClD,OAAO,IAAI,kBAAkB,EAAE,CAAC;IAClC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,OAAO,EAAE,CAAC;YACZ,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,UAAU,CAAC,iBAAiB,EAAE,QAAQ,EAAE,CAAC,CAAC;QACvE,CAAC;QAED,OAAO;YACL,IAAI,EAAE,GAAG,EAAE;gBACT,OAAO,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC;YAC5D,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC;AAEF;;GAEG;AACH,MAAM,mBAAmB,GAAgD;IACvE,EAAE,EAAE,yDAAyD;IAC7D,WAAW,EAAE,iDAAiD;IAC9D,SAAS,EAAE,IAAI;IACf,QAAQ,EAAE,oBAAoB;IAC9B,QAAQ,EAAE,CAAC,GAAoB,EAAE,EAAE;QACjC,OAAO,IAAI,uBAAuB,EAAE,CAAC;IACvC,CAAC;CACF,CAAC;AAEF,MAAM,OAAO,GAAiC;IAC5C,cAAc;IACd,mBAAmB;IACnB,mBAAmB;CACpB,CAAC;AAEF,eAAe,OAAO,CAAC"}
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "@jupyterlite/apputils-extension",
3
+ "version": "0.6.0-alpha.10",
4
+ "description": "JupyterLite - Application Utilities Extension",
5
+ "homepage": "https://github.com/jupyterlite/jupyterlite",
6
+ "bugs": {
7
+ "url": "https://github.com/jupyterlite/jupyterlite/issues"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/jupyterlite/jupyterlite.git"
12
+ },
13
+ "license": "BSD-3-Clause",
14
+ "author": "JupyterLite Contributors",
15
+ "sideEffects": [
16
+ "style/*.css",
17
+ "style/index.js"
18
+ ],
19
+ "main": "lib/index.js",
20
+ "types": "lib/index.d.ts",
21
+ "style": "style/index.css",
22
+ "directories": {
23
+ "lib": "lib/"
24
+ },
25
+ "files": [
26
+ "lib/*.d.ts",
27
+ "lib/*.js.map",
28
+ "lib/*.js",
29
+ "style/*.css",
30
+ "style/index.js",
31
+ "src/**/*.{ts,tsx}"
32
+ ],
33
+ "scripts": {
34
+ "build": "tsc -b",
35
+ "clean": "rimraf lib && rimraf tsconfig.tsbuildinfo",
36
+ "docs": "typedoc src",
37
+ "prepublishOnly": "npm run build",
38
+ "watch": "tsc -b --watch"
39
+ },
40
+ "dependencies": {
41
+ "@jupyterlab/application": "~4.4.2",
42
+ "@jupyterlab/apputils": "~4.5.2",
43
+ "@jupyterlab/pluginmanager": "~4.4.2",
44
+ "@jupyterlab/translation": "~4.4.2",
45
+ "@jupyterlab/ui-components": "~4.4.2",
46
+ "@jupyterlite/apputils": "^0.6.0-alpha.10"
47
+ },
48
+ "devDependencies": {
49
+ "rimraf": "~5.0.1",
50
+ "typescript": "~5.5.4"
51
+ },
52
+ "publishConfig": {
53
+ "access": "public"
54
+ },
55
+ "jupyterlab": {
56
+ "extension": true
57
+ },
58
+ "styleModule": "style/index.js"
59
+ }
package/src/index.tsx ADDED
@@ -0,0 +1,161 @@
1
+ // Copyright (c) Jupyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+
4
+ import {
5
+ JupyterFrontEnd,
6
+ JupyterFrontEndPlugin,
7
+ JupyterLab,
8
+ } from '@jupyterlab/application';
9
+
10
+ import {
11
+ ILicensesClient,
12
+ ICommandPalette,
13
+ MainAreaWidget,
14
+ WidgetTracker,
15
+ } from '@jupyterlab/apputils';
16
+
17
+ import { IPluginManager, PluginListModel, Plugins } from '@jupyterlab/pluginmanager';
18
+
19
+ import {
20
+ ITranslator,
21
+ ITranslatorConnector,
22
+ nullTranslator,
23
+ } from '@jupyterlab/translation';
24
+
25
+ import { extensionIcon } from '@jupyterlab/ui-components';
26
+
27
+ import {
28
+ LiteLicensesClient,
29
+ LitePluginListModel,
30
+ LiteTranslatorConnector,
31
+ } from '@jupyterlite/apputils';
32
+
33
+ /**
34
+ * The command IDs used by the apputils extension.
35
+ */
36
+ namespace CommandIDs {
37
+ /**
38
+ * The command ID for opening the plugin manager.
39
+ */
40
+ export const openPluginManager = 'apputils:open-plugin-manager';
41
+ }
42
+
43
+ /**
44
+ * The client for fetching licenses data.
45
+ */
46
+ const licensesClient: JupyterFrontEndPlugin<ILicensesClient> = {
47
+ id: '@jupyterlite/application-extension:licenses-client',
48
+ autoStart: true,
49
+ provides: ILicensesClient,
50
+ activate: (app: JupyterFrontEnd): ILicensesClient => {
51
+ return new LiteLicensesClient();
52
+ },
53
+ };
54
+
55
+ /**
56
+ * A plugin for managing the status of other plugins.
57
+ */
58
+ export const pluginManagerPlugin: JupyterFrontEndPlugin<IPluginManager> = {
59
+ id: '@jupyterlite/application-extension:plugin-manager',
60
+ description: 'Plugin manager viewer',
61
+ autoStart: true,
62
+ optional: [JupyterLab.IInfo, ITranslator, ICommandPalette],
63
+ provides: IPluginManager,
64
+ activate: (
65
+ app: JupyterFrontEnd,
66
+ info: JupyterLab.IInfo | null,
67
+ translator: ITranslator | null,
68
+ palette: ICommandPalette | null,
69
+ ): IPluginManager => {
70
+ const availablePlugins = info?.availablePlugins ?? [];
71
+
72
+ if (availablePlugins.length === 0) {
73
+ return {
74
+ open: async () => {
75
+ // eslint-disable-next-line no-console
76
+ console.info('The application does not contain information about plugins');
77
+ },
78
+ };
79
+ }
80
+
81
+ const { commands, serviceManager, shell } = app;
82
+
83
+ translator = translator ?? nullTranslator;
84
+ const trans = translator.load('jupyterlab');
85
+
86
+ const category = trans.__('Plugin Manager');
87
+ const widgetLabel = trans.__('Advanced Plugin Manager');
88
+
89
+ const namespace = 'plugin-manager';
90
+ const tracker = new WidgetTracker<MainAreaWidget<Plugins>>({
91
+ namespace: namespace,
92
+ });
93
+
94
+ function createWidget(args?: PluginListModel.IConfigurableState) {
95
+ const model = new LitePluginListModel({
96
+ ...args,
97
+ pluginData: {
98
+ availablePlugins,
99
+ },
100
+ serverSettings: serviceManager.serverSettings,
101
+ extraLockedPlugins: [pluginManagerPlugin.id],
102
+ translator: translator ?? nullTranslator,
103
+ });
104
+ const content = new Plugins({
105
+ model,
106
+ translator: translator ?? nullTranslator,
107
+ });
108
+ content.title.label = widgetLabel;
109
+ content.title.icon = extensionIcon;
110
+ content.title.caption = trans.__('Plugin Manager');
111
+ const main = new MainAreaWidget({ content, reveal: model.ready });
112
+ return main;
113
+ }
114
+
115
+ commands.addCommand(CommandIDs.openPluginManager, {
116
+ label: widgetLabel,
117
+ execute: (args) => {
118
+ const main = createWidget(args);
119
+ shell.add(main, 'main', { type: 'Plugins' });
120
+
121
+ // add to tracker so it can be restored, and update when choices change
122
+ void tracker.add(main);
123
+ main.content.model.trackerDataChanged.connect(() => {
124
+ void tracker.save(main);
125
+ });
126
+ return main;
127
+ },
128
+ });
129
+
130
+ if (palette) {
131
+ palette.addItem({ command: CommandIDs.openPluginManager, category });
132
+ }
133
+
134
+ return {
135
+ open: () => {
136
+ return app.commands.execute(CommandIDs.openPluginManager);
137
+ },
138
+ };
139
+ },
140
+ };
141
+
142
+ /**
143
+ * The main translator connector plugin.
144
+ */
145
+ const translatorConnector: JupyterFrontEndPlugin<ITranslatorConnector> = {
146
+ id: '@jupyterlite/application-extension:translator-connector',
147
+ description: 'Provides the application translation connector.',
148
+ autoStart: true,
149
+ provides: ITranslatorConnector,
150
+ activate: (app: JupyterFrontEnd) => {
151
+ return new LiteTranslatorConnector();
152
+ },
153
+ };
154
+
155
+ const plugins: JupyterFrontEndPlugin<any>[] = [
156
+ licensesClient,
157
+ pluginManagerPlugin,
158
+ translatorConnector,
159
+ ];
160
+
161
+ export default plugins;
package/style/base.css ADDED
@@ -0,0 +1,4 @@
1
+ /*-----------------------------------------------------------------------------
2
+ | Copyright (c) Jupyter Development Team.
3
+ | Distributed under the terms of the Modified BSD License.
4
+ |----------------------------------------------------------------------------*/
@@ -0,0 +1,6 @@
1
+ /*-----------------------------------------------------------------------------
2
+ | Copyright (c) Jupyter Development Team.
3
+ | Distributed under the terms of the Modified BSD License.
4
+ |----------------------------------------------------------------------------*/
5
+
6
+ @import url('./base.css');
package/style/index.js ADDED
@@ -0,0 +1,6 @@
1
+ /*-----------------------------------------------------------------------------
2
+ | Copyright (c) Jupyter Development Team.
3
+ | Distributed under the terms of the Modified BSD License.
4
+ |----------------------------------------------------------------------------*/
5
+
6
+ import './base.css';