C#C
C#13mo ago
ero

Avalonia app with WASM-based UI-plugins; looking to bounce some ideas around

Hey everyone.

I'm currently working on a plugin system as a side project to my main Avalonia app. The plugins are meant to be compiled WASM core modules and my app will consume them. The idea is to provide a sandboxed environment that any language (that compiles valid WASM core modules) can interact with. This is to allow developers some freedoms in what language they can choose to build the plugins.

Interop between the app and the plugin happens via Extism, a WASM plugin<->host service available for many languages. It allows for the following:
  1. Sending packages from and to the plugin
    • Extism can allocate a block of memory to place the data in, which is then read by the other side
    • This can include any JSON-serialized object, which is then deserialized on the other side
    • I have not found (or not checked enough for) a way to send unmanaged structs without serializing
  2. Plugins can import and export unmanaged methods
    • The app can define unmanaged callbacks, which the plugin can then
      DllImport
      and call at any time (with some limited arguments)
    • The plugin must define some expected exports (
      [UnmanagedCallersOnly]
      ) that the app will then call to get certain data
These plugins should now gain the ability to draw on and update the UI of my app.
For some context on that: each plugin gets a dedicated slot on my app. One whole grid row that spans the entire width of the app. The height is determined by the content that the plugin wants to present (or a fixed height, if provided).
Was this page helpful?
Avalonia app with WASM-based UI-plugins; looking to bounce some ideas around - C#