@jupyterlab/terminal 4.0.0-alpha.9 → 4.0.0-beta.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/tokens.d.ts CHANGED
@@ -33,6 +33,18 @@ export declare namespace ITerminal {
33
33
  * Refresh the terminal session.
34
34
  */
35
35
  refresh(): Promise<void>;
36
+ /**
37
+ * Check if terminal has any text selected.
38
+ */
39
+ hasSelection(): boolean;
40
+ /**
41
+ * Paste text into terminal.
42
+ */
43
+ paste(data: string): void;
44
+ /**
45
+ * Get selected text from terminal.
46
+ */
47
+ getSelection(): string | null;
36
48
  }
37
49
  /**
38
50
  * Options for the terminal widget.
@@ -110,6 +122,7 @@ export declare namespace ITerminal {
110
122
  background: string;
111
123
  cursor: string;
112
124
  cursorAccent: string;
113
- selection: string;
125
+ selectionBackground: string;
126
+ selectionInactiveBackground: string;
114
127
  }
115
128
  }
package/lib/tokens.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"tokens.js","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAI3D,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAS1C;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,KAAK,CACvC,uCAAuC,CACxC,CAAC;AAEF;;;GAGG;AACH,MAAM,KAAW,SAAS,CAiIzB;AAjID,WAAiB,SAAS;IA+FxB;;OAEG;IACU,wBAAc,GAAa;QACtC,KAAK,EAAE,SAAS;QAChB,UAAU,EAAE,gDAAgD;QAC5D,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,GAAG;QACf,UAAU,EAAE,IAAI;QAChB,eAAe,EAAE,KAAK;QACtB,WAAW,EAAE,IAAI;QACjB,WAAW,EAAE,IAAI;QACjB,cAAc,EAAE,EAAE;QAClB,gBAAgB,EAAE,KAAK;QACvB,cAAc,EAAE,IAAI;QACpB,OAAO,EAAE,IAAI;QACb,eAAe,EAAE,KAAK;KACvB,CAAC;AAiBJ,CAAC,EAjIgB,SAAS,KAAT,SAAS,QAiIzB"}
1
+ {"version":3,"file":"tokens.js","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAI3D,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAS1C;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,KAAK,CACvC,uCAAuC,CACxC,CAAC;AAEF;;;GAGG;AACH,MAAM,KAAW,SAAS,CAiJzB;AAjJD,WAAiB,SAAS;IA8GxB;;OAEG;IACU,wBAAc,GAAa;QACtC,KAAK,EAAE,SAAS;QAChB,UAAU,EAAE,gDAAgD;QAC5D,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,GAAG;QACf,UAAU,EAAE,IAAI;QAChB,eAAe,EAAE,KAAK;QACtB,WAAW,EAAE,IAAI;QACjB,WAAW,EAAE,IAAI;QACjB,cAAc,EAAE,EAAE;QAClB,gBAAgB,EAAE,KAAK;QACvB,cAAc,EAAE,IAAI;QACpB,OAAO,EAAE,IAAI;QACb,eAAe,EAAE,KAAK;KACvB,CAAC;AAkBJ,CAAC,EAjJgB,SAAS,KAAT,SAAS,QAiJzB"}
package/lib/widget.d.ts CHANGED
@@ -17,8 +17,10 @@ export declare class Terminal extends Widget implements ITerminal.ITerminal {
17
17
  * @param translator - The language translator.
18
18
  */
19
19
  constructor(session: TerminalNS.ITerminalConnection, options?: Partial<ITerminal.IOptions>, translator?: ITranslator);
20
- private _setThemeAttribute;
21
- private _initialConnection;
20
+ /**
21
+ * A promise that is fulfilled when the terminal is ready.
22
+ */
23
+ get ready(): Promise<void>;
22
24
  /**
23
25
  * The terminal session associated with the widget.
24
26
  */
@@ -42,6 +44,18 @@ export declare class Terminal extends Widget implements ITerminal.ITerminal {
42
44
  * Failure to reconnect to the session should be caught appropriately
43
45
  */
44
46
  refresh(): Promise<void>;
47
+ /**
48
+ * Check if terminal has any text selected.
49
+ */
50
+ hasSelection(): boolean;
51
+ /**
52
+ * Paste text into terminal.
53
+ */
54
+ paste(data: string): void;
55
+ /**
56
+ * Get selected text from terminal.
57
+ */
58
+ getSelection(): string | null;
45
59
  /**
46
60
  * Process a message sent to the widget.
47
61
  *
@@ -75,6 +89,7 @@ export declare class Terminal extends Widget implements ITerminal.ITerminal {
75
89
  * Handle `'activate-request'` messages.
76
90
  */
77
91
  protected onActivateRequest(msg: Message): void;
92
+ private _initialConnection;
78
93
  /**
79
94
  * Initialize the terminal object.
80
95
  */
@@ -91,12 +106,15 @@ export declare class Terminal extends Widget implements ITerminal.ITerminal {
91
106
  * Set the size of the terminal in the session.
92
107
  */
93
108
  private _setSessionSize;
94
- private readonly _term;
95
- private readonly _fitAddon;
96
- private _trans;
109
+ private _setThemeAttribute;
110
+ private _fitAddon;
97
111
  private _needsResize;
98
- private _termOpened;
99
112
  private _offsetWidth;
100
113
  private _offsetHeight;
101
114
  private _options;
115
+ private _isReady;
116
+ private _ready;
117
+ private _term;
118
+ private _termOpened;
119
+ private _trans;
102
120
  }
package/lib/widget.js CHANGED
@@ -1,22 +1,10 @@
1
1
  // Copyright (c) Jupyter Development Team.
2
2
  // Distributed under the terms of the Modified BSD License.
3
- var __rest = (this && this.__rest) || function (s, e) {
4
- var t = {};
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
6
- t[p] = s[p];
7
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
8
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
9
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
10
- t[p[i]] = s[p[i]];
11
- }
12
- return t;
13
- };
14
3
  import { nullTranslator } from '@jupyterlab/translation';
4
+ import { PromiseDelegate } from '@lumino/coreutils';
15
5
  import { Platform } from '@lumino/domutils';
16
6
  import { MessageLoop } from '@lumino/messaging';
17
7
  import { Widget } from '@lumino/widgets';
18
- import { Terminal as Xterm } from 'xterm';
19
- import { FitAddon } from 'xterm-addon-fit';
20
8
  import { ITerminal } from '.';
