Skip to content

Commit 3d4dcf9

Browse files
committed
feat: upgrade xterm to @xterm/* scoped packages v6
Migrate from deprecated xterm v5.3 packages to the new @xterm/* scoped packages (v6.0.0). Replace CanvasAddon with WebglAddon as the canvas renderer was removed in v6. Move terminal styles from extension dir to src/styles/Extn-Terminal.less to bake into core CSS.
1 parent 384510d commit 3d4dcf9

7 files changed

Lines changed: 113 additions & 136 deletions

File tree

gulpfile.js/thirdparty-lib-copy.js

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -245,31 +245,27 @@ let copyThirdPartyLibs = series(
245245
copyLicence.bind(copyLicence, 'node_modules/jasmine-reporters/LICENSE', 'jasmine-reporters'),
246246
// lmdb
247247
copyLicence.bind(copyLicence, 'node_modules/lmdb/LICENSE', 'lmdb'),
248-
// xterm.js terminal emulator
249-
copyFiles.bind(copyFiles, ['node_modules/xterm/lib/xterm.js',
250-
'node_modules/xterm/lib/xterm.js.map'], 'src/thirdparty/xterm'),
251-
copyFiles.bind(copyFiles, ['node_modules/xterm/css/xterm.css'], 'src/thirdparty/xterm'),
252-
renameFile.bind(renameFile, 'node_modules/xterm-addon-fit/lib/xterm-addon-fit.js',
248+
// xterm.js terminal emulator (@xterm/* scoped packages, v6)
249+
copyFiles.bind(copyFiles, ['node_modules/@xterm/xterm/lib/xterm.js',
250+
'node_modules/@xterm/xterm/lib/xterm.js.map'], 'src/thirdparty/xterm'),
251+
copyFiles.bind(copyFiles, ['node_modules/@xterm/xterm/css/xterm.css'], 'src/thirdparty/xterm'),
252+
renameFile.bind(renameFile, 'node_modules/@xterm/addon-fit/lib/addon-fit.js',
253253
'addon-fit.js', 'src/thirdparty/xterm'),
254-
renameFile.bind(renameFile, 'node_modules/xterm-addon-fit/lib/xterm-addon-fit.js.map',
254+
renameFile.bind(renameFile, 'node_modules/@xterm/addon-fit/lib/addon-fit.js.map',
255255
'addon-fit.js.map', 'src/thirdparty/xterm'),
256-
renameFile.bind(renameFile, 'node_modules/xterm-addon-canvas/lib/xterm-addon-canvas.js',
257-
'addon-canvas.js', 'src/thirdparty/xterm'),
258-
renameFile.bind(renameFile, 'node_modules/xterm-addon-canvas/lib/xterm-addon-canvas.js.map',
259-
'addon-canvas.js.map', 'src/thirdparty/xterm'),
260-
renameFile.bind(renameFile, 'node_modules/xterm-addon-search/lib/xterm-addon-search.js',
256+
renameFile.bind(renameFile, 'node_modules/@xterm/addon-search/lib/addon-search.js',
261257
'addon-search.js', 'src/thirdparty/xterm'),
262-
renameFile.bind(renameFile, 'node_modules/xterm-addon-search/lib/xterm-addon-search.js.map',
258+
renameFile.bind(renameFile, 'node_modules/@xterm/addon-search/lib/addon-search.js.map',
263259
'addon-search.js.map', 'src/thirdparty/xterm'),
264-
renameFile.bind(renameFile, 'node_modules/xterm-addon-web-links/lib/xterm-addon-web-links.js',
260+
renameFile.bind(renameFile, 'node_modules/@xterm/addon-web-links/lib/addon-web-links.js',
265261
'addon-web-links.js', 'src/thirdparty/xterm'),
266-
renameFile.bind(renameFile, 'node_modules/xterm-addon-web-links/lib/xterm-addon-web-links.js.map',
262+
renameFile.bind(renameFile, 'node_modules/@xterm/addon-web-links/lib/addon-web-links.js.map',
267263
'addon-web-links.js.map', 'src/thirdparty/xterm'),
268-
renameFile.bind(renameFile, 'node_modules/xterm-addon-webgl/lib/xterm-addon-webgl.js',
264+
renameFile.bind(renameFile, 'node_modules/@xterm/addon-webgl/lib/addon-webgl.js',
269265
'addon-webgl.js', 'src/thirdparty/xterm'),
270-
renameFile.bind(renameFile, 'node_modules/xterm-addon-webgl/lib/xterm-addon-webgl.js.map',
266+
renameFile.bind(renameFile, 'node_modules/@xterm/addon-webgl/lib/addon-webgl.js.map',
271267
'addon-webgl.js.map', 'src/thirdparty/xterm'),
272-
copyLicence.bind(copyLicence, 'node_modules/xterm/LICENSE', 'xterm')
268+
copyLicence.bind(copyLicence, 'node_modules/@xterm/xterm/LICENSE', 'xterm')
273269

274270
);
275271

package-lock.json

Lines changed: 64 additions & 101 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,10 @@
122122
"tern": "^0.24.3",
123123
"tinycolor2": "^1.4.2",
124124
"underscore": "^1.13.4",
125-
"xterm": "^5.3.0",
126-
"xterm-addon-canvas": "^0.5.0",
127-
"xterm-addon-fit": "^0.8.0",
128-
"xterm-addon-search": "^0.13.0",
129-
"xterm-addon-web-links": "^0.9.0",
130-
"xterm-addon-webgl": "^0.16.0"
125+
"@xterm/xterm": "^6.0.0",
126+
"@xterm/addon-fit": "^0.11.0",
127+
"@xterm/addon-search": "^0.16.0",
128+
"@xterm/addon-web-links": "^0.12.0",
129+
"@xterm/addon-webgl": "^0.19.0"
131130
}
132131
}

src/extensionsIntegrated/Terminal/TerminalInstance.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,21 @@
2424
*/
2525
define(function (require, exports, module) {
2626

27-
const KeyBindingManager = brackets.getModule("command/KeyBindingManager");
28-
const CommandManager = brackets.getModule("command/CommandManager");
27+
const KeyBindingManager = require("command/KeyBindingManager");
28+
const CommandManager = require("command/CommandManager");
2929

3030
// xterm.js and addons (loaded as AMD modules from thirdparty)
3131
const xtermModule = require("thirdparty/xterm/xterm");
3232
const FitAddonModule = require("thirdparty/xterm/addon-fit");
3333
const WebLinksAddonModule = require("thirdparty/xterm/addon-web-links");
3434
const SearchAddonModule = require("thirdparty/xterm/addon-search");
35-
const CanvasAddonModule = require("thirdparty/xterm/addon-canvas");
35+
const WebglAddonModule = require("thirdparty/xterm/addon-webgl");
3636

3737
const Terminal = xtermModule.Terminal;
3838
const FitAddon = FitAddonModule.FitAddon;
3939
const WebLinksAddon = WebLinksAddonModule.WebLinksAddon;
4040
const SearchAddon = SearchAddonModule.SearchAddon;
41-
const CanvasAddon = CanvasAddonModule.CanvasAddon;
41+
const WebglAddon = WebglAddonModule.WebglAddon;
4242

4343
let _nextId = 0;
4444

@@ -146,11 +146,11 @@ define(function (require, exports, module) {
146146
// Open terminal in DOM
147147
this.terminal.open(this.$container[0]);
148148

149-
// Load canvas renderer for better performance
149+
// Load WebGL renderer for better performance
150150
try {
151-
this.terminal.loadAddon(new CanvasAddon());
151+
this.terminal.loadAddon(new WebglAddon());
152152
} catch (e) {
153-
console.warn("Terminal: CanvasAddon failed to load, using default renderer:", e);
153+
console.warn("Terminal: WebglAddon failed to load, using default renderer:", e);
154154
}
155155

156156
// Fit to container

src/extensionsIntegrated/Terminal/main.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,15 @@ define(function (require, exports, module) {
3434
const WorkspaceManager = require("view/WorkspaceManager");
3535
const ProjectManager = require("project/ProjectManager");
3636
const ExtensionUtils = require("utils/ExtensionUtils");
37-
const NodeConnector = brackets.getModule("NodeConnector");
37+
const NodeConnector = require("NodeConnector");
3838
const Mustache = require("thirdparty/mustache/mustache");
3939
const Strings = require("strings");
4040

4141
const TerminalInstance = require("./TerminalInstance");
4242
const ShellProfiles = require("./ShellProfiles");
4343
const panelHTML = require("text!./terminal-panel.html");
4444

45-
// Load CSS
46-
ExtensionUtils.loadStyleSheet(module, "terminal.css");
47-
48-
// Load xterm.css
45+
// Load xterm.css (terminal panel styles are in src/styles/Extn-Terminal.less)
4946
ExtensionUtils.loadStyleSheet(module, "../../thirdparty/xterm/xterm.css");
5047

5148
// Constants

src/extensionsIntegrated/Terminal/terminal.css renamed to src/styles/Extn-Terminal.less

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
/*
2+
* GNU AGPL-3.0 License
3+
*
4+
* Copyright (c) 2021 - present core.ai . All rights reserved.
5+
*
6+
* This program is free software: you can redistribute it and/or modify it
7+
* under the terms of the GNU Affero General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful, but WITHOUT
12+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License
14+
* for more details.
15+
*
16+
* You should have received a copy of the GNU Affero General Public License
17+
* along with this program. If not, see https://opensource.org/licenses/AGPL-3.0.
18+
*
19+
*/
20+
121
/* Terminal Extension Styles */
222

323
/* Dark theme (default) */
@@ -264,6 +284,7 @@
264284

265285
.terminal-instance-container .xterm-viewport {
266286
overflow-y: auto;
287+
background-color: var(--terminal-background) !important;
267288
}
268289

269290
/* Toolbar icon in right sidebar */

src/styles/brackets.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
@import "Extn-SidebarTabs.less";
5050
@import "Extn-BottomPanelTabs.less";
5151
@import "Extn-AIChatPanel.less";
52+
@import "Extn-Terminal.less";
5253
@import "UserProfile.less";
5354
@import "phoenix-pro.less";
5455

0 commit comments

Comments
 (0)