Skip to content

Commit b8349f2

Browse files
The great summer package update (gitpod-io#20)
1 parent 89393d6 commit b8349f2

File tree

9 files changed

+1132
-579
lines changed

9 files changed

+1132
-579
lines changed

.gitpod.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
FROM gitpod/workspace-node
2-
RUN bash -c 'VERSION="16.19.0" \
2+
RUN bash -c 'VERSION="20.15.1" \
33
&& source $HOME/.nvm/nvm.sh && nvm install $VERSION \
44
&& nvm use $VERSION && nvm alias default $VERSION'
55

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v16.19.0
1+
v20.15.1

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Licensed under the GNU Affero General Public License (AGPL).
33
# See License-AGPL.txt in the project root for license information.
44

5-
FROM node:16 as ide_installer
5+
FROM node:20 as ide_installer
66

77
ARG XTERM_COMMIT
88

package.json

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"preview": "vite preview",
1010
"start": "yarn package && node dist/index.cjs",
1111
"package:client": "rimraf out/ && yarn build && mkdir -p out/ && cp -r index.html dist/ assets/ out/",
12-
"package:server": "ncc build -m server.cjs -o dist/",
12+
"package:server": "ncc build -m server.cjs -o dist/ --target es2022 --source-map",
1313
"inject-commit": "git rev-parse HEAD > dist/commit.txt",
1414
"package": "yarn build && yarn package:server && yarn inject-commit"
1515
},
@@ -28,36 +28,39 @@
2828
"homepage": "https://github.com/gitpod-io/xterm-web-ide#readme",
2929
"dependencies": {
3030
"@gitpod/gitpod-protocol": "^0.1.5-main.6983",
31+
"@xterm/addon-attach": "^0.11.0",
32+
"@xterm/addon-canvas": "^0.7.0",
33+
"@xterm/addon-fit": "^0.10.0",
34+
"@xterm/addon-ligatures": "^0.9.0",
35+
"@xterm/addon-unicode11": "^0.8.0",
36+
"@xterm/addon-web-links": "^0.11.0",
37+
"@xterm/addon-webgl": "^0.18.0",
38+
"@xterm/xterm": "^5.5.0",
3139
"buffer": "^6.0.3",
32-
"express-rate-limit": "^6.7.0",
40+
"express-rate-limit": "^7.3.1",
3341
"fetch-retry": "^5.0.3",
34-
"node": "16",
35-
"reconnecting-websocket": "^4.4.0",
36-
"xterm": "^5.1.0",
37-
"xterm-addon-attach": "^0.8.0",
38-
"xterm-addon-canvas": "^0.4.0-beta.7",
39-
"xterm-addon-fit": "^0.7.0",
40-
"xterm-addon-web-links": "^0.8.0",
41-
"xterm-addon-webgl": "^0.15.0-beta.7"
42+
"lodash": "^4.17.21",
43+
"node": "20",
44+
"reconnecting-websocket": "^4.4.0"
4245
},
4346
"devDependencies": {
44-
"@open-wc/building-rollup": "^2.2.1",
45-
"@rollup/plugin-commonjs": "^24.0.1",
46-
"@rollup/plugin-terser": "^0.4.0",
47-
"@rollup/plugin-typescript": "^11.0.0",
48-
"@vercel/ncc": "^0.36.1",
47+
"@open-wc/building-rollup": "^3.0.2",
48+
"@rollup/plugin-commonjs": "^26.0.1",
49+
"@rollup/plugin-terser": "^0.4.4",
50+
"@rollup/plugin-typescript": "^11.1.6",
51+
"@types/lodash": "^4.17.7",
52+
"@types/node": "^20.14.11",
53+
"@vercel/ncc": "^0.38.1",
4954
"deepmerge": "^4.3.0",
50-
"express": "^4.18.2",
55+
"express": "^4.19.2",
5156
"express-ws": "^5.0.2",
52-
"node-pty": "^0.10.1",
57+
"node-pty": "^1.0.0",
5358
"rimraf": "^4.1.2",
54-
"rollup": "^3.15.0",
59+
"rollup": "^4.19.0",
5560
"rollup-plugin-node-polyfills": "^0.2.1",
56-
"rollup-plugin-polyfill-node": "^0.12.0",
61+
"rollup-plugin-polyfill-node": "^0.13.0",
5762
"sass": "^1.58.3",
58-
"typescript": "^4.9.5",
59-
"vite": "^4.5.3",
60-
"xterm-addon-ligatures": "^0.6.0",
61-
"xterm-addon-unicode11": "^0.5.0"
63+
"typescript": "^5.5.3",
64+
"vite": "^5.3.4"
6265
}
6366
}

