Skip to content

Commit

Permalink
Added @xterm/addon-web-links to the terminal (#2027)
Browse files Browse the repository at this point in the history
* Added @xterm/addon-web-links to the terminal

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
WebReflection and pre-commit-ci[bot] committed Apr 12, 2024
1 parent 44cd627 commit c653296
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 8 deletions.
14 changes: 12 additions & 2 deletions pyscript.core/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pyscript.core/package.json
@@ -1,6 +1,6 @@
{
"name": "@pyscript/core",
"version": "0.4.20",
"version": "0.4.21",
"type": "module",
"description": "PyScript",
"module": "./index.js",
Expand Down Expand Up @@ -59,6 +59,7 @@
"@rollup/plugin-terser": "^0.4.4",
"@webreflection/toml-j0.4": "^1.1.3",
"@xterm/addon-fit": "^0.10.0",
"@xterm/addon-web-links": "^0.11.0",
"chokidar": "^3.6.0",
"codemirror": "^6.0.1",
"eslint": "^9.0.0",
Expand Down
3 changes: 3 additions & 0 deletions pyscript.core/rollup/3rd-party.cjs
Expand Up @@ -51,6 +51,9 @@ const modules = {
"xterm_addon-fit.js": fetch(`${CDN}/@xterm/addon-fit/+esm`).then((b) =>
b.text(),
),
"xterm_addon-web-links.js": fetch(
`${CDN}/@xterm/addon-web-links/+esm`,
).then((b) => b.text()),
"xterm.css": fetch(`${CDN}/xterm@${v("xterm")}/css/xterm.min.css`).then(
(b) => b.text(),
),
Expand Down
15 changes: 10 additions & 5 deletions pyscript.core/src/plugins/py-terminal.js
Expand Up @@ -134,11 +134,15 @@ const workerReady = ({ interpreter, io, run, type }, { sync }) => {

const pyTerminal = async (element) => {
// lazy load these only when a valid terminal is found
const [{ Terminal }, { Readline }, { FitAddon }] = await Promise.all([
import(/* webpackIgnore: true */ "../3rd-party/xterm.js"),
import(/* webpackIgnore: true */ "../3rd-party/xterm-readline.js"),
import(/* webpackIgnore: true */ "../3rd-party/xterm_addon-fit.js"),
]);
const [{ Terminal }, { Readline }, { FitAddon }, { WebLinksAddon }] =
await Promise.all([
import(/* webpackIgnore: true */ "../3rd-party/xterm.js"),
import(/* webpackIgnore: true */ "../3rd-party/xterm-readline.js"),
import(/* webpackIgnore: true */ "../3rd-party/xterm_addon-fit.js"),
import(
/* webpackIgnore: true */ "../3rd-party/xterm_addon-web-links.js"
),
]);

const readline = new Readline();

Expand Down Expand Up @@ -167,6 +171,7 @@ const pyTerminal = async (element) => {
const fitAddon = new FitAddon();
terminal.loadAddon(fitAddon);
terminal.loadAddon(readline);
terminal.loadAddon(new WebLinksAddon());
terminal.open(target);
fitAddon.fit();
terminal.focus();
Expand Down
4 changes: 4 additions & 0 deletions pyscript.core/types/3rd-party/xterm_addon-web-links.d.ts
@@ -0,0 +1,4 @@
declare var r: any;
declare var n: any;
declare var t: {};
export { r as WebLinksAddon, n as __esModule, t as default };

0 comments on commit c653296

Please sign in to comment.