@xterm/xterm 6.1.0-beta.246 → 6.1.0-beta.247
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/xterm.js +1 -1
- package/lib/xterm.js.map +1 -1
- package/lib/xterm.mjs +7 -7
- package/lib/xterm.mjs.map +3 -3
- package/package.json +2 -2
- package/src/common/Version.ts +1 -1
- package/src/common/input/WriteBuffer.ts +40 -8
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xterm/xterm",
|
|
3
3
|
"description": "Full xterm terminal, in your browser",
|
|
4
|
-
"version": "6.1.0-beta.
|
|
4
|
+
"version": "6.1.0-beta.247",
|
|
5
5
|
"main": "lib/xterm.js",
|
|
6
6
|
"module": "lib/xterm.mjs",
|
|
7
7
|
"style": "css/xterm.css",
|
|
@@ -111,5 +111,5 @@
|
|
|
111
111
|
"ws": "^8.2.3",
|
|
112
112
|
"xterm-benchmark": "^0.3.1"
|
|
113
113
|
},
|
|
114
|
-
"commit": "
|
|
114
|
+
"commit": "ec0c93fd5a62fb5c0b16e1cb110212b76efec03c"
|
|
115
115
|
}
|
package/src/common/Version.ts
CHANGED
|
@@ -4,11 +4,10 @@
|
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { TimeoutTimer } from 'common/Async';
|
|
8
|
+
import { Disposable, toDisposable } from 'common/Lifecycle';
|
|
8
9
|
import { Emitter } from 'common/Event';
|
|
9
10
|
|
|
10
|
-
declare const setTimeout: (handler: () => void, timeout?: number) => void;
|
|
11
|
-
|
|
12
11
|
const enum Constants {
|
|
13
12
|
/**
|
|
14
13
|
* Safety watermark to avoid memory exhaustion and browser engine crash on fast data input.
|
|
@@ -43,11 +42,18 @@ export class WriteBuffer extends Disposable {
|
|
|
43
42
|
private _syncCalls = 0;
|
|
44
43
|
private _didUserInput = false;
|
|
45
44
|
|
|
45
|
+
private readonly _innerWriteTimer = this._register(new TimeoutTimer());
|
|
46
46
|
private readonly _onWriteParsed = this._register(new Emitter<void>());
|
|
47
47
|
public readonly onWriteParsed = this._onWriteParsed.event;
|
|
48
48
|
|
|
49
49
|
constructor(private _action: (data: string | Uint8Array, promiseResult?: boolean) => void | Promise<boolean>) {
|
|
50
50
|
super();
|
|
51
|
+
this._register(toDisposable(() => {
|
|
52
|
+
this._writeBuffer.length = 0;
|
|
53
|
+
this._callbacks.length = 0;
|
|
54
|
+
this._pendingData = 0;
|
|
55
|
+
this._bufferOffset = 0;
|
|
56
|
+
}));
|
|
51
57
|
}
|
|
52
58
|
|
|
53
59
|
public handleUserInput(): void {
|
|
@@ -63,6 +69,9 @@ export class WriteBuffer extends Disposable {
|
|
|
63
69
|
* promises to resolve.
|
|
64
70
|
*/
|
|
65
71
|
public flushSync(): void {
|
|
72
|
+
if (this._store.isDisposed) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
66
75
|
// exit early if another sync write loop is active
|
|
67
76
|
if (this._isSyncWriting) {
|
|
68
77
|
return;
|
|
@@ -95,6 +104,9 @@ export class WriteBuffer extends Disposable {
|
|
|
95
104
|
* @deprecated Unreliable, to be removed soon.
|
|
96
105
|
*/
|
|
97
106
|
public writeSync(data: string | Uint8Array, maxSubsequentCalls?: number): void {
|
|
107
|
+
if (this._store.isDisposed) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
98
110
|
// stop writeSync recursions with maxSubsequentCalls argument
|
|
99
111
|
// This is dangerous to use as it will lose the current data chunk
|
|
100
112
|
// and return immediately.
|
|
@@ -138,6 +150,9 @@ export class WriteBuffer extends Disposable {
|
|
|
138
150
|
}
|
|
139
151
|
|
|
140
152
|
public write(data: string | Uint8Array, callback?: () => void): void {
|
|
153
|
+
if (this._store.isDisposed) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
141
156
|
if (this._pendingData > Constants.DISCARD_WATERMARK) {
|
|
142
157
|
throw new Error('write data discarded, use flow control to avoid losing data');
|
|
143
158
|
}
|
|
@@ -158,7 +173,7 @@ export class WriteBuffer extends Disposable {
|
|
|
158
173
|
return;
|
|
159
174
|
}
|
|
160
175
|
|
|
161
|
-
|
|
176
|
+
this._scheduleInnerWrite();
|
|
162
177
|
}
|
|
163
178
|
|
|
164
179
|
this._pendingData += data.length;
|
|
@@ -194,7 +209,17 @@ export class WriteBuffer extends Disposable {
|
|
|
194
209
|
*
|
|
195
210
|
* Note, for pure sync code `lastTime` and `promiseResult` have no meaning.
|
|
196
211
|
*/
|
|
212
|
+
private _scheduleInnerWrite(lastTime: number = 0, promiseResult: boolean = true): void {
|
|
213
|
+
if (this._store.isDisposed) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
this._innerWriteTimer.cancelAndSet(() => this._innerWrite(lastTime, promiseResult), 0);
|
|
217
|
+
}
|
|
218
|
+
|
|
197
219
|
protected _innerWrite(lastTime: number = 0, promiseResult: boolean = true): void {
|
|
220
|
+
if (this._store.isDisposed) {
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
198
223
|
const startTime = lastTime || performance.now();
|
|
199
224
|
while (this._writeBuffer.length > this._bufferOffset) {
|
|
200
225
|
const data = this._writeBuffer[this._bufferOffset];
|
|
@@ -223,9 +248,16 @@ export class WriteBuffer extends Disposable {
|
|
|
223
248
|
* responsibility to slice hard work), but we can at least schedule a screen update as we
|
|
224
249
|
* gain control.
|
|
225
250
|
*/
|
|
226
|
-
const continuation: (r: boolean) => void = (r: boolean) =>
|
|
227
|
-
|
|
228
|
-
|
|
251
|
+
const continuation: (r: boolean) => void = (r: boolean) => {
|
|
252
|
+
if (this._store.isDisposed) {
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
if (performance.now() - startTime >= Constants.WRITE_TIMEOUT_MS) {
|
|
256
|
+
this._scheduleInnerWrite(0, r);
|
|
257
|
+
} else {
|
|
258
|
+
this._innerWrite(startTime, r);
|
|
259
|
+
}
|
|
260
|
+
};
|
|
229
261
|
|
|
230
262
|
/**
|
|
231
263
|
* Optimization considerations:
|
|
@@ -272,7 +304,7 @@ export class WriteBuffer extends Disposable {
|
|
|
272
304
|
this._callbacks = this._callbacks.slice(this._bufferOffset);
|
|
273
305
|
this._bufferOffset = 0;
|
|
274
306
|
}
|
|
275
|
-
|
|
307
|
+
this._scheduleInnerWrite();
|
|
276
308
|
} else {
|
|
277
309
|
this._writeBuffer.length = 0;
|
|
278
310
|
this._callbacks.length = 0;
|