@illgrenoble/webx-client 0.9.0 → 1.0.0
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/dist/WebXClient.d.ts +148 -16
- package/dist/WebXClient.js +148 -22
- package/dist/WebXClient.js.map +1 -1
- package/dist/display/WebXCursor.d.ts +65 -0
- package/dist/display/WebXCursor.js +65 -0
- package/dist/display/WebXCursor.js.map +1 -1
- package/dist/display/WebXCursorFactory.d.ts +18 -0
- package/dist/display/WebXCursorFactory.js +39 -16
- package/dist/display/WebXCursorFactory.js.map +1 -1
- package/dist/display/WebXDisplay.d.ts +139 -8
- package/dist/display/WebXDisplay.js +140 -8
- package/dist/display/WebXDisplay.js.map +1 -1
- package/dist/display/WebXSubImage.d.ts +42 -11
- package/dist/display/WebXSubImage.js +18 -12
- package/dist/display/WebXSubImage.js.map +1 -1
- package/dist/display/WebXTextureFactory.d.ts +30 -0
- package/dist/display/WebXTextureFactory.js +56 -19
- package/dist/display/WebXTextureFactory.js.map +1 -1
- package/dist/display/WebXWindow.d.ts +152 -0
- package/dist/display/WebXWindow.js +152 -0
- package/dist/display/WebXWindow.js.map +1 -1
- package/dist/display/WebXWindowProperties.d.ts +31 -6
- package/dist/display/WebXWindowProperties.js +16 -9
- package/dist/display/WebXWindowProperties.js.map +1 -1
- package/dist/input/WebXKeyboard.d.ts +40 -5
- package/dist/input/WebXKeyboard.js +52 -14
- package/dist/input/WebXKeyboard.js.map +1 -1
- package/dist/input/WebXMouse.d.ts +9 -0
- package/dist/input/WebXMouse.js +9 -4
- package/dist/input/WebXMouse.js.map +1 -1
- package/dist/input/keyboard/WebXKeyEvent.d.ts +35 -3
- package/dist/input/keyboard/WebXKeyEvent.js +115 -3
- package/dist/input/keyboard/WebXKeyEvent.js.map +1 -1
- package/dist/input/keyboard/WebXKeyPressEvent.d.ts +25 -8
- package/dist/input/keyboard/WebXKeyPressEvent.js +29 -11
- package/dist/input/keyboard/WebXKeyPressEvent.js.map +1 -1
- package/dist/input/keyboard/WebXKeyUpEvent.d.ts +30 -9
- package/dist/input/keyboard/WebXKeyUpEvent.js +19 -16
- package/dist/input/keyboard/WebXKeyUpEvent.js.map +1 -1
- package/dist/input/keyboard/WebXKeyboardModifierState.d.ts +69 -8
- package/dist/input/keyboard/WebXKeyboardModifierState.js +69 -8
- package/dist/input/keyboard/WebXKeyboardModifierState.js.map +1 -1
- package/dist/input/keyboard/WebXKeyboardUtils.d.ts +18 -2
- package/dist/input/keyboard/WebXKeyboardUtils.js +18 -2
- package/dist/input/keyboard/WebXKeyboardUtils.js.map +1 -1
- package/dist/input/keyboard/WebXKeydownEvent.d.ts +26 -9
- package/dist/input/keyboard/WebXKeydownEvent.js +17 -22
- package/dist/input/keyboard/WebXKeydownEvent.js.map +1 -1
- package/dist/input/mouse/WebXMouseState.d.ts +113 -2
- package/dist/input/mouse/WebXMouseState.js +104 -2
- package/dist/input/mouse/WebXMouseState.js.map +1 -1
- package/dist/instruction/WebXConnectInstruction.d.ts +16 -1
- package/dist/instruction/WebXConnectInstruction.js +13 -1
- package/dist/instruction/WebXConnectInstruction.js.map +1 -1
- package/dist/instruction/WebXCursorImageInstruction.d.ts +15 -3
- package/dist/instruction/WebXCursorImageInstruction.js +12 -5
- package/dist/instruction/WebXCursorImageInstruction.js.map +1 -1
- package/dist/instruction/WebXDataAckInstruction.d.ts +22 -5
- package/dist/instruction/WebXDataAckInstruction.js +15 -9
- package/dist/instruction/WebXDataAckInstruction.js.map +1 -1
- package/dist/instruction/WebXImageInstruction.d.ts +14 -3
- package/dist/instruction/WebXImageInstruction.js +11 -7
- package/dist/instruction/WebXImageInstruction.js.map +1 -1
- package/dist/instruction/WebXInstruction.d.ts +26 -10
- package/dist/instruction/WebXInstruction.js +19 -25
- package/dist/instruction/WebXInstruction.js.map +1 -1
- package/dist/instruction/WebXInstructionResponse.d.ts +55 -2
- package/dist/instruction/WebXInstructionResponse.js +40 -2
- package/dist/instruction/WebXInstructionResponse.js.map +1 -1
- package/dist/instruction/WebXInstructionType.d.ts +40 -0
- package/dist/instruction/WebXInstructionType.js +40 -0
- package/dist/instruction/WebXInstructionType.js.map +1 -1
- package/dist/instruction/WebXKeyboardInstruction.d.ts +19 -6
- package/dist/instruction/WebXKeyboardInstruction.js +13 -14
- package/dist/instruction/WebXKeyboardInstruction.js.map +1 -1
- package/dist/instruction/WebXMouseInstruction.d.ts +24 -9
- package/dist/instruction/WebXMouseInstruction.js +15 -21
- package/dist/instruction/WebXMouseInstruction.js.map +1 -1
- package/dist/instruction/WebXPongInstruction.d.ts +15 -3
- package/dist/instruction/WebXPongInstruction.js +12 -5
- package/dist/instruction/WebXPongInstruction.js.map +1 -1
- package/dist/instruction/WebXQualityInstruction.d.ts +16 -4
- package/dist/instruction/WebXQualityInstruction.js +13 -8
- package/dist/instruction/WebXQualityInstruction.js.map +1 -1
- package/dist/instruction/WebXScreenInstruction.d.ts +8 -0
- package/dist/instruction/WebXScreenInstruction.js +8 -0
- package/dist/instruction/WebXScreenInstruction.js.map +1 -1
- package/dist/instruction/WebXWindowsInstruction.d.ts +9 -0
- package/dist/instruction/WebXWindowsInstruction.js +9 -0
- package/dist/instruction/WebXWindowsInstruction.js.map +1 -1
- package/dist/message/WebXCursorImageMessage.d.ts +42 -13
- package/dist/message/WebXCursorImageMessage.js +24 -25
- package/dist/message/WebXCursorImageMessage.js.map +1 -1
- package/dist/message/WebXImageMessage.d.ts +37 -11
- package/dist/message/WebXImageMessage.js +22 -21
- package/dist/message/WebXImageMessage.js.map +1 -1
- package/dist/message/WebXMessage.d.ts +22 -6
- package/dist/message/WebXMessage.js +15 -9
- package/dist/message/WebXMessage.js.map +1 -1
- package/dist/message/WebXMessageType.d.ts +35 -0
- package/dist/message/WebXMessageType.js +35 -0
- package/dist/message/WebXMessageType.js.map +1 -1
- package/dist/message/WebXMouseMessage.d.ts +27 -7
- package/dist/message/WebXMouseMessage.js +18 -13
- package/dist/message/WebXMouseMessage.js.map +1 -1
- package/dist/message/WebXPingMessage.d.ts +9 -0
- package/dist/message/WebXPingMessage.js +9 -0
- package/dist/message/WebXPingMessage.js.map +1 -1
- package/dist/message/WebXQualityMessage.d.ts +36 -11
- package/dist/message/WebXQualityMessage.js +21 -21
- package/dist/message/WebXQualityMessage.js.map +1 -1
- package/dist/message/WebXScreenMessage.d.ts +17 -3
- package/dist/message/WebXScreenMessage.js +14 -5
- package/dist/message/WebXScreenMessage.js.map +1 -1
- package/dist/message/WebXSubImagesMessage.d.ts +27 -7
- package/dist/message/WebXSubImagesMessage.js +18 -13
- package/dist/message/WebXSubImagesMessage.js.map +1 -1
- package/dist/message/WebXWindowsMessage.d.ts +17 -3
- package/dist/message/WebXWindowsMessage.js +14 -5
- package/dist/message/WebXWindowsMessage.js.map +1 -1
- package/dist/tracer/WebXDebugImageMessageHandler.d.ts +30 -0
- package/dist/tracer/WebXDebugImageMessageHandler.js +30 -0
- package/dist/tracer/WebXDebugImageMessageHandler.js.map +1 -1
- package/dist/tracer/WebXHandler.d.ts +11 -0
- package/dist/tracer/WebXInstructionHandler.d.ts +17 -0
- package/dist/tracer/WebXInstructionHandler.js +6 -0
- package/dist/tracer/WebXInstructionHandler.js.map +1 -1
- package/dist/tracer/WebXMessageHandler.d.ts +17 -0
- package/dist/tracer/WebXMessageHandler.js +6 -0
- package/dist/tracer/WebXMessageHandler.js.map +1 -1
- package/dist/tracer/WebXStatsHandler.d.ts +16 -0
- package/dist/tracer/WebXStatsHandler.js +6 -0
- package/dist/tracer/WebXStatsHandler.js.map +1 -1
- package/dist/transport/WebXBinarySerializer.d.ts +20 -0
- package/dist/transport/WebXBinarySerializer.js +20 -0
- package/dist/transport/WebXBinarySerializer.js.map +1 -1
- package/dist/transport/WebXInstructionBuffer.d.ts +19 -0
- package/dist/transport/WebXInstructionBuffer.js +19 -0
- package/dist/transport/WebXInstructionBuffer.js.map +1 -1
- package/dist/transport/WebXInstructionEncoder.d.ts +138 -0
- package/dist/transport/WebXInstructionEncoder.js +138 -110
- package/dist/transport/WebXInstructionEncoder.js.map +1 -1
- package/dist/transport/WebXMessageBuffer.d.ts +63 -8
- package/dist/transport/WebXMessageBuffer.js +51 -16
- package/dist/transport/WebXMessageBuffer.js.map +1 -1
- package/dist/transport/WebXMessageDecoder.d.ts +69 -0
- package/dist/transport/WebXMessageDecoder.js +96 -18
- package/dist/transport/WebXMessageDecoder.js.map +1 -1
- package/dist/tunnel/WebXTunnel.d.ts +71 -0
- package/dist/tunnel/WebXTunnel.js +51 -4
- package/dist/tunnel/WebXTunnel.js.map +1 -1
- package/dist/tunnel/WebXWebSocketTunnel.d.ts +26 -0
- package/dist/tunnel/WebXWebSocketTunnel.js +26 -0
- package/dist/tunnel/WebXWebSocketTunnel.js.map +1 -1
- package/dist/utils/ColorGenerator.d.ts +19 -0
- package/dist/utils/ColorGenerator.js +19 -0
- package/dist/utils/ColorGenerator.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,21 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a buffer for encoding and decoding WebX messages.
|
|
3
|
+
*
|
|
4
|
+
* This class provides methods to write and read data in a structured format
|
|
5
|
+
* for communication with the WebX Engine.
|
|
6
|
+
*/
|
|
1
7
|
export declare class WebXMessageBuffer {
|
|
2
8
|
private _buffer;
|
|
9
|
+
/**
|
|
10
|
+
* The length of the message header in bytes.
|
|
11
|
+
*/
|
|
3
12
|
static readonly MESSAGE_HEADER_LENGTH = 48;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
13
|
+
/**
|
|
14
|
+
* The timestamp in milliseconds when the message was created.
|
|
15
|
+
*/
|
|
16
|
+
readonly timestampMs: Uint8Array;
|
|
17
|
+
/**
|
|
18
|
+
* The type ID of the message.
|
|
19
|
+
*/
|
|
20
|
+
readonly messageTypeId: number;
|
|
21
|
+
/**
|
|
22
|
+
* The unique ID of the message.
|
|
23
|
+
*/
|
|
24
|
+
readonly messageId: number;
|
|
25
|
+
/**
|
|
26
|
+
* The total length of the buffer in bytes.
|
|
27
|
+
*/
|
|
28
|
+
readonly bufferLength: number;
|
|
8
29
|
private _readOffset;
|
|
9
30
|
private _encoder;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Creates a new instance of WebXMessageBuffer.
|
|
33
|
+
*
|
|
34
|
+
* @param _buffer The buffer to read from.
|
|
35
|
+
*/
|
|
14
36
|
constructor(_buffer: ArrayBuffer);
|
|
37
|
+
/**
|
|
38
|
+
* Reads a 32-bit signed integer from the buffer.
|
|
39
|
+
*
|
|
40
|
+
* @returns The read value.
|
|
41
|
+
*/
|
|
15
42
|
getInt32(): number;
|
|
43
|
+
/**
|
|
44
|
+
* Reads a 32-bit unsigned integer from the buffer.
|
|
45
|
+
*
|
|
46
|
+
* @returns The read value.
|
|
47
|
+
*/
|
|
16
48
|
getUint32(): number;
|
|
49
|
+
/**
|
|
50
|
+
* Reads a 32-bit floating point number from the buffer.
|
|
51
|
+
*
|
|
52
|
+
* @returns The read value.
|
|
53
|
+
*/
|
|
17
54
|
getFloat(): number;
|
|
55
|
+
/**
|
|
56
|
+
* Reads a Uint8Array from the buffer.
|
|
57
|
+
*
|
|
58
|
+
* @param length The length of the array to read.
|
|
59
|
+
* @returns The read Uint8Array.
|
|
60
|
+
*/
|
|
18
61
|
getUint8Array(length: number): Uint8Array;
|
|
62
|
+
/**
|
|
63
|
+
* Reads a string from the buffer.
|
|
64
|
+
*
|
|
65
|
+
* @param length The length of the string to read.
|
|
66
|
+
* @returns The read string.
|
|
67
|
+
*/
|
|
19
68
|
getString(length: number): string;
|
|
69
|
+
/**
|
|
70
|
+
* Calculates the next read offset, ensuring alignment.
|
|
71
|
+
*
|
|
72
|
+
* @param sizeOfData The size of the data to read.
|
|
73
|
+
* @returns The next read offset.
|
|
74
|
+
*/
|
|
20
75
|
private _getNextReadOffset;
|
|
21
76
|
}
|
|
@@ -1,55 +1,87 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WebXMessageBuffer = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Represents a buffer for encoding and decoding WebX messages.
|
|
6
|
+
*
|
|
7
|
+
* This class provides methods to write and read data in a structured format
|
|
8
|
+
* for communication with the WebX Engine.
|
|
9
|
+
*/
|
|
4
10
|
class WebXMessageBuffer {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
get messageId() {
|
|
12
|
-
return this._messageId;
|
|
13
|
-
}
|
|
14
|
-
get bufferLength() {
|
|
15
|
-
return this._bufferLength;
|
|
16
|
-
}
|
|
11
|
+
/**
|
|
12
|
+
* Creates a new instance of WebXMessageBuffer.
|
|
13
|
+
*
|
|
14
|
+
* @param _buffer The buffer to read from.
|
|
15
|
+
*/
|
|
17
16
|
constructor(_buffer) {
|
|
18
17
|
this._buffer = _buffer;
|
|
19
18
|
this._readOffset = 24;
|
|
20
19
|
this._encoder = new TextDecoder('utf-8');
|
|
21
20
|
this._readOffset = 24; // Session Id (16) and client index mask (8)
|
|
22
|
-
this.
|
|
23
|
-
this.
|
|
24
|
-
this.
|
|
25
|
-
this.
|
|
21
|
+
this.timestampMs = this.getUint8Array(8);
|
|
22
|
+
this.messageTypeId = this.getUint32();
|
|
23
|
+
this.messageId = this.getUint32();
|
|
24
|
+
this.bufferLength = this.getUint32();
|
|
26
25
|
this._readOffset = WebXMessageBuffer.MESSAGE_HEADER_LENGTH;
|
|
27
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Reads a 32-bit signed integer from the buffer.
|
|
29
|
+
*
|
|
30
|
+
* @returns The read value.
|
|
31
|
+
*/
|
|
28
32
|
getInt32() {
|
|
29
33
|
const offset = this._getNextReadOffset(4);
|
|
30
34
|
const typedArray = new Int32Array(this._buffer, offset, 1);
|
|
31
35
|
return typedArray[0];
|
|
32
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Reads a 32-bit unsigned integer from the buffer.
|
|
39
|
+
*
|
|
40
|
+
* @returns The read value.
|
|
41
|
+
*/
|
|
33
42
|
getUint32() {
|
|
34
43
|
const offset = this._getNextReadOffset(4);
|
|
35
44
|
const typedArray = new Uint32Array(this._buffer, offset, 1);
|
|
36
45
|
return typedArray[0];
|
|
37
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Reads a 32-bit floating point number from the buffer.
|
|
49
|
+
*
|
|
50
|
+
* @returns The read value.
|
|
51
|
+
*/
|
|
38
52
|
getFloat() {
|
|
39
53
|
const offset = this._getNextReadOffset(4);
|
|
40
54
|
const typedArray = new Float32Array(this._buffer, offset, 1);
|
|
41
55
|
return typedArray[0];
|
|
42
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Reads a Uint8Array from the buffer.
|
|
59
|
+
*
|
|
60
|
+
* @param length The length of the array to read.
|
|
61
|
+
* @returns The read Uint8Array.
|
|
62
|
+
*/
|
|
43
63
|
getUint8Array(length) {
|
|
44
64
|
const typedArray = new Uint8Array(this._buffer, this._readOffset, length);
|
|
45
65
|
this._readOffset += length;
|
|
46
66
|
return typedArray;
|
|
47
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* Reads a string from the buffer.
|
|
70
|
+
*
|
|
71
|
+
* @param length The length of the string to read.
|
|
72
|
+
* @returns The read string.
|
|
73
|
+
*/
|
|
48
74
|
getString(length) {
|
|
49
75
|
const array = new Uint8Array(this._buffer, this._readOffset, length);
|
|
50
76
|
this._readOffset += length;
|
|
51
77
|
return this._encoder.decode(array);
|
|
52
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* Calculates the next read offset, ensuring alignment.
|
|
81
|
+
*
|
|
82
|
+
* @param sizeOfData The size of the data to read.
|
|
83
|
+
* @returns The next read offset.
|
|
84
|
+
*/
|
|
53
85
|
_getNextReadOffset(sizeOfData) {
|
|
54
86
|
// Ensure alignment
|
|
55
87
|
const padding = this._readOffset % sizeOfData > 0 ? sizeOfData - (this._readOffset % sizeOfData) : 0;
|
|
@@ -59,5 +91,8 @@ class WebXMessageBuffer {
|
|
|
59
91
|
}
|
|
60
92
|
}
|
|
61
93
|
exports.WebXMessageBuffer = WebXMessageBuffer;
|
|
94
|
+
/**
|
|
95
|
+
* The length of the message header in bytes.
|
|
96
|
+
*/
|
|
62
97
|
WebXMessageBuffer.MESSAGE_HEADER_LENGTH = 48;
|
|
63
98
|
//# sourceMappingURL=WebXMessageBuffer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebXMessageBuffer.js","sourceRoot":"","sources":["../../src/transport/WebXMessageBuffer.ts"],"names":[],"mappings":";;;AAAA,MAAa,iBAAiB;
|
|
1
|
+
{"version":3,"file":"WebXMessageBuffer.js","sourceRoot":"","sources":["../../src/transport/WebXMessageBuffer.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,MAAa,iBAAiB;IA6B5B;;;;OAIG;IACH,YAAoB,OAAoB;QAApB,YAAO,GAAP,OAAO,CAAa;QARhC,gBAAW,GAAW,EAAE,CAAC;QACzB,aAAQ,GAAgB,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC;QAQvD,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC,CAAC,4CAA4C;QACnE,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;QACzC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QACtC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QAClC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QACrC,IAAI,CAAC,WAAW,GAAG,iBAAiB,CAAC,qBAAqB,CAAC;IAC7D,CAAC;IAED;;;;OAIG;IACI,QAAQ;QACb,MAAM,MAAM,GAAG,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;QAC1C,MAAM,UAAU,GAAG,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AG,CAAC,CAAC,CAAC,CAAC,UAAU,GAAG,CAAC,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACrG,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC;QAE5C,IAAI,CAAC,WAAW,IAAI,UAAU,GAAG,OAAO,CAAC;QAEzC,OAAO,QAAQ,CAAC;IAClB,CAAC;;AAlHH,8CAmHC;AAlHC;;GAEG;AACoB,uCAAqB,GAAG,EAAE,AAAL,CAAM"}
|
|
@@ -1,17 +1,86 @@
|
|
|
1
1
|
import { WebXMessage } from '../message';
|
|
2
2
|
import { WebXTextureFactory } from '../display';
|
|
3
3
|
import { WebXMessageBuffer } from './WebXMessageBuffer';
|
|
4
|
+
/**
|
|
5
|
+
* Decodes binary messages received from the WebX Engine into WebXMessage objects.
|
|
6
|
+
* This class handles various message types and converts them into their respective
|
|
7
|
+
* WebXMessage implementations.
|
|
8
|
+
*/
|
|
4
9
|
export declare class WebXMessageDecoder {
|
|
5
10
|
private _textureFactory;
|
|
11
|
+
/**
|
|
12
|
+
* Creates a new instance of WebXMessageDecoder.
|
|
13
|
+
*
|
|
14
|
+
* @param _textureFactory The texture factory used to create textures from image data.
|
|
15
|
+
*/
|
|
6
16
|
constructor(_textureFactory: WebXTextureFactory);
|
|
17
|
+
/**
|
|
18
|
+
* Decodes a binary message buffer into a WebXMessage object.
|
|
19
|
+
*
|
|
20
|
+
* @param buffer The binary message buffer to decode.
|
|
21
|
+
* @returns A promise that resolves to the decoded WebXMessage.
|
|
22
|
+
*/
|
|
7
23
|
decode(buffer: WebXMessageBuffer): Promise<WebXMessage>;
|
|
24
|
+
/**
|
|
25
|
+
* Determines the MIME type of an image based on its type string.
|
|
26
|
+
*
|
|
27
|
+
* @param imageType The image type string (e.g., 'jpg', 'png').
|
|
28
|
+
* @returns The corresponding MIME type.
|
|
29
|
+
*/
|
|
8
30
|
private _determineMimeType;
|
|
31
|
+
/**
|
|
32
|
+
* Decodes a buffer into a WebXImageMessage.
|
|
33
|
+
*
|
|
34
|
+
* @param buffer The binary message buffer to decode.
|
|
35
|
+
* @returns A promise that resolves to a WebXImageMessage.
|
|
36
|
+
*/
|
|
9
37
|
private _createImageMessage;
|
|
38
|
+
/**
|
|
39
|
+
* Decodes a buffer into a WebXSubImagesMessage containing multiple sub-images.
|
|
40
|
+
*
|
|
41
|
+
* @param buffer The binary message buffer to decode.
|
|
42
|
+
* @returns A promise that resolves to a WebXSubImagesMessage.
|
|
43
|
+
*/
|
|
10
44
|
private _createSubImagesMessage;
|
|
45
|
+
/**
|
|
46
|
+
* Decodes a buffer into a WebXMouseMessage, which contains mouse position and cursor ID.
|
|
47
|
+
*
|
|
48
|
+
* @param buffer The binary message buffer to decode.
|
|
49
|
+
* @returns A promise that resolves to a WebXMouseMessage.
|
|
50
|
+
*/
|
|
11
51
|
private _createMouseMessage;
|
|
52
|
+
/**
|
|
53
|
+
* Decodes a buffer into a WebXWindowsMessage, which contains information about multiple windows.
|
|
54
|
+
*
|
|
55
|
+
* @param buffer The binary message buffer to decode.
|
|
56
|
+
* @returns A promise that resolves to a WebXWindowsMessage.
|
|
57
|
+
*/
|
|
12
58
|
private _createWindowsMessage;
|
|
59
|
+
/**
|
|
60
|
+
* Decodes a buffer into a WebXCursorImageMessage, which contains cursor image data.
|
|
61
|
+
*
|
|
62
|
+
* @param buffer The binary message buffer to decode.
|
|
63
|
+
* @returns A promise that resolves to a WebXCursorImageMessage.
|
|
64
|
+
*/
|
|
13
65
|
private _createCursorImageMessage;
|
|
66
|
+
/**
|
|
67
|
+
* Decodes a buffer into a WebXScreenMessage, which contains screen dimensions.
|
|
68
|
+
*
|
|
69
|
+
* @param buffer The binary message buffer to decode.
|
|
70
|
+
* @returns A promise that resolves to a WebXScreenMessage.
|
|
71
|
+
*/
|
|
14
72
|
private _createScreenMessage;
|
|
73
|
+
/**
|
|
74
|
+
* Creates a WebXPingMessage, which is used for pinging purposes.
|
|
75
|
+
*
|
|
76
|
+
* @returns A promise that resolves to a WebXPingMessage.
|
|
77
|
+
*/
|
|
15
78
|
private _createPingMessage;
|
|
79
|
+
/**
|
|
80
|
+
* Decodes a buffer into a WebXQualityMessage, which contains quality metrics.
|
|
81
|
+
*
|
|
82
|
+
* @param buffer The binary message buffer to decode.
|
|
83
|
+
* @returns A promise that resolves to a WebXQualityMessage.
|
|
84
|
+
*/
|
|
16
85
|
private _createQualityMessage;
|
|
17
86
|
}
|
|
@@ -1,12 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.WebXMessageDecoder = void 0;
|
|
4
13
|
const message_1 = require("../message");
|
|
5
14
|
const display_1 = require("../display");
|
|
15
|
+
/**
|
|
16
|
+
* Decodes binary messages received from the WebX Engine into WebXMessage objects.
|
|
17
|
+
* This class handles various message types and converts them into their respective
|
|
18
|
+
* WebXMessage implementations.
|
|
19
|
+
*/
|
|
6
20
|
class WebXMessageDecoder {
|
|
21
|
+
/**
|
|
22
|
+
* Creates a new instance of WebXMessageDecoder.
|
|
23
|
+
*
|
|
24
|
+
* @param _textureFactory The texture factory used to create textures from image data.
|
|
25
|
+
*/
|
|
7
26
|
constructor(_textureFactory) {
|
|
8
27
|
this._textureFactory = _textureFactory;
|
|
9
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Decodes a binary message buffer into a WebXMessage object.
|
|
31
|
+
*
|
|
32
|
+
* @param buffer The binary message buffer to decode.
|
|
33
|
+
* @returns A promise that resolves to the decoded WebXMessage.
|
|
34
|
+
*/
|
|
10
35
|
decode(buffer) {
|
|
11
36
|
const { messageTypeId } = buffer;
|
|
12
37
|
if (messageTypeId === message_1.WebXMessageType.SCREEN) {
|
|
@@ -35,6 +60,12 @@ class WebXMessageDecoder {
|
|
|
35
60
|
}
|
|
36
61
|
console.error(`Failed to decode message with typeId ${messageTypeId}`);
|
|
37
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Determines the MIME type of an image based on its type string.
|
|
65
|
+
*
|
|
66
|
+
* @param imageType The image type string (e.g., 'jpg', 'png').
|
|
67
|
+
* @returns The corresponding MIME type.
|
|
68
|
+
*/
|
|
38
69
|
_determineMimeType(imageType) {
|
|
39
70
|
if (imageType.substr(0, 3) === 'jpg') {
|
|
40
71
|
return 'image/jpeg';
|
|
@@ -44,6 +75,12 @@ class WebXMessageDecoder {
|
|
|
44
75
|
}
|
|
45
76
|
return 'image/bmp';
|
|
46
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Decodes a buffer into a WebXImageMessage.
|
|
80
|
+
*
|
|
81
|
+
* @param buffer The binary message buffer to decode.
|
|
82
|
+
* @returns A promise that resolves to a WebXImageMessage.
|
|
83
|
+
*/
|
|
47
84
|
_createImageMessage(buffer) {
|
|
48
85
|
return new Promise((resolve) => {
|
|
49
86
|
const commandId = buffer.getUint32();
|
|
@@ -63,6 +100,12 @@ class WebXMessageDecoder {
|
|
|
63
100
|
});
|
|
64
101
|
});
|
|
65
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* Decodes a buffer into a WebXSubImagesMessage containing multiple sub-images.
|
|
105
|
+
*
|
|
106
|
+
* @param buffer The binary message buffer to decode.
|
|
107
|
+
* @returns A promise that resolves to a WebXSubImagesMessage.
|
|
108
|
+
*/
|
|
66
109
|
_createSubImagesMessage(buffer) {
|
|
67
110
|
return new Promise((resolve) => {
|
|
68
111
|
const commandId = buffer.getUint32();
|
|
@@ -97,17 +140,29 @@ class WebXMessageDecoder {
|
|
|
97
140
|
});
|
|
98
141
|
});
|
|
99
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* Decodes a buffer into a WebXMouseMessage, which contains mouse position and cursor ID.
|
|
145
|
+
*
|
|
146
|
+
* @param buffer The binary message buffer to decode.
|
|
147
|
+
* @returns A promise that resolves to a WebXMouseMessage.
|
|
148
|
+
*/
|
|
100
149
|
_createMouseMessage(buffer) {
|
|
101
|
-
return
|
|
150
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
102
151
|
const commandId = buffer.getUint32();
|
|
103
152
|
const x = buffer.getInt32();
|
|
104
153
|
const y = buffer.getInt32();
|
|
105
154
|
const cursorId = buffer.getUint32();
|
|
106
|
-
|
|
155
|
+
return new message_1.WebXMouseMessage(x, y, cursorId, commandId);
|
|
107
156
|
});
|
|
108
157
|
}
|
|
158
|
+
/**
|
|
159
|
+
* Decodes a buffer into a WebXWindowsMessage, which contains information about multiple windows.
|
|
160
|
+
*
|
|
161
|
+
* @param buffer The binary message buffer to decode.
|
|
162
|
+
* @returns A promise that resolves to a WebXWindowsMessage.
|
|
163
|
+
*/
|
|
109
164
|
_createWindowsMessage(buffer) {
|
|
110
|
-
return
|
|
165
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
111
166
|
const commandId = buffer.getUint32();
|
|
112
167
|
const numberOfWindows = buffer.getUint32();
|
|
113
168
|
const windows = new Array();
|
|
@@ -119,11 +174,17 @@ class WebXMessageDecoder {
|
|
|
119
174
|
const height = buffer.getInt32();
|
|
120
175
|
windows.push(new display_1.WebXWindowProperties({ id: windowId, x: x, y: y, width: width, height: height }));
|
|
121
176
|
}
|
|
122
|
-
|
|
177
|
+
return new message_1.WebXWindowsMessage(windows, commandId);
|
|
123
178
|
});
|
|
124
179
|
}
|
|
180
|
+
/**
|
|
181
|
+
* Decodes a buffer into a WebXCursorImageMessage, which contains cursor image data.
|
|
182
|
+
*
|
|
183
|
+
* @param buffer The binary message buffer to decode.
|
|
184
|
+
* @returns A promise that resolves to a WebXCursorImageMessage.
|
|
185
|
+
*/
|
|
125
186
|
_createCursorImageMessage(buffer) {
|
|
126
|
-
return
|
|
187
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
127
188
|
const commandId = buffer.getUint32();
|
|
128
189
|
const x = buffer.getInt32();
|
|
129
190
|
const y = buffer.getInt32();
|
|
@@ -132,36 +193,53 @@ class WebXMessageDecoder {
|
|
|
132
193
|
const cursorId = buffer.getUint32();
|
|
133
194
|
const imageDataSize = buffer.getUint32();
|
|
134
195
|
const imageData = buffer.getUint8Array(imageDataSize);
|
|
135
|
-
|
|
136
|
-
.
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
console.error(
|
|
141
|
-
}
|
|
196
|
+
try {
|
|
197
|
+
const texture = yield this._textureFactory.createTextureFromArray(imageData, 'image/png');
|
|
198
|
+
return new message_1.WebXCursorImageMessage(x, y, xHot, yHot, cursorId, texture, commandId);
|
|
199
|
+
}
|
|
200
|
+
catch (error) {
|
|
201
|
+
console.error(`Failed to get texture for cursor image: ${error}`);
|
|
202
|
+
}
|
|
142
203
|
});
|
|
143
204
|
}
|
|
205
|
+
/**
|
|
206
|
+
* Decodes a buffer into a WebXScreenMessage, which contains screen dimensions.
|
|
207
|
+
*
|
|
208
|
+
* @param buffer The binary message buffer to decode.
|
|
209
|
+
* @returns A promise that resolves to a WebXScreenMessage.
|
|
210
|
+
*/
|
|
144
211
|
_createScreenMessage(buffer) {
|
|
145
|
-
return
|
|
212
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
146
213
|
const commandId = buffer.getUint32();
|
|
147
214
|
const screenWidth = buffer.getInt32();
|
|
148
215
|
const screenHeight = buffer.getInt32();
|
|
149
|
-
|
|
216
|
+
return new message_1.WebXScreenMessage({ width: screenWidth, height: screenHeight }, commandId);
|
|
150
217
|
});
|
|
151
218
|
}
|
|
219
|
+
/**
|
|
220
|
+
* Creates a WebXPingMessage, which is used for pinging purposes.
|
|
221
|
+
*
|
|
222
|
+
* @returns A promise that resolves to a WebXPingMessage.
|
|
223
|
+
*/
|
|
152
224
|
_createPingMessage() {
|
|
153
|
-
return
|
|
154
|
-
|
|
225
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
226
|
+
return new message_1.WebXPingMessage();
|
|
155
227
|
});
|
|
156
228
|
}
|
|
229
|
+
/**
|
|
230
|
+
* Decodes a buffer into a WebXQualityMessage, which contains quality metrics.
|
|
231
|
+
*
|
|
232
|
+
* @param buffer The binary message buffer to decode.
|
|
233
|
+
* @returns A promise that resolves to a WebXQualityMessage.
|
|
234
|
+
*/
|
|
157
235
|
_createQualityMessage(buffer) {
|
|
158
|
-
return
|
|
236
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
159
237
|
const index = buffer.getUint32();
|
|
160
238
|
const imageFPS = buffer.getFloat();
|
|
161
239
|
const rgbQuality = buffer.getFloat();
|
|
162
240
|
const alphaQuality = buffer.getFloat();
|
|
163
241
|
const maxMbps = buffer.getFloat();
|
|
164
|
-
|
|
242
|
+
return new message_1.WebXQualityMessage(index, imageFPS, rgbQuality, alphaQuality, maxMbps);
|
|
165
243
|
});
|
|
166
244
|
}
|
|
167
245
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebXMessageDecoder.js","sourceRoot":"","sources":["../../src/transport/WebXMessageDecoder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"WebXMessageDecoder.js","sourceRoot":"","sources":["../../src/transport/WebXMessageDecoder.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wCAUoB;AACpB,wCAAoF;AAGpF;;;;GAIG;AACH,MAAa,kBAAkB;IAC7B;;;;OAIG;IACH,YAAoB,eAAmC;QAAnC,oBAAe,GAAf,eAAe,CAAoB;IAAG,CAAC;I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AAM,UAAU,GAAW,MAAM,CAAC,QAAQ,EAAE,CAAC;YAC7C,MAAM,YAAY,GAAW,MAAM,CAAC,QAAQ,EAAE,CAAC;YAC/C,MAAM,OAAO,GAAW,MAAM,CAAC,QAAQ,EAAE,CAAC;YAC1C,OAAO,IAAI,4BAAkB,CAAC,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;QACpF,CAAC;KAAA;CAEF;AAvOD,gDAuOC"}
|
|
@@ -1,22 +1,93 @@
|
|
|
1
1
|
import { WebXInstruction } from '../instruction';
|
|
2
2
|
import { WebXMessage } from '../message';
|
|
3
3
|
import { WebXBinarySerializer } from '../transport';
|
|
4
|
+
/**
|
|
5
|
+
* Represents a communication tunnel between the WebX client and the WebX Engine.
|
|
6
|
+
*
|
|
7
|
+
* This class handles sending and receiving data, managing the connection state,
|
|
8
|
+
* and processing responses from the WebX Engine.
|
|
9
|
+
*/
|
|
4
10
|
export declare abstract class WebXTunnel {
|
|
5
11
|
private static readonly MIN_BUFFER_LENGTH_FOR_ACK;
|
|
6
12
|
protected _serializer: WebXBinarySerializer;
|
|
7
13
|
private _instructionResponses;
|
|
8
14
|
protected constructor();
|
|
15
|
+
/**
|
|
16
|
+
* Establishes a connection to the WebX Engine.
|
|
17
|
+
*
|
|
18
|
+
* @param data The data required to establish the connection.
|
|
19
|
+
* @param serializer The serializer to use for encoding/decoding messages.
|
|
20
|
+
* @returns A promise that resolves when the connection is successfully established.
|
|
21
|
+
*/
|
|
9
22
|
abstract connect(data: any, serializer: WebXBinarySerializer): Promise<Event>;
|
|
23
|
+
/**
|
|
24
|
+
* Closes the connection to the WebX Engine.
|
|
25
|
+
*/
|
|
10
26
|
abstract disconnect(): void;
|
|
27
|
+
/**
|
|
28
|
+
* Sends data to the WebX Engine.
|
|
29
|
+
*
|
|
30
|
+
* @param data The data to send.
|
|
31
|
+
*/
|
|
11
32
|
abstract send(data: ArrayBuffer): void;
|
|
33
|
+
/**
|
|
34
|
+
* Checks if the tunnel is currently connected.
|
|
35
|
+
*
|
|
36
|
+
* @returns True if the tunnel is connected, false otherwise.
|
|
37
|
+
*/
|
|
12
38
|
abstract isConnected(): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Sends an instruction to the WebX Engine.
|
|
41
|
+
*
|
|
42
|
+
* @param command The instruction to send.
|
|
43
|
+
*/
|
|
13
44
|
sendInstruction(command: WebXInstruction): void;
|
|
45
|
+
/**
|
|
46
|
+
* Sends a request to the WebX Engine and waits for a response.
|
|
47
|
+
*
|
|
48
|
+
* @param command The request to send.
|
|
49
|
+
* @param timeout The timeout in milliseconds to wait for a response.
|
|
50
|
+
* @returns A promise that resolves with the response from the WebX Engine.
|
|
51
|
+
*/
|
|
14
52
|
sendRequest(command: WebXInstruction, timeout?: number): Promise<WebXMessage>;
|
|
53
|
+
/**
|
|
54
|
+
* Handles incoming messages from the WebX Engine.
|
|
55
|
+
*
|
|
56
|
+
* @param data The received data.
|
|
57
|
+
*/
|
|
15
58
|
protected onMessage(data: ArrayBuffer): Promise<void>;
|
|
59
|
+
/**
|
|
60
|
+
* Handles a received message from the WebX Engine.
|
|
61
|
+
*
|
|
62
|
+
* @param message The received message.
|
|
63
|
+
*/
|
|
16
64
|
handleMessage(message: WebXMessage): void;
|
|
65
|
+
/**
|
|
66
|
+
* Handles received bytes from the WebX Engine.
|
|
67
|
+
*
|
|
68
|
+
* @param data The received data.
|
|
69
|
+
*/
|
|
17
70
|
handleReceivedBytes(data: ArrayBuffer): void;
|
|
71
|
+
/**
|
|
72
|
+
* Handles sent bytes to the WebX Engine.
|
|
73
|
+
*
|
|
74
|
+
* @param data The sent data.
|
|
75
|
+
*/
|
|
18
76
|
handleSentBytes(data: ArrayBuffer): void;
|
|
77
|
+
/**
|
|
78
|
+
* Handles the close event of the connection.
|
|
79
|
+
*
|
|
80
|
+
* @param event The close event.
|
|
81
|
+
*/
|
|
19
82
|
handleClose(event: CloseEvent): void;
|
|
83
|
+
/**
|
|
84
|
+
* Called when the connection is closed.
|
|
85
|
+
*/
|
|
20
86
|
onClosed(): void;
|
|
87
|
+
/**
|
|
88
|
+
* Handles critical messages such as PING and data acknowledgments.
|
|
89
|
+
*
|
|
90
|
+
* @param buffer The message buffer.
|
|
91
|
+
*/
|
|
21
92
|
private _handleCriticalMessages;
|
|
22
93
|
}
|