21
9
  /**
22
10
  * The class name added to a terminal widget.
@@ -42,61 +30,75 @@ export class Terminal extends Widget {
42
30
  constructor(session, options = {}, translator) {
43
31
  super();
44
32
  this._needsResize = true;
45
- this._termOpened = false;
46
33
  this._offsetWidth = -1;
47
34
  this._offsetHeight = -1;
35
+ this._isReady = false;
36
+ this._ready = new PromiseDelegate();
37
+ this._termOpened = false;
48
38
  translator = translator || nullTranslator;
49
39
  this._trans = translator.load('jupyterlab');
50
40
  this.session = session;
51
41
  // Initialize settings.
52
- this._options = Object.assign(Object.assign({}, ITerminal.defaultOptions), options);
53
- const _a = this._options, { theme } = _a, other = __rest(_a, ["theme"]);
54
- const xtermOptions = Object.assign({ theme: Private.getXTermTheme(theme) }, other);
42
+ this._options = { ...ITerminal.defaultOptions, ...options };
43
+ const { theme, ...other } = this._options;
44
+ const xtermOptions = {
45
+ theme: Private.getXTermTheme(theme),
46
+ ...other
47
+ };
55
48
  this.addClass(TERMINAL_CLASS);
56
49
  this._setThemeAttribute(theme);
57
- // Create the xterm.
58
- this._term = new Xterm(xtermOptions);
59
- this._fitAddon = new FitAddon();
60
- this._term.loadAddon(this._fitAddon);
61
- this._initializeTerm();
62
- this.id = `jp-Terminal-${Private.id++}`;
63
- this.title.label = this._trans.__('Terminal');
64
- session.messageReceived.connect(this._onMessage, this);
50
+ // Buffer session message while waiting for the terminal
51
+ let buffer = '';
52
+ const bufferMessage = (sender, msg) => {
53
+ switch (msg.type) {
54
+ case 'stdout':
55
+ if (msg.content) {
56
+ buffer += msg.content[0];
57
+ }
58
+ break;
59
+ default:
60
+ break;
61
+ }
62
+ };
63
+ session.messageReceived.connect(bufferMessage);
65
64
  session.disposed.connect(() => {
66
65
  if (this.getOption('closeOnExit')) {
67
66
  this.dispose();
68
67
  }
69
68
  }, this);
70
- if (session.connectionStatus === 'connected') {
71
- this._initialConnection();
72
- }
73
- else {
74
- session.connectionStatusChanged.connect(this._initialConnection, this);
75
- }
76
- }
77
- _setThemeAttribute(theme) {
78
- if (this.isDisposed) {
79
- return;
80
- }
81
- this.node.setAttribute('data-term-theme', theme ? theme.toLowerCase() : 'inherit');
69
+ // Create the xterm.
70
+ Private.createTerminal(xtermOptions)
71
+ .then(([term, fitAddon]) => {
72
+ this._term = term;
73
+ this._fitAddon = fitAddon;
74
+ this._initializeTerm();
75
+ this.id = `jp-Terminal-${Private.id++}`;
76
+ this.title.label = this._trans.__('Terminal');
77
+ this._isReady = true;
78
+ this._ready.resolve();
79
+ if (buffer) {
80
+ this._term.write(buffer);
81
+ }
82
+ session.messageReceived.disconnect(bufferMessage);
83
+ session.messageReceived.connect(this._onMessage, this);
84
+ if (session.connectionStatus === 'connected') {
85
+ this._initialConnection();
86
+ }
87
+ else {
88
+ session.connectionStatusChanged.connect(this._initialConnection, this);
89
+ }
90
+ this.update();
91
+ })
92
+ .catch(reason => {
93
+ console.error('Failed to create a terminal.\n', reason);
94
+ this._ready.reject(reason);
95
+ });
82
96
  }
83
- _initialConnection() {
84
- if (this.isDisposed) {
85
- return;
86
- }
87
- if (this.session.connectionStatus !== 'connected') {
88
- return;
89
- }
90
- this.title.label = this._trans.__('Terminal %1', this.session.name);
91
- this._setSessionSize();
92
- if (this._options.initialCommand) {
93
- this.session.send({
94
- type: 'stdin',
95
- content: [this._options.initialCommand + '\r']
96
- });
97
- }
98
- // Only run this initial connection logic once.
99
- this.session.connectionStatusChanged.disconnect(this._initialConnection, this);
97
+ /**
98
+ * A promise that is fulfilled when the terminal is ready.
99
+ */
100
+ get ready() {
101
+ return this._ready.promise;
100
102
  }
101
103
  /**
102
104
  * Get a config option for the terminal.
@@ -114,15 +116,32 @@ export class Terminal extends Widget {
114
116
  }
115
117
  this._options[option] = value;
116
118
  switch (option) {
117
- case 'shutdownOnClose': // Do not transmit to XTerm
118
- case 'closeOnExit': // Do not transmit to XTerm
119
+ case 'fontFamily':
120
+ this._term.options.fontFamily = value;
121
+ break;
122
+ case 'fontSize':
123
+ this._term.options.fontSize = value;
124
+ break;
125
+ case 'lineHeight':
126
+ this._term.options.lineHeight = value;
127
+ break;
128
+ case 'screenReaderMode':
129
+ this._term.options.screenReaderMode = value;
130
+ break;
131
+ case 'scrollback':
132
+ this._term.options.scrollback = value;
119
133
  break;
120
134
  case 'theme':
121
- this._term.setOption('theme', Private.getXTermTheme(value));
135
+ this._term.options.theme = {
136
+ ...Private.getXTermTheme(value)
137
+ };
122
138
  this._setThemeAttribute(value);
123
139
  break;
140
+ case 'macOptionIsMeta':
141
+ this._term.options.macOptionIsMeta = value;
142
+ break;
124
143
  default:
125
- this._term.setOption(option, value);
144
+ // Do not transmit options not listed above to XTerm
126
145
  break;
127
146
  }
128
147
  this._needsResize = true;
@@ -139,7 +158,9 @@ export class Terminal extends Widget {
139
158
  });
140
159
  }
141
160
  }
142
- this._term.dispose();
161
+ void this.ready.then(() => {
162
+ this._term.dispose();
163
+ });
143
164
  super.dispose();
144
165
  }
145
166
  /**
@@ -149,11 +170,37 @@ export class Terminal extends Widget {
149
170
  * Failure to reconnect to the session should be caught appropriately
150
171
  */
