Huge News!Announcing our $40M Series B led by Abstract Ventures.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-beta11 to 3.14.0-beta12

9

lib/core/input/TextDecoder.d.ts

@@ -0,1 +1,3 @@

export declare function stringFromCodePoint(codePoint: number): string;
export declare function utf32ToString(data: Uint32Array, start?: number, end?: number): string;
export declare class StringToUtf32 {

@@ -6,3 +8,6 @@ private _interim;

}
export declare function stringFromCodePoint(codePoint: number): string;
export declare function utf32ToString(data: Uint32Array, start?: number, end?: number): string;
export declare class Utf8ToUtf32 {
interim: Uint8Array;
clear(): void;
decode(input: Uint8Array, target: Uint32Array): number;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function stringFromCodePoint(codePoint) {
if (codePoint > 0xFFFF) {
codePoint -= 0x10000;
return String.fromCharCode((codePoint >> 10) + 0xD800) + String.fromCharCode((codePoint % 0x400) + 0xDC00);
}
return String.fromCharCode(codePoint);
}
exports.stringFromCodePoint = stringFromCodePoint;
function utf32ToString(data, start, end) {
if (start === void 0) { start = 0; }
if (end === void 0) { end = data.length; }
var result = '';
for (var i = start; i < end; ++i) {
var codepoint = data[i];
if (codepoint > 0xFFFF) {
codepoint -= 0x10000;
result += String.fromCharCode((codepoint >> 10) + 0xD800) + String.fromCharCode((codepoint % 0x400) + 0xDC00);
}
else {
result += String.fromCharCode(codepoint);
}
}
return result;
}
exports.utf32ToString = utf32ToString;
var StringToUtf32 = (function () {

@@ -52,27 +77,181 @@ function StringToUtf32() {

exports.StringToUtf32 = StringToUtf32;
function stringFromCodePoint(codePoint) {
if (codePoint > 0xFFFF) {
codePoint -= 0x10000;
return String.fromCharCode((codePoint >> 10) + 0xD800) + String.fromCharCode((codePoint % 0x400) + 0xDC00);
var Utf8ToUtf32 = (function () {
function Utf8ToUtf32() {
this.interim = new Uint8Array(3);
}
return String.fromCharCode(codePoint);
}
exports.stringFromCodePoint = stringFromCodePoint;
function utf32ToString(data, start, end) {
if (start === void 0) { start = 0; }
if (end === void 0) { end = data.length; }
var result = '';
for (var i = start; i < end; ++i) {
var codepoint = data[i];
if (codepoint > 0xFFFF) {
codepoint -= 0x10000;
result += String.fromCharCode((codepoint >> 10) + 0xD800) + String.fromCharCode((codepoint % 0x400) + 0xDC00);
Utf8ToUtf32.prototype.clear = function () {
this.interim.fill(0);
};
Utf8ToUtf32.prototype.decode = function (input, target) {
var length = input.length;
if (!length) {
return 0;
}
else {
result += String.fromCharCode(codepoint);
var size = 0;
var byte1;
var byte2;
var byte3;
var byte4;
var codepoint = 0;
var startPos = 0;
if (this.interim[0]) {
var discardInterim = false;
var cp = this.interim[0];
cp &= ((((cp & 0xE0) === 0xC0)) ? 0x1F : (((cp & 0xF0) === 0xE0)) ? 0x0F : 0x07);
var pos = 0;
var tmp = void 0;
while ((tmp = this.interim[++pos] & 0x3F) && pos < 4) {
cp <<= 6;
cp |= tmp;
}
var type = (((this.interim[0] & 0xE0) === 0xC0)) ? 2 : (((this.interim[0] & 0xF0) === 0xE0)) ? 3 : 4;
var missing = type - pos;
while (startPos < missing) {
if (startPos >= length) {
return 0;
}
tmp = input[startPos++];
if ((tmp & 0xC0) !== 0x80) {
startPos--;
discardInterim = true;
break;
}
else {
this.interim[pos++] = tmp;
cp <<= 6;
cp |= tmp & 0x3F;
}
}
if (!discardInterim) {
if (type === 2) {
if (cp < 0x80) {
startPos--;
}
else {
target[size++] = cp;
}
}
else if (type === 3) {
if (cp < 0x0800 || (cp >= 0xD800 && cp <= 0xDFFF)) {
}
else {
target[size++] = cp;
}
}
else {
if (codepoint < 0x010000 || codepoint > 0x10FFFF) {
}
else {
target[size++] = cp;
}
}
}
this.interim.fill(0);
}
}
return result;
}
exports.utf32ToString = utf32ToString;
var fourStop = length - 4;
var i = startPos;
while (i < length) {
while (i < fourStop
&& !((byte1 = input[i]) & 0x80)
&& !((byte2 = input[i + 1]) & 0x80)
&& !((byte3 = input[i + 2]) & 0x80)
&& !((byte4 = input[i + 3]) & 0x80)) {
target[size++] = byte1;
target[size++] = byte2;
target[size++] = byte3;
target[size++] = byte4;
i += 4;
}
byte1 = input[i++];
if (byte1 < 0x80) {
target[size++] = byte1;
}
else if ((byte1 & 0xE0) === 0xC0) {
if (i >= length) {
this.interim[0] = byte1;
return size;
}
byte2 = input[i++];
if ((byte2 & 0xC0) !== 0x80) {
i--;
continue;
}
codepoint = (byte1 & 0x1F) << 6 | (byte2 & 0x3F);
if (codepoint < 0x80) {
i--;
continue;
}
target[size++] = codepoint;
}
else if ((byte1 & 0xF0) === 0xE0) {
if (i >= length) {
this.interim[0] = byte1;
return size;
}
byte2 = input[i++];
if ((byte2 & 0xC0) !== 0x80) {
i--;
continue;
}
if (i >= length) {
this.interim[0] = byte1;
this.interim[1] = byte2;
return size;
}
byte3 = input[i++];
if ((byte3 & 0xC0) !== 0x80) {
i--;
continue;
}
codepoint = (byte1 & 0x0F) << 12 | (byte2 & 0x3F) << 6 | (byte3 & 0x3F);
if (codepoint < 0x0800 || (codepoint >= 0xD800 && codepoint <= 0xDFFF)) {
continue;
}
target[size++] = codepoint;
}
else if ((byte1 & 0xF8) === 0xF0) {
if (i >= length) {
this.interim[0] = byte1;
return size;
}
byte2 = input[i++];
if ((byte2 & 0xC0) !== 0x80) {
i--;
continue;
}
if (i >= length) {
this.interim[0] = byte1;
this.interim[1] = byte2;
return size;
}
byte3 = input[i++];
if ((byte3 & 0xC0) !== 0x80) {
i--;
continue;
}
if (i >= length) {
this.interim[0] = byte1;
this.interim[1] = byte2;
this.interim[2] = byte3;
return size;
}
byte4 = input[i++];
if ((byte4 & 0xC0) !== 0x80) {
i--;
continue;
}
codepoint = (byte1 & 0x07) << 18 | (byte2 & 0x3F) << 12 | (byte3 & 0x3F) << 6 | (byte4 & 0x3F);
if (codepoint < 0x010000 || codepoint > 0x10FFFF) {
continue;
}
target[size++] = codepoint;
}
else {
}
}
return size;
};
return Utf8ToUtf32;
}());
exports.Utf8ToUtf32 = Utf8ToUtf32;
//# sourceMappingURL=TextDecoder.js.map

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

_this._stringDecoder = new TextDecoder_1.StringToUtf32();
_this._utf8Decoder = new TextDecoder_1.Utf8ToUtf32();
_this._workCell = new BufferLine_1.CellData();

@@ -221,2 +222,21 @@ _this._onCursorMove = new EventEmitter2_1.EventEmitter2();

};
InputHandler.prototype.parseUtf8 = function (data) {
if (!this._terminal) {
return;
}
var buffer = this._terminal.buffer;
var cursorStartX = buffer.x;
var cursorStartY = buffer.y;
if (this._terminal.debug) {
this._terminal.log('data: ' + data);
}
if (this._parseBuffer.length < data.length) {
this._parseBuffer = new Uint32Array(data.length);
}
this._parser.parse(this._parseBuffer, this._utf8Decoder.decode(data, this._parseBuffer));
buffer = this._terminal.buffer;
if (buffer.x !== cursorStartX || buffer.y !== cursorStartY) {
this._terminal.emit('cursormove');
}
};
InputHandler.prototype.print = function (data, start, end) {

@@ -223,0 +243,0 @@ var code;

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

_c.sent();
return [4, page.evaluate("\n window.term.write('foo');\n window.term.write('bar');\n ")];
return [4, page.evaluate("\n window.term.write('foo');\n window.term.write('bar');\n window.term.write('\u6587');\n ")];
case 2:

@@ -124,3 +124,3 @@ _c.sent();

case 3:
_b.apply(_a, [_c.sent(), 'foobar']);
_b.apply(_a, [_c.sent(), 'foobar文']);
return [2];

@@ -133,5 +133,5 @@ }

return __awaiter(this, void 0, void 0, function () {
var _a, _b, _c, _d;
return __generator(this, function (_e) {
switch (_e.label) {
var _a, _b, _c, _d, _e, _f;
return __generator(this, function (_g) {
switch (_g.label) {
case 0:

@@ -141,14 +141,18 @@ this.timeout(10000);

case 1:
_e.sent();
return [4, page.evaluate("\n window.term.writeln('foo');\n window.term.writeln('bar');\n ")];
_g.sent();
return [4, page.evaluate("\n window.term.writeln('foo');\n window.term.writeln('bar');\n window.term.writeln('\u6587');\n ")];
case 2:
_e.sent();
_g.sent();
_b = (_a = chai_1.assert).equal;
return [4, page.evaluate("window.term.buffer.getLine(0).translateToString(true)")];
case 3:
_b.apply(_a, [_e.sent(), 'foo']);
_b.apply(_a, [_g.sent(), 'foo']);
_d = (_c = chai_1.assert).equal;
return [4, page.evaluate("window.term.buffer.getLine(1).translateToString(true)")];
case 4:
_d.apply(_c, [_e.sent(), 'bar']);
_d.apply(_c, [_g.sent(), 'bar']);
_f = (_e = chai_1.assert).equal;
return [4, page.evaluate("window.term.buffer.getLine(2).translateToString(true)")];
case 5:
_f.apply(_e, [_g.sent(), '文']);
return [2];

@@ -159,2 +163,24 @@ }

});
it('writeUtf8', function () {
return __awaiter(this, void 0, void 0, function () {
var _a, _b;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
this.timeout(10000);
return [4, openTerminal()];
case 1:
_c.sent();
return [4, page.evaluate("\n // foo\n window.term.writeUtf8(new Uint8Array([102, 111, 111]));\n // bar\n window.term.writeUtf8(new Uint8Array([98, 97, 114]));\n // \u6587\n window.term.writeUtf8(new Uint8Array([230, 150, 135]));\n ")];
case 2:
_c.sent();
_b = (_a = chai_1.assert).equal;
return [4, page.evaluate("window.term.buffer.getLine(0).translateToString(true)")];
case 3:
_b.apply(_a, [_c.sent(), 'foobar文']);
return [2];
}
});
});
});
it('clear', function () {

@@ -161,0 +187,0 @@ return __awaiter(this, void 0, void 0, function () {

@@ -186,2 +186,5 @@ "use strict";

};
Terminal.prototype.writeUtf8 = function (data) {
this._core.writeUtf8(data);
};
Terminal.prototype.getOption = function (key) {

@@ -188,0 +191,0 @@ return this._core.getOption(key);

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

this.writeBuffer = [];
this.writeBufferUtf8 = [];
this._writeInProgress = false;

@@ -953,2 +954,53 @@ this._xoffSentToCatchUp = false;

};
Terminal.prototype.writeUtf8 = function (data) {
var _this = this;
if (this._isDisposed) {
return;
}
if (!data) {
return;
}
this.writeBufferUtf8.push(data);
if (this.options.useFlowControl && !this._xoffSentToCatchUp && this.writeBufferUtf8.length >= WRITE_BUFFER_PAUSE_THRESHOLD) {
this.handler(EscapeSequences_1.C0.DC3);
this._xoffSentToCatchUp = true;
}
if (!this._writeInProgress && this.writeBufferUtf8.length > 0) {
this._writeInProgress = true;
setTimeout(function () {
_this._innerWriteUtf8();
});
}
};
Terminal.prototype._innerWriteUtf8 = function (bufferOffset) {
var _this = this;
if (bufferOffset === void 0) { bufferOffset = 0; }
if (this._isDisposed) {
this.writeBufferUtf8 = [];
}
var startTime = Date.now();
while (this.writeBufferUtf8.length > bufferOffset) {
var data = this.writeBufferUtf8[bufferOffset];
bufferOffset++;
if (this._xoffSentToCatchUp && this.writeBufferUtf8.length === bufferOffset) {
this.handler(EscapeSequences_1.C0.DC1);
this._xoffSentToCatchUp = false;
}
this._refreshStart = this.buffer.y;
this._refreshEnd = this.buffer.y;
this._inputHandler.parseUtf8(data);
this.updateRange(this.buffer.y);
this.refresh(this._refreshStart, this._refreshEnd);
if (Date.now() - startTime >= WRITE_TIMEOUT_MS) {
break;
}
}
if (this.writeBufferUtf8.length > bufferOffset) {
setTimeout(function () { return _this._innerWriteUtf8(bufferOffset); }, 0);
}
else {
this._writeInProgress = false;
this.writeBufferUtf8 = [];
}
};
Terminal.prototype.write = function (data) {

@@ -955,0 +1007,0 @@ var _this = this;

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

@@ -16,2 +16,3 @@ "types": "typings/xterm.d.ts",

"@types/puppeteer": "^1.12.4",
"@types/utf8": "^2.1.6",
"@types/webpack": "^4.4.11",

@@ -44,2 +45,3 @@ "browserify": "^13.3.0",

"typescript": "3.4",
"utf8": "^3.0.0",
"vinyl-buffer": "^1.0.0",

@@ -49,3 +51,3 @@ "vinyl-source-stream": "^1.1.0",

"webpack-cli": "^3.1.0",
"xterm-addon-attach": "0.1.0-beta7",
"xterm-addon-attach": "0.1.0-beta8",
"xterm-addon-search": "0.1.0-beta4",

@@ -52,0 +54,0 @@ "xterm-addon-web-links": "0.1.0-beta6",

@@ -7,2 +7,41 @@ /**

/**
* Polyfill - Convert UTF32 codepoint into JS string.
* Note: The built-in String.fromCodePoint happens to be much slower
* due to additional sanity checks. We can avoid them since
* we always operate on legal UTF32 (granted by the input decoders)
* and use this faster version instead.
*/
export function stringFromCodePoint(codePoint: number): string {
if (codePoint > 0xFFFF) {
codePoint -= 0x10000;
return String.fromCharCode((codePoint >> 10) + 0xD800) + String.fromCharCode((codePoint % 0x400) + 0xDC00);
}
return String.fromCharCode(codePoint);
}
/**
* Convert UTF32 char codes into JS string.
* Basically the same as `stringFromCodePoint` but for multiple codepoints
* in a loop (which is a lot faster).
*/
export function utf32ToString(data: Uint32Array, start: number = 0, end: number = data.length): string {
let result = '';
for (let i = start; i < end; ++i) {
let codepoint = data[i];
if (codepoint > 0xFFFF) {
// JS strings are encoded as UTF16, thus a non BMP codepoint gets converted into a surrogate pair
// conversion rules:
// - subtract 0x10000 from code point, leaving a 20 bit number
// - add high 10 bits to 0xD800 --> first surrogate
// - add low 10 bits to 0xDC00 --> second surrogate
codepoint -= 0x10000;
result += String.fromCharCode((codepoint >> 10) + 0xD800) + String.fromCharCode((codepoint % 0x400) + 0xDC00);
} else {
result += String.fromCharCode(codepoint);
}
}
return result;
}
/**
* StringToUtf32 - decodes UTF16 sequences into UTF32 codepoints.

@@ -77,35 +116,229 @@ * To keep the decoder in line with JS strings it handles single surrogates as UCS2.

/**
* Convert UTF32 codepoint into JS string.
* Utf8Decoder - decodes UTF8 byte sequences into UTF32 codepoints.
*/
export function stringFromCodePoint(codePoint: number): string {
if (codePoint > 0xFFFF) {
// UTF32 to UTF16 conversion (see comments in utf32ToString)
codePoint -= 0x10000;
return String.fromCharCode((codePoint >> 10) + 0xD800) + String.fromCharCode((codePoint % 0x400) + 0xDC00);
export class Utf8ToUtf32 {
public interim: Uint8Array = new Uint8Array(3);
/**
* Clears interim bytes and resets decoder to clean state.
*/
public clear(): void {
this.interim.fill(0);
}
return String.fromCharCode(codePoint);
}
/**
* Convert UTF32 char codes into JS string.
* Basically the same as `stringFromCodePoint` but for multiple codepoints
* in a loop (which is a lot faster).
*/
export function utf32ToString(data: Uint32Array, start: number = 0, end: number = data.length): string {
let result = '';
for (let i = start; i < end; ++i) {
let codepoint = data[i];
if (codepoint > 0xFFFF) {
// JS string are encoded as UTF16, thus a non BMP codepoint gets converted into a surrogate pair
// conversion rules:
// - subtract 0x10000 from code point, leaving a 20 bit number
// - add high 10 bits to 0xD800 --> first surrogate
// - add low 10 bits to 0xDC00 --> second surrogate
codepoint -= 0x10000;
result += String.fromCharCode((codepoint >> 10) + 0xD800) + String.fromCharCode((codepoint % 0x400) + 0xDC00);
} else {
result += String.fromCharCode(codepoint);
/**
* Decodes UTF8 byte sequences in `input` to UTF32 codepoints in `target`.
* The methods assumes stream input and will store partly transmitted bytes
* and decode them with the next data chunk.
* Note: The method does no bound checks for target, therefore make sure
* the provided data chunk does not exceed the size of `target`.
* Returns the number of written codepoints in `target`.
*/
decode(input: Uint8Array, target: Uint32Array): number {
const length = input.length;
if (!length) {
return 0;
}
let size = 0;
let byte1: number;
let byte2: number;
let byte3: number;
let byte4: number;
let codepoint = 0;
let startPos = 0;
// handle leftover bytes
if (this.interim[0]) {
let discardInterim = false;
let cp = this.interim[0];
cp &= ((((cp & 0xE0) === 0xC0)) ? 0x1F : (((cp & 0xF0) === 0xE0)) ? 0x0F : 0x07);
let pos = 0;
let tmp: number;
while ((tmp = this.interim[++pos] & 0x3F) && pos < 4) {
cp <<= 6;
cp |= tmp;
}
// missing bytes - read ahead from input
const type = (((this.interim[0] & 0xE0) === 0xC0)) ? 2 : (((this.interim[0] & 0xF0) === 0xE0)) ? 3 : 4;
const missing = type - pos;
while (startPos < missing) {
if (startPos >= length) {
return 0;
}
tmp = input[startPos++];
if ((tmp & 0xC0) !== 0x80) {
// wrong continuation, discard interim bytes completely
startPos--;
discardInterim = true;
break;
} else {
// need to save so we can continue short inputs in next call
this.interim[pos++] = tmp;
cp <<= 6;
cp |= tmp & 0x3F;
}
}
if (!discardInterim) {
// final test is type dependent
if (type === 2) {
if (cp < 0x80) {
// wrong starter byte
startPos--;
} else {
target[size++] = cp;
}
} else if (type === 3) {
if (cp < 0x0800 || (cp >= 0xD800 && cp <= 0xDFFF)) {
// illegal codepoint
} else {
target[size++] = cp;
}
} else {
if (codepoint < 0x010000 || codepoint > 0x10FFFF) {
// illegal codepoint
} else {
target[size++] = cp;
}
}
}
this.interim.fill(0);
}
// loop through input
const fourStop = length - 4;
let i = startPos;
while (i < length) {
/**
* ASCII shortcut with loop unrolled to 4 consecutive ASCII chars.
* This is a compromise between speed gain for ASCII
* and penalty for non ASCII:
* For best ASCII performance the char should be stored directly into target,
* but even a single attempt to write to target and compare afterwards
* penalizes non ASCII really bad (-50%), thus we load the char into byteX first,
* which reduces ASCII performance by ~15%.
* This trial for ASCII reduces non ASCII performance by ~10% which seems acceptible
* compared to the gains.
* Note that this optimization only takes place for 4 consecutive ASCII chars,
* for any shorter it bails out. Worst case - all 4 bytes being read but
* thrown away due to the last being a non ASCII char (-10% performance).
*/
while (i < fourStop
&& !((byte1 = input[i]) & 0x80)
&& !((byte2 = input[i + 1]) & 0x80)
&& !((byte3 = input[i + 2]) & 0x80)
&& !((byte4 = input[i + 3]) & 0x80))
{
target[size++] = byte1;
target[size++] = byte2;
target[size++] = byte3;
target[size++] = byte4;
i += 4;
}
// reread byte1
byte1 = input[i++];
// 1 byte
if (byte1 < 0x80) {
target[size++] = byte1;
// 2 bytes
} else if ((byte1 & 0xE0) === 0xC0) {
if (i >= length) {
this.interim[0] = byte1;
return size;
}
byte2 = input[i++];
if ((byte2 & 0xC0) !== 0x80) {
// wrong continuation
i--;
continue;
}
codepoint = (byte1 & 0x1F) << 6 | (byte2 & 0x3F);
if (codepoint < 0x80) {
// wrong starter byte
i--;
continue;
}
target[size++] = codepoint;
// 3 bytes
} else if ((byte1 & 0xF0) === 0xE0) {
if (i >= length) {
this.interim[0] = byte1;
return size;
}
byte2 = input[i++];
if ((byte2 & 0xC0) !== 0x80) {
// wrong continuation
i--;
continue;
}
if (i >= length) {
this.interim[0] = byte1;
this.interim[1] = byte2;
return size;
}
byte3 = input[i++];
if ((byte3 & 0xC0) !== 0x80) {
// wrong continuation
i--;
continue;
}
codepoint = (byte1 & 0x0F) << 12 | (byte2 & 0x3F) << 6 | (byte3 & 0x3F);
if (codepoint < 0x0800 || (codepoint >= 0xD800 && codepoint <= 0xDFFF)) {
// illegal codepoint, no i-- here
continue;
}
target[size++] = codepoint;
// 4 bytes
} else if ((byte1 & 0xF8) === 0xF0) {
if (i >= length) {
this.interim[0] = byte1;
return size;
}
byte2 = input[i++];
if ((byte2 & 0xC0) !== 0x80) {
// wrong continuation
i--;
continue;
}
if (i >= length) {
this.interim[0] = byte1;
this.interim[1] = byte2;
return size;
}
byte3 = input[i++];
if ((byte3 & 0xC0) !== 0x80) {
// wrong continuation
i--;
continue;
}
if (i >= length) {
this.interim[0] = byte1;
this.interim[1] = byte2;
this.interim[2] = byte3;
return size;
}
byte4 = input[i++];
if ((byte4 & 0xC0) !== 0x80) {
// wrong continuation
i--;
continue;
}
codepoint = (byte1 & 0x07) << 18 | (byte2 & 0x3F) << 12 | (byte3 & 0x3F) << 6 | (byte4 & 0x3F);
if (codepoint < 0x010000 || codepoint > 0x10FFFF) {
// illegal codepoint, no i-- here
continue;
}
target[size++] = codepoint;
} else {
// illegal byte, just skip
}
}
return size;
}
return result;
}

@@ -50,4 +50,5 @@ /**

window.term.write('bar');
window.term.write('文');
`);
assert.equal(await page.evaluate(`window.term.buffer.getLine(0).translateToString(true)`), 'foobar');
assert.equal(await page.evaluate(`window.term.buffer.getLine(0).translateToString(true)`), 'foobar文');
});

@@ -61,7 +62,23 @@

window.term.writeln('bar');
window.term.writeln('文');
`);
assert.equal(await page.evaluate(`window.term.buffer.getLine(0).translateToString(true)`), 'foo');
assert.equal(await page.evaluate(`window.term.buffer.getLine(1).translateToString(true)`), 'bar');
assert.equal(await page.evaluate(`window.term.buffer.getLine(2).translateToString(true)`), '文');
});
it('writeUtf8', async function(): Promise<any> {
this.timeout(10000);
await openTerminal();
await page.evaluate(`
// foo
window.term.writeUtf8(new Uint8Array([102, 111, 111]));
// bar
window.term.writeUtf8(new Uint8Array([98, 97, 114]));
// 文
window.term.writeUtf8(new Uint8Array([230, 150, 135]));
`);
assert.equal(await page.evaluate(`window.term.buffer.getLine(0).translateToString(true)`), 'foobar文');
});
it('clear', async function(): Promise<any> {

@@ -68,0 +85,0 @@ this.timeout(10000);

@@ -148,2 +148,5 @@ /**

}
public writeUtf8(data: Uint8Array): void {
this._core.writeUtf8(data);
}
public getOption(key: 'bellSound' | 'bellStyle' | 'cursorStyle' | 'fontFamily' | 'fontWeight' | 'fontWeightBold' | 'rendererType' | 'termName'): string;

@@ -150,0 +153,0 @@ public getOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'debug' | 'disableStdin' | 'enableBold' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'screenKeys' | 'useFlowControl' | 'visualBell'): boolean;

@@ -106,2 +106,3 @@ /**

parse(data: string): void;
parseUtf8(data: Uint8Array): void;
print(data: Uint32Array, start: number, end: number): void;

@@ -269,2 +270,3 @@

write(data: string): void;
writeUtf8(data: Uint8Array): void;
getOption(key: string): any;

@@ -271,0 +273,0 @@ setOption(key: string, value: any): void;

@@ -557,8 +557,2 @@ /**

/**
* Writes text to the terminal, followed by a break line character (\n).
* @param data The text to write to the terminal.
*/
writeln(data: string): void;
/**
* Opens the terminal within an element.

@@ -763,2 +757,16 @@ * @param parent The element to create the terminal within. This element

/**
* Writes text to the terminal, followed by a break line character (\n).
* @param data The text to write to the terminal.
*/
writeln(data: string): void;
/**
* Writes UTF8 data to the terminal.
* This has a slight performance advantage over the string based write method
* due to lesser data conversions needed on the way from the pty to xterm.js.
* @param data The data to write to the terminal.
*/
writeUtf8(data: Uint8Array): void;
/**
* Retrieves an option's value from the terminal.

@@ -765,0 +773,0 @@ * @param key The option key.

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 not supported yet

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

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