@@ -2,7 +2,6 @@ import { BehaviorSubject, from, Observable, of, Subject } from 'rxjs';
22import { loggingService } from './logging.service' ;
33import { catchError , filter , map } from 'rxjs/operators' ;
44import { scanCode } from '../lib/scancodes' ;
5- import { LogType } from '../enums/LogType' ;
65import { OS } from '../enums/OS' ;
76import { ModifierKey } from '../enums/ModifierKey' ;
87import { LockKey } from '../enums/LockKey' ;
@@ -65,14 +64,7 @@ export class RemoteDesktopService {
6564 }
6665
6766 createClipboardData ( ) : ClipboardData {
68- return this . module . ClipboardData . init ( ) ;
69- }
70-
71- async init ( debug : LogType ) {
72- loggingService . info ( 'Load wasm file...' ) ;
73- await this . module . init ( ) ;
74- loggingService . info ( 'Initialize the remote desktop module...' ) ;
75- this . module . setup ( LogType [ debug ] ) ;
67+ return this . module . createClipboardData ( ) ;
7668 }
7769
7870 // If set to false, the clipboard will not be enabled and the callbacks will not be registered to the Rust side
@@ -116,14 +108,12 @@ export class RemoteDesktopService {
116108 if ( preventDefault ) {
117109 event . preventDefault ( ) ; // prevent default behavior (context menu, etc)
118110 }
119- const mouseFnc = isDown
120- ? this . module . DeviceEvent . mouse_button_pressed
121- : this . module . DeviceEvent . mouse_button_released ;
111+ const mouseFnc = isDown ? this . module . createMouseButtonPressed : this . module . createMouseButtonReleased ;
122112 this . doTransactionFromDeviceEvents ( [ mouseFnc ( event . button ) ] ) ;
123113 }
124114
125115 updateMousePosition ( position : MousePosition ) {
126- this . doTransactionFromDeviceEvents ( [ this . module . DeviceEvent . mouse_move ( position . x , position . y ) ] ) ;
116+ this . doTransactionFromDeviceEvents ( [ this . module . createMouseMove ( position . x , position . y ) ] ) ;
127117 this . mousePosition . next ( position ) ;
128118 }
129119
@@ -132,7 +122,7 @@ export class RemoteDesktopService {
132122 }
133123
134124 connect ( config : Config ) : Observable < NewSessionInfo > {
135- const sessionBuilder = this . module . SessionBuilder . init ( ) ;
125+ const sessionBuilder = this . module . createSessionBuilder ( ) ;
136126
137127 sessionBuilder . proxy_address ( config . proxyAddress ) ;
138128 sessionBuilder . destination ( config . destination ) ;
@@ -160,7 +150,7 @@ export class RemoteDesktopService {
160150
161151 if ( config . desktopSize != null ) {
162152 sessionBuilder . desktop_size (
163- this . module . DesktopSize . init ( config . desktopSize . width , config . desktopSize . height ) ,
153+ this . module . createDesktopSize ( config . desktopSize . width , config . desktopSize . height ) ,
164154 ) ;
165155 }
166156
@@ -242,7 +232,7 @@ export class RemoteDesktopService {
242232 mouseWheel ( event : WheelEvent ) {
243233 const vertical = event . deltaY !== 0 ;
244234 const rotation = vertical ? event . deltaY : event . deltaX ;
245- this . doTransactionFromDeviceEvents ( [ this . module . DeviceEvent . wheel_rotations ( vertical , - rotation ) ] ) ;
235+ this . doTransactionFromDeviceEvents ( [ this . module . createWheelRotations ( vertical , - rotation ) ] ) ;
246236 }
247237
248238 setVisibility ( state : boolean ) {
@@ -273,7 +263,7 @@ export class RemoteDesktopService {
273263
274264 onClipboardChangedEmpty ( ) : Promise < void > {
275265 const onClipboardChangedPromise = async ( ) => {
276- await this . session ?. on_clipboard_paste ( this . module . ClipboardData . init ( ) ) ;
266+ await this . session ?. on_clipboard_paste ( this . module . createClipboardData ( ) ) ;
277267 } ;
278268 return onClipboardChangedPromise ( ) ;
279269 }
@@ -318,11 +308,11 @@ export class RemoteDesktopService {
318308 let unicodeEvent ;
319309
320310 if ( evt . type === 'keydown' ) {
321- keyEvent = this . module . DeviceEvent . key_pressed ;
322- unicodeEvent = this . module . DeviceEvent . unicode_pressed ;
311+ keyEvent = this . module . createKeyPressed ;
312+ unicodeEvent = this . module . createUnicodePressed ;
323313 } else if ( evt . type === 'keyup' ) {
324- keyEvent = this . module . DeviceEvent . key_released ;
325- unicodeEvent = this . module . DeviceEvent . unicode_released ;
314+ keyEvent = this . module . createKeyReleased ;
315+ unicodeEvent = this . module . createUnicodeReleased ;
326316 }
327317
328318 let sendAsUnicode = true ;
@@ -453,7 +443,7 @@ export class RemoteDesktopService {
453443 }
454444
455445 private doTransactionFromDeviceEvents ( deviceEvents : DeviceEvent [ ] ) {
456- const transaction = this . module . InputTransaction . init ( ) ;
446+ const transaction = this . module . createInputTransaction ( ) ;
457447 deviceEvents . forEach ( ( event ) => transaction . add_event ( event ) ) ;
458448 this . session ?. apply_inputs ( transaction ) ;
459449 }
@@ -464,21 +454,18 @@ export class RemoteDesktopService {
464454 const suppr = parseInt ( '0xE053' , 16 ) ;
465455
466456 this . doTransactionFromDeviceEvents ( [
467- this . module . DeviceEvent . key_pressed ( ctrl ) ,
468- this . module . DeviceEvent . key_pressed ( alt ) ,
469- this . module . DeviceEvent . key_pressed ( suppr ) ,
470- this . module . DeviceEvent . key_released ( ctrl ) ,
471- this . module . DeviceEvent . key_released ( alt ) ,
472- this . module . DeviceEvent . key_released ( suppr ) ,
457+ this . module . createKeyPressed ( ctrl ) ,
458+ this . module . createKeyPressed ( alt ) ,
459+ this . module . createKeyPressed ( suppr ) ,
460+ this . module . createKeyReleased ( ctrl ) ,
461+ this . module . createKeyReleased ( alt ) ,
462+ this . module . createKeyReleased ( suppr ) ,
473463 ] ) ;
474464 }
475465
476466 private sendMeta ( ) {
477467 const meta = parseInt ( '0xE05B' , 16 ) ;
478468
479- this . doTransactionFromDeviceEvents ( [
480- this . module . DeviceEvent . key_pressed ( meta ) ,
481- this . module . DeviceEvent . key_released ( meta ) ,
482- ] ) ;
469+ this . doTransactionFromDeviceEvents ( [ this . module . createKeyPressed ( meta ) , this . module . createKeyReleased ( meta ) ] ) ;
483470 }
484471}
0 commit comments