151
172
  async refresh() {
152
- if (!this.isDisposed) {
173
+ if (!this.isDisposed && this._isReady) {
153
174
  await this.session.reconnect();
154
175
  this._term.clear();
155
176
  }
156
177
  }
178
+ /**
179
+ * Check if terminal has any text selected.
180
+ */
181
+ hasSelection() {
182
+ if (!this.isDisposed && this._isReady) {
183
+ return this._term.hasSelection();
184
+ }
185
+ return false;
186
+ }
187
+ /**
188
+ * Paste text into terminal.
189
+ */
190
+ paste(data) {
191
+ if (!this.isDisposed && this._isReady) {
192
+ return this._term.paste(data);
193
+ }
194
+ }
195
+ /**
196
+ * Get selected text from terminal.
197
+ */
198
+ getSelection() {
199
+ if (!this.isDisposed && this._isReady) {
200
+ return this._term.getSelection();
201
+ }
202
+ return null;
203
+ }
157
204
  /**
158
205
  * Process a message sent to the widget.
159
206
  *
@@ -198,7 +245,7 @@ export class Terminal extends Widget {
198
245
  */
199
246
  onUpdateRequest(msg) {
200
247
  var _a;
201
- if (!this.isVisible || !this.isAttached) {
248
+ if (!this.isVisible || !this.isAttached || !this._isReady) {
202
249
  return;
203
250
  }
204
251
  // Open the terminal if necessary.
@@ -222,7 +269,26 @@ export class Terminal extends Widget {
222
269
  * Handle `'activate-request'` messages.
223
270
  */
224
271
  onActivateRequest(msg) {
225
- this._term.focus();
272
+ var _a;
273
+ (_a = this._term) === null || _a === void 0 ? void 0 : _a.focus();
274
+ }
275
+ _initialConnection() {
276
+ if (this.isDisposed) {
277
+ return;
278
+ }
279
+ if (this.session.connectionStatus !== 'connected') {
280
+ return;
281
+ }
282
+ this.title.label = this._trans.__('Terminal %1', this.session.name);
283
+ this._setSessionSize();
284
+ if (this._options.initialCommand) {
285
+ this.session.send({
286
+ type: 'stdin',
287
+ content: [this._options.initialCommand + '\r']
288
+ });
289
+ }
290
+ // Only run this initial connection logic once.
291
+ this.session.connectionStatusChanged.disconnect(this._initialConnection, this);
226
292
  }
227
293
  /**
228
294
  * Initialize the terminal object.
@@ -306,6 +372,12 @@ export class Terminal extends Widget {
306
372
  this.session.send({ type: 'set_size', content });
307
373
  }
308
374
  }
375
+ _setThemeAttribute(theme) {
376
+ if (this.isDisposed) {
377
+ return;
378
+ }
379
+ this.node.setAttribute('data-term-theme', theme ? theme.toLowerCase() : 'inherit');
380
+ }
309
381
  }
310
382
  /**
311
383
  * A namespace for private data.
@@ -324,7 +396,8 @@ var Private;
324
396
  background: '#fff',
325
397
  cursor: '#616161',
326
398
  cursorAccent: '#F5F5F5',
327
- selection: 'rgba(97, 97, 97, 0.3)' // md-grey-700
399
+ selectionBackground: 'rgba(97, 97, 97, 0.3)',
400
+ selectionInactiveBackground: 'rgba(189, 189, 189, 0.3)' // md-grey-400
328
401
  };
329
402
  /**
330
403
  * The dark terminal theme.
@@ -334,7 +407,8 @@ var Private;
334
407
  background: '#000',
335
408
  cursor: '#fff',
336
409
  cursorAccent: '#000',
337
- selection: 'rgba(255, 255, 255, 0.3)'
410
+ selectionBackground: 'rgba(255, 255, 255, 0.3)',
411
+ selectionInactiveBackground: 'rgba(238, 238, 238, 0.3)' // md-grey-200
338
412
  };
339
413
  /**
340
414
  * The current theme.
@@ -352,8 +426,11 @@ var Private;
352
426
  cursorAccent: getComputedStyle(document.body)
353
427
  .getPropertyValue('--jp-ui-inverse-font-color0')
354
428
  .trim(),
355
- selection: getComputedStyle(document.body)
356
- .getPropertyValue('--jp-ui-font-color3')
429
+ selectionBackground: getComputedStyle(document.body)
430
+ .getPropertyValue('--jp-layout-color3')
431
+ .trim(),
432
+ selectionInactiveBackground: getComputedStyle(document.body)
433
+ .getPropertyValue('--jp-layout-color2')
357
434
  .trim()
358
435
  });
359
436
  function getXTermTheme(theme) {
@@ -369,4 +446,75 @@ var Private;
369
446
  }
370
447
  Private.getXTermTheme = getXTermTheme;
371
448
  })(Private || (Private = {}));
449
+ /**
450
+ * Utility functions for creating a Terminal widget
451
+ */
452
+ (function (Private) {
453
+ let supportWebGL = false;
454
+ let Xterm_;
455
+ let FitAddon_;
456
+ let WeblinksAddon_;
457
+ let Renderer_;
458
+ /**
459
+ * Detect if the browser supports WebGL or not.
460
+ *
461
+ * Reference: https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/By_example/Detect_WebGL
462
+ */
463
+ function hasWebGLContext() {
464
+ // Create canvas element. The canvas is not added to the
465
+ // document itself, so it is never displayed in the
466
+ // browser window.
467
+ const canvas = document.createElement('canvas');
468
+ // Get WebGLRenderingContext from canvas element.
469
+ const gl = canvas.getContext('webgl') || canvas.getContext('experimental-webgl');
470
+ // Report the result.
471
+ try {
472
+ return gl instanceof WebGLRenderingContext;
473
+ }
474
+ catch (error) {
475
+ return false;
476
+ }
477
+ }
478
+ function addRenderer(term) {
479
+ let renderer = new Renderer_();
480
+ term.loadAddon(renderer);
481
+ if (supportWebGL) {
482
+ renderer.onContextLoss(event => {
483
+ console.debug('WebGL context lost - reinitialize Xtermjs renderer.');
484
+ renderer.dispose();
485
+ // If the Webgl context is lost, reinitialize the addon
486
+ addRenderer(term);
487
+ });
488
+ }
489
+ }
490
+ /**
491
+ * Create a xterm.js terminal asynchronously.
492
+ */
493
+ async function createTerminal(options) {
494
+ var _a;
495
+ if (!Xterm_) {
496
+ supportWebGL = hasWebGLContext();
497
+ const [xterm_, fitAddon_, renderer_, weblinksAddon_] = await Promise.all([
498
+ import('xterm'),
499
+ import('xterm-addon-fit'),
500
+ supportWebGL
501
+ ? import('xterm-addon-webgl')
502
+ : import('xterm-addon-canvas'),
503
+ import('xterm-addon-web-links')
504
+ ]);
505
+ Xterm_ = xterm_.Terminal;
506
+ FitAddon_ = fitAddon_.FitAddon;
507
+ Renderer_ =
508
+ (_a = renderer_.WebglAddon) !== null && _a !== void 0 ? _a : renderer_.CanvasAddon;
509
+ WeblinksAddon_ = weblinksAddon_.WebLinksAddon;
510
+ }
511
+ const term = new Xterm_(options);
512
+ addRenderer(term);
513
+ const fitAddon = new FitAddon_();
514
+ term.loadAddon(fitAddon);
515
+ term.loadAddon(new WeblinksAddon_());
516
+ return [term, fitAddon];
517
+ }
518
+ Private.createTerminal = createTerminal;
519
+ })(Private || (Private = {}));
372
520
  //# sourceMappingURL=widget.js.map
package/lib/widget.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"widget.js","sourceRoot":"","sources":["../src/widget.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;;;;;;;;;;;;AAG3D,OAAO,EAEL,cAAc,EAEf,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAW,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,QAAQ,IAAI,KAAK,EAAE,MAAM,OAAO,CAAC;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CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,cAAc,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;gBACvE,MAAM,CAAC,OAAO,CAAC;gBACf,MAAM,CAAC,iBAAiB,CAAC;gBACzB,YAAY;oBACV,CAAC,CAAC,MAAM,CAAC,mBAAmB,CAAC;oBAC7B,CAAC,CAAC,MAAM,CAAC,oBAAoB,CAAC;gBAChC,MAAM,CAAC,uBAAuB,CAAC;aAChC,CAAC,CAAC;YACH,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC;YACzB,SAAS,GAAG,SAAS,CAAC,QAAQ,CAAC;YAC/B,SAAS;gBACP,MAAC,SAAiB,CAAC,UAAU,mCAAK,SAAiB,CAAC,WAAW,CAAC;YAClE,cAAc,GAAG,cAAc,CAAC,aAAa,CAAC;SAC/C;QAED,MAAM,IAAI,GAAG,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC;QACjC,WAAW,CAAC,IAAI,CAAC,CAAC;QAClB,MAAM,QAAQ,GAAG,IAAI,SAAS,EAAE,CAAC;QACjC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QACzB,IAAI,CAAC,SAAS,CAAC,IAAI,cAAc,EAAE,CAAC,CAAC;QACrC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC1B,CAAC;IA1BqB,sBAAc,iBA0BnC,CAAA;AACH,CAAC,EAzES,OAAO,KAAP,OAAO,QAyEhB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jupyterlab/terminal",
3
- "version": "4.0.0-alpha.9",
3
+ "version": "4.0.0-beta.1",
4
4
  "description": "JupyterLab - Terminal Emulator Widget",
5
5
  "homepage": "https://github.com/jupyterlab/jupyterlab",
6
6
  "bugs": {
@@ -27,7 +27,8 @@
27
27
  "lib/*.js.map",
28
28
  "lib/*.js",
29
29
  "style/*.css",
30
- "style/index.js"
30
+ "style/index.js",
31
+ "src/**/*.{ts,tsx}"
31
32
  ],
32
33
  "scripts": {
33
34
  "build": "tsc -b",
@@ -41,25 +42,27 @@
41
42
  "watch": "tsc -b --watch"
42
43
  },
43
44
  "dependencies": {
44
- "@jupyterlab/apputils": "^4.0.0-alpha.9",
45
- "@jupyterlab/services": "^7.0.0-alpha.9",
46
- "@jupyterlab/translation": "^4.0.0-alpha.9",
47
- "@lumino/coreutils": "^1.12.0",
48
- "@lumino/domutils": "^1.8.1",
49
- "@lumino/messaging": "^1.10.1",
50
- "@lumino/widgets": "^1.31.1",
51
- "xterm": "~4.8.1",
52
- "xterm-addon-fit": "~0.4.0"
45
+ "@jupyterlab/apputils": "^4.0.0-beta.1",
46
+ "@jupyterlab/services": "^7.0.0-beta.1",
47
+ "@jupyterlab/translation": "^4.0.0-beta.1",
48
+ "@lumino/coreutils": "^2.0.0",
49
+ "@lumino/domutils": "^2.0.0",
50
+ "@lumino/messaging": "^2.0.0",
51
+ "@lumino/widgets": "^2.0.1",
52
+ "xterm": "~5.1.0",
53
+ "xterm-addon-canvas": "~0.3.0",
54
+ "xterm-addon-fit": "~0.7.0",
55
+ "xterm-addon-web-links": "~0.8.0",
56
+ "xterm-addon-webgl": "~0.14.0"
53
57
  },
54
58
  "devDependencies": {
55
- "@jupyterlab/testutils": "^4.0.0-alpha.9",
56
- "@types/jest": "^26.0.10",
59
+ "@jupyterlab/testing": "^4.0.0-beta.1",
60
+ "@types/jest": "^29.2.0",
57
61
  "canvas": "^2.9.1",
58
- "jest": "^26.4.2",
62
+ "jest": "^29.2.0",
59
63
  "rimraf": "~3.0.0",
60
- "ts-jest": "^26.3.0",
61
- "typedoc": "~0.22.10",
62
- "typescript": "~4.6.3"
64
+ "typedoc": "~0.23.25",
65
+ "typescript": "~5.0.2"
63
66
  },
64
67
  "publishConfig": {
65
68
  "access": "public"
package/src/index.ts ADDED
@@ -0,0 +1,9 @@
1
+ // Copyright (c) Jupyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+ /**
4
+ * @packageDocumentation
5
+ * @module terminal
6
+ */
7
+
8
+ export * from './tokens';
9
+ export * from './widget';
package/src/tokens.ts ADDED
@@ -0,0 +1,171 @@
1
+ // Copyright (c) Jupyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+
4
+ import { IWidgetTracker, MainAreaWidget } from '@jupyterlab/apputils';
5
+ import { Terminal } from '@jupyterlab/services';
6
+ import { Token } from '@lumino/coreutils';
7
+ import { Widget } from '@lumino/widgets';
8
+
9
+ /**
10
+ * A class that tracks editor widgets.
11
+ */
12
+ export interface ITerminalTracker
13
+ extends IWidgetTracker<MainAreaWidget<ITerminal.ITerminal>> {}
14
+
15
+ /**
16
+ * The editor tracker token.
17
+ */
18
+ export const ITerminalTracker = new Token<ITerminalTracker>(
19
+ '@jupyterlab/terminal:ITerminalTracker'
20
+ );
21
+
22
+ /**
23
+ * The namespace for terminals. Separated from the widget so it can be lazy
24
+ * loaded.
25
+ */
26
+ export namespace ITerminal {
27
+ export interface ITerminal extends Widget {
28
+ /**
29
+ * The terminal session associated with the widget.
30
+ */
31
+ session: Terminal.ITerminalConnection;
32
+
33
+ /**
34
+ * Get a config option for the terminal.
35
+ */
36
+ getOption<K extends keyof IOptions>(option: K): IOptions[K];
37
+
38
+ /**
39
+ * Set a config option for the terminal.
40
+ */
41
+ setOption<K extends keyof IOptions>(option: K, value: IOptions[K]): void;
42
+
43
+ /**
44
+ * Refresh the terminal session.
45
+ */
46
+ refresh(): Promise<void>;
47
+
48
+ /**
49
+ * Check if terminal has any text selected.
50
+ */
51
+ hasSelection(): boolean;
52
+
53
+ /**
54
+ * Paste text into terminal.
55
+ */
56
+ paste(data: string): void;
57
+
58
+ /**
59
+ * Get selected text from terminal.
60
+ */
61
+ getSelection(): string | null;
62
+ }
63
+ /**
64
+ * Options for the terminal widget.
65
+ */
66
+ export interface IOptions {
67
+ /**
68
+ * The font family used to render text.
69
+ */
70
+ fontFamily?: string;
71
+
72
+ /**
73
+ * The font size of the terminal in pixels.
74
+ */
75
+ fontSize: number;
76
+
77
+ /**
78
+ * The line height used to render text.
79
+ */
80
+ lineHeight?: number;
81
+
82
+ /**
83
+ * The theme of the terminal.
84
+ */
85
+ theme: Theme;
86
+
87
+ /**
88
+ * The amount of buffer scrollback to be used
89
+ * with the terminal
90
+ */
91
+ scrollback?: number;
92
+
93
+ /**
94
+ * Whether to shut down the session when closing a terminal or not.
95
+ */
96
+ shutdownOnClose: boolean;
97
+
98
+ /**
99
+ * Whether to close the widget when exiting a terminal or not.
100
+ */
101
+ closeOnExit: boolean;
102
+
103
+ /**
104
+ * Whether to blink the cursor. Can only be set at startup.
105
+ */
106
+ cursorBlink: boolean;
107
+
108
+ /**
109
+ * An optional command to run when the session starts.
110
+ */
111
+ initialCommand: string;
112
+
113
+ /**
114
+ * Whether to enable screen reader support.
115
+ */
116
+ screenReaderMode: boolean;
117
+
118
+ /**
119
+ * Whether to enable using Ctrl+V to paste.
120
+ *
121
+ * This setting has no effect on macOS, where Cmd+V is available.
122
+ */
123
+ pasteWithCtrlV: boolean;
124
+
125
+ /**
126
+ * Whether to auto-fit the terminal to its host element size.
127
+ */
128
+ autoFit?: boolean;
129
+
130
+ /**
131
+ * Treat option as meta key on macOS.
132
+ */
133
+ macOptionIsMeta?: boolean;
134
+ }
135
+
136
+ /**
137
+ * The default options used for creating terminals.
138
+ */
139
+ export const defaultOptions: IOptions = {
140
+ theme: 'inherit',
141
+ fontFamily: 'Menlo, Consolas, "DejaVu Sans Mono", monospace',
142
+ fontSize: 13,
143
+ lineHeight: 1.0,
144
+ scrollback: 1000,
145
+ shutdownOnClose: false,
146
+ closeOnExit: true,
147
+ cursorBlink: true,
148
+ initialCommand: '',
149
+ screenReaderMode: false, // False by default, can cause scrollbar mouse interaction issues.
150
+ pasteWithCtrlV: true,
151
+ autoFit: true,
152
+ macOptionIsMeta: false
153
+ };
154
+
155
+ /**
156
+ * A type for the terminal theme.
157
+ */
158
+ export type Theme = 'light' | 'dark' | 'inherit';
159
+
160
+ /**
161
+ * A type for the terminal theme.
162
+ */
163
+ export interface IThemeObject {
164
+ foreground: string;
165
+ background: string;
166
+ cursor: string;
167
+ cursorAccent: string;
168
+ selectionBackground: string;
169
+ selectionInactiveBackground: string;
170
+ }
171
+ }
package/src/widget.ts ADDED
@@ -0,0 +1,626 @@
1
+ // Copyright (c) Jupyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+
4
+ import { Terminal as TerminalNS } from '@jupyterlab/services';
5
+ import {
6
+ ITranslator,
7
+ nullTranslator,
8
+ TranslationBundle
9
+ } from '@jupyterlab/translation';
10
+ import { PromiseDelegate } from '@lumino/coreutils';
11
+ import { Platform } from '@lumino/domutils';
12
+ import { Message, MessageLoop } from '@lumino/messaging';
13
+ import { Widget } from '@lumino/widgets';
14
+ import type {
15
+ ITerminalInitOnlyOptions,
16
+ ITerminalOptions,
17
+ Terminal as Xterm
18
+ } from 'xterm';
19
+ import type { CanvasAddon } from 'xterm-addon-canvas';
20
+ import type { FitAddon } from 'xterm-addon-fit';
21
+ import type { WebLinksAddon } from 'xterm-addon-web-links';
22
+ import type { WebglAddon } from 'xterm-addon-webgl';
23
+ import { ITerminal } from '.';
24
+
25
+ /**
26
+ * The class name added to a terminal widget.
27
+ */
28
+ const TERMINAL_CLASS = 'jp-Terminal';
29
+
30
+ /**
31
+ * The class name added to a terminal body.
32
+ */
33
+ const TERMINAL_BODY_CLASS = 'jp-Terminal-body';
34
+
35
+ /**
36
+ * A widget which manages a terminal session.
37
+ */
38
+ export class Terminal extends Widget implements ITerminal.ITerminal {
39
+ /**
40
+ * Construct a new terminal widget.
41
+ *
42
+ * @param session - The terminal session object.
43
+ *
44
+ * @param options - The terminal configuration options.
45
+ *
46
+ * @param translator - The language translator.
47
+ */
48
+ constructor(
49
+ session: TerminalNS.ITerminalConnection,
50
+ options: Partial<ITerminal.IOptions> = {},
51
+ translator?: ITranslator
52
+ ) {
53
+ super();
54
+ translator = translator || nullTranslator;
55
+ this._trans = translator.load('jupyterlab');
56
+ this.session = session;
57
+
58
+ // Initialize settings.
59
+ this._options = { ...ITerminal.defaultOptions, ...options };
60
+
61
+ const { theme, ...other } = this._options;
62
+ const xtermOptions = {
63
+ theme: Private.getXTermTheme(theme),
64
+ ...other
65
+ };
66
+
67
+ this.addClass(TERMINAL_CLASS);
68
+
69
+ this._setThemeAttribute(theme);
70
+
71
+ // Buffer session message while waiting for the terminal
72
+ let buffer = '';
73
+ const bufferMessage = (
74
+ sender: TerminalNS.ITerminalConnection,
75
+ msg: TerminalNS.IMessage
76
+ ): void => {
77
+ switch (msg.type) {
78
+ case 'stdout':
79
+ if (msg.content) {
80
+ buffer += msg.content[0] as string;
81
+ }
82
+ break;
83
+ default:
84
+ break;
85
+ }
86
+ };
87
+ session.messageReceived.connect(bufferMessage);
88
+ session.disposed.connect(() => {
89
+ if (this.getOption('closeOnExit')) {
90
+ this.dispose();
91
+ }
92
+ }, this);
93
+
94
+ // Create the xterm.
95
+ Private.createTerminal(xtermOptions)
96
+ .then(([term, fitAddon]) => {
97
+ this._term = term;
98
+ this._fitAddon = fitAddon;
99
+ this._initializeTerm();
100
+
101
+ this.id = `jp-Terminal-${Private.id++}`;
102
+ this.title.label = this._trans.__('Terminal');
103
+ this._isReady = true;
104
+ this._ready.resolve();
105
+
106
+ if (buffer) {
107
+ this._term.write(buffer);
108
+ }
109
+ session.messageReceived.disconnect(bufferMessage);
110
+ session.messageReceived.connect(this._onMessage, this);
111
+
112
+ if (session.connectionStatus === 'connected') {
113
+ this._initialConnection();
114
+ } else {
115
+ session.connectionStatusChanged.connect(
116
+ this._initialConnection,
117
+ this
118
+ );
119
+ }
120
+ this.update();
121
+ })
122
+ .catch(reason => {
123
+ console.error('Failed to create a terminal.\n', reason);
124
+ this._ready.reject(reason);
125
+ });
126
+ }
127
+
128
+ /**
129
+ * A promise that is fulfilled when the terminal is ready.
130
+ */
131
+ get ready(): Promise<void> {
132
+ return this._ready.promise;
133
+ }
134
+
135
+ /**
136
+ * The terminal session associated with the widget.
137
+ */
138
+ readonly session: TerminalNS.ITerminalConnection;
139
+
140
+ /**
141
+ * Get a config option for the terminal.
142
+ */
143
+ getOption<K extends keyof ITerminal.IOptions>(
144
+ option: K
145
+ ): ITerminal.IOptions[K] {
146
+ return this._options[option];
147
+ }
148
+
149
+ /**
150
+ * Set a config option for the terminal.
151
+ */
152
+ setOption<K extends keyof ITerminal.IOptions>(
153
+ option: K,
154
+ value: ITerminal.IOptions[K]
155
+ ): void {
156
+ if (
157
+ option !== 'theme' &&
158
+ (this._options[option] === value || option === 'initialCommand')
159
+ ) {
160
+ return;
161
+ }
162
+
163
+ this._options[option] = value;
164
+
165
+ switch (option) {
166
+ case 'fontFamily':
167
+ this._term.options.fontFamily = value as string | undefined;
168
+ break;
169
+ case 'fontSize':
170
+ this._term.options.fontSize = value as number | undefined;
171
+ break;
172
+ case 'lineHeight':
173
+ this._term.options.lineHeight = value as number | undefined;
174
+ break;
175
+ case 'screenReaderMode':
176
+ this._term.options.screenReaderMode = value as boolean | undefined;
177
+ break;
178
+ case 'scrollback':
179
+ this._term.options.scrollback = value as number | undefined;
180
+ break;
181
+ case 'theme':
182
+ this._term.options.theme = {
183
+ ...Private.getXTermTheme(value as ITerminal.Theme)
184
+ };
185
+ this._setThemeAttribute(value as ITerminal.Theme);
186
+ break;
187
+ case 'macOptionIsMeta':
188
+ this._term.options.macOptionIsMeta = value as boolean | undefined;
189
+ break;
190
+ default:
191
+ // Do not transmit options not listed above to XTerm
192
+ break;
193
+ }
194
+
195
+ this._needsResize = true;
196
+ this.update();
197
+ }
198
+
199
+ /**
200
+ * Dispose of the resources held by the terminal widget.
201
+ */
202
+ dispose(): void {
203
+ if (!this.session.isDisposed) {
204
+ if (this.getOption('shutdownOnClose')) {
205
+ this.session.shutdown().catch(reason => {
206
+ console.error(`Terminal not shut down: ${reason}`);
207
+ });
208
+ }
209
+ }
210
+ void this.ready.then(() => {
211
+ this._term.dispose();
212
+ });
213
+ super.dispose();
214
+ }
215
+
216
+ /**
217
+ * Refresh the terminal session.
218
+ *
219
+ * #### Notes
220
+ * Failure to reconnect to the session should be caught appropriately
221
+ */
222
+ async refresh(): Promise<void> {
223
+ if (!this.isDisposed && this._isReady) {
224
+ await this.session.reconnect();
225
+ this._term.clear();
226
+ }
227
+ }
228
+
229
+ /**
230
+ * Check if terminal has any text selected.
231
+ */
232
+ hasSelection(): boolean {
233
+ if (!this.isDisposed && this._isReady) {
234
+ return this._term.hasSelection();
235
+ }
236
+ return false;
237
+ }
238
+
239
+ /**
240
+ * Paste text into terminal.
241
+ */
242
+ paste(data: string): void {
243
+ if (!this.isDisposed && this._isReady) {
244
+ return this._term.paste(data);
245
+ }
246
+ }
247
+
248
+ /**
249
+ * Get selected text from terminal.
250
+ */
251
+ getSelection(): string | null {
252
+ if (!this.isDisposed && this._isReady) {
253
+ return this._term.getSelection();
254
+ }
255
+ return null;
256
+ }
257
+
258
+ /**
259
+ * Process a message sent to the widget.
260
+ *
261
+ * @param msg - The message sent to the widget.
262
+ *
263
+ * #### Notes
264
+ * Subclasses may reimplement this method as needed.
265
+ */
266
+ processMessage(msg: Message): void {
267
+ super.processMessage(msg);
268
+ switch (msg.type) {
269
+ case 'fit-request':
270
+ this.onFitRequest(msg);
271
+ break;
272
+ default:
273
+ break;
274
+ }
275
+ }
276
+
277
+ /**
278
+ * Set the size of the terminal when attached if dirty.
279
+ */
280
+ protected onAfterAttach(msg: Message): void {
281
+ this.update();
282
+ }
283
+
284
+ /**
285
+ * Set the size of the terminal when shown if dirty.
286
+ */
287
+ protected onAfterShow(msg: Message): void {
288
+ this.update();
289
+ }
290
+
291
+ /**
292
+ * On resize, use the computed row and column sizes to resize the terminal.
293
+ */
294
+ protected onResize(msg: Widget.ResizeMessage): void {
295
+ this._offsetWidth = msg.width;
296
+ this._offsetHeight = msg.height;
297
+ this._needsResize = true;
298
+ this.update();
299
+ }
300
+
301
+ /**
302
+ * A message handler invoked on an `'update-request'` message.
303
+ */
304
+ protected onUpdateRequest(msg: Message): void {
305
+ if (!this.isVisible || !this.isAttached || !this._isReady) {
306
+ return;
307
+ }
308
+
309
+ // Open the terminal if necessary.
310
+ if (!this._termOpened) {
311
+ this._term.open(this.node);
312
+ this._term.element?.classList.add(TERMINAL_BODY_CLASS);
313
+ this._termOpened = true;
314
+ }
315
+
316
+ if (this._needsResize) {
317
+ this._resizeTerminal();
318
+ }
319
+ }
320
+
321
+ /**
322
+ * A message handler invoked on an `'fit-request'` message.
323
+ */
324
+ protected onFitRequest(msg: Message): void {
325
+ const resize = Widget.ResizeMessage.UnknownSize;
326
+ MessageLoop.sendMessage(this, resize);
327
+ }
328
+
329
+ /**
330
+ * Handle `'activate-request'` messages.
331
+ */
332
+ protected onActivateRequest(msg: Message): void {
333
+ this._term?.focus();
334
+ }
335
+
336
+ private _initialConnection() {
337
+ if (this.isDisposed) {
338
+ return;
339
+ }
340
+
341
+ if (this.session.connectionStatus !== 'connected') {
342
+ return;
343
+ }
344
+
345
+ this.title.label = this._trans.__('Terminal %1', this.session.name);
346
+ this._setSessionSize();
347
+ if (this._options.initialCommand) {
348
+ this.session.send({
349
+ type: 'stdin',
350
+ content: [this._options.initialCommand + '\r']
351
+ });
352
+ }
353
+
354
+ // Only run this initial connection logic once.
355
+ this.session.connectionStatusChanged.disconnect(
356
+ this._initialConnection,
357
+ this
358
+ );
359
+ }
360
+
361
+ /**
362
+ * Initialize the terminal object.
363
+ */
364
+ private _initializeTerm(): void {
365
+ const term = this._term;
366
+ term.onData((data: string) => {
367
+ if (this.isDisposed) {
368
+ return;
369
+ }
370
+ this.session.send({
371
+ type: 'stdin',
372
+ content: [data]
373
+ });
374
+ });
375
+
376
+ term.onTitleChange((title: string) => {
377
+ this.title.label = title;
378
+ });
379
+
380
+ // Do not add any Ctrl+C/Ctrl+V handling on macOS,
381
+ // where Cmd+C/Cmd+V works as intended.
382
+ if (Platform.IS_MAC) {
383
+ return;
384
+ }
385
+
386
+ term.attachCustomKeyEventHandler(event => {
387
+ if (event.ctrlKey && event.key === 'c' && term.hasSelection()) {
388
+ // Return so that the usual OS copy happens
389
+ // instead of interrupt signal.
390
+ return false;
391
+ }
392
+
393
+ if (event.ctrlKey && event.key === 'v' && this._options.pasteWithCtrlV) {
394
+ // Return so that the usual paste happens.
395
+ return false;
396
+ }
397
+
398
+ return true;
399
+ });
400
+ }
401
+
402
+ /**
403
+ * Handle a message from the terminal session.
404
+ */
405
+ private _onMessage(
406
+ sender: TerminalNS.ITerminalConnection,
407
+ msg: TerminalNS.IMessage
408
+ ): void {
409
+ switch (msg.type) {
410
+ case 'stdout':
411
+ if (msg.content) {
412
+ this._term.write(msg.content[0] as string);
413
+ }
414
+ break;
415
+ case 'disconnect':
416
+ this._term.write('\r\n\r\n[Finished… Term Session]\r\n');
417
+ break;
418
+ default:
419
+ break;
420
+ }
421
+ }
422
+
423
+ /**
424
+ * Resize the terminal based on computed geometry.
425
+ */
426
+ private _resizeTerminal() {
427
+ if (this._options.autoFit) {
428
+ this._fitAddon.fit();
429
+ }
430
+ if (this._offsetWidth === -1) {
431
+ this._offsetWidth = this.node.offsetWidth;
432
+ }
433
+ if (this._offsetHeight === -1) {
434
+ this._offsetHeight = this.node.offsetHeight;
435
+ }
436
+ this._setSessionSize();
437
+ this._needsResize = false;
438
+ }
439
+
440
+ /**
441
+ * Set the size of the terminal in the session.
442
+ */
443
+ private _setSessionSize(): void {
444
+ const content = [
445
+ this._term.rows,
446
+ this._term.cols,
447
+ this._offsetHeight,
448
+ this._offsetWidth
449
+ ];
450
+ if (!this.isDisposed) {
451
+ this.session.send({ type: 'set_size', content });
452
+ }
453
+ }
454
+
455
+ private _setThemeAttribute(theme: string | null | undefined) {
456
+ if (this.isDisposed) {
457
+ return;
458
+ }
459
+
460
+ this.node.setAttribute(
461
+ 'data-term-theme',
462
+ theme ? theme.toLowerCase() : 'inherit'
463
+ );
464
+ }
465
+
466
+ private _fitAddon: FitAddon;
467
+ private _needsResize = true;
468
+ private _offsetWidth = -1;
469
+ private _offsetHeight = -1;
470
+ private _options: ITerminal.IOptions;
471
+ private _isReady = false;
472
+ private _ready = new PromiseDelegate<void>();
473
+ private _term: Xterm;
474
+ private _termOpened = false;
475
+ private _trans: TranslationBundle;
476
+ }
477
+
478
+ /**
479
+ * A namespace for private data.
480
+ */
481
+ namespace Private {
482
+ /**
483
+ * An incrementing counter for ids.
484
+ */
485
+ export let id = 0;
486
+
487
+ /**
488
+ * The light terminal theme.
489
+ */
490
+ export const lightTheme: ITerminal.IThemeObject = {
491
+ foreground: '#000',
492
+ background: '#fff',
493
+ cursor: '#616161', // md-grey-700
494
+ cursorAccent: '#F5F5F5', // md-grey-100
495
+ selectionBackground: 'rgba(97, 97, 97, 0.3)', // md-grey-700
496
+ selectionInactiveBackground: 'rgba(189, 189, 189, 0.3)' // md-grey-400
497
+ };
498
+
499
+ /**
500
+ * The dark terminal theme.
501
+ */
502
+ export const darkTheme: ITerminal.IThemeObject = {
503
+ foreground: '#fff',
504
+ background: '#000',
505
+ cursor: '#fff',
506
+ cursorAccent: '#000',
507
+ selectionBackground: 'rgba(255, 255, 255, 0.3)',
508
+ selectionInactiveBackground: 'rgba(238, 238, 238, 0.3)' // md-grey-200
509
+ };
510
+
511
+ /**
512
+ * The current theme.
513
+ */
514
+ export const inheritTheme = (): ITerminal.IThemeObject => ({
515
+ foreground: getComputedStyle(document.body)
516
+ .getPropertyValue('--jp-ui-font-color0')
517
+ .trim(),
518
+ background: getComputedStyle(document.body)
519
+ .getPropertyValue('--jp-layout-color0')
520
+ .trim(),
521
+ cursor: getComputedStyle(document.body)
522
+ .getPropertyValue('--jp-ui-font-color1')
523
+ .trim(),
524
+ cursorAccent: getComputedStyle(document.body)
525
+ .getPropertyValue('--jp-ui-inverse-font-color0')
526
+ .trim(),
527
+ selectionBackground: getComputedStyle(document.body)
528
+ .getPropertyValue('--jp-layout-color3')
529
+ .trim(),
530
+ selectionInactiveBackground: getComputedStyle(document.body)
531
+ .getPropertyValue('--jp-layout-color2')
532
+ .trim()
533
+ });
534
+
535
+ export function getXTermTheme(
536
+ theme: ITerminal.Theme
537
+ ): ITerminal.IThemeObject {
538
+ switch (theme) {
539
+ case 'light':
540
+ return lightTheme;
541
+ case 'dark':
542
+ return darkTheme;
543
+ case 'inherit':
544
+ default:
545
+ return inheritTheme();
546
+ }
547
+ }
548
+ }
549
+
550
+ /**
551
+ * Utility functions for creating a Terminal widget
552
+ */
553
+ namespace Private {
554
+ let supportWebGL: boolean = false;
555
+ let Xterm_: typeof Xterm;
556
+ let FitAddon_: typeof FitAddon;
557
+ let WeblinksAddon_: typeof WebLinksAddon;
558
+ let Renderer_: typeof CanvasAddon | typeof WebglAddon;
559
+
560
+ /**
561
+ * Detect if the browser supports WebGL or not.
562
+ *
563
+ * Reference: https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/By_example/Detect_WebGL
564
+ */
565
+ function hasWebGLContext(): boolean {
566
+ // Create canvas element. The canvas is not added to the
567
+ // document itself, so it is never displayed in the
568
+ // browser window.
569
+ const canvas = document.createElement('canvas');
570
+
571
+ // Get WebGLRenderingContext from canvas element.
572
+ const gl =
573
+ canvas.getContext('webgl') || canvas.getContext('experimental-webgl');
574
+
575
+ // Report the result.
576
+ try {
577
+ return gl instanceof WebGLRenderingContext;
578
+ } catch (error) {
579
+ return false;
580
+ }
581
+ }
582
+
583
+ function addRenderer(term: Xterm): void {
584
+ let renderer = new Renderer_();
585
+ term.loadAddon(renderer);
586
+ if (supportWebGL) {
587
+ (renderer as WebglAddon).onContextLoss(event => {
588
+ console.debug('WebGL context lost - reinitialize Xtermjs renderer.');
589
+ renderer.dispose();
590
+ // If the Webgl context is lost, reinitialize the addon
591
+ addRenderer(term);
592
+ });
593
+ }
594
+ }
595
+
596
+ /**
597
+ * Create a xterm.js terminal asynchronously.
598
+ */
599
+ export async function createTerminal(
600
+ options: ITerminalOptions & ITerminalInitOnlyOptions
601
+ ): Promise<[Xterm, FitAddon]> {
602
+ if (!Xterm_) {
603
+ supportWebGL = hasWebGLContext();
604
+ const [xterm_, fitAddon_, renderer_, weblinksAddon_] = await Promise.all([
605
+ import('xterm'),
606
+ import('xterm-addon-fit'),
607
+ supportWebGL
608
+ ? import('xterm-addon-webgl')
609
+ : import('xterm-addon-canvas'),
610
+ import('xterm-addon-web-links')
611
+ ]);
612
+ Xterm_ = xterm_.Terminal;
613
+ FitAddon_ = fitAddon_.FitAddon;
614
+ Renderer_ =
615
+ (renderer_ as any).WebglAddon ?? (renderer_ as any).CanvasAddon;
616
+ WeblinksAddon_ = weblinksAddon_.WebLinksAddon;
617
+ }
618
+
619
+ const term = new Xterm_(options);
620
+ addRenderer(term);
621
+ const fitAddon = new FitAddon_();
622
+ term.loadAddon(fitAddon);
623
+ term.loadAddon(new WeblinksAddon_());
624
+ return [term, fitAddon];
625
+ }
626
+ }