server.cjs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const config = {
2020

2121
const rateLimiter = rateLimit({
2222
windowMs: 60 * 1000,
23-
max: 50,
23+
limit: 50,
2424
message: "Too many requests from this IP, please try again after 1 minute",
2525
standardHeaders: true,
2626
legacyHeaders: false,
@@ -107,7 +107,6 @@ function startServer() {
107107
});
108108

109109
app.post('/terminals/:pid/size', rateLimiter, (req, res) => {
110-
111110
if (!req.query.cols || !req.query.rows) {
112111
res.statusCode = 400;
113112
res.send('`cols` and `rows` are required');

src/client.ts

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,19 @@ import type { IDEFrontendState } from '@gitpod/gitpod-protocol/lib/ide-frontend-
44

55
import type ReconnectingWebSocket from "reconnecting-websocket";
66
import fetchBuilder from "fetch-retry";
7-
import type { Terminal, ITerminalOptions, ITerminalAddon } from "xterm";
7+
import type { Terminal, ITerminalOptions, ITerminalAddon } from "@xterm/xterm";
88

9-
import { AttachAddon } from "xterm-addon-attach";
10-
import { FitAddon } from "xterm-addon-fit";
9+
import { AttachAddon } from "@xterm/addon-attach";
10+
import { FitAddon } from "@xterm/addon-fit";
1111

1212
import { resizeRemoteTerminal } from "./lib/remote";
1313
import { IXtermWindow } from "./lib/types";
1414
import { webLinksHandler } from "./lib/addons";
1515
import { initiateRemoteCommunicationChannelSocket } from "./lib/remote";
1616
import { Emitter } from '@gitpod/gitpod-protocol/lib/util/event';
1717
import { DisposableCollection } from '@gitpod/gitpod-protocol/lib/util/disposable';
18-
import { debounce, isWindows } from './lib/helpers';
18+
import { isWindows } from './lib/helpers';
19+
import debounce from "lodash/debounce"
1920

2021
const onDidChangeState = new Emitter<void>();
2122
let state: IDEFrontendState = "initializing" as IDEFrontendState;
@@ -24,11 +25,11 @@ const maxReconnectionRetries = 50;
2425

2526
const fetchOptions = {
2627
retries: maxReconnectionRetries,
27-
retryDelay: (attempt: number, _error: Error, _response: Response) => {
28+
retryDelay: (attempt: number, _error: Error | null, _response: Response | null) => {
2829
return Math.pow(1.25, attempt) * 200;
2930
},
30-
retryOn: (attempt: number, error: Error, response: Response) => {
31-
if (error !== null || response.status >= 400) {
31+
retryOn: (attempt: number, error: Error | null, response: Response | null) => {
32+
if (error !== null || (response?.status ?? 0) >= 400) {
3233
console.log(`retrying, attempt number ${attempt + 1}, ${(Math.pow(1.25, attempt) * 300) / 1000}`);
3334
return true;
3435
} else {
@@ -59,17 +60,17 @@ export const webSocketSettings: ReconnectingWebSocket['_options'] = {
5960
const extraTerminalAddons: { [key: string]: ITerminalAddon } = {};
6061

6162
(async () => {
62-
extraTerminalAddons['ligatures'] = new (await import("xterm-addon-ligatures")).LigaturesAddon();
63-
extraTerminalAddons['unicode'] = new (await import("xterm-addon-unicode11")).Unicode11Addon();
64-
extraTerminalAddons['webLinks'] = new (await import("xterm-addon-web-links")).WebLinksAddon(webLinksHandler);
63+
extraTerminalAddons['ligatures'] = new (await import("@xterm/addon-ligatures")).LigaturesAddon();
64+
extraTerminalAddons['unicode'] = new (await import("@xterm/addon-unicode11")).Unicode11Addon();
65+
extraTerminalAddons['webLinks'] = new (await import("@xterm/addon-web-links")).WebLinksAddon(webLinksHandler);
6566
})()
6667

6768
async function initAddons(term: Terminal): Promise<void> {
6869
for (const addon of Object.values(extraTerminalAddons)) {
6970
term.loadAddon(addon);
7071
}
7172

72-
const webglRenderer = new (await import("xterm-addon-webgl")).WebglAddon;
73+
const webglRenderer = new (await import("@xterm/addon-webgl")).WebglAddon;
7374
try {
7475
term.loadAddon(webglRenderer);
7576
console.debug("Loaded webgl renderer");
@@ -79,7 +80,7 @@ async function initAddons(term: Terminal): Promise<void> {
7980
} catch (e) {
8081
console.warn(`Webgl renderer could not be loaded. Falling back to the canvas renderer type.`, e);
8182
webglRenderer.dispose();
82-
const canvasRenderer = new (await import("xterm-addon-canvas")).CanvasAddon;
83+
const canvasRenderer = new (await import("@xterm/addon-canvas")).CanvasAddon;
8384
term.loadAddon(canvasRenderer);
8485
}
8586

@@ -133,7 +134,7 @@ async function createTerminal(element: HTMLElement, toDispose: DisposableCollect
133134
element.removeChild(element.children[0]);
134135
}
135136

136-
const { Terminal } = (await import("xterm"));
137+
const { Terminal } = (await import("@xterm/xterm"));
137138

138139
term = new Terminal({
139140
windowsMode: isWindows,
@@ -191,7 +192,7 @@ async function createTerminal(element: HTMLElement, toDispose: DisposableCollect
191192
throw new Error("Couldn't set up a remote connection to the terminal process");
192193
}
193194

194-
const debouncedUpdateTerminalSize = debounce(() => updateTerminalSize(term), 200, true);
195+
const debouncedUpdateTerminalSize = debounce(() => updateTerminalSize(term), 200, { trailing: true });
195196
window.onresize = () => debouncedUpdateTerminalSize();
196197

197198
return { terminal: term, socket: terminalSocket };

src/lib/helpers.ts

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,2 @@
1-
/**
2-
* Debounces a function by limiting the rate at which it is called.
3-
* The debounced function will be called immediately when first called,
4-
* and then at most once every `wait` milliseconds during subsequent calls.
5-
* If `trailing` is set to `true`, the function will also be called once
6-
* after the last event is triggered.
7-
*
8-
* @param {() => void} func - The function to be debounced.
9-
* @param {number} wait - The number of milliseconds to wait before allowing the function to be called again.
10-
* @param {boolean} trailing - Whether to call the function once after the last event is triggered.
11-
* @returns {() => void} - The debounced function.
12-
*/
13-
export const debounce = (func: () => void, wait: number, trailing: boolean): () => void => {
14-
let timeout: NodeJS.Timeout | null = null;
15-
16-
return () => {
17-
const later = () => {
18-
timeout = null;
19-
if (trailing) {
20-
func();
21-
}
22-
};
23-
24-
if (timeout === null) {
25-
func();
26-
} else {
27-
clearTimeout(timeout);
28-
}
29-
timeout = setTimeout(later, wait);
30-
};
31-
}
32-
331
export const isWindows =
342
["Windows", "Win16", "Win32", "WinCE"].includes(navigator.platform);

src/lib/types.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { AttachAddon } from 'xterm-addon-attach';
2-
import { FitAddon } from 'xterm-addon-fit';
3-
import { WebLinksAddon } from 'xterm-addon-web-links';
4-
import { WebglAddon } from 'xterm-addon-webgl';
5-
import { Unicode11Addon } from 'xterm-addon-unicode11';
6-
import { LigaturesAddon } from 'xterm-addon-ligatures';
7-
import { Terminal } from 'xterm';
1+
import { AttachAddon } from '@xterm/addon-attach';
2+
import { FitAddon } from '@xterm/addon-fit';
3+
import { WebLinksAddon } from '@xterm/addon-web-links';
4+
import { WebglAddon } from '@xterm/addon-webgl';
5+
import { Unicode11Addon } from '@xterm/addon-unicode11';
6+
import { LigaturesAddon } from '@xterm/addon-ligatures';
7+
import { Terminal } from '@xterm/xterm';
88
import ReconnectingWebSocket from 'reconnecting-websocket';
99

1010
export type AddonType = "attach" | "fit" | "unicode11" | "web-links" | "webgl" | "ligatures";

0 commit comments

Comments
 (0)