@theia/core 1.78.0-next.19 → 1.78.0-next.23
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/browser/catalog.json +39 -0
- package/lib/browser/shell/application-shell.d.ts.map +1 -1
- package/lib/browser/shell/application-shell.js +13 -1
- package/lib/browser/shell/application-shell.js.map +1 -1
- package/lib/browser/shell/tab-bars.d.ts +71 -1
- package/lib/browser/shell/tab-bars.d.ts.map +1 -1
- package/lib/browser/shell/tab-bars.js +243 -8
- package/lib/browser/shell/tab-bars.js.map +1 -1
- package/lib/browser/shell/tab-bars.spec.js +382 -2
- package/lib/browser/shell/tab-bars.spec.js.map +1 -1
- package/lib/browser/widgets/widget.d.ts.map +1 -1
- package/lib/browser/widgets/widget.js +34 -1
- package/lib/browser/widgets/widget.js.map +1 -1
- package/lib/common/core-preferences.d.ts +1 -0
- package/lib/common/core-preferences.d.ts.map +1 -1
- package/lib/common/core-preferences.js +10 -0
- package/lib/common/core-preferences.js.map +1 -1
- package/lib/common/messaging/socket-write-buffer.d.ts +8 -2
- package/lib/common/messaging/socket-write-buffer.d.ts.map +1 -1
- package/lib/common/messaging/socket-write-buffer.js +18 -12
- package/lib/common/messaging/socket-write-buffer.js.map +1 -1
- package/lib/common/messaging/socket-write-buffer.spec.d.ts +2 -0
- package/lib/common/messaging/socket-write-buffer.spec.d.ts.map +1 -0
- package/lib/common/messaging/socket-write-buffer.spec.js +72 -0
- package/lib/common/messaging/socket-write-buffer.spec.js.map +1 -0
- package/package.json +4 -4
- package/src/browser/shell/application-shell.ts +14 -1
- package/src/browser/shell/tab-bars.spec.ts +431 -2
- package/src/browser/shell/tab-bars.ts +261 -9
- package/src/browser/style/tabs.css +58 -3
- package/src/browser/widgets/widget.ts +36 -1
- package/src/common/core-preferences.ts +11 -0
- package/src/common/messaging/socket-write-buffer.spec.ts +90 -0
- package/src/common/messaging/socket-write-buffer.ts +18 -14
|
@@ -21,38 +21,42 @@ import { WebSocket } from './web-socket-channel.js';
|
|
|
21
21
|
export class SocketWriteBuffer {
|
|
22
22
|
private static readonly DEFAULT_DISCONNECTED_BUFFER_SIZE = 100 * 1024;
|
|
23
23
|
|
|
24
|
-
protected
|
|
25
|
-
protected
|
|
24
|
+
protected bufferedMessages: Uint8Array[] = [];
|
|
25
|
+
protected bufferedBytes = 0;
|
|
26
26
|
|
|
27
27
|
protected get maxBufferSize(): number {
|
|
28
28
|
return SocketWriteBuffer.DEFAULT_DISCONNECTED_BUFFER_SIZE;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Stores a copy of `data`, so the caller can reuse its buffer before the next flush.
|
|
33
|
+
*/
|
|
31
34
|
buffer(data: Uint8Array): void {
|
|
32
35
|
this.ensureWriteBuffer(data.byteLength);
|
|
33
|
-
|
|
34
|
-
this.
|
|
36
|
+
// Not `data.slice()`: on a Node `Buffer` that returns a view of the same memory.
|
|
37
|
+
this.bufferedMessages.push(new Uint8Array(data));
|
|
38
|
+
this.bufferedBytes += data.byteLength;
|
|
35
39
|
}
|
|
36
40
|
|
|
37
41
|
protected ensureWriteBuffer(byteLength: number): void {
|
|
38
|
-
if (
|
|
39
|
-
this.disconnectedBuffer = new Uint8Array(this.maxBufferSize);
|
|
40
|
-
this.bufferWritePosition = 0;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (this.bufferWritePosition + byteLength > this.disconnectedBuffer.byteLength) {
|
|
42
|
+
if (this.bufferedBytes + byteLength > this.maxBufferSize) {
|
|
44
43
|
throw new Error(`Max disconnected buffer size exceeded by adding ${byteLength} bytes`);
|
|
45
44
|
}
|
|
46
45
|
}
|
|
47
46
|
|
|
47
|
+
/**
|
|
48
|
+
* Sends each buffered message on its own: the receiving side reads one message per socket message.
|
|
49
|
+
*/
|
|
48
50
|
flush(socket: WebSocket): void {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
const messages = this.bufferedMessages;
|
|
52
|
+
this.drain();
|
|
53
|
+
for (const message of messages) {
|
|
54
|
+
socket.send(message);
|
|
52
55
|
}
|
|
53
56
|
}
|
|
54
57
|
|
|
55
58
|
drain(): void {
|
|
56
|
-
this.
|
|
59
|
+
this.bufferedMessages = [];
|
|
60
|
+
this.bufferedBytes = 0;
|
|
57
61
|
}
|
|
58
62
|
}
|