tauri-apps / plugins-workspace

All of the official Tauri plugins in one place!
https://tauri.app
Apache License 2.0
979 stars 274 forks source link

[feat][deep-link] On Windows and Linux, configuring `fileAssociations` does not trigger the `onOpenUrl` method #1990

Open ayangweb opened 3 weeks ago

ayangweb commented 3 weeks ago

Describe the bug

On Windows and Linux, configuring fileAssociations does not trigger the onOpenUrl method of the deep-link plugin when double-clicking a file.

tauri.config.json

"fileAssociations": [
  {
    "ext": ["EcoPaste-backup"],
    "mimeType": "text/plain",
    "description": "EcoPaste Backup File"
  }
]
import { onOpenUrl } from "@tauri-apps/plugin-deep-link";

onOpenUrl((urls) => {
  console.log("urls", urls);
});

MacOS:

https://github.com/user-attachments/assets/8c48bc7f-a37a-4064-9cd2-5cec861f51f2

Windows:

https://github.com/user-attachments/assets/c9375e3e-79f5-4d6c-9b13-2802b07a9ed9

Linux:

https://github.com/user-attachments/assets/e41c468d-fe34-44a9-a1f8-39e3b463d21b

Reproduction

No response

Expected behavior

No response

Full tauri info output

[✘] Environment
    - OS: Windows 10.0.22631 x86_64 (X64)
    ✔ WebView2: 130.0.2849.56
    ✘ Couldn't detect any Visual Studio or VS Build Tools instance with MSVC and SDK components. Download from https://aka.ms/vs/17/release/vs_BuildTools.exe
    ✔ rustc: 1.81.0 (eeb90cda1 2024-09-04)
    ✔ cargo: 1.81.0 (2dbb1af80 2024-08-20)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-aarch64-pc-windows-msvc (default)
    - node: 20.14.0
    - pnpm: 9.10.0
    - npm: 10.7.0

[-] Packages
    - tauri 🦀: 2.0.6
    - tauri-build 🦀: 2.0.2
    - wry 🦀: 0.46.3
    - tao 🦀: 0.30.5
    - @tauri-apps/api : 2.0.3
    - @tauri-apps/cli : 2.0.5

[-] Plugins
    - tauri-plugin-deep-link 🦀: 2.0.1
    - @tauri-apps/plugin-deep-link : 2.0.0
    - tauri-plugin-dialog 🦀: 2.0.3
    - @tauri-apps/plugin-dialog : 2.0.1
    - tauri-plugin-fs 🦀: 2.0.3
    - @tauri-apps/plugin-fs : 2.0.1
    - tauri-plugin-updater 🦀: 2.0.2
    - @tauri-apps/plugin-updater : 2.0.0
    - tauri-plugin-os 🦀: 2.0.1
    - @tauri-apps/plugin-os : 2.0.0
    - tauri-plugin-sql 🦀: 2.0.1
    - @tauri-apps/plugin-sql : 2.0.0
    - tauri-plugin-autostart 🦀: 2.0.1
    - @tauri-apps/plugin-autostart : 2.0.0
    - tauri-plugin-log 🦀: 2.0.1
    - @tauri-apps/plugin-log : 2.0.0
    - tauri-plugin-process 🦀: 2.0.1
    - @tauri-apps/plugin-process : 2.0.0
    - tauri-plugin-shell 🦀: 2.0.2
    - @tauri-apps/plugin-shell : 2.0.1
    - tauri-plugin-global-shortcut 🦀: 2.0.1
    - @tauri-apps/plugin-global-shortcut : 2.0.0
    - tauri-plugin-single-instance 🦀: 2.0.1
    - @tauri-apps/plugin-single-instance : not installed!

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../dist
    - devUrl: http://localhost:1420/
    - framework: React
    - bundler: Vite

Stack trace

No response

Additional context

No response

FabianLars commented 3 weeks ago

Hmm, it's not supposed to trigger it so not really a bug. 🤔

FabianLars commented 3 weeks ago

On a lower level file as docs and deep links behave the same so I'll leave this issue open to wait for Amr's thoughts.

amrbashir commented 3 weeks ago

Not sure what you mean by "file as docs and deep link behave the same", did you mean file associations?

Anyways, I'd prefer to keep file associations (and deep links) on Windows and Linux to be handled by user explicitly but recently we tried to automatically detect and trigger onOpenUrl for deep links on Linux and Windows so I don't think we shouldn't handle this one either.

FabianLars commented 3 weeks ago

Not sure what you mean by "file as docs and deep link behave the same", did you mean file associations?

Yes, stupid auto correct is going absolutely mental