JSPM

@xterm/addon-webgl

0.19.0-beta.112
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 71614
  • Score
    100M100P100Q161058F
  • License MIT

Package Exports

  • @xterm/addon-webgl
  • @xterm/addon-webgl/lib/addon-webgl.js
  • @xterm/addon-webgl/lib/addon-webgl.mjs

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@xterm/addon-webgl) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@xterm/addon-webgl

An addon for xterm.js that enables a WebGL2-based renderer. This addon requires xterm.js v4+.

Install

npm install --save @xterm/addon-webgl

Usage

import { Terminal } from '@xterm/xterm';
import { WebglAddon } from '@xterm/addon-webgl';

const terminal = new Terminal();
terminal.open(element);
terminal.loadAddon(new WebglAddon());

See the full API for more advanced usage.

Handling Context Loss

The browser may drop WebGL contexts for various reasons like OOM or after the system has been suspended. There is an API exposed that fires the webglcontextlost event fired on the canvas so embedders can handle it however they wish. An easy, but suboptimal way, to handle this is by disposing of WebglAddon when the event fires:

const terminal = new Terminal();
const addon = new WebglAddon();
addon.onContextLoss(e => {
  addon.dispose();
});
terminal.loadAddon(addon);

Read more about handling WebGL context losses on the Khronos wiki.