@jupyter-notebook/terminal-extension 7.0.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.d.ts +6 -0
- package/lib/index.js +64 -0
- package/package.json +58 -0
- package/style/base.css +0 -0
- package/style/index.css +1 -0
- package/style/index.js +1 -0
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// Copyright (c) Jupyter Development Team.
|
|
2
|
+
// Distributed under the terms of the Modified BSD License.
|
|
3
|
+
import { IRouter } from '@jupyterlab/application';
|
|
4
|
+
import { PageConfig } from '@jupyterlab/coreutils';
|
|
5
|
+
import { ITerminalTracker } from '@jupyterlab/terminal';
|
|
6
|
+
import { find } from '@lumino/algorithm';
|
|
7
|
+
/**
|
|
8
|
+
* A plugin to open terminals in a new tab
|
|
9
|
+
*/
|
|
10
|
+
const opener = {
|
|
11
|
+
id: '@jupyter-notebook/terminal-extension:opener',
|
|
12
|
+
requires: [IRouter, ITerminalTracker],
|
|
13
|
+
autoStart: true,
|
|
14
|
+
activate: (app, router, tracker) => {
|
|
15
|
+
const { commands } = app;
|
|
16
|
+
const terminalPattern = new RegExp('/terminals/(.*)');
|
|
17
|
+
const command = 'router:terminal';
|
|
18
|
+
commands.addCommand(command, {
|
|
19
|
+
execute: (args) => {
|
|
20
|
+
const parsed = args;
|
|
21
|
+
const matches = parsed.path.match(terminalPattern);
|
|
22
|
+
if (!matches) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const [, name] = matches;
|
|
26
|
+
if (!name) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
tracker.widgetAdded.connect((send, terminal) => {
|
|
30
|
+
terminal.content.setOption('closeOnExit', false);
|
|
31
|
+
});
|
|
32
|
+
commands.execute('terminal:open', { name });
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
router.register({ command, pattern: terminalPattern });
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Open terminals in a new tab.
|
|
40
|
+
*/
|
|
41
|
+
const redirect = {
|
|
42
|
+
id: '@jupyter-notebook/terminal-extension:redirect',
|
|
43
|
+
requires: [ITerminalTracker],
|
|
44
|
+
autoStart: true,
|
|
45
|
+
activate: (app, tracker) => {
|
|
46
|
+
const baseUrl = PageConfig.getBaseUrl();
|
|
47
|
+
tracker.widgetAdded.connect((send, terminal) => {
|
|
48
|
+
const widget = find(app.shell.widgets('main'), w => w.id === terminal.id);
|
|
49
|
+
if (widget) {
|
|
50
|
+
// bail if the terminal is already added to the main area
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const name = terminal.content.session.name;
|
|
54
|
+
window.open(`${baseUrl}terminals/${name}`, '_blank');
|
|
55
|
+
// dispose the widget since it is not used on this page
|
|
56
|
+
terminal.dispose();
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Export the plugins as default.
|
|
62
|
+
*/
|
|
63
|
+
const plugins = [opener, redirect];
|
|
64
|
+
export default plugins;
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@jupyter-notebook/terminal-extension",
|
|
3
|
+
"version": "7.0.0-alpha.1",
|
|
4
|
+
"description": "Jupyter Notebook - Terminal Extension",
|
|
5
|
+
"homepage": "https://github.com/jupyter/notebook",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/jupyter/notebook/issues"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/jupyter/notebook.git"
|
|
12
|
+
},
|
|
13
|
+
"license": "BSD-3-Clause",
|
|
14
|
+
"author": "Project Jupyter",
|
|
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
|
+
"schema/*.json",
|
|
30
|
+
"style/**/*.css",
|
|
31
|
+
"style/index.js"
|
|
32
|
+
],
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "tsc -b",
|
|
35
|
+
"build:prod": "tsc -b",
|
|
36
|
+
"clean": "rimraf lib && rimraf tsconfig.tsbuildinfo",
|
|
37
|
+
"docs": "typedoc src",
|
|
38
|
+
"prepublishOnly": "npm run build",
|
|
39
|
+
"watch": "tsc -b --watch"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@jupyterlab/application": "^4.0.0-alpha.5",
|
|
43
|
+
"@jupyterlab/coreutils": "^6.0.0-alpha.5",
|
|
44
|
+
"@jupyterlab/terminal": "^4.0.0-alpha.5",
|
|
45
|
+
"@lumino/algorithm": "^1.9.1"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"rimraf": "~3.0.0",
|
|
49
|
+
"typescript": "~4.1.3"
|
|
50
|
+
},
|
|
51
|
+
"publishConfig": {
|
|
52
|
+
"access": "public"
|
|
53
|
+
},
|
|
54
|
+
"jupyterlab": {
|
|
55
|
+
"extension": true
|
|
56
|
+
},
|
|
57
|
+
"styleModule": "style/index.js"
|
|
58
|
+
}
|
package/style/base.css
ADDED
|
File without changes
|
package/style/index.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import url('./base.css');
|
package/style/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './base.css';
|