New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

xterm

Package Overview
Dependencies
Maintainers
2
Versions
1092
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xterm - npm Package Compare versions

Comparing version 3.14.0-beta26 to 3.14.0-beta27

292

lib/InputHandler.api.js

@@ -65,2 +65,8 @@ "use strict";

_a.sent();
return [4, page.goto(APP)];
case 4:
_a.sent();
return [4, openTerminal()];
case 5:
_a.sent();
return [2];

@@ -74,14 +80,31 @@ }

});
beforeEach(function () { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4, page.goto(APP)];
case 1:
_a.sent();
return [2];
}
describe('CSI', function () {
beforeEach(function () { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4, page.evaluate("window.term.reset()")];
case 1:
_a.sent();
return [2];
}
});
}); });
it('ICH: Insert Ps (Blank) Character(s) (default = 1) - CSI Ps @', function () {
return __awaiter(this, void 0, void 0, function () {
var _a, _b;
return __generator(this, function (_c) {
switch (_c.label) {
case 0: return [4, page.evaluate("\n // Default\n window.term.write('foo\\x1b[3D\\x1b[@\\n\\r')\n // Explicit\n window.term.write('bar\\x1b[3D\\x1b[4@')\n ")];
case 1:
_c.sent();
_b = (_a = chai_1.assert).deepEqual;
return [4, getLinesAsArray(2)];
case 2:
_b.apply(_a, [_c.sent(), [' foo', ' bar']]);
return [2];
}
});
});
});
}); });
describe('Device Status Report (DSR)', function () {
it('Status Report - CSI 5 n', function () {
it('CUU: Cursor Up Ps Times (default = 1) - CSI Ps A', function () {
return __awaiter(this, void 0, void 0, function () {

@@ -91,12 +114,26 @@ var _a, _b;

switch (_c.label) {
case 0: return [4, openTerminal()];
case 0: return [4, page.evaluate("\n // Default\n window.term.write('\\n\\n\\n\\n\u001B[Aa')\n // Explicit\n window.term.write('\u001B[2Ab')\n ")];
case 1:
_c.sent();
return [4, page.evaluate("\n window.term.onData(e => window.result = e);\n window.term.write('\\x1b[5n');\n ")];
_b = (_a = chai_1.assert).deepEqual;
return [4, getLinesAsArray(4)];
case 2:
_b.apply(_a, [_c.sent(), ['', ' b', '', 'a']]);
return [2];
}
});
});
});
it('CUD: Cursor Down Ps Times (default = 1) - CSI Ps B', function () {
return __awaiter(this, void 0, void 0, function () {
var _a, _b;
return __generator(this, function (_c) {
switch (_c.label) {
case 0: return [4, page.evaluate("\n // Default\n window.term.write('\u001B[Ba')\n // Explicit\n window.term.write('\u001B[2Bb')\n ")];
case 1:
_c.sent();
_b = (_a = chai_1.assert).equal;
return [4, page.evaluate("window.result")];
case 3:
_b.apply(_a, [_c.sent(), '\x1b[0n']);
_b = (_a = chai_1.assert).deepEqual;
return [4, getLinesAsArray(4)];
case 2:
_b.apply(_a, [_c.sent(), ['', 'a', '', ' b']]);
return [2];

@@ -107,24 +144,31 @@ }

});
it('Report Cursor Position (CPR) - CSI 6 n', function () {
it('CUF: Cursor Forward Ps Times (default = 1) - CSI Ps C', function () {
return __awaiter(this, void 0, void 0, function () {
var _a, _b, _c, _d;
return __generator(this, function (_e) {
switch (_e.label) {
case 0: return [4, openTerminal()];
var _a, _b;
return __generator(this, function (_c) {
switch (_c.label) {
case 0: return [4, page.evaluate("\n // Default\n window.term.write('\u001B[Ca')\n // Explicit\n window.term.write('\u001B[2Cb')\n ")];
case 1:
_e.sent();
return [4, page.evaluate("window.term.write('\\n\\nfoo')")];
_c.sent();
_b = (_a = chai_1.assert).deepEqual;
return [4, getLinesAsArray(1)];
case 2:
_e.sent();
_b.apply(_a, [_c.sent(), [' a b']]);
return [2];
}
});
});
});
it('CUB: Cursor Backward Ps Times (default = 1) - CSI Ps D', function () {
return __awaiter(this, void 0, void 0, function () {
var _a, _b;
return __generator(this, function (_c) {
switch (_c.label) {
case 0: return [4, page.evaluate("\n // Default\n window.term.write('foo\u001B[Da')\n // Explicit\n window.term.write('\u001B[2Db')\n ")];
case 1:
_c.sent();
_b = (_a = chai_1.assert).deepEqual;
return [4, page.evaluate("\n [window.term.buffer.cursorY, window.term.buffer.cursorX]\n ")];
case 3:
_b.apply(_a, [_e.sent(), [2, 3]]);
return [4, page.evaluate("\n window.term.onData(e => window.result = e);\n window.term.write('\\x1b[6n');\n ")];
case 4:
_e.sent();
_d = (_c = chai_1.assert).equal;
return [4, page.evaluate("window.result")];
case 5:
_d.apply(_c, [_e.sent(), '\x1b[3;4R']);
return [4, getLinesAsArray(1)];
case 2:
_b.apply(_a, [_c.sent(), ['fba']]);
return [2];

@@ -135,24 +179,31 @@ }

});
it('Report Cursor Position (DECXCPR) - CSI ? 6 n', function () {
it('CNL: Cursor Next Line Ps Times (default = 1) - CSI Ps E', function () {
return __awaiter(this, void 0, void 0, function () {
var _a, _b, _c, _d;
return __generator(this, function (_e) {
switch (_e.label) {
case 0: return [4, openTerminal()];
var _a, _b;
return __generator(this, function (_c) {
switch (_c.label) {
case 0: return [4, page.evaluate("\n // Default\n window.term.write('\u001B[Ea')\n // Explicit\n window.term.write('\u001B[2Eb')\n ")];
case 1:
_e.sent();
return [4, page.evaluate("window.term.write('\\n\\nfoo')")];
_c.sent();
_b = (_a = chai_1.assert).deepEqual;
return [4, getLinesAsArray(4)];
case 2:
_e.sent();
_b.apply(_a, [_c.sent(), ['', 'a', '', 'b']]);
return [2];
}
});
});
});
it('CPL: Cursor Preceding Line Ps Times (default = 1) - CSI Ps F', function () {
return __awaiter(this, void 0, void 0, function () {
var _a, _b;
return __generator(this, function (_c) {
switch (_c.label) {
case 0: return [4, page.evaluate("\n // Default\n window.term.write('\\n\\n\\n\\n\u001B[Fa')\n // Explicit\n window.term.write('\u001B[2Fb')\n ")];
case 1:
_c.sent();
_b = (_a = chai_1.assert).deepEqual;
return [4, page.evaluate("\n [window.term.buffer.cursorY, window.term.buffer.cursorX]\n ")];
case 3:
_b.apply(_a, [_e.sent(), [2, 3]]);
return [4, page.evaluate("\n window.term.onData(e => window.result = e);\n window.term.write('\\x1b[?6n');\n ")];
case 4:
_e.sent();
_d = (_c = chai_1.assert).equal;
return [4, page.evaluate("window.result")];
case 5:
_d.apply(_c, [_e.sent(), '\x1b[?3;4R']);
return [4, getLinesAsArray(5)];
case 2:
_b.apply(_a, [_c.sent(), ['', 'b', '', 'a', '']]);
return [2];

@@ -163,2 +214,120 @@ }

});
it('CHA: Cursor Character Absolute [column] (default = [row,1]) - CSI Ps G', function () {
return __awaiter(this, void 0, void 0, function () {
var _a, _b;
return __generator(this, function (_c) {
switch (_c.label) {
case 0: return [4, page.evaluate("\n // Default\n window.term.write('foo\u001B[Ga')\n // Explicit\n window.term.write('\u001B[10Gb')\n ")];
case 1:
_c.sent();
_b = (_a = chai_1.assert).deepEqual;
return [4, getLinesAsArray(1)];
case 2:
_b.apply(_a, [_c.sent(), ['aoo b']]);
return [2];
}
});
});
});
it('CUP: Cursor Position [row;column] (default = [1,1]) - CSI Ps ; Ps H', function () {
return __awaiter(this, void 0, void 0, function () {
var _a, _b;
return __generator(this, function (_c) {
switch (_c.label) {
case 0: return [4, page.evaluate("\n // Default\n window.term.write('foo\u001B[Ha')\n // Explicit\n window.term.write('\u001B[3;3Hb')\n ")];
case 1:
_c.sent();
_b = (_a = chai_1.assert).deepEqual;
return [4, getLinesAsArray(3)];
case 2:
_b.apply(_a, [_c.sent(), ['aoo', '', ' b']]);
return [2];
}
});
});
});
it('CHT: Cursor Forward Tabulation Ps tab stops (default = 1) - CSI Ps I', function () {
return __awaiter(this, void 0, void 0, function () {
var _a, _b;
return __generator(this, function (_c) {
switch (_c.label) {
case 0: return [4, page.evaluate("\n // Default\n window.term.write('\u001B[Ia')\n // Explicit\n window.term.write('\\n\\r\u001B[2Ib')\n ")];
case 1:
_c.sent();
_b = (_a = chai_1.assert).deepEqual;
return [4, getLinesAsArray(2)];
case 2:
_b.apply(_a, [_c.sent(), [' a', ' b']]);
return [2];
}
});
});
});
describe('DSR: Device Status Report', function () {
it('Status Report - CSI 5 n', function () {
return __awaiter(this, void 0, void 0, function () {
var _a, _b;
return __generator(this, function (_c) {
switch (_c.label) {
case 0: return [4, page.evaluate("\n window.term.onData(e => window.result = e);\n window.term.write('\\x1b[5n');\n ")];
case 1:
_c.sent();
_b = (_a = chai_1.assert).equal;
return [4, page.evaluate("window.result")];
case 2:
_b.apply(_a, [_c.sent(), '\x1b[0n']);
return [2];
}
});
});
});
it('Report Cursor Position (CPR) - CSI 6 n', function () {
return __awaiter(this, void 0, void 0, function () {
var _a, _b, _c, _d;
return __generator(this, function (_e) {
switch (_e.label) {
case 0: return [4, page.evaluate("window.term.write('\\n\\nfoo')")];
case 1:
_e.sent();
_b = (_a = chai_1.assert).deepEqual;
return [4, page.evaluate("\n [window.term.buffer.cursorY, window.term.buffer.cursorX]\n ")];
case 2:
_b.apply(_a, [_e.sent(), [2, 3]]);
return [4, page.evaluate("\n window.term.onData(e => window.result = e);\n window.term.write('\\x1b[6n');\n ")];
case 3:
_e.sent();
_d = (_c = chai_1.assert).equal;
return [4, page.evaluate("window.result")];
case 4:
_d.apply(_c, [_e.sent(), '\x1b[3;4R']);
return [2];
}
});
});
});
it('Report Cursor Position (DECXCPR) - CSI ? 6 n', function () {
return __awaiter(this, void 0, void 0, function () {
var _a, _b, _c, _d;
return __generator(this, function (_e) {
switch (_e.label) {
case 0: return [4, page.evaluate("window.term.write('\\n\\nfoo')")];
case 1:
_e.sent();
_b = (_a = chai_1.assert).deepEqual;
return [4, page.evaluate("\n [window.term.buffer.cursorY, window.term.buffer.cursorX]\n ")];
case 2:
_b.apply(_a, [_e.sent(), [2, 3]]);
return [4, page.evaluate("\n window.term.onData(e => window.result = e);\n window.term.write('\\x1b[?6n');\n ")];
case 3:
_e.sent();
_d = (_c = chai_1.assert).equal;
return [4, page.evaluate("window.result")];
case 4:
_d.apply(_c, [_e.sent(), '\x1b[?3;4R']);
return [2];
}
});
});
});
});
});

@@ -191,2 +360,19 @@ });

}
function getLinesAsArray(count, start) {
if (start === void 0) { start = 0; }
return __awaiter(this, void 0, void 0, function () {
var text, i;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
text = '';
for (i = start; i < start + count; i++) {
text += "window.term.buffer.getLine(" + i + ").translateToString(true),";
}
return [4, page.evaluate("[" + text + "]")];
case 1: return [2, _a.sent()];
}
});
});
}
//# sourceMappingURL=InputHandler.api.js.map

2

lib/renderer/dom/DomRenderer.js

@@ -75,3 +75,3 @@ "use strict";

var _this = this;
this.dimensions.scaledCharWidth = this._terminal.charMeasure.width * window.devicePixelRatio;
this.dimensions.scaledCharWidth = Math.floor(this._terminal.charMeasure.width * window.devicePixelRatio);
this.dimensions.scaledCharHeight = Math.ceil(this._terminal.charMeasure.height * window.devicePixelRatio);

@@ -78,0 +78,0 @@ this.dimensions.scaledCellWidth = this.dimensions.scaledCharWidth + Math.round(this._terminal.options.letterSpacing);

@@ -82,2 +82,3 @@ "use strict";

describe('xterm output comparison', function () {
this.timeout(10000);
var xterm;

@@ -84,0 +85,0 @@ beforeEach(function () {

@@ -47,2 +47,3 @@ "use strict";

var WRITE_TIMEOUT_MS = 12;
var WRITE_BUFFER_LENGTH_THRESHOLD = 50;
var MINIMUM_COLS = 2;

@@ -989,2 +990,6 @@ var MINIMUM_ROWS = 1;

if (this.writeBufferUtf8.length > bufferOffset) {
if (bufferOffset > WRITE_BUFFER_LENGTH_THRESHOLD) {
this.writeBufferUtf8 = this.writeBufferUtf8.slice(bufferOffset);
bufferOffset = 0;
}
setTimeout(function () { return _this._innerWriteUtf8(bufferOffset); }, 0);

@@ -1041,2 +1046,6 @@ }

if (this.writeBuffer.length > bufferOffset) {
if (bufferOffset > WRITE_BUFFER_LENGTH_THRESHOLD) {
this.writeBuffer = this.writeBuffer.slice(bufferOffset);
bufferOffset = 0;
}
setTimeout(function () { return _this._innerWrite(bufferOffset); }, 0);

@@ -1043,0 +1052,0 @@ }

{
"name": "xterm",
"description": "Full xterm terminal, in your browser",
"version": "3.14.0-beta26",
"version": "3.14.0-beta27",
"main": "lib/public/Terminal.js",

@@ -6,0 +6,0 @@ "types": "typings/xterm.d.ts",

@@ -28,2 +28,4 @@ /**

await page.setViewport({ width, height });
await page.goto(APP);
await openTerminal();
});

@@ -35,41 +37,140 @@

beforeEach(async () => {
await page.goto(APP);
});
describe('CSI', () => {
beforeEach(async () => {
await page.evaluate(`window.term.reset()`);
});
describe('Device Status Report (DSR)', () => {
it('Status Report - CSI 5 n', async function(): Promise<any> {
await openTerminal();
it('ICH: Insert Ps (Blank) Character(s) (default = 1) - CSI Ps @', async function(): Promise<any> {
await page.evaluate(`
window.term.onData(e => window.result = e);
window.term.write('\\x1b[5n');
// Default
window.term.write('foo\\x1b[3D\\x1b[@\\n\\r')
// Explicit
window.term.write('bar\\x1b[3D\\x1b[4@')
`);
assert.equal(await page.evaluate(`window.result`), '\x1b[0n');
assert.deepEqual(await getLinesAsArray(2), [' foo', ' bar']);
});
it('Report Cursor Position (CPR) - CSI 6 n', async function(): Promise<any> {
await openTerminal();
await page.evaluate(`window.term.write('\\n\\nfoo')`);
assert.deepEqual(await page.evaluate(`
[window.term.buffer.cursorY, window.term.buffer.cursorX]
`), [2, 3]);
it('CUU: Cursor Up Ps Times (default = 1) - CSI Ps A', async function(): Promise<any> {
await page.evaluate(`
window.term.onData(e => window.result = e);
window.term.write('\\x1b[6n');
// Default
window.term.write('\\n\\n\\n\\n\x1b[Aa')
// Explicit
window.term.write('\x1b[2Ab')
`);
assert.equal(await page.evaluate(`window.result`), '\x1b[3;4R');
assert.deepEqual(await getLinesAsArray(4), ['', ' b', '', 'a']);
});
it('Report Cursor Position (DECXCPR) - CSI ? 6 n', async function(): Promise<any> {
await openTerminal();
await page.evaluate(`window.term.write('\\n\\nfoo')`);
assert.deepEqual(await page.evaluate(`
[window.term.buffer.cursorY, window.term.buffer.cursorX]
`), [2, 3]);
it('CUD: Cursor Down Ps Times (default = 1) - CSI Ps B', async function(): Promise<any> {
await page.evaluate(`
window.term.onData(e => window.result = e);
window.term.write('\\x1b[?6n');
// Default
window.term.write('\x1b[Ba')
// Explicit
window.term.write('\x1b[2Bb')
`);
assert.equal(await page.evaluate(`window.result`), '\x1b[?3;4R');
assert.deepEqual(await getLinesAsArray(4), ['', 'a', '', ' b']);
});
it('CUF: Cursor Forward Ps Times (default = 1) - CSI Ps C', async function(): Promise<any> {
await page.evaluate(`
// Default
window.term.write('\x1b[Ca')
// Explicit
window.term.write('\x1b[2Cb')
`);
assert.deepEqual(await getLinesAsArray(1), [' a b']);
});
it('CUB: Cursor Backward Ps Times (default = 1) - CSI Ps D', async function(): Promise<any> {
await page.evaluate(`
// Default
window.term.write('foo\x1b[Da')
// Explicit
window.term.write('\x1b[2Db')
`);
assert.deepEqual(await getLinesAsArray(1), ['fba']);
});
it('CNL: Cursor Next Line Ps Times (default = 1) - CSI Ps E', async function(): Promise<any> {
await page.evaluate(`
// Default
window.term.write('\x1b[Ea')
// Explicit
window.term.write('\x1b[2Eb')
`);
assert.deepEqual(await getLinesAsArray(4), ['', 'a', '', 'b']);
});
it('CPL: Cursor Preceding Line Ps Times (default = 1) - CSI Ps F', async function(): Promise<any> {
await page.evaluate(`
// Default
window.term.write('\\n\\n\\n\\n\x1b[Fa')
// Explicit
window.term.write('\x1b[2Fb')
`);
assert.deepEqual(await getLinesAsArray(5), ['', 'b', '', 'a', '']);
});
it('CHA: Cursor Character Absolute [column] (default = [row,1]) - CSI Ps G', async function(): Promise<any> {
await page.evaluate(`
// Default
window.term.write('foo\x1b[Ga')
// Explicit
window.term.write('\x1b[10Gb')
`);
assert.deepEqual(await getLinesAsArray(1), ['aoo b']);
});
it('CUP: Cursor Position [row;column] (default = [1,1]) - CSI Ps ; Ps H', async function(): Promise<any> {
await page.evaluate(`
// Default
window.term.write('foo\x1b[Ha')
// Explicit
window.term.write('\x1b[3;3Hb')
`);
assert.deepEqual(await getLinesAsArray(3), ['aoo', '', ' b']);
});
it('CHT: Cursor Forward Tabulation Ps tab stops (default = 1) - CSI Ps I', async function(): Promise<any> {
await page.evaluate(`
// Default
window.term.write('\x1b[Ia')
// Explicit
window.term.write('\\n\\r\x1b[2Ib')
`);
assert.deepEqual(await getLinesAsArray(2), [' a', ' b']);
});
describe('DSR: Device Status Report', () => {
it('Status Report - CSI 5 n', async function(): Promise<any> {
await page.evaluate(`
window.term.onData(e => window.result = e);
window.term.write('\\x1b[5n');
`);
assert.equal(await page.evaluate(`window.result`), '\x1b[0n');
});
it('Report Cursor Position (CPR) - CSI 6 n', async function(): Promise<any> {
await page.evaluate(`window.term.write('\\n\\nfoo')`);
assert.deepEqual(await page.evaluate(`
[window.term.buffer.cursorY, window.term.buffer.cursorX]
`), [2, 3]);
await page.evaluate(`
window.term.onData(e => window.result = e);
window.term.write('\\x1b[6n');
`);
assert.equal(await page.evaluate(`window.result`), '\x1b[3;4R');
});
it('Report Cursor Position (DECXCPR) - CSI ? 6 n', async function(): Promise<any> {
await page.evaluate(`window.term.write('\\n\\nfoo')`);
assert.deepEqual(await page.evaluate(`
[window.term.buffer.cursorY, window.term.buffer.cursorX]
`), [2, 3]);
await page.evaluate(`
window.term.onData(e => window.result = e);
window.term.write('\\x1b[?6n');
`);
assert.equal(await page.evaluate(`window.result`), '\x1b[?3;4R');
});
});
});

@@ -87,1 +188,9 @@ });

}
async function getLinesAsArray(count: number, start: number = 0): Promise<string[]> {
let text = '';
for (let i = start; i < start + count; i++) {
text += `window.term.buffer.getLine(${i}).translateToString(true),`;
}
return await page.evaluate(`[${text}]`);
}

@@ -93,3 +93,3 @@ /**

private _updateDimensions(): void {
this.dimensions.scaledCharWidth = this._terminal.charMeasure.width * window.devicePixelRatio;
this.dimensions.scaledCharWidth = Math.floor(this._terminal.charMeasure.width * window.devicePixelRatio);
this.dimensions.scaledCharHeight = Math.ceil(this._terminal.charMeasure.height * window.devicePixelRatio);

@@ -96,0 +96,0 @@ this.dimensions.scaledCellWidth = this.dimensions.scaledCharWidth + Math.round(this._terminal.options.letterSpacing);

@@ -94,3 +94,4 @@ /**

/** tests */
describe('xterm output comparison', () => {
describe('xterm output comparison', function(): void {
this.timeout(10000);
let xterm: TestTerminal;

@@ -97,0 +98,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc