(
app: &AppHandle<R>,
html: String,
width: u32,
height: u32,
task: F,
)
| 90 | } |
| 91 | |
| 92 | async fn with_export_webview<R: tauri::Runtime, F, Fut, T>( |
| 93 | app: &AppHandle<R>, |
| 94 | html: String, |
| 95 | width: u32, |
| 96 | height: u32, |
| 97 | task: F, |
| 98 | ) -> Result<T, String> |
| 99 | where |
| 100 | F: FnOnce(tauri::Webview<R>) -> Fut, |
| 101 | Fut: std::future::Future<Output = Result<T, String>>, |
| 102 | { |
| 103 | let window = ensure_export_host_window(app, width, height)?; |
| 104 | let wrapped = wrap_slide_html(&html, width, height); |
| 105 | let (url, temp_html) = file_url_for_export_html(app, &wrapped)?; |
| 106 | |
| 107 | window |
| 108 | .navigate(url) |
| 109 | .map_err(|error| format!("Failed to navigate export webview: {error}"))?; |
| 110 | |
| 111 | tokio::time::sleep(Duration::from_millis(RENDER_SETTLE_MS)).await; |
| 112 | |
| 113 | let webview = app |
| 114 | .get_webview(EXPORT_HOST_LABEL) |
| 115 | .ok_or_else(|| format!("Export webview is not ready: {EXPORT_HOST_LABEL}"))?; |
| 116 | |
| 117 | let result = task(webview).await; |
| 118 | let _ = std::fs::remove_file(&temp_html); |
| 119 | let _ = window.hide(); |
| 120 | result |
| 121 | } |
| 122 | |
| 123 | #[tauri::command] |
| 124 | pub async fn miniapp_render_slide_page( |
no test coverage detected