Skip to main content

Crate tauri_plugin_gpui

Crate tauri_plugin_gpui 

Source
Expand description

§tauri-plugin-gpui

Render GPUI views inside ordinary Tauri windows.

Tauri/TAO stays authoritative for the application lifecycle, the event loop and native windows. This plugin permanently attaches GPUI as the content renderer of an existing Tauri window; all attached windows share one GPUI App running on Tauri’s event-loop thread.

use tauri_plugin_gpui::{GpuiWindowExt, gpui::{self, prelude::*}};

struct Hello;

impl gpui::Render for Hello {
    fn render(&mut self, _: &mut gpui::Window, _: &mut gpui::Context<Self>) -> impl IntoElement {
        gpui::div().size_full().child("Hello from GPUI")
    }
}

// In an app, `context` is `tauri::generate_context!()`.
fn run(context: tauri::Context) {
    tauri::Builder::default()
        .setup(|app| {
            tauri_plugin_gpui::init(app)?;
            let window = tauri::WindowBuilder::new(app, "main").title("Example").build()?;
            window.attach_gpui(|cx| cx.new(|_| Hello))?;
            Ok(())
        })
        .run(context)
        .expect("error while running tauri application");
}

§Platforms and features

Linux, macOS and Windows work with default features. Android and iOS need the mobile feature; without it, init returns GpuiError::UnsupportedOperation on those targets. Embedding Tauri child webviews (webview_frame) is desktop-only.

Re-exports§

pub use gpui;

Structs§

GpuiConfig
Application-wide configuration for the shared GPUI runtime.
GpuiOptions
Per-window attachment options.
WebviewFrameNeither Android nor iOS
The element returned by webview_frame.

Enums§

GpuiError
Errors returned by the plugin’s public API.

Traits§

GpuiWindowExt
Attaches GPUI as the content renderer of a Tauri window.

Functions§

focus_webviewNeither Android nor iOS
Gives keyboard focus to webview, a child webview placed with webview_frame, as clicking it would. Use it when a GPUI control opens something in the webview that expects typing, such as a search box.
init
Initializes the shared GPUI runtime and hooks it into Tauri’s event loop.
init_with
init with explicit configuration.
on_back
Sets the handler for the system back action (the Android back button or gesture). It only runs while set_back_enabled is true; otherwise back leaves the app as usual. Never called on desktop.
set_back_enabled
Declares whether the app currently handles the back action, typically whether its navigation stack is deeper than its root. No-op on desktop.
webview_frameNeither Android nor iOS
Creates a GPUI element that hosts webview, a child webview of the GPUI-backed Tauri window this element renders in.
with_app
Runs f with the shared GPUI App.