Write slide HTML to app cache and return a `file://` URL for the export webview.
(
app: &AppHandle<R>,
html: &str,
)
| 43 | |
| 44 | /// Write slide HTML to app cache and return a `file://` URL for the export webview. |
| 45 | fn file_url_for_export_html<R: tauri::Runtime>( |
| 46 | app: &AppHandle<R>, |
| 47 | html: &str, |
| 48 | ) -> Result<(tauri::Url, PathBuf), String> { |
| 49 | let cache_dir = app |
| 50 | .path() |
| 51 | .app_cache_dir() |
| 52 | .map_err(|error| format!("Failed to resolve app cache dir: {error}"))?; |
| 53 | let export_dir = cache_dir.join("miniapp-slide-export"); |
| 54 | std::fs::create_dir_all(&export_dir) |
| 55 | .map_err(|error| format!("Failed to create export cache dir: {error}"))?; |
| 56 | let file_path = export_dir.join(format!("slide-{}.html", Uuid::new_v4())); |
| 57 | std::fs::write(&file_path, html) |
| 58 | .map_err(|error| format!("Failed to write export HTML: {error}"))?; |
| 59 | let url = tauri::Url::from_file_path(&file_path) |
| 60 | .map_err(|_| "Failed to build file URL for export webview".to_string())?; |
| 61 | Ok((url, file_path)) |
| 62 | } |
| 63 | |
| 64 | fn ensure_export_host_window<R: tauri::Runtime>( |
| 65 | app: &AppHandle<R>, |
no test coverage detected