@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
package/dist/WebXClient.d.ts
CHANGED
|
@@ -2,6 +2,12 @@ import { WebXTunnel } from './tunnel';
|
|
|
2
2
|
import { WebXDisplay } from './display';
|
|
3
3
|
import { WebXKeyboard, WebXMouse, WebXMouseState } from './input';
|
|
4
4
|
import { WebXDebugImageMessageHandler, WebXHandler } from './tracer';
|
|
5
|
+
/**
|
|
6
|
+
* The main client class for interacting with the WebX Engine.
|
|
7
|
+
*
|
|
8
|
+
* This class provides methods to connect to the WebX Engine, manage the display,
|
|
9
|
+
* handle user input (mouse and keyboard), and send/receive instructions and messages.
|
|
10
|
+
*/
|
|
5
11
|
export declare class WebXClient {
|
|
6
12
|
private _tunnel;
|
|
7
13
|
private readonly _textureFactory;
|
|
@@ -11,26 +17,57 @@ export declare class WebXClient {
|
|
|
11
17
|
private _display;
|
|
12
18
|
private _mouse;
|
|
13
19
|
private _keyboard;
|
|
20
|
+
/**
|
|
21
|
+
* Gets the WebXTunnel instance used for communication with the WebX Engine.
|
|
22
|
+
*/
|
|
14
23
|
get tunnel(): WebXTunnel;
|
|
24
|
+
/**
|
|
25
|
+
* Gets the map of registered tracer handlers.
|
|
26
|
+
*/
|
|
15
27
|
get tracers(): Map<string, WebXHandler>;
|
|
28
|
+
/**
|
|
29
|
+
* Gets the WebXDisplay instance used for rendering the display.
|
|
30
|
+
*/
|
|
16
31
|
get display(): WebXDisplay;
|
|
32
|
+
/**
|
|
33
|
+
* Gets the WebXMouse instance used for handling mouse input.
|
|
34
|
+
*/
|
|
17
35
|
get mouse(): WebXMouse;
|
|
36
|
+
/**
|
|
37
|
+
* Gets the WebXKeyboard instance used for handling keyboard input.
|
|
38
|
+
*/
|
|
18
39
|
get keyboard(): WebXKeyboard;
|
|
40
|
+
/**
|
|
41
|
+
* Creates a new instance of the WebXClient.
|
|
42
|
+
*
|
|
43
|
+
* @param _tunnel The WebXTunnel instance used for communication with the WebX Engine.
|
|
44
|
+
*/
|
|
19
45
|
constructor(_tunnel: WebXTunnel);
|
|
46
|
+
/**
|
|
47
|
+
* Connects to the WebX Engine and initializes the communication tunnel.
|
|
48
|
+
*
|
|
49
|
+
* @param onCloseCallback Callback function to execute when the connection is closed.
|
|
50
|
+
* @param data Additional data to send during the connection process.
|
|
51
|
+
*/
|
|
20
52
|
connect(onCloseCallback: () => void, data: any): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Disconnects from the WebX Engine and cleans up resources.
|
|
55
|
+
*/
|
|
21
56
|
disconnect(): void;
|
|
22
57
|
/**
|
|
58
|
+
* Initializes the WebX display and input devices.
|
|
23
59
|
*
|
|
24
|
-
* @param containerElement The
|
|
25
|
-
* @
|
|
26
|
-
* @param screenHeight the screen height
|
|
60
|
+
* @param containerElement The HTML element to render the display.
|
|
61
|
+
* @returns A promise that resolves to the initialized WebXDisplay instance.
|
|
27
62
|
*/
|
|
28
63
|
initialise(containerElement: HTMLElement): Promise<WebXDisplay>;
|
|
29
64
|
/**
|
|
65
|
+
* Creates a new WebXDisplay instance.
|
|
30
66
|
*
|
|
31
|
-
* @param containerElement The
|
|
32
|
-
* @param screenWidth
|
|
33
|
-
* @param screenHeight the screen
|
|
67
|
+
* @param containerElement The HTML element to render the display.
|
|
68
|
+
* @param screenWidth The width of the screen.
|
|
69
|
+
* @param screenHeight The height of the screen.
|
|
70
|
+
* @returns The created WebXDisplay instance.
|
|
34
71
|
*/
|
|
35
72
|
createDisplay(containerElement: HTMLElement, screenWidth: number, screenHeight: number): WebXDisplay;
|
|
36
73
|
/**
|
|
@@ -44,14 +81,16 @@ export declare class WebXClient {
|
|
|
44
81
|
*/
|
|
45
82
|
createKeyboard(element: HTMLElement): WebXKeyboard;
|
|
46
83
|
/**
|
|
47
|
-
* Sends a mouse event
|
|
48
|
-
*
|
|
84
|
+
* Sends a mouse event to the WebX Engine.
|
|
85
|
+
*
|
|
86
|
+
* @param mouseState The state of the mouse to send in the event.
|
|
49
87
|
*/
|
|
50
88
|
sendMouse(mouseState: WebXMouseState): void;
|
|
51
89
|
/**
|
|
52
|
-
* Sends a key event
|
|
53
|
-
*
|
|
54
|
-
* @param key
|
|
90
|
+
* Sends a key event to the WebX Engine.
|
|
91
|
+
*
|
|
92
|
+
* @param key The key code to send.
|
|
93
|
+
* @param pressed Whether the key is pressed (true) or released (false).
|
|
55
94
|
*/
|
|
56
95
|
sendKeyEvent(key: number, pressed: boolean): void;
|
|
57
96
|
/**
|
|
@@ -65,29 +104,122 @@ export declare class WebXClient {
|
|
|
65
104
|
*/
|
|
66
105
|
sendKeyUp(key: number): void;
|
|
67
106
|
/**
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
* @param
|
|
107
|
+
* Registers a new tracer handler.
|
|
108
|
+
*
|
|
109
|
+
* @param name The unique name of the tracer.
|
|
110
|
+
* @param handler The tracer handler instance.
|
|
71
111
|
*/
|
|
72
112
|
registerTracer(name: string, handler: WebXHandler): void;
|
|
73
113
|
createDebugImageMessageHandler(): WebXDebugImageMessageHandler;
|
|
114
|
+
/**
|
|
115
|
+
* Resets the input devices (mouse and keyboard).
|
|
116
|
+
*/
|
|
74
117
|
resetInputs(): void;
|
|
118
|
+
/**
|
|
119
|
+
* Resizes the WebX display to fit the container.
|
|
120
|
+
*/
|
|
75
121
|
resizeDisplay(): void;
|
|
76
122
|
/**
|
|
77
|
-
*
|
|
78
|
-
*
|
|
123
|
+
* Unregisters a tracer handler.
|
|
124
|
+
*
|
|
125
|
+
* @param name The name of the tracer to unregister.
|
|
79
126
|
*/
|
|
80
127
|
unregisterTracer(name: string): void;
|
|
128
|
+
/**
|
|
129
|
+
* Sets the quality index for the WebX Engine.
|
|
130
|
+
*
|
|
131
|
+
* @param qualityIndex The quality index to set.
|
|
132
|
+
*/
|
|
81
133
|
setQualityIndex(qualityIndex: number): void;
|
|
134
|
+
/**
|
|
135
|
+
* Retrieves the screen message from the WebX Engine.
|
|
136
|
+
*
|
|
137
|
+
* This method attempts to get the screen message, retrying up to 3 times
|
|
138
|
+
* if the initial attempts fail.
|
|
139
|
+
*
|
|
140
|
+
* @returns A promise that resolves to the WebXScreenMessage.
|
|
141
|
+
*/
|
|
82
142
|
private _getScreenMessage;
|
|
143
|
+
/**
|
|
144
|
+
* Sends an instruction to the WebX Engine.
|
|
145
|
+
*
|
|
146
|
+
* This method sends the provided instruction to the WebX Engine if the tunnel
|
|
147
|
+
* is connected.
|
|
148
|
+
*
|
|
149
|
+
* @param command The instruction to send.
|
|
150
|
+
*/
|
|
83
151
|
private _sendInstruction;
|
|
152
|
+
/**
|
|
153
|
+
* Sends a request to the WebX Engine and returns the response.
|
|
154
|
+
*
|
|
155
|
+
* This method sends the provided request to the WebX Engine and returns a promise
|
|
156
|
+
* that resolves to the response message.
|
|
157
|
+
*
|
|
158
|
+
* @param command The request to send.
|
|
159
|
+
* @param timeout Optional timeout for the request.
|
|
160
|
+
* @returns A promise that resolves to the WebXMessage.
|
|
161
|
+
*/
|
|
84
162
|
private _sendRequest;
|
|
163
|
+
/**
|
|
164
|
+
* Handles incoming messages from the WebX Engine.
|
|
165
|
+
*
|
|
166
|
+
* This method processes messages received from the WebX Engine and takes
|
|
167
|
+
* appropriate actions based on the message type.
|
|
168
|
+
*
|
|
169
|
+
* @param message The received message.
|
|
170
|
+
*/
|
|
85
171
|
private _handleMessage;
|
|
172
|
+
/**
|
|
173
|
+
* Handles received bytes from the WebX Engine.
|
|
174
|
+
*
|
|
175
|
+
* This method processes the received bytes and updates the tracers with the
|
|
176
|
+
* received data.
|
|
177
|
+
*
|
|
178
|
+
* @param data The received data as an ArrayBuffer.
|
|
179
|
+
*/
|
|
86
180
|
private _handleReceivedBytes;
|
|
181
|
+
/**
|
|
182
|
+
* Handles sent bytes to the WebX Engine.
|
|
183
|
+
*
|
|
184
|
+
* This method processes the sent bytes and updates the tracers with the
|
|
185
|
+
* sent data.
|
|
186
|
+
*
|
|
187
|
+
* @param data The sent data as an ArrayBuffer.
|
|
188
|
+
*/
|
|
87
189
|
private _handleSentBytes;
|
|
190
|
+
/**
|
|
191
|
+
* Handles the quality of the connection to the WebX Engine.
|
|
192
|
+
*
|
|
193
|
+
* This method processes the quality data and updates the tracers with the
|
|
194
|
+
* quality information.
|
|
195
|
+
*
|
|
196
|
+
* @param data The quality data as an ArrayBuffer.
|
|
197
|
+
*/
|
|
88
198
|
private _handleQuality;
|
|
199
|
+
/**
|
|
200
|
+
* Handles the tunnel closed event.
|
|
201
|
+
*
|
|
202
|
+
* This method performs cleanup and executes the onCloseCallback when the
|
|
203
|
+
* tunnel is closed.
|
|
204
|
+
*/
|
|
89
205
|
private _onTunnelClosed;
|
|
206
|
+
/**
|
|
207
|
+
* Disposes of the WebX client resources.
|
|
208
|
+
*
|
|
209
|
+
* This method cleans up the display, mouse, and keyboard resources.
|
|
210
|
+
*/
|
|
90
211
|
private _dispose;
|
|
212
|
+
/**
|
|
213
|
+
* Adds mouse event listeners to the WebX client.
|
|
214
|
+
*
|
|
215
|
+
* This method sets up the mouse event listeners for mouse move, mouse out,
|
|
216
|
+
* mouse down, and mouse up events.
|
|
217
|
+
*/
|
|
91
218
|
private _addMouseListeners;
|
|
219
|
+
/**
|
|
220
|
+
* Adds keyboard event listeners to the WebX client.
|
|
221
|
+
*
|
|
222
|
+
* This method sets up the keyboard event listeners for key down and key up events.
|
|
223
|
+
*/
|
|
92
224
|
private _addKeyboardListeners;
|
|
93
225
|
}
|
package/dist/WebXClient.js
CHANGED
|
@@ -16,28 +16,60 @@ const display_1 = require("./display");
|
|
|
16
16
|
const input_1 = require("./input");
|
|
17
17
|
const tracer_1 = require("./tracer");
|
|
18
18
|
const transport_1 = require("./transport");
|
|
19
|
+
/**
|
|
20
|
+
* The main client class for interacting with the WebX Engine.
|
|
21
|
+
*
|
|
22
|
+
* This class provides methods to connect to the WebX Engine, manage the display,
|
|
23
|
+
* handle user input (mouse and keyboard), and send/receive instructions and messages.
|
|
24
|
+
*/
|
|
19
25
|
class WebXClient {
|
|
26
|
+
/**
|
|
27
|
+
* Gets the WebXTunnel instance used for communication with the WebX Engine.
|
|
28
|
+
*/
|
|
20
29
|
get tunnel() {
|
|
21
30
|
return this._tunnel;
|
|
22
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Gets the map of registered tracer handlers.
|
|
34
|
+
*/
|
|
23
35
|
get tracers() {
|
|
24
36
|
return this._tracers;
|
|
25
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Gets the WebXDisplay instance used for rendering the display.
|
|
40
|
+
*/
|
|
26
41
|
get display() {
|
|
27
42
|
return this._display;
|
|
28
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Gets the WebXMouse instance used for handling mouse input.
|
|
46
|
+
*/
|
|
29
47
|
get mouse() {
|
|
30
48
|
return this._mouse;
|
|
31
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Gets the WebXKeyboard instance used for handling keyboard input.
|
|
52
|
+
*/
|
|
32
53
|
get keyboard() {
|
|
33
54
|
return this._keyboard;
|
|
34
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Creates a new instance of the WebXClient.
|
|
58
|
+
*
|
|
59
|
+
* @param _tunnel The WebXTunnel instance used for communication with the WebX Engine.
|
|
60
|
+
*/
|
|
35
61
|
constructor(_tunnel) {
|
|
36
62
|
this._tunnel = _tunnel;
|
|
37
63
|
this._tracers = new Map();
|
|
38
64
|
this._textureFactory = new display_1.WebXTextureFactory(this._tunnel);
|
|
39
65
|
this._cursorFactory = new display_1.WebXCursorFactory(this._tunnel);
|
|
40
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* Connects to the WebX Engine and initializes the communication tunnel.
|
|
69
|
+
*
|
|
70
|
+
* @param onCloseCallback Callback function to execute when the connection is closed.
|
|
71
|
+
* @param data Additional data to send during the connection process.
|
|
72
|
+
*/
|
|
41
73
|
connect(onCloseCallback, data) {
|
|
42
74
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43
75
|
this._onCloseCallback = onCloseCallback;
|
|
@@ -48,14 +80,17 @@ class WebXClient {
|
|
|
48
80
|
this._tunnel.onClosed = this._onTunnelClosed.bind(this);
|
|
49
81
|
});
|
|
50
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* Disconnects from the WebX Engine and cleans up resources.
|
|
85
|
+
*/
|
|
51
86
|
disconnect() {
|
|
52
87
|
this._tunnel.disconnect();
|
|
53
88
|
}
|
|
54
89
|
/**
|
|
90
|
+
* Initializes the WebX display and input devices.
|
|
55
91
|
*
|
|
56
|
-
* @param containerElement The
|
|
57
|
-
* @
|
|
58
|
-
* @param screenHeight the screen height
|
|
92
|
+
* @param containerElement The HTML element to render the display.
|
|
93
|
+
* @returns A promise that resolves to the initialized WebXDisplay instance.
|
|
59
94
|
*/
|
|
60
95
|
initialise(containerElement) {
|
|
61
96
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -86,10 +121,12 @@ class WebXClient {
|
|
|
86
121
|
});
|
|
87
122
|
}
|
|
88
123
|
/**
|
|
124
|
+
* Creates a new WebXDisplay instance.
|
|
89
125
|
*
|
|
90
|
-
* @param containerElement The
|
|
91
|
-
* @param screenWidth
|
|
92
|
-
* @param screenHeight the screen
|
|
126
|
+
* @param containerElement The HTML element to render the display.
|
|
127
|
+
* @param screenWidth The width of the screen.
|
|
128
|
+
* @param screenHeight The height of the screen.
|
|
129
|
+
* @returns The created WebXDisplay instance.
|
|
93
130
|
*/
|
|
94
131
|
createDisplay(containerElement, screenWidth, screenHeight) {
|
|
95
132
|
return new display_1.WebXDisplay(containerElement, screenWidth, screenHeight, this._textureFactory, this._cursorFactory);
|
|
@@ -109,16 +146,18 @@ class WebXClient {
|
|
|
109
146
|
return new input_1.WebXKeyboard(element);
|
|
110
147
|
}
|
|
111
148
|
/**
|
|
112
|
-
* Sends a mouse event
|
|
113
|
-
*
|
|
149
|
+
* Sends a mouse event to the WebX Engine.
|
|
150
|
+
*
|
|
151
|
+
* @param mouseState The state of the mouse to send in the event.
|
|
114
152
|
*/
|
|
115
153
|
sendMouse(mouseState) {
|
|
116
154
|
this._sendInstruction(new instruction_1.WebXMouseInstruction(mouseState.x, mouseState.y, mouseState.getButtonMask()));
|
|
117
155
|
}
|
|
118
156
|
/**
|
|
119
|
-
* Sends a key event
|
|
120
|
-
*
|
|
121
|
-
* @param key
|
|
157
|
+
* Sends a key event to the WebX Engine.
|
|
158
|
+
*
|
|
159
|
+
* @param key The key code to send.
|
|
160
|
+
* @param pressed Whether the key is pressed (true) or released (false).
|
|
122
161
|
*/
|
|
123
162
|
sendKeyEvent(key, pressed) {
|
|
124
163
|
this._sendInstruction(new instruction_1.WebXKeyboardInstruction(key, pressed));
|
|
@@ -138,9 +177,10 @@ class WebXClient {
|
|
|
138
177
|
this.sendKeyEvent(key, false);
|
|
139
178
|
}
|
|
140
179
|
/**
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
* @param
|
|
180
|
+
* Registers a new tracer handler.
|
|
181
|
+
*
|
|
182
|
+
* @param name The unique name of the tracer.
|
|
183
|
+
* @param handler The tracer handler instance.
|
|
144
184
|
*/
|
|
145
185
|
registerTracer(name, handler) {
|
|
146
186
|
this._tracers.set(name, handler);
|
|
@@ -152,6 +192,9 @@ class WebXClient {
|
|
|
152
192
|
console.log('Cannot create DebugImageMessageHandler as display is null');
|
|
153
193
|
return null;
|
|
154
194
|
}
|
|
195
|
+
/**
|
|
196
|
+
* Resets the input devices (mouse and keyboard).
|
|
197
|
+
*/
|
|
155
198
|
resetInputs() {
|
|
156
199
|
if (this._mouse) {
|
|
157
200
|
this._mouse.reset();
|
|
@@ -160,14 +203,18 @@ class WebXClient {
|
|
|
160
203
|
this._keyboard.reset();
|
|
161
204
|
}
|
|
162
205
|
}
|
|
206
|
+
/**
|
|
207
|
+
* Resizes the WebX display to fit the container.
|
|
208
|
+
*/
|
|
163
209
|
resizeDisplay() {
|
|
164
210
|
if (this._display) {
|
|
165
211
|
this._display.resize();
|
|
166
212
|
}
|
|
167
213
|
}
|
|
168
214
|
/**
|
|
169
|
-
*
|
|
170
|
-
*
|
|
215
|
+
* Unregisters a tracer handler.
|
|
216
|
+
*
|
|
217
|
+
* @param name The name of the tracer to unregister.
|
|
171
218
|
*/
|
|
172
219
|
unregisterTracer(name) {
|
|
173
220
|
const tracer = this._tracers.get(name);
|
|
@@ -177,10 +224,23 @@ class WebXClient {
|
|
|
177
224
|
this._tracers.delete(name);
|
|
178
225
|
}
|
|
179
226
|
}
|
|
227
|
+
/**
|
|
228
|
+
* Sets the quality index for the WebX Engine.
|
|
229
|
+
*
|
|
230
|
+
* @param qualityIndex The quality index to set.
|
|
231
|
+
*/
|
|
180
232
|
setQualityIndex(qualityIndex) {
|
|
181
233
|
const qualityInstruction = new instruction_1.WebXQualityInstruction(qualityIndex);
|
|
182
234
|
this._sendInstruction(qualityInstruction);
|
|
183
235
|
}
|
|
236
|
+
/**
|
|
237
|
+
* Retrieves the screen message from the WebX Engine.
|
|
238
|
+
*
|
|
239
|
+
* This method attempts to get the screen message, retrying up to 3 times
|
|
240
|
+
* if the initial attempts fail.
|
|
241
|
+
*
|
|
242
|
+
* @returns A promise that resolves to the WebXScreenMessage.
|
|
243
|
+
*/
|
|
184
244
|
_getScreenMessage() {
|
|
185
245
|
return __awaiter(this, void 0, void 0, function* () {
|
|
186
246
|
// Perform retries on the first instruction (client can sometimes be activated before the server connection$
|
|
@@ -200,6 +260,14 @@ class WebXClient {
|
|
|
200
260
|
}
|
|
201
261
|
});
|
|
202
262
|
}
|
|
263
|
+
/**
|
|
264
|
+
* Sends an instruction to the WebX Engine.
|
|
265
|
+
*
|
|
266
|
+
* This method sends the provided instruction to the WebX Engine if the tunnel
|
|
267
|
+
* is connected.
|
|
268
|
+
*
|
|
269
|
+
* @param command The instruction to send.
|
|
270
|
+
*/
|
|
203
271
|
_sendInstruction(command) {
|
|
204
272
|
if (this._tunnel.isConnected()) {
|
|
205
273
|
this._tunnel.sendInstruction(command);
|
|
@@ -209,18 +277,30 @@ class WebXClient {
|
|
|
209
277
|
}
|
|
210
278
|
});
|
|
211
279
|
}
|
|
212
|
-
else {
|
|
213
|
-
throw new Error("Tunnel is closed");
|
|
214
|
-
}
|
|
215
280
|
}
|
|
281
|
+
/**
|
|
282
|
+
* Sends a request to the WebX Engine and returns the response.
|
|
283
|
+
*
|
|
284
|
+
* This method sends the provided request to the WebX Engine and returns a promise
|
|
285
|
+
* that resolves to the response message.
|
|
286
|
+
*
|
|
287
|
+
* @param command The request to send.
|
|
288
|
+
* @param timeout Optional timeout for the request.
|
|
289
|
+
* @returns A promise that resolves to the WebXMessage.
|
|
290
|
+
*/
|
|
216
291
|
_sendRequest(command, timeout) {
|
|
217
292
|
if (this._tunnel.isConnected()) {
|
|
218
293
|
return this._tunnel.sendRequest(command, timeout);
|
|
219
294
|
}
|
|
220
|
-
else {
|
|
221
|
-
throw new Error("Tunnel is closed");
|
|
222
|
-
}
|
|
223
295
|
}
|
|
296
|
+
/**
|
|
297
|
+
* Handles incoming messages from the WebX Engine.
|
|
298
|
+
*
|
|
299
|
+
* This method processes messages received from the WebX Engine and takes
|
|
300
|
+
* appropriate actions based on the message type.
|
|
301
|
+
*
|
|
302
|
+
* @param message The received message.
|
|
303
|
+
*/
|
|
224
304
|
_handleMessage(message) {
|
|
225
305
|
if (!this._display) {
|
|
226
306
|
return;
|
|
@@ -249,6 +329,14 @@ class WebXClient {
|
|
|
249
329
|
}
|
|
250
330
|
});
|
|
251
331
|
}
|
|
332
|
+
/**
|
|
333
|
+
* Handles received bytes from the WebX Engine.
|
|
334
|
+
*
|
|
335
|
+
* This method processes the received bytes and updates the tracers with the
|
|
336
|
+
* received data.
|
|
337
|
+
*
|
|
338
|
+
* @param data The received data as an ArrayBuffer.
|
|
339
|
+
*/
|
|
252
340
|
_handleReceivedBytes(data) {
|
|
253
341
|
this._tracers.forEach((value) => {
|
|
254
342
|
if (value instanceof tracer_1.WebXStatsHandler) {
|
|
@@ -256,6 +344,14 @@ class WebXClient {
|
|
|
256
344
|
}
|
|
257
345
|
});
|
|
258
346
|
}
|
|
347
|
+
/**
|
|
348
|
+
* Handles sent bytes to the WebX Engine.
|
|
349
|
+
*
|
|
350
|
+
* This method processes the sent bytes and updates the tracers with the
|
|
351
|
+
* sent data.
|
|
352
|
+
*
|
|
353
|
+
* @param data The sent data as an ArrayBuffer.
|
|
354
|
+
*/
|
|
259
355
|
_handleSentBytes(data) {
|
|
260
356
|
this._tracers.forEach((value) => {
|
|
261
357
|
if (value instanceof tracer_1.WebXStatsHandler) {
|
|
@@ -263,6 +359,14 @@ class WebXClient {
|
|
|
263
359
|
}
|
|
264
360
|
});
|
|
265
361
|
}
|
|
362
|
+
/**
|
|
363
|
+
* Handles the quality of the connection to the WebX Engine.
|
|
364
|
+
*
|
|
365
|
+
* This method processes the quality data and updates the tracers with the
|
|
366
|
+
* quality information.
|
|
367
|
+
*
|
|
368
|
+
* @param data The quality data as an ArrayBuffer.
|
|
369
|
+
*/
|
|
266
370
|
_handleQuality(data) {
|
|
267
371
|
this._tracers.forEach((value) => {
|
|
268
372
|
if (value instanceof tracer_1.WebXStatsHandler) {
|
|
@@ -270,12 +374,23 @@ class WebXClient {
|
|
|
270
374
|
}
|
|
271
375
|
});
|
|
272
376
|
}
|
|
377
|
+
/**
|
|
378
|
+
* Handles the tunnel closed event.
|
|
379
|
+
*
|
|
380
|
+
* This method performs cleanup and executes the onCloseCallback when the
|
|
381
|
+
* tunnel is closed.
|
|
382
|
+
*/
|
|
273
383
|
_onTunnelClosed() {
|
|
274
384
|
this._dispose();
|
|
275
385
|
if (this._onCloseCallback) {
|
|
276
386
|
this._onCloseCallback();
|
|
277
387
|
}
|
|
278
388
|
}
|
|
389
|
+
/**
|
|
390
|
+
* Disposes of the WebX client resources.
|
|
391
|
+
*
|
|
392
|
+
* This method cleans up the display, mouse, and keyboard resources.
|
|
393
|
+
*/
|
|
279
394
|
_dispose() {
|
|
280
395
|
if (this._display) {
|
|
281
396
|
this._display.dispose();
|
|
@@ -287,6 +402,12 @@ class WebXClient {
|
|
|
287
402
|
this._keyboard.dispose();
|
|
288
403
|
}
|
|
289
404
|
}
|
|
405
|
+
/**
|
|
406
|
+
* Adds mouse event listeners to the WebX client.
|
|
407
|
+
*
|
|
408
|
+
* This method sets up the mouse event listeners for mouse move, mouse out,
|
|
409
|
+
* mouse down, and mouse up events.
|
|
410
|
+
*/
|
|
290
411
|
_addMouseListeners() {
|
|
291
412
|
this._mouse.onMouseMove = this._mouse.onMouseOut = (mouseState) => {
|
|
292
413
|
const scale = this._display.scale;
|
|
@@ -299,6 +420,11 @@ class WebXClient {
|
|
|
299
420
|
this.sendMouse(mouseState);
|
|
300
421
|
};
|
|
301
422
|
}
|
|
423
|
+
/**
|
|
424
|
+
* Adds keyboard event listeners to the WebX client.
|
|
425
|
+
*
|
|
426
|
+
* This method sets up the keyboard event listeners for key down and key up events.
|
|
427
|
+
*/
|
|
302
428
|
_addKeyboardListeners() {
|
|
303
429
|
this._keyboard.onKeyDown = key => {
|
|
304
430
|
this.sendKeyDown(key);
|
package/dist/WebXClient.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebXClient.js","sourceRoot":"","sources":["../src/WebXClient.ts"],"names":[],"mappings":";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,SAAS,GAAG,CAAC,UAA0B,EAAE,EAAE;YAC/E,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;QAC7B,CAAC,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACK,qBAAqB;QAC3B,IAAI,CAAC,SAAS,CAAC,SAAS,GAAG,GAAG,CAAC,EAAE;YAC/B,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QACxB,CAAC,CAAC;QAEF,IAAI,CAAC,SAAS,CAAC,OAAO,GAAG,GAAG,CAAC,EAAE;YAC7B,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QACtB,CAAC,CAAC;IACJ,CAAC;CACF;AA7cD,gCA6cC"}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
2
|
import { Texture } from 'three';
|
|
3
3
|
import { WebXCursorFactory } from './WebXCursorFactory';
|
|
4
|
+
/**
|
|
5
|
+
* Represents the cursor in the WebX display.
|
|
6
|
+
*
|
|
7
|
+
* This class manages the cursor's position, appearance, and updates based on
|
|
8
|
+
* the cursor ID and coordinates provided by the WebX Engine.
|
|
9
|
+
*/
|
|
4
10
|
export declare class WebXCursor {
|
|
5
11
|
private _cursorFactory;
|
|
6
12
|
private static _PLANE_GEOMETRY;
|
|
@@ -14,15 +20,74 @@ export declare class WebXCursor {
|
|
|
14
20
|
private _yHot;
|
|
15
21
|
private _width;
|
|
16
22
|
private _height;
|
|
23
|
+
/**
|
|
24
|
+
* Gets the THREE.js mesh representing the cursor.
|
|
25
|
+
*
|
|
26
|
+
* @returns The cursor mesh.
|
|
27
|
+
*/
|
|
17
28
|
get mesh(): THREE.Mesh;
|
|
29
|
+
/**
|
|
30
|
+
* Gets the cursor ID.
|
|
31
|
+
*
|
|
32
|
+
* @returns The cursor ID.
|
|
33
|
+
*/
|
|
18
34
|
get cursorId(): number;
|
|
35
|
+
/**
|
|
36
|
+
* Gets the texture of the cursor.
|
|
37
|
+
*
|
|
38
|
+
* @returns The cursor texture.
|
|
39
|
+
*/
|
|
19
40
|
get texture(): Texture;
|
|
41
|
+
/**
|
|
42
|
+
* Sets the x-coordinate of the cursor.
|
|
43
|
+
*
|
|
44
|
+
* @param value The x-coordinate.
|
|
45
|
+
*/
|
|
20
46
|
set x(value: number);
|
|
47
|
+
/**
|
|
48
|
+
* Sets the y-coordinate of the cursor.
|
|
49
|
+
*
|
|
50
|
+
* @param value The y-coordinate.
|
|
51
|
+
*/
|
|
21
52
|
set y(value: number);
|
|
53
|
+
/**
|
|
54
|
+
* Creates a new instance of WebXCursor.
|
|
55
|
+
*
|
|
56
|
+
* @param cursorFactory The factory used to create cursor textures.
|
|
57
|
+
*/
|
|
22
58
|
constructor(_cursorFactory: WebXCursorFactory);
|
|
59
|
+
/**
|
|
60
|
+
* Sets the position of the cursor.
|
|
61
|
+
*
|
|
62
|
+
* @param x The x-coordinate of the cursor.
|
|
63
|
+
* @param y The y-coordinate of the cursor.
|
|
64
|
+
*/
|
|
23
65
|
setPosition(x: number, y: number): void;
|
|
66
|
+
/**
|
|
67
|
+
* Updates the cursor's position and appearance based on the given cursor ID and coordinates.
|
|
68
|
+
*
|
|
69
|
+
* @param x The x-coordinate of the cursor.
|
|
70
|
+
* @param y The y-coordinate of the cursor.
|
|
71
|
+
* @param cursorId The ID of the cursor to display.
|
|
72
|
+
*/
|
|
24
73
|
updateCursorId(x: number, y: number, cursorId: number): void;
|
|
74
|
+
/**
|
|
75
|
+
* Updates the cursor's position, appearance, and texture.
|
|
76
|
+
*
|
|
77
|
+
* @param x The x-coordinate of the cursor.
|
|
78
|
+
* @param y The y-coordinate of the cursor.
|
|
79
|
+
* @param xHot The x-coordinate of the cursor's hotspot.
|
|
80
|
+
* @param yHot The y-coordinate of the cursor's hotspot.
|
|
81
|
+
* @param cursorId The ID of the cursor to display.
|
|
82
|
+
* @param texture The texture of the cursor.
|
|
83
|
+
*/
|
|
25
84
|
update(x: number, y: number, xHot: number, yHot: number, cursorId: number, texture: Texture): void;
|
|
85
|
+
/**
|
|
86
|
+
* Updates the scale of the cursor mesh based on its width and height.
|
|
87
|
+
*/
|
|
26
88
|
private _updateScale;
|
|
89
|
+
/**
|
|
90
|
+
* Updates the position of the cursor mesh based on its coordinates and hotspot.
|
|
91
|
+
*/
|
|
27
92
|
private _updatePosition;
|
|
28
93
|
}
|