specta-rs/tauri-specta

Tauri/Tauri Specta v2 known issues

oscartbeaumont opened this issue · 12 comments

Example App with Plugin

This example shows using Tauri Specta within a Tauri plugin and then mounting and using it within a Tauri app.

To reproduce

pnpm i
cd examples/custom-plugin/app
pnpm tauri dev

I'm using tauri-plugin within examples/custom-plugin/plugin/build.rs, however I am getting the following error:

Caused by:
  process didn't exit successfully: `/Users/oscar/Desktop/tauri-specta/target/debug/build/tauri-specta-example-custom-plugin-51c83bbcfcceee66/build-script-build` (exit status: 1)
  --- stdout
  tauri-plugin: expected build script env var CARGO_MANIFEST_LINKS, but it was not found - ensure this is called in a build script
warning: build failed, waiting for other jobs to finish...

ManagerExt trait

We had to introduce a ManagerExt trait as tauri::Manager does not have listen, once and unlisten.

It would be great to either merge this into tauri::Manager or upstream it as tauri::ManagerExt as this may be generally useful to other ecosystem packages.

Other observations

  • The Tauri migrate tool failed.
    • I ran npx @tauri-apps/cli@next migrate in examples/app on this commit 4e48b7b.
  • Sometimes clicking into the Tauri window just won't work until I refocus another app and try again. It shows "Code" or "Spotify" or "Discord" on the macOS menubar instead of the Tauri app. This is hard to reproduce because it's been rare but I could it in video. In the following video I am continually clicking my mouse and the Tauri window is not taking focus and the webview buttons are not reacting.
Screen_Recording_2024-04-30_at_3.40.47_PM.mov

Edit: I wonder these Window issues could actually be our fault because they sound related to #75

I'm using tauri-plugin within examples/custom-plugin/plugin/build.rs, however I am getting the following error:

The plugin is missing this line in Cargo.toml

  [package]
  name = "tauri-specta-example-custom-plugin"
+ links = "tauri-specta-example-custom-plugin"

see https://github.com/tauri-apps/plugins-workspace/blob/f39586bcb44ba13aca16d1b7ade77ce3d1d84982/plugins/fs/Cargo.toml#L10

also iirc, I think we require that the plugin crate name be prefixed with tauri-plugin.

ManagerExt trait

We had to introduce a ManagerExt trait as tauri::Manager does not have listen, once and unlisten.

It would be great to either merge this into tauri::Manager or upstream it as tauri::ManagerExt as this may be generally useful to other ecosystem packages.

I guess that's fine to upstream, we lose the customized documentation but that should be okay.

The Tauri migrate tool failed.

  • I ran npx @tauri-apps/cli@next migrate in examples/app on this commit 4e48b7b.

Any particular errors logged?

  • Sometimes clicking into the Tauri window just won't work until I refocus another app and try again. It shows "Code" or "Spotify" or "Discord" on the macOS menubar instead of the Tauri app. This is hard to reproduce because it's been rare but I could it in video. In the following video I am continually clicking my mouse and the Tauri window is not taking focus and the webview buttons are not reacting.

Can't help with this one so I will ping @pewsheen if he has any idea

The plugin is missing this line in Cargo.toml

Okay I added the links property and managed to fix a couple of other compile-time errors but now i'm getting this when I execute the command defined by the plugin:
Screenshot 2024-04-30 at 10 33 31 PM

Screenshot taken in the webview devtools.

ManagerExt trait

If I did it as a PR, do you recon the methods would be better directly on the Manager trait or just introducing the new ManagerExt trait? Both options should be technically viable.

I personally would lean towards the Manager as it matches the Tauri v1 behavior closer but I wonder if removing these methods from it was actually intentional or if it was just lost unintentionally in other changes.

It's completely fine if this isn't upstreamed too, I just think it's probably gonna be useful outside of Tauri Specta, athough its utility is probably going to be niche so that would be a fair argument against it.

Any particular errors logged?

git clone https://github.com/oscartbeaumont/tauri-specta
cd tauri-specta
git checkout 4e48b7b378ce89590a9e9befe29a83b0cd4b322a
pnpm i
cd examples/app/
npx @tauri-apps/cli@next migrate
➜ npx @tauri-apps/cli@next migrate
    Info Replacing `@tauri-apps/api/window` with `@tauri-apps/api/webviewWindow` on /Users/oscar/Desktop/ts2/examples/app/src/main.ts
    Info Replacing `@tauri-apps/api/tauri` with `@tauri-apps/api/core` on /Users/oscar/Desktop/ts2/examples/app/src/bindings.ts
    Info Replacing `@tauri-apps/api/window` with `@tauri-apps/api/webviewWindow` on /Users/oscar/Desktop/ts2/examples/app/src/bindings.ts
    Info Installing Cargo dependency "tauri-plugin-http"...
    Error Could not migrate plugin 'http': Failed to install Cargo dependency

I feel like I recall it failing on the CLI plugin last time but don't quote me on that.

p.s. thanks @amrbashir for taking the time to help!

If I did it as a PR, do you recon the methods would be better directly on the Manager trait or just introducing the new ManagerExt trait? Both options should be technically viable.

I was thinking about Emitter and Listener traits tbh but that feels it will require users to have lots of imports so let's go with directly on Manager.

I personally would lean towards the Manager as it matches the Tauri v1 behavior closer but I wonder if removing these methods from it was actually intentional or if it was just lost unintentionally in other changes.

the only relevant changes to events in the Manager trait between v1 and v2 is listen_global, once_global were renamed to listen_any and once_any. listen and once were only available on Window.

About the migration errors, seems to be because you have tauri v1 in the workspace root and the migration tool will try to add tauri v2 to the app and that will cause dependency conflicts, so it is better to run the migration tool after you changed tauri version in the workspace or move the app outside the workspace until you migrate.

The plugin is missing this line in Cargo.toml

Okay I added the links property and managed to fix a couple of other compile-time errors but now i'm getting this when I execute the command defined by the plugin: Screenshot 2024-04-30 at 10 33 31 PM

Screenshot taken in the webview devtools.

I think that's because the plugin is named in tauri-plugin-specta-example in Cargo.toml but then registered as custom-plugin in lib.rs, maybe use one the same name. so either use tauri-plugin-custom-plugin in Cargo.toml or specta-example in lib.rs

the only relevant changes to events in the Manager trait between v1 and v2

Yeah, your completely right, my bad for getting lost in all the changes.

About the migration errors,

Ahhh, okay makes sense.

I think that's because the plugin is named in

Yeah, that was it thanks for your help!

I have opened the PR to Tauri about the manager stuff - tauri-apps/tauri#9627.

@amrbashir do you have an idea of when the next Tauri release is going to happen?
Tauri Specta right now requires a Git patch for #9392 which prevents me from publishing to crates.io.

Thanks again for taking the time to help!

Sick!

I have just published Tauri Specta v2.0.0-rc.5 but the build has failed on docs.rs with some issues about javascriptcore and soup3.

Do you know if Tauri did anything special to workaround this?

build logs