Fix import for CommonJS consumers

CommonJS now imports the Terminal object directly as the trick in xterm.ts
wasn't working properly.

Fixes #865
This commit is contained in:
Daniel Imms
2017-08-08 00:24:41 -07:00
parent a0ce9a79a9
commit 3b787824d3
9 changed files with 44 additions and 32 deletions
+12
View File
@@ -126,6 +126,18 @@ var xterm = new Terminal();
xterm.fit();
```
## CommonJS
Importing xterm.js in a CommonJS environment (eg. [Electron](https://electron.atom.io/)) can be done like so:
```ts
// JavaScript
var Terminal = require('xterm').Terminal;
// TypeScript
import { Terminal } from 'xterm';
```
## Releases
Xterm.js follows a monthly release cycle roughly.
+9
View File
@@ -8,6 +8,15 @@
* has been extended to include xterm CSI codes, among
* other features.
* @license MIT
*
* Terminal Emulation References:
* http://vt100.net/
* http://invisible-island.net/xterm/ctlseqs/ctlseqs.txt
* http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
* http://invisible-island.net/vttest/
* http://www.inwap.com/pdp10/ansicode.txt
* http://linux.die.net/man/4/console_codes
* http://linux.die.net/man/7/urxvt
*/
import { BufferSet } from './BufferSet';
+6 -6
View File
@@ -9,7 +9,7 @@
/*
* CommonJS environment
*/
module.exports = attach(require('../../xterm'));
module.exports = attach(require('../../Terminal').Terminal);
} else if (typeof define == 'function') {
/*
* Require.js is available
@@ -21,7 +21,7 @@
*/
attach(window.Terminal);
}
})(function (Xterm) {
})(function (Terminal) {
'use strict';
var exports = {};
@@ -29,7 +29,7 @@
/**
* Attaches the given terminal to the given socket.
*
* @param {Xterm} term - The terminal to be attached to the given socket.
* @param {Terminal} term - The terminal to be attached to the given socket.
* @param {WebSocket} socket - The socket to attach the current terminal.
* @param {boolean} bidirectional - Whether the terminal should send data
* to the socket as well.
@@ -82,7 +82,7 @@
/**
* Detaches the given terminal from the given socket
*
* @param {Xterm} term - The terminal to be detached from the given socket.
* @param {Terminal} term - The terminal to be detached from the given socket.
* @param {WebSocket} socket - The socket from which to detach the current
* terminal.
*/
@@ -108,7 +108,7 @@
* should happen instantly or at a maximum
* frequency of 1 rendering per 10ms.
*/
Xterm.prototype.attach = function (socket, bidirectional, buffered) {
Terminal.prototype.attach = function (socket, bidirectional, buffered) {
return exports.attach(this, socket, bidirectional, buffered);
};
@@ -118,7 +118,7 @@
* @param {WebSocket} socket - The socket from which to detach the current
* terminal.
*/
Xterm.prototype.detach = function (socket) {
Terminal.prototype.detach = function (socket) {
return exports.detach(this, socket);
};
+4 -4
View File
@@ -16,7 +16,7 @@
/*
* CommonJS environment
*/
module.exports = fit(require('../../xterm'));
module.exports = fit(require('../../Terminal').Terminal);
} else if (typeof define == 'function') {
/*
* Require.js is available
@@ -28,7 +28,7 @@
*/
fit(window.Terminal);
}
})(function (Xterm) {
})(function (Terminal) {
var exports = {};
exports.proposeGeometry = function (term) {
@@ -74,11 +74,11 @@
}
};
Xterm.prototype.proposeGeometry = function () {
Terminal.prototype.proposeGeometry = function () {
return exports.proposeGeometry(this);
};
Xterm.prototype.fit = function () {
Terminal.prototype.fit = function () {
return exports.fit(this);
};
+4 -4
View File
@@ -8,7 +8,7 @@
/*
* CommonJS environment
*/
module.exports = fullscreen(require('../../xterm'));
module.exports = fullscreen(require('../../Terminal').Terminal);
} else if (typeof define == 'function') {
/*
* Require.js is available
@@ -20,12 +20,12 @@
*/
fullscreen(window.Terminal);
}
})(function (Xterm) {
})(function (Terminal) {
var exports = {};
/**
* Toggle the given terminal's fullscreen mode.
* @param {Xterm} term - The terminal to toggle full screen mode
* @param {Terminal} term - The terminal to toggle full screen mode
* @param {boolean} fullscreen - Toggle fullscreen on (true) or off (false)
*/
exports.toggleFullScreen = function (term, fullscreen) {
@@ -42,7 +42,7 @@
term.element.classList[fn]('fullscreen');
};
Xterm.prototype.toggleFullscreen = function (fullscreen) {
Terminal.prototype.toggleFullscreen = function (fullscreen) {
exports.toggleFullScreen(this, fullscreen);
};
+1 -1
View File
@@ -20,7 +20,7 @@ declare var window: any;
/**
* CommonJS environment
*/
module.exports = addon(require('../../xterm'));
module.exports = addon(require('../../Terminal').Terminal);
} else if (typeof define === 'function') {
/**
* Require.js is available
+5 -5
View File
@@ -10,7 +10,7 @@
/*
* CommonJS environment
*/
module.exports = attach(require('../../xterm'));
module.exports = attach(require('../../Terminal').Terminal);
} else if (typeof define == 'function') {
/*
* Require.js is available
@@ -22,7 +22,7 @@
*/
attach(window.Terminal);
}
})(function (Xterm) {
})(function (Terminal) {
'use strict';
var exports = {};
@@ -30,7 +30,7 @@
/**
* Attaches the given terminal to the given socket.
*
* @param {Xterm} term - The terminal to be attached to the given socket.
* @param {Terminal} term - The terminal to be attached to the given socket.
* @param {WebSocket} socket - The socket to attach the current terminal.
* @param {boolean} bidirectional - Whether the terminal should send data
* to the socket as well.
@@ -117,7 +117,7 @@
* should happen instantly or at a maximum
* frequency of 1 rendering per 10ms.
*/
Xterm.prototype.terminadoAttach = function (socket, bidirectional, buffered) {
Terminal.prototype.terminadoAttach = function (socket, bidirectional, buffered) {
return exports.terminadoAttach(this, socket, bidirectional, buffered);
};
@@ -127,7 +127,7 @@
* @param {WebSocket} socket - The socket from which to detach the current
* terminal.
*/
Xterm.prototype.terminadoDetach = function (socket) {
Terminal.prototype.terminadoDetach = function (socket) {
return exports.terminadoDetach(this, socket);
};
+1 -1
View File
@@ -1,5 +1,5 @@
import { assert } from 'chai';
import * as Terminal from '../xterm';
import * as Terminal from '../Terminal';
import * as Clipboard from './Clipboard';
describe('evaluatePastedTextProcessing', () => {
+2 -11
View File
@@ -1,18 +1,9 @@
/**
* @license MIT
*
* This file is the entry point for browserify.
*/
import { Terminal } from './Terminal';
/**
* Terminal Emulation References:
* http://vt100.net/
* http://invisible-island.net/xterm/ctlseqs/ctlseqs.txt
* http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
* http://invisible-island.net/vttest/
* http://www.inwap.com/pdp10/ansicode.txt
* http://linux.die.net/man/4/console_codes
* http://linux.die.net/man/7/urxvt
*/
module.exports = Terminal;