-
Notifications
You must be signed in to change notification settings - Fork 126
refactor(web-client): refactor iron-remote-gui
into iron-remote-desktop
#722
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
web-client/iron-remote-desktop-rdp/src/services/logging.service.ts
Outdated
Show resolved
Hide resolved
web-client/iron-remote-desktop-rdp/src/services/wasm-bridge.service.ts
Outdated
Show resolved
Hide resolved
web-client/iron-remote-desktop-rdp/src/iron-remote-desktop.svelte
Outdated
Show resolved
Hide resolved
web-client/iron-svelte-client/src/services/server-bridge.service.ts
Outdated
Show resolved
Hide resolved
I think you are aware of this yourself as far as I can see in your own comments, but this is not really what I imagined when I talked about dependency injection. To clarify: the new I’m not very good at JavaScript/TypeScript, so let me illustrate what I mean using Rust: // -- iron-remote-desktop --
// Implements all the backend-agnostic logic, based on a given "remote desktop interface".
trait RemoteDesktopApi {
fn remote_desktop_init(&self);
}
fn run(api: Box<dyn RemoteDesktopApi>) {
// The logic is calling the remote desktop API, and does not know whether this is RDP or VNC.
api.remote_desktop_init();
}
// -- ironrdp-web --
// This is what actually implements the interface.
// But TypeScript is kind of working in a duck-typed way,
// so unlike Rust you don’t need to import the interface definition in order to implement it!
pub struct Api;
impl RemoteDesktopApi for Api {
fn remote_desktop_init(&self) {
// do stuff
}
}
// -- iron-remote-desktop-rdp --
// The purpose is to inline the WASM module in base64,
// but essentially, it exposes the exact same things as ironrdp-web.
pub use ironrdp_web::Api;
// -- iron-svelte-client --
// Injects the dependency (IronRDP) into the web component (iron-remote-desktop), and uses it.
// It knows that its IronRDP behind the scenes, and may inject additional extensions (future improvement).
iron_remote_desktop::run(Box::new(iron_remote_desktop_rdp::Api)); Because of the way JavaScript/TypeScript works, we don’t need Keep in mind that I’m only trying to illustrate what I meant for dependency injection. I do not ask you to modify drastically any Rust code (ideally My expectation is that export * as default from './path/to/wasm/module' = Re-export the whole interface of the WASM module. You can then import this module in import * as rdp from '@devolutions/iron-remote-desktop-rdp'
// I think we have something called "userInteraction" somewhere?
// Use it to inject the module ("dependency").
userInteraction.setBackend(rdp);
// Or maybe it’s `userInteractionService` which wraps the `userInteraction`?
// Try to look for the `onMount` function.
// We retrieve the `userInteraction` (`event.detail.irgUserInteraction`) and
// store it in a `writeable` that is accessible globally. (Also refer to this section.) If you hit a problem, let me know in Slack so we can think through this together. I never implemented such a thing myself, so I don’t know all the problems you may encounter beforehand in details, but I have a solid idea of what it should looks like. |
Let's clarify: iron-remote-desktop-rdp has to re-export WASM and provide extension types. The next step is to modify the UserInteraction to accept the "backend" which will be either RDP or VNC and implements an interface (I have really missed the fact that JS/TS has a duck types). The next step should be the refactoring of the |
Exactly! |
…e interface declarations
…e-desktop` package
…ct` to be able to create interfaces and call them via interfaces; move logic into `iron-remote-desktop` crate as Benoit have asked; implemented dependency injection
3a4a47a
to
f7a4b86
Compare
Coverage Report 🤖 ⚙️Past: New: Diff: +0.00% [this comment will be updated automatically] |
web-client/iron-remote-desktop/src/services/wasm-bridge.service.ts
Outdated
Show resolved
Hide resolved
…ated WASM package
web-client/iron-remote-desktop/src/interfaces/SessionBuilder.ts
Outdated
Show resolved
Hide resolved
web-client/iron-remote-desktop/src/interfaces/RemoteDesktopModule.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really good work so far. Remaining comments are "minor" 🙂
That was a big refactoring, but we are almost done!
Summing up. Remaining questions to address before merging:
Suggestions to address in follow up PRs: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Excellent work. Let’s follow up with small incremental changes in separate PRs 🙂
This is the first part of the "Modularize the remote desktop WebComponent" ticket.
PR changes the
web-client
of the IronRDP:iron-remote-gui
packageiron-remote-desktop
package with the TypeScript interfaces and exposed more interfaces from the WASM bindingsiron-remote-desktop-rdp
package which combines WASM bindings and the TypeScript interfaces from theiron-remote-desktop
to create aniron-remote-desktop
HTML tag which is responsible for the RDP connection.xtask
Although GitHub says that there are 5K changes, most of the things are just file moves/renaming from
iron-remote-gui
toiron-remote-desktop
andiron-remote-desktop-rdp
. It doesn't seem to be able to diff it properly.