Repair: the Google Fonts host commands as 7f9e172 meant them (a staging race split them from 43fc8a1)
Two agents staged the same host files at once:7f9e172went in with the diagnostics' hunks of app.rs, commands.rs and lib.rs instead of its own, and43fc8a1then dropped fonts_commands.rs. This puts back exactly the Google Fonts wiring from the working tree (AppConfig::with_fonts, SiteHooks::fonts_changed, commands::GFONTS, the fonts handler, fonts_commands.rs); the diagnostics stay as committed. theme.rs, still in progress, is not included. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
43fc8a15f5
commit
825742b964
4 changed files with 112 additions and 5 deletions
|
|
@ -86,6 +86,9 @@ pub struct AppConfig {
|
|||
pub store: Option<&'static crate::store::StoreConfig>,
|
||||
/// The shell's media panel (gallery folders, the clipboard history): serves [`commands::MEDIA`].
|
||||
pub media: bool,
|
||||
/// Google Fonts (install, remove, preview; the cache in app data): serves [`commands::GFONTS`]
|
||||
/// and calls [`SiteHooks::fonts_changed`]. Needs the `net` feature.
|
||||
pub fonts: bool,
|
||||
}
|
||||
|
||||
impl AppConfig {
|
||||
|
|
@ -109,9 +112,16 @@ impl AppConfig {
|
|||
home_url: None,
|
||||
store: None,
|
||||
media: false,
|
||||
fonts: false,
|
||||
}
|
||||
}
|
||||
|
||||
/// Serves the Google Fonts commands ([`commands::GFONTS`]).
|
||||
pub const fn with_fonts(mut self) -> Self {
|
||||
self.fonts = true;
|
||||
self
|
||||
}
|
||||
|
||||
/// Serves the media panel's commands ([`commands::MEDIA`]).
|
||||
pub const fn with_media(mut self) -> Self {
|
||||
self.media = true;
|
||||
|
|
@ -202,6 +212,10 @@ pub trait SiteHooks: Send + Sync + 'static {
|
|||
/// A tab webview was created.
|
||||
fn tab_created(&self, _app: &AppHandle) {}
|
||||
|
||||
/// A Google font was installed or removed ([`commands::GFONTS`]): give the site tabs their
|
||||
/// theme, and the font bytes, again.
|
||||
fn fonts_changed(&self, _app: &AppHandle) {}
|
||||
|
||||
/// `tab` was laid out for `item` (existing or new), before it is placed.
|
||||
fn tab_placed(&self, _app: &AppHandle, _tab: &Webview, _item: &TabLayout) {}
|
||||
|
||||
|
|
@ -248,6 +262,11 @@ fn host_state(app: &AppHandle) -> tauri::State<'_, Host> {
|
|||
app.state::<Host>()
|
||||
}
|
||||
|
||||
/// The app's site hooks ([`run_app`] must be running).
|
||||
pub(crate) fn hooks(app: &AppHandle) -> Arc<dyn SiteHooks> {
|
||||
host_state(app).hooks.clone()
|
||||
}
|
||||
|
||||
/// The app's config ([`run_app`] must be running).
|
||||
pub fn config(app: &AppHandle) -> AppConfig {
|
||||
host_state(app).config
|
||||
|
|
@ -1115,6 +1134,17 @@ fn store_handler() -> impl Fn(tauri::ipc::Invoke<Wry>) -> bool + Send + Sync + '
|
|||
|_| false
|
||||
}
|
||||
|
||||
/// The Google Fonts commands ([`commands::GFONTS`]): with the `net` feature (downloads) only.
|
||||
#[cfg(feature = "net")]
|
||||
fn fonts_handler() -> impl Fn(tauri::ipc::Invoke<Wry>) -> bool + Send + Sync + 'static {
|
||||
crate::fonts_commands::handler()
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "net"))]
|
||||
fn fonts_handler() -> impl Fn(tauri::ipc::Invoke<Wry>) -> bool + Send + Sync + 'static {
|
||||
|_| false
|
||||
}
|
||||
|
||||
/// The media panel's commands ([`commands::MEDIA`]).
|
||||
fn media_handler() -> impl Fn(tauri::ipc::Invoke<Wry>) -> bool + Send + Sync + 'static {
|
||||
crate::media_commands::handler()
|
||||
|
|
@ -1152,6 +1182,7 @@ impl App {
|
|||
let host_handler = host_handler();
|
||||
let store_handler = store_handler();
|
||||
let media_handler = media_handler();
|
||||
let fonts_handler = fonts_handler();
|
||||
let builder = tauri::Builder::<Wry>::default()
|
||||
// Must be first: a second launch focuses the running window instead of fighting over
|
||||
// the app's data and WebView profile (and hands over its link).
|
||||
|
|
@ -1232,6 +1263,8 @@ impl App {
|
|||
#[cfg(feature = "net")]
|
||||
crate::store_commands::init(&handle, &config);
|
||||
crate::media_commands::init(&handle);
|
||||
#[cfg(feature = "net")]
|
||||
crate::fonts_commands::init(&handle);
|
||||
// Safe mode for this run: the launch argument, or Shift held while starting (Windows).
|
||||
crate::safe::set(crate::safe::at_launch(std::env::args(), host::shift_held()));
|
||||
// Focus and layering diagnostics for this run: `--diag` or WAYBETTER_DIAG=1 (app log folder, diag.log).
|
||||
|
|
@ -1250,6 +1283,8 @@ impl App {
|
|||
store_handler(invoke)
|
||||
} else if commands::MEDIA.contains(&invoke.message.command()) {
|
||||
media_handler(invoke)
|
||||
} else if commands::GFONTS.contains(&invoke.message.command()) {
|
||||
fonts_handler(invoke)
|
||||
} else if commands::is_host(invoke.message.command()) {
|
||||
host_handler(invoke)
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue