Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 19 additions & 18 deletions web-client/iron-remote-desktop-rdp/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
import init, {
import wasm_init, {
setup,
DesktopSize,
DeviceEvent,
InputTransaction,
IronError,
Session,
SessionBuilder,
SessionTerminationInfo,
ClipboardData,
ClipboardItem,
Extension,
} from '../../../crates/ironrdp-web/pkg/ironrdp_web';

export default {
init,
setup,
DesktopSize,
DeviceEvent,
InputTransaction,
IronError,
SessionBuilder,
ClipboardData,
ClipboardItem,
Session,
SessionTerminationInfo,
Extension,
export async function init(log_level: string) {
await wasm_init();
setup(log_level);
}

export const Backend = {
createDesktopSize: DesktopSize.init,
createMouseButtonPressed: DeviceEvent.mouse_button_pressed,
createMouseButtonReleased: DeviceEvent.mouse_button_released,
createMouseMove: DeviceEvent.mouse_move,
createWheelRotations: DeviceEvent.wheel_rotations,
createKeyPressed: DeviceEvent.key_pressed,
createKeyReleased: DeviceEvent.key_released,
createUnicodePressed: DeviceEvent.unicode_pressed,
createUnicodeReleased: DeviceEvent.unicode_released,
createInputTransaction: InputTransaction.init,
createSessionBuilder: SessionBuilder.init,
createClipboardData: ClipboardData.init,
};

export function preConnectionBlob(pcb: string): Extension {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { ClipboardItem } from './ClipboardItem';

export interface ClipboardData {
init(): ClipboardData;
add_text(mime_type: string, text: string): void;
add_binary(mime_type: string, binary: Uint8Array): void;
items(): ClipboardItem[];
Expand Down
2 changes: 0 additions & 2 deletions web-client/iron-remote-desktop/src/interfaces/DesktopSize.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
export interface DesktopSize {
width: number;
height: number;

init(width: number, height: number): DesktopSize;
}
11 changes: 1 addition & 10 deletions web-client/iron-remote-desktop/src/interfaces/DeviceEvent.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1 @@
export interface DeviceEvent {
mouse_button_pressed(button: number): DeviceEvent;
mouse_button_released(button: number): DeviceEvent;
mouse_move(x: number, y: number): DeviceEvent;
wheel_rotations(vertical: boolean, rotation_units: number): DeviceEvent;
key_pressed(scancode: number): DeviceEvent;
key_released(scancode: number): DeviceEvent;
unicode_pressed(unicode: string): DeviceEvent;
unicode_released(unicode: string): DeviceEvent;
}
export type DeviceEvent = unknown;
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
import type { DesktopSize } from './DesktopSize';
import type { DeviceEvent } from './DeviceEvent';
import type { InputTransaction } from './InputTransaction';
import type { IronError } from './session-event';
import type { Session } from './Session';
import type { SessionBuilder } from './SessionBuilder';
import type { SessionTerminationInfo } from './SessionTerminationInfo';
import type { ClipboardData } from './ClipboardData';
import type { ClipboardItem } from './ClipboardItem';

export interface RemoteDesktopModule {
init: () => Promise<unknown>;
setup: (logLevel: string) => void;
DesktopSize: DesktopSize;
DeviceEvent: DeviceEvent;
InputTransaction: InputTransaction;
RemoteDesktopError: IronError;
Session: Session;
SessionBuilder: SessionBuilder;
SessionTerminationInfo: SessionTerminationInfo;
ClipboardData: ClipboardData;
ClipboardItem: ClipboardItem;
createDesktopSize(width: number, height: number): DesktopSize;
createMouseButtonPressed(button: number): DeviceEvent;
createMouseButtonReleased(button: number): DeviceEvent;
createMouseMove(x: number, y: number): DeviceEvent;
createWheelRotations(vertical: boolean, rotation_units: number): DeviceEvent;
createKeyPressed(scancode: number): DeviceEvent;
createKeyReleased(scancode: number): DeviceEvent;
createUnicodePressed(unicode: string): DeviceEvent;
createUnicodeReleased(unicode: string): DeviceEvent;
createInputTransaction(): InputTransaction;
createSessionBuilder(): SessionBuilder;
createClipboardData(): ClipboardData;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type { DesktopSize } from './DesktopSize';
import type { ClipboardData } from './ClipboardData';

export interface SessionBuilder {
init(): SessionBuilder;
/**
* Required
*/
Expand Down
5 changes: 0 additions & 5 deletions web-client/iron-remote-desktop/src/iron-remote-desktop.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import { onMount } from 'svelte';
import { loggingService } from './services/logging.service';
import { RemoteDesktopService } from './services/remote-desktop.service';
import { LogType } from './enums/LogType';
import type { ResizeEvent } from './interfaces/ResizeEvent';
import { PublicAPI } from './services/PublicAPI';
import { ScreenScale } from './enums/ScreenScale';
Expand All @@ -27,13 +26,11 @@
let {
scale,
verbose,
debugwasm,
flexcenter,
module,
}: {
scale: string;
verbose: 'true' | 'false';
debugwasm: 'OFF' | 'ERROR' | 'WARN' | 'INFO' | 'DEBUG' | 'TRACE';
flexcenter: string;
module: RemoteDesktopModule;
} = $props();
Expand Down Expand Up @@ -667,8 +664,6 @@
canvas.width = 800;
canvas.height = 600;

const logLevel = LogType[debugwasm] ?? LogType.INFO;
await remoteDesktopService.init(logLevel);
remoteDesktopService.setCanvas(canvas);

initListeners();
Expand Down
1 change: 0 additions & 1 deletion web-client/iron-remote-desktop/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ export * as default from './iron-remote-desktop.svelte';
export type { ResizeEvent } from './interfaces/ResizeEvent';
export type { NewSessionInfo } from './interfaces/NewSessionInfo';
export type { ServerRect } from './interfaces/ServerRect';
export type { DesktopSize } from './interfaces/DesktopSize';
export type { SessionEvent, IronError, IronErrorKind } from './interfaces/session-event';
export type { SessionEventType } from './enums/SessionEventType';
export type { SessionTerminationInfo } from './interfaces/SessionTerminationInfo';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { BehaviorSubject, from, Observable, of, Subject } from 'rxjs';
import { loggingService } from './logging.service';
import { catchError, filter, map } from 'rxjs/operators';
import { scanCode } from '../lib/scancodes';
import { LogType } from '../enums/LogType';
import { OS } from '../enums/OS';
import { ModifierKey } from '../enums/ModifierKey';
import { LockKey } from '../enums/LockKey';
Expand Down Expand Up @@ -65,14 +64,7 @@ export class RemoteDesktopService {
}

createClipboardData(): ClipboardData {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: For myself. Verify if we still need this function.

return this.module.ClipboardData.init();
}

async init(debug: LogType) {
loggingService.info('Load wasm file...');
await this.module.init();
loggingService.info('Initialize the remote desktop module...');
this.module.setup(LogType[debug]);
return this.module.createClipboardData();
}

// If set to false, the clipboard will not be enabled and the callbacks will not be registered to the Rust side
Expand Down Expand Up @@ -116,14 +108,12 @@ export class RemoteDesktopService {
if (preventDefault) {
event.preventDefault(); // prevent default behavior (context menu, etc)
}
const mouseFnc = isDown
? this.module.DeviceEvent.mouse_button_pressed
: this.module.DeviceEvent.mouse_button_released;
const mouseFnc = isDown ? this.module.createMouseButtonPressed : this.module.createMouseButtonReleased;
this.doTransactionFromDeviceEvents([mouseFnc(event.button)]);
}

updateMousePosition(position: MousePosition) {
this.doTransactionFromDeviceEvents([this.module.DeviceEvent.mouse_move(position.x, position.y)]);
this.doTransactionFromDeviceEvents([this.module.createMouseMove(position.x, position.y)]);
this.mousePosition.next(position);
}

Expand All @@ -132,7 +122,7 @@ export class RemoteDesktopService {
}

connect(config: Config): Observable<NewSessionInfo> {
const sessionBuilder = this.module.SessionBuilder.init();
const sessionBuilder = this.module.createSessionBuilder();

sessionBuilder.proxy_address(config.proxyAddress);
sessionBuilder.destination(config.destination);
Expand Down Expand Up @@ -160,7 +150,7 @@ export class RemoteDesktopService {

if (config.desktopSize != null) {
sessionBuilder.desktop_size(
this.module.DesktopSize.init(config.desktopSize.width, config.desktopSize.height),
this.module.createDesktopSize(config.desktopSize.width, config.desktopSize.height),
);
}

Expand Down Expand Up @@ -242,7 +232,7 @@ export class RemoteDesktopService {
mouseWheel(event: WheelEvent) {
const vertical = event.deltaY !== 0;
const rotation = vertical ? event.deltaY : event.deltaX;
this.doTransactionFromDeviceEvents([this.module.DeviceEvent.wheel_rotations(vertical, -rotation)]);
this.doTransactionFromDeviceEvents([this.module.createWheelRotations(vertical, -rotation)]);
}

setVisibility(state: boolean) {
Expand Down Expand Up @@ -273,7 +263,7 @@ export class RemoteDesktopService {

onClipboardChangedEmpty(): Promise<void> {
const onClipboardChangedPromise = async () => {
await this.session?.on_clipboard_paste(this.module.ClipboardData.init());
await this.session?.on_clipboard_paste(this.module.createClipboardData());
};
return onClipboardChangedPromise();
}
Expand Down Expand Up @@ -318,11 +308,11 @@ export class RemoteDesktopService {
let unicodeEvent;

if (evt.type === 'keydown') {
keyEvent = this.module.DeviceEvent.key_pressed;
unicodeEvent = this.module.DeviceEvent.unicode_pressed;
keyEvent = this.module.createKeyPressed;
unicodeEvent = this.module.createUnicodePressed;
} else if (evt.type === 'keyup') {
keyEvent = this.module.DeviceEvent.key_released;
unicodeEvent = this.module.DeviceEvent.unicode_released;
keyEvent = this.module.createKeyReleased;
unicodeEvent = this.module.createUnicodeReleased;
}

let sendAsUnicode = true;
Expand Down Expand Up @@ -453,7 +443,7 @@ export class RemoteDesktopService {
}

private doTransactionFromDeviceEvents(deviceEvents: DeviceEvent[]) {
const transaction = this.module.InputTransaction.init();
const transaction = this.module.createInputTransaction();
deviceEvents.forEach((event) => transaction.add_event(event));
this.session?.apply_inputs(transaction);
}
Expand All @@ -464,21 +454,18 @@ export class RemoteDesktopService {
const suppr = parseInt('0xE053', 16);

this.doTransactionFromDeviceEvents([
this.module.DeviceEvent.key_pressed(ctrl),
this.module.DeviceEvent.key_pressed(alt),
this.module.DeviceEvent.key_pressed(suppr),
this.module.DeviceEvent.key_released(ctrl),
this.module.DeviceEvent.key_released(alt),
this.module.DeviceEvent.key_released(suppr),
this.module.createKeyPressed(ctrl),
this.module.createKeyPressed(alt),
this.module.createKeyPressed(suppr),
this.module.createKeyReleased(ctrl),
this.module.createKeyReleased(alt),
this.module.createKeyReleased(suppr),
]);
}

private sendMeta() {
const meta = parseInt('0xE05B', 16);

this.doTransactionFromDeviceEvents([
this.module.DeviceEvent.key_pressed(meta),
this.module.DeviceEvent.key_released(meta),
]);
this.doTransactionFromDeviceEvents([this.module.createKeyPressed(meta), this.module.createKeyReleased(meta)]);
}
}
10 changes: 7 additions & 3 deletions web-client/iron-svelte-client/src/lib/login/login.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
import { currentSession, userInteractionService } from '../../services/session.service';
import { catchError, filter } from 'rxjs/operators';
import type { UserInteraction, NewSessionInfo } from '../../../static/iron-remote-desktop';
import { preConnectionBlob, displayControl, kdcProxyUrl } from '../../../static/iron-remote-desktop-rdp';
import { preConnectionBlob, displayControl, kdcProxyUrl, init } from '../../../static/iron-remote-desktop-rdp';
import { from, of } from 'rxjs';
import { toast } from '$lib/messages/message-store';
import { showLogin } from '$lib/login/login-store';
import { DesktopSize } from '../../models/desktop-size';
import { onMount } from 'svelte';

let username = 'Administrator';
let password = 'DevoLabs123!';
Expand All @@ -15,7 +15,7 @@
let domain = '';
let authtoken = '';
let kdc_proxy_url = '';
let desktopSize = new DesktopSize(1280, 768);
let desktopSize = { width: 1280, height: 720 };
let pcb = '';
let pop_up = false;
let enable_clipboard = true;
Expand Down Expand Up @@ -171,6 +171,10 @@
}
});
};

onMount(async () => {
await init('INFO');
});
</script>

<main class="responsive login-container">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { onMount } from 'svelte';
import { setCurrentSessionActive, userInteractionService } from '../../services/session.service';
import type { UserInteraction } from '../../../static/iron-remote-desktop';
import IronRdp from '../../../static/iron-remote-desktop-rdp';
import { Backend } from '../../../static/iron-remote-desktop-rdp';
import { preConnectionBlob, displayControl, kdcProxyUrl } from '../../../static/iron-remote-desktop-rdp';

let userInteraction: UserInteraction;
Expand Down Expand Up @@ -146,7 +146,7 @@
</label>
</div>
</div>
<iron-remote-desktop debugwasm="INFO" verbose="true" scale="fit" flexcenter="true" module={IronRdp} />
<iron-remote-desktop verbose="true" scale="fit" flexcenter="true" module={Backend} />
</div>

<style>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { setCurrentSessionActive, userInteractionService } from '../../services/session.service';
import { showLogin } from '$lib/login/login-store';
import type { UserInteraction } from '../../../static/iron-remote-desktop';
import IronRdp from '../../../static/iron-remote-desktop-rdp';
import { Backend } from '../../../static/iron-remote-desktop-rdp';

let uiService: UserInteraction;
let cursorOverrideActive = false;
Expand Down Expand Up @@ -101,7 +101,7 @@
</div>
{/if}
</div>
<iron-remote-desktop debugwasm="INFO" verbose="true" scale="fit" flexcenter="true" module={IronRdp} />
<iron-remote-desktop verbose="true" scale="fit" flexcenter="true" module={Backend} />
</div>

<style>
Expand Down
14 changes: 0 additions & 14 deletions web-client/iron-svelte-client/src/models/desktop-size.ts

This file was deleted.

3 changes: 1 addition & 2 deletions web-client/iron-svelte-client/src/models/session.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { Guid } from 'guid-typescript';
import type { DesktopSize } from './desktop-size';

export class Session {
id: Guid;
sessionId!: number;
name?: string;
active!: boolean;
desktopSize!: DesktopSize;
desktopSize!: { width: number; height: number };

constructor(name?: string) {
this.id = Guid.create();
Expand Down
Loading