Repository: moeru-ai/airi
File: apps/stage-tamagotchi/src-tauri/src/plugins/window_pass_through_on_hover/mod.rs (Rust)

Code before:
) -> std::result::Result<(), String> {
  set_pass_through_enabled(&window, false).map_err(|e| {
    log::error!("Failed to disable click-through: {e}");
    e
  })
}

const PLUGIN_NAME: &str = "proj-airi-tauri-plugin-window-pass-through-on-hover";

pub fn init<R: Runtime>() -> TauriPlugin<R> {
  let builder = tauri_specta::Builder::<R>::new()
    .plugin_name(PLUGIN_NAME)
    // ↓ HACKY WARNING
    // ↓ Below is a modified version from the expansion of `tauri_specta::collect_commands!`,
    // ↓ as the original macro does not accept a mix of commands with and without `#[specta::specta]`
    .commands(tauri_specta::internal::command(
      tauri::generate_handler![
        start_monitor,
        stop_monitor,
        start_pass_through,
        stop_pass_through
      ],
      specta::function::collect_functions![
        start_pass_through::<tauri::Wry>,
        //                   ^^^^^^^^^^
        // We have to specify the runtime type here. This is a known issue:
        // - https://github.com/specta-rs/tauri-specta/issues/70
        // - https://github.com/specta-rs/tauri-specta/issues/162
        stop_pass_through::<tauri::Wry>,
      ]
    ));

  #[cfg(debug_assertions)]
  builder
    .export(
      Typescript::default(),
      "../src/commands/bindings/window-pass-through-on-hover.ts",
    )
    .expect("Failed to export typescript bindings");

  PluginBuilder::new(PLUGIN_NAME)
    .setup(|app, _| {
      app.manage(WindowClickThroughState::default());
      Ok(())
    })
    .invoke_handler(builder.invoke_handler())
    .build()
}


Review comment (suggestion):
```suggestion
        // TODO: We have to specify the runtime type here. This is a known issue:
```

Code after:
) -> std::result::Result<(), String> {
  set_pass_through_enabled(&window, false).map_err(|e| {
    log::error!("Failed to disable click-through: {e}");
    e
  })
}

const PLUGIN_NAME: &str = "proj-airi-tauri-plugin-window-pass-through-on-hover";

pub fn init<R: Runtime>() -> TauriPlugin<R> {
  let builder = tauri_specta::Builder::<R>::new()
    .plugin_name(PLUGIN_NAME)
    // ↓ HACKY WARNING
    // ↓ Below is a modified version from the expansion of `tauri_specta::collect_commands!`,
    // ↓ as the original macro does not accept a mix of commands with and without `#[specta::specta]`
    .commands(tauri_specta::internal::command(
      tauri::generate_handler![
        start_monitor,
        stop_monitor,
        start_pass_through,
        stop_pass_through
      ],
      specta::function::collect_functions![
        start_pass_through::<tauri::Wry>,
        //                   ^^^^^^^^^^
        // TODO: We have to specify the runtime type here. This is a known issue:
        // - https://github.com/specta-rs/tauri-specta/issues/70
        // - https://github.com/specta-rs/tauri-specta/issues/162
        stop_pass_through::<tauri::Wry>,
      ]
    ));

  #[cfg(debug_assertions)]
  builder
    .export(
      Typescript::default(),
      "../src/commands/bindings/window-pass-through-on-hover.ts",
    )
    .expect("Failed to export typescript bindings");

  PluginBuilder::new(PLUGIN_NAME)
    .setup(|app, _| {
      app.manage(WindowClickThroughState::default());
      Ok(())
    })
    .invoke_handler(builder.invoke_handler())
    .build()
}