Files
AFFiNE-Mirror/packages/frontend/mobile-native/src/preview.rs
T
DarkSky 0c16d7110d feat: improve native preview (#15223)
#### PR Dependency Tree


* **PR #15223** 👈

This tree was auto-generated by
[Charcoal](https://github.com/danerwilliams/charcoal)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Improvements**
* Updated Mermaid and Typst preview rendering in native/mobile apps to
use a shared preview implementation.
* Improved production Release builds with additional Rust release tuning
and enhanced iOS Release stripping/symbol settings.
* Enabled stronger release output optimization for the native package
build.
* **Bug Fixes**
* Strengthened handling of unsupported self-hosted server versions
during login preflight.
* Refreshed unsupported-version messaging with localized text and a
direct upgrade link.
* **Tests**
* Added coverage for login preflight behavior when the server version is
unsupported.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-07-13 03:23:08 +08:00

46 lines
1.0 KiB
Rust

use std::path::PathBuf;
use affine_preview::{MermaidRenderOptions, TypstRenderOptions};
use crate::{Result, UniffiError};
#[uniffi::export]
pub fn render_mermaid_preview_svg(
code: String,
theme: Option<String>,
font_family: Option<String>,
font_size: Option<f64>,
) -> Result<String> {
affine_preview::render_mermaid_svg(
&code,
MermaidRenderOptions {
theme,
font_family,
font_size,
},
)
.map_err(|error| UniffiError::Err(error.to_string()))
}
fn resolve_typst_font_dirs(font_dirs: Option<Vec<String>>) -> Vec<PathBuf> {
font_dirs
.map(|dirs| dirs.into_iter().map(PathBuf::from).collect())
.unwrap_or_default()
}
#[uniffi::export]
pub fn render_typst_preview_svg(
code: String,
font_dirs: Option<Vec<String>>,
cache_dir: Option<String>,
) -> Result<String> {
affine_preview::render_typst_svg(
&code,
TypstRenderOptions {
font_dirs: resolve_typst_font_dirs(font_dirs),
cache_dir: cache_dir.map(PathBuf::from),
},
)
.map_err(|error| UniffiError::Err(error.to_string()))
}