@illgrenoble/webx-client 1.13.0 → 1.14.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.
@@ -29,8 +29,11 @@ export declare class WebXClient {
29
29
  private _mouse;
30
30
  private _keyboard;
31
31
  private _clipboardHandler;
32
+ private _keyboardLayoutHandler;
32
33
  private _connectionHandler;
33
34
  private _maxQualityIndex;
35
+ private _canResizeScreen;
36
+ private _keyboardLayoutName;
34
37
  /**
35
38
  * Gets the WebXTunnel instance used for communication with the WebX Engine.
36
39
  */
@@ -56,10 +59,19 @@ export declare class WebXClient {
56
59
  * @param handler the handler when clipboard data is received from the server
57
60
  */
58
61
  set clipboardHandler(handler: (clipboardContent: string) => void);
62
+ /**
63
+ * Handles notification that the keyboard layout has been changed in the server.
64
+ * @param handler the handler when the keyboard layout changes in the server
65
+ */
66
+ set keyboardLayoutHandler(value: (keyboardLayoutName: string) => void);
59
67
  /**
60
68
  * Gets the max quality index of the display.
61
69
  */
62
70
  get maxQualityIndex(): number;
71
+ /**
72
+ * Gets the keyboard layout name
73
+ */
74
+ get keyboardLayoutName(): string;
63
75
  /**
64
76
  * Creates a new instance of the WebXClient.
65
77
  *
@@ -169,6 +181,26 @@ export declare class WebXClient {
169
181
  * @returns A promise that resolves to image data in Blob form.
170
182
  */
171
183
  createScreenshot(type: string, quality: number): Promise<Blob>;
184
+ /**
185
+ * Requests a change in the screen size. If successful a message will be sent
186
+ * asynchronously from the engine with the new screen size.
187
+ *
188
+ * @param width The requested width of the screen
189
+ * @param height The requested height of the screen
190
+ */
191
+ resizeScreen(width: number, height: number): void;
192
+ /**
193
+ * Returns true if the WebXEngine is capable of resizing the screen
194
+ *
195
+ * @returns True if screen resizing is available
196
+ */
197
+ canResizeScreen(): boolean;
198
+ /**
199
+ * Requests a change in the keyboard layout.
200
+ *
201
+ * @param layout the keyboard layout
202
+ */
203
+ setKeyboardLayout(layout: string): void;
172
204
  /**
173
205
  * Retrieves the screen message from the WebX Engine.
174
206
  *
@@ -18,11 +18,11 @@ export declare class WebXDisplay {
18
18
  private readonly _scene;
19
19
  private readonly _camera;
20
20
  private readonly _renderer;
21
- private readonly _filter;
21
+ private _filter;
22
22
  private readonly _screen;
23
23
  private readonly _isWebGL;
24
- private readonly _screenWidth;
25
- private readonly _screenHeight;
24
+ private _screenWidth;
25
+ private _screenHeight;
26
26
  private readonly _options;
27
27
  private readonly _windowImageFactory;
28
28
  private readonly _containerElement;
@@ -41,6 +41,11 @@ export declare class WebXDisplay {
41
41
  * @returns The WebGLRenderer instance.
42
42
  */
43
43
  get renderer(): THREE.WebGLRenderer | WebXCanvasRenderer;
44
+ /**
45
+ * Gets the active filter name if there is one
46
+ */
47
+ get filter(): string;
48
+ set filter(filter: string);
44
49
  /**
45
50
  * Gets the width of the screen.
46
51
  *
@@ -106,6 +111,13 @@ export declare class WebXDisplay {
106
111
  * Hides the screen by removing it from the scene.
107
112
  */
108
113
  hideScreen(): void;
114
+ /**
115
+ * Resizes the display to the new screen size
116
+ *
117
+ * @param width the new screen width
118
+ * @param height the new screen height
119
+ */
120
+ onScreenResized(width: number, height: number): void;
109
121
  /**
110
122
  * Disposes of all resources used by the display.
111
123
  *
@@ -241,4 +253,8 @@ export declare class WebXDisplay {
241
253
  * Returns details about the availability and type of WebGL2 rendering
242
254
  */
243
255
  private _detectWebGL2;
256
+ /**
257
+ * Returns an object with parameters for the filter
258
+ */
259
+ private _getFilterParams;
244
260
  }
@@ -9,10 +9,14 @@ import { WebXFilterMaterial } from "./WebXFilterMaterial";
9
9
  * effect to the entire screen.
10
10
  */
11
11
  export declare class WebXFilter {
12
+ /**
13
+ * The name of the filter
14
+ */
15
+ private readonly _name;
12
16
  /**
13
17
  * Renderer used for both offscreen and final compositing passes.
14
18
  */
15
- private _renderer;
19
+ private readonly _renderer;
16
20
  /**
17
21
  * Scene containing the single mesh used to draw the filter pass.
18
22
  *
@@ -28,6 +32,10 @@ export declare class WebXFilter {
28
32
  * May be `null` if no `filterMaterial` was provided.
29
33
  */
30
34
  private readonly _rtTexture;
35
+ /**
36
+ * Returns the name of the filter
37
+ */
38
+ get name(): string;
31
39
  /**
32
40
  * Create a new WebXFilter.
33
41
  *
@@ -35,12 +43,13 @@ export declare class WebXFilter {
35
43
  * - An offscreen `WebGLRenderTarget` is created with the given width/height.
36
44
  * - The filter material's `tDiffuse` is set to the render target's texture (the fully rendered scene of windows)
37
45
  *
46
+ * @param name - The name of the filter
38
47
  * @param renderer - WebGL renderer used to perform rendering.
39
48
  * @param screenWidth - Width to use for the offscreen render target and screen plane.
40
49
  * @param screenHeight - Height to use for the offscreen render target and screen plane.
41
50
  * @param filterMaterial - Optional filter material; when omitted the filter pass is disabled.
42
51
  */
43
- constructor(renderer: THREE.WebGLRenderer, screenWidth: number, screenHeight: number, filterMaterial?: WebXFilterMaterial);
52
+ constructor(name: string, renderer: THREE.WebGLRenderer, screenWidth: number, screenHeight: number, filterMaterial?: WebXFilterMaterial);
44
53
  /**
45
54
  * Render the scene with optional post-processing filter. If the scene is dirty then all the webx windows
46
55
  * are redrawn. The rendering is done on the render texture if present or the default framebuffer otherwise.
@@ -52,4 +61,8 @@ export declare class WebXFilter {
52
61
  * @param isSceneDirty - When true the main scene will be re-rendered.
53
62
  */
54
63
  render(scene: Scene, camera: Camera, isSceneDirty: boolean): void;
64
+ /**
65
+ * Disposes of WebGL elements
66
+ */
67
+ dispose(): void;
55
68
  }
@@ -1,5 +1,6 @@
1
1
  import { WebXFilter } from "./WebXFilter";
2
2
  import { WebGLRenderer } from "three";
3
+ import { WebXCanvasRenderer } from "../../renderer";
3
4
  /**
4
5
  * WebXFilterFactory
5
6
  *
@@ -12,14 +13,14 @@ export declare class WebXFilterFactory {
12
13
  /**
13
14
  * Build a `WebXFilter` configured with a named filter material.
14
15
  *
15
- * @param renderer - Three.js WebGLRenderer used for rendering passes.
16
+ * @param renderer - Three.js WebGLRenderer or WebXCanvasRenderer used for rendering passes (filter is only applied for WebGLRenderer).
16
17
  * @param screenWidth - Width in pixels for the offscreen render target and screen plane.
17
18
  * @param screenHeight - Height in pixels for the offscreen render target and screen plane.
18
19
  * @param name - Name of the filter to create (e.g. `test`, `crt`).
19
20
  * @param params - Optional parameters forwarded to the chosen filter material constructor.
20
21
  * @returns A `WebXFilter` configured with the selected filter material, or a `WebXFilter` with no filter if the name is unknown.
21
22
  */
22
- static Build(renderer: WebGLRenderer, screenWidth: number, screenHeight: number, name: string, params: any): WebXFilter;
23
+ static Build(renderer: WebGLRenderer | WebXCanvasRenderer, screenWidth: number, screenHeight: number, name: string, params?: any): WebXFilter;
23
24
  /**
24
25
  * Create an instance of a filter material by name.
25
26
  *
@@ -51,7 +51,15 @@ export declare enum WebXInstructionType {
51
51
  /**
52
52
  * Instruction to request the window shape image (stencil image).
53
53
  */
54
- SHAPE = 12
54
+ SHAPE = 12,
55
+ /**
56
+ * Instruction to request a screen resize
57
+ */
58
+ SCREEN_RESIZE = 13,
59
+ /**
60
+ * Instruction to request a change in keyboard layouts
61
+ */
62
+ KEYBOARD_LAYOUT = 14
55
63
  }
56
64
  export declare namespace WebXInstructionType {
57
65
  /**
@@ -0,0 +1,16 @@
1
+ import { WebXInstruction } from './WebXInstruction';
2
+ /**
3
+ * This instruction is used to request a change in keyboards in the engine
4
+ */
5
+ export declare class WebXKeyboardLayoutInstruction extends WebXInstruction {
6
+ /**
7
+ * The keyboard layout.
8
+ */
9
+ readonly keyboardLayout: string;
10
+ /**
11
+ * Constructs a new WebXKeyboardLayoutInstruction.
12
+ *
13
+ * @param keyboardLayout The keyboard layout
14
+ */
15
+ constructor(keyboardLayout: string);
16
+ }
@@ -0,0 +1,21 @@
1
+ import { WebXInstruction } from './WebXInstruction';
2
+ /**
3
+ * Represents an instruction to request a screen resize
4
+ */
5
+ export declare class WebXScreenResizeInstruction extends WebXInstruction {
6
+ /**
7
+ * The requested width of the screen.
8
+ */
9
+ readonly width: number;
10
+ /**
11
+ * The requested height of the screen.
12
+ */
13
+ readonly height: number;
14
+ /**
15
+ * Constructs a new WebXScreenResizeInstruction.
16
+ *
17
+ * @param width The requested width of the screen
18
+ * @param height The requested height of the screen
19
+ */
20
+ constructor(width: number, height: number);
21
+ }
@@ -13,3 +13,5 @@ export * from './WebXPongInstruction';
13
13
  export * from './WebXDataAckInstruction';
14
14
  export * from './WebXClipboardInstruction';
15
15
  export * from './WebXShapeInstruction';
16
+ export * from './WebXScreenResizeInstruction';
17
+ export * from './WebXKeyboardLayoutInstruction';
@@ -0,0 +1,19 @@
1
+ import { WebXMessage } from './WebXMessage';
2
+ /**
3
+ * Represents a message containing the keyboard layout name.
4
+ *
5
+ * This message is received from the WebX Engine when a client changes the keyboard layout
6
+ */
7
+ export declare class WebXKeyboardLayoutMessage extends WebXMessage {
8
+ /**
9
+ * The keyboard layout name.
10
+ * @private
11
+ */
12
+ readonly keyboardLayoutName: string;
13
+ /**
14
+ * Constructs a new WebXKeyboardLayoutMessage.
15
+ *
16
+ * @param keyboardLayoutName The content of the clipboard.
17
+ */
18
+ constructor(keyboardLayoutName: string);
19
+ }
@@ -55,5 +55,13 @@ export declare enum WebXMessageType {
55
55
  /**
56
56
  * Message containing window shape information (stencil image).
57
57
  */
58
- SHAPE = 12
58
+ SHAPE = 12,
59
+ /**
60
+ * Message containing window resize information.
61
+ */
62
+ SCREEN_RESIZE = 13,
63
+ /**
64
+ * Message containing keyboard layout name
65
+ */
66
+ KEYBOARD_LAYOUT = 14
59
67
  }
@@ -22,16 +22,26 @@ export declare class WebXScreenMessage extends WebXMessage {
22
22
  * The version of the WebX Engine.
23
23
  */
24
24
  readonly engineVersion: WebXVersion;
25
+ /**
26
+ * Whether the screen can be resized
27
+ */
28
+ readonly canResizeScreen: boolean;
29
+ /**
30
+ * The name of the current keyboard layout
31
+ */
32
+ readonly keyboardLayoutName: string;
25
33
  /**
26
34
  * Constructs a new WebXScreenMessage.
27
35
  *
36
+ * @param commandId The ID of the command associated with this message.
28
37
  * @param screenSize The size of the screen.
29
38
  * @param maxQualityIndex The maximum quality index for the display.
30
39
  * @param engineVersion The version of the WebX Engine.
31
- * @param commandId The ID of the command associated with this message.
40
+ * @param canResizeScreen Whether the screen can be resized
41
+ * @param keyboardLayoutName The name of the current keyboard layout
32
42
  */
33
- constructor(screenSize: {
43
+ constructor(commandId: number, screenSize: {
34
44
  width: number;
35
45
  height: number;
36
- }, maxQualityIndex: number, engineVersion: WebXVersion, commandId: number);
46
+ }, maxQualityIndex: number, engineVersion: WebXVersion, canResizeScreen: boolean, keyboardLayoutName: string);
37
47
  }
@@ -0,0 +1,22 @@
1
+ import { WebXMessage } from './WebXMessage';
2
+ /**
3
+ * This message is received from the WebX Engine when the screen is resized
4
+ */
5
+ export declare class WebXScreenResizeMessage extends WebXMessage {
6
+ /**
7
+ * The size of the screen.
8
+ */
9
+ readonly screenSize: {
10
+ width: number;
11
+ height: number;
12
+ };
13
+ /**
14
+ * Constructs a new WebXScreenResizeMessage.
15
+ *
16
+ * @param screenSize The size of the screen.
17
+ */
18
+ constructor(screenSize: {
19
+ width: number;
20
+ height: number;
21
+ });
22
+ }
@@ -12,3 +12,5 @@ export * from './WebXClipboardMessage';
12
12
  export * from './WebXConnectionMessage';
13
13
  export * from './WebXNopMessage';
14
14
  export * from './WebXShapeMessage';
15
+ export * from './WebXScreenResizeMessage';
16
+ export * from './WebXKeyboardLayoutMessage';
@@ -0,0 +1,22 @@
1
+ import { WebXInstructionHandler } from "./WebXInstructionHandler";
2
+ import { WebXHandler } from "./WebXHandler";
3
+ import { WebXInstruction } from "../instruction";
4
+ /**
5
+ * Provides a callback method when a specific combination of keys is pressed.
6
+ */
7
+ export declare class WebXKeyboardCombinationHandler extends WebXInstructionHandler implements WebXHandler {
8
+ private _combination;
9
+ private _callback;
10
+ private _keys;
11
+ constructor(_combination: number[], _callback: () => void);
12
+ /**
13
+ * Handles the instruction, recording key presses and determining if they match the provided combination. If they
14
+ * do then the callback is called.
15
+ * @param instruction The WebX instruction
16
+ */
17
+ handle(instruction: WebXInstruction): void;
18
+ /**
19
+ * Called when removed to clean up any resources: not needed here.
20
+ */
21
+ destroy(): void;
22
+ }
@@ -3,3 +3,4 @@ export * from './WebXMessageHandler';
3
3
  export * from './WebXStatsHandler';
4
4
  export * from './WebXDebugImageMessageHandler';
5
5
  export * from './WebXHandler';
6
+ export * from './WebXKeyboardCombinationHandler';
@@ -178,4 +178,34 @@ export declare class WebXInstructionEncoder {
178
178
  * windowId: 4 bytes
179
179
  */
180
180
  private _createShapeInstruction;
181
+ /**
182
+ * Create a new screen resize instruction
183
+ * @param instruction the screen resize instruction to encode
184
+ * Structure:
185
+ * Header: 32 bytes
186
+ * sessionId: 16 bytes
187
+ * clientId: 4 bytes
188
+ * type: 4 bytes
189
+ * id: 4 bytes
190
+ * padding: 4 bytes
191
+ * Content: 4 bytes
192
+ * width: 4 bytes
193
+ * height: 4 bytes
194
+ */
195
+ private _createScreenResizeInstruction;
196
+ /**
197
+ * Create a new keyboard layout instruction
198
+ * @param instruction the keyboard layout instruction to encode
199
+ * Structure:
200
+ * Header: 32 bytes
201
+ * sessionId: 16 bytes
202
+ * clientId: 4 bytes
203
+ * type: 4 bytes
204
+ * id: 4 bytes
205
+ * padding: 4 bytes
206
+ * Content:
207
+ * keyboardLayoutLength: 4 bytes
208
+ * keyboardLayout: N bytes
209
+ */
210
+ private _createKeyboardLayoutInstruction;
181
211
  }
@@ -102,4 +102,18 @@ export declare class WebXMessageDecoder {
102
102
  * @returns A promise that resolves to a WebXShapeMessage.
103
103
  */
104
104
  private _createShapeMessage;
105
+ /**
106
+ * Decodes a buffer into a WebXScreenResizeMessage containing the new screen dimensions
107
+ *
108
+ * @param buffer The binary message buffer to decode.
109
+ * @returns A promise that resolves to a WebXScreenResizeMessage.
110
+ */
111
+ private _createScreenResizeMessage;
112
+ /**
113
+ * Decodes a buffer into a WebxKeyboardLayoutMessage, which contains updated keyboard layout name.
114
+ *
115
+ * @param buffer The binary message buffer to decode.
116
+ * @returns A promise that resolves to a WebxKeyboardLayoutMessage.
117
+ */
118
+ private _createKeyboardLayoutMessage;
105
119
  }
@@ -64,7 +64,7 @@ export declare abstract class WebXTunnel {
64
64
  *
65
65
  * @param message The received message.
66
66
  */
67
- handleMessage(message: WebXMessage): void;
67
+ handleMessage(message: WebXMessage): Promise<void>;
68
68
  /**
69
69
  * Handles received bytes from the WebX Engine.
70
70
  *