diff --git a/THIRD-PARTY.md b/THIRD-PARTY.md index d077fd2..5f79ee9 100644 --- a/THIRD-PARTY.md +++ b/THIRD-PARTY.md @@ -84,8 +84,8 @@ installed as a runtime dependency. | `@tauri-apps/api` | ^2.0.0 | Apache-2.0 OR MIT | [tauri.app](https://tauri.app/) | | `@tauri-apps/plugin-dialog` | ^2.0.0 | Apache-2.0 OR MIT | [tauri.app](https://tauri.app/) | | `@tauri-apps/plugin-fs` | ^2.0.0 | Apache-2.0 OR MIT | [tauri.app](https://tauri.app/) | +| `@tauri-apps/plugin-opener` | ^2.0.0 | Apache-2.0 OR MIT | [tauri.app](https://tauri.app/) | | `@tauri-apps/plugin-os` | ^2.0.0 | Apache-2.0 OR MIT | [tauri.app](https://tauri.app/) | -| `@tauri-apps/plugin-shell` | ^2.0.0 | Apache-2.0 OR MIT | [tauri.app](https://tauri.app/) | | `@tauri-apps/cli` (devDep) | ^2.0.0 | Apache-2.0 OR MIT | [tauri.app](https://tauri.app/) | ### Rust crates (`src-tauri/Cargo.toml`) @@ -96,8 +96,8 @@ installed as a runtime dependency. | `tauri-build` | 2 | Apache-2.0 OR MIT | [crates.io/crates/tauri-build](https://crates.io/crates/tauri-build) | | `tauri-plugin-dialog` | 2 | Apache-2.0 OR MIT | [crates.io/crates/tauri-plugin-dialog](https://crates.io/crates/tauri-plugin-dialog) | | `tauri-plugin-fs` | 2 | Apache-2.0 OR MIT | [crates.io/crates/tauri-plugin-fs](https://crates.io/crates/tauri-plugin-fs) | +| `tauri-plugin-opener` | 2 | Apache-2.0 OR MIT | [crates.io/crates/tauri-plugin-opener](https://crates.io/crates/tauri-plugin-opener) | | `tauri-plugin-os` | 2 | Apache-2.0 OR MIT | [crates.io/crates/tauri-plugin-os](https://crates.io/crates/tauri-plugin-os) | -| `tauri-plugin-shell` | 2 | Apache-2.0 OR MIT | [crates.io/crates/tauri-plugin-shell](https://crates.io/crates/tauri-plugin-shell) | | `tauri-plugin-single-instance` | 2 | Apache-2.0 OR MIT | [crates.io/crates/tauri-plugin-single-instance](https://crates.io/crates/tauri-plugin-single-instance) | | `serde` | 1 | Apache-2.0 OR MIT | [serde.rs](https://serde.rs/) | | `serde_json` | 1 | Apache-2.0 OR MIT | [github.com/serde-rs/json](https://github.com/serde-rs/json) | diff --git a/docs/TAURI-NOTES.md b/docs/TAURI-NOTES.md index a92f494..29b4347 100644 --- a/docs/TAURI-NOTES.md +++ b/docs/TAURI-NOTES.md @@ -15,8 +15,8 @@ process from outliving the main webview: any spawned shell children (none today, but the hook is in place) are signaled before the process exits. -If you ever add long-running spawned commands (e.g. via `tauri_plugin_shell`), -remember to track their handles and kill them in the same hook. +If you ever add long-running spawned commands (e.g. via a shell/command +plugin), remember to track their handles and kill them in the same hook. ## WebView2 GDI leak (Windows, upstream) @@ -45,8 +45,9 @@ See `src-tauri/capabilities/default.json`. Scope is intentionally narrow: - Filesystem reads/writes only inside `$HOME`, `$DOCUMENT`, `$DOWNLOAD`, `$DESKTOP`. - Dialog plugin for open/save. -- Shell plugin restricted to `shell:allow-open` (URL opening only — no - arbitrary command spawn). +- Opener plugin (`opener:default`) for handing external URLs to the system + browser — `shell:open` has no native Android URL handler, so the opener + plugin's `openUrl` is used instead. Widening the scope requires both a capability edit and a CSP review in `tauri.conf.json`. diff --git a/knip.json b/knip.json index 0defc80..fa702c5 100644 --- a/knip.json +++ b/knip.json @@ -5,8 +5,8 @@ "@radix-ui/react-slot", "tailwindcss", "tw-animate-css", + "@tauri-apps/plugin-opener", "@tauri-apps/plugin-os", - "@tauri-apps/plugin-shell", "@testing-library/user-event" ], "rules": { diff --git a/package-lock.json b/package-lock.json index 42d7906..e8d77a9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "jsonprism", - "version": "1.7.1", + "version": "1.7.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "jsonprism", - "version": "1.7.1", + "version": "1.7.2", "license": "Apache-2.0", "dependencies": { "@codemirror/lang-json": "^6.0.0", @@ -31,8 +31,8 @@ "@tauri-apps/api": "^2.0.0", "@tauri-apps/plugin-dialog": "^2.0.0", "@tauri-apps/plugin-fs": "^2.0.0", + "@tauri-apps/plugin-opener": "^2.0.0", "@tauri-apps/plugin-os": "^2.0.0", - "@tauri-apps/plugin-shell": "^2.0.0", "@uiw/react-codemirror": "^4.25.10", "bson": "^7.2.0", "cbor-x": "^1.6.4", @@ -3133,6 +3133,15 @@ "@tauri-apps/api": "^2.11.0" } }, + "node_modules/@tauri-apps/plugin-opener": { + "version": "2.5.4", + "resolved": "https://registry.npmjs.org/@tauri-apps/plugin-opener/-/plugin-opener-2.5.4.tgz", + "integrity": "sha512-1HnPkb+AmgO29HBazm4uPLKB+r7zzcTBW1d0fyYp1uP+jwtpoiNDGKMMzz58SFp49nOIrxdE3aUJtT57lfO9CQ==", + "license": "MIT OR Apache-2.0", + "dependencies": { + "@tauri-apps/api": "^2.11.0" + } + }, "node_modules/@tauri-apps/plugin-os": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/@tauri-apps/plugin-os/-/plugin-os-2.3.2.tgz", @@ -3142,15 +3151,6 @@ "@tauri-apps/api": "^2.8.0" } }, - "node_modules/@tauri-apps/plugin-shell": { - "version": "2.3.5", - "resolved": "https://registry.npmjs.org/@tauri-apps/plugin-shell/-/plugin-shell-2.3.5.tgz", - "integrity": "sha512-jewtULhiQ7lI7+owCKAjc8tYLJr92U16bPOeAa472LHJdgaibLP83NcfAF2e+wkEcA53FxKQAZ7byDzs2eeizg==", - "license": "MIT OR Apache-2.0", - "dependencies": { - "@tauri-apps/api": "^2.10.1" - } - }, "node_modules/@testing-library/dom": { "version": "10.4.1", "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-10.4.1.tgz", diff --git a/package.json b/package.json index 4270c52..b0c841a 100644 --- a/package.json +++ b/package.json @@ -59,8 +59,8 @@ "@tauri-apps/api": "^2.0.0", "@tauri-apps/plugin-dialog": "^2.0.0", "@tauri-apps/plugin-fs": "^2.0.0", + "@tauri-apps/plugin-opener": "^2.0.0", "@tauri-apps/plugin-os": "^2.0.0", - "@tauri-apps/plugin-shell": "^2.0.0", "@uiw/react-codemirror": "^4.25.10", "bson": "^7.2.0", "cbor-x": "^1.6.4", diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index c14adaa..6a8c002 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -860,15 +860,6 @@ version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ef6b89e5b37196644d8796de5268852ff179b44e96276cf4290264843743bb7" -[[package]] -name = "encoding_rs" -version = "0.8.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" -dependencies = [ - "cfg-if", -] - [[package]] name = "endi" version = "1.1.1" @@ -1875,8 +1866,8 @@ dependencies = [ "tauri-build", "tauri-plugin-dialog", "tauri-plugin-fs", + "tauri-plugin-opener", "tauri-plugin-os", - "tauri-plugin-shell", "tauri-plugin-single-instance", ] @@ -2391,16 +2382,6 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "os_pipe" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d8fae84b431384b68627d0f9b3b1245fcf9f46f6c0e3dc902e9dce64edd1967" -dependencies = [ - "libc", - "windows-sys 0.61.2", -] - [[package]] name = "pango" version = "0.18.3" @@ -3150,44 +3131,12 @@ dependencies = [ "digest", ] -[[package]] -name = "shared_child" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e362d9935bc50f019969e2f9ecd66786612daae13e8f277be7bfb66e8bed3f7" -dependencies = [ - "libc", - "sigchld", - "windows-sys 0.60.2", -] - [[package]] name = "shlex" version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" -[[package]] -name = "sigchld" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47106eded3c154e70176fc83df9737335c94ce22f821c32d17ed1db1f83badb1" -dependencies = [ - "libc", - "os_pipe", - "signal-hook", -] - -[[package]] -name = "signal-hook" -version = "0.3.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d881a16cf4426aa584979d30bd82cb33429027e42122b169753d6ef1085ed6e2" -dependencies = [ - "libc", - "signal-hook-registry", -] - [[package]] name = "signal-hook-registry" version = "1.4.8" @@ -3618,6 +3567,28 @@ dependencies = [ "url", ] +[[package]] +name = "tauri-plugin-opener" +version = "2.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17e1bea14edce6b793a04e2417e3fd924b9bc4faae83cdee7d714156cceeed29" +dependencies = [ + "dunce", + "glob", + "objc2-app-kit", + "objc2-foundation", + "open", + "schemars 0.8.22", + "serde", + "serde_json", + "tauri", + "tauri-plugin", + "thiserror 2.0.18", + "url", + "windows", + "zbus", +] + [[package]] name = "tauri-plugin-os" version = "2.3.2" @@ -3636,27 +3607,6 @@ dependencies = [ "thiserror 2.0.18", ] -[[package]] -name = "tauri-plugin-shell" -version = "2.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8457dbf9e2bab1edd8df22bb2c20857a59a9868e79cb3eac5ed639eec4d0c73b" -dependencies = [ - "encoding_rs", - "log", - "open", - "os_pipe", - "regex", - "schemars 0.8.22", - "serde", - "serde_json", - "shared_child", - "tauri", - "tauri-plugin", - "thiserror 2.0.18", - "tokio", -] - [[package]] name = "tauri-plugin-single-instance" version = "2.4.2" diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index e9981d9..11e7bdc 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -20,8 +20,8 @@ tauri-build = { version = "2", features = [] } tauri = { version = "2", features = [] } tauri-plugin-dialog = "2" tauri-plugin-fs = "2" +tauri-plugin-opener = "2" tauri-plugin-os = "2" -tauri-plugin-shell = "2" serde = { version = "1", features = ["derive"] } serde_json = "1" diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.json index 0bc4290..a547083 100644 --- a/src-tauri/capabilities/default.json +++ b/src-tauri/capabilities/default.json @@ -10,7 +10,7 @@ "core:webview:default", "core:window:default", "core:window:allow-set-title", - "shell:allow-open", + "opener:default", "os:default", "dialog:default", "dialog:allow-open", diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index ca6202c..a500bc2 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -42,7 +42,7 @@ pub fn run() { } let app = builder - .plugin(tauri_plugin_shell::init()) + .plugin(tauri_plugin_opener::init()) .plugin(tauri_plugin_dialog::init()) .plugin(tauri_plugin_fs::init()) .plugin(tauri_plugin_os::init()) diff --git a/src/lib/tauri.ts b/src/lib/tauri.ts index fbcba0a..a01c6a4 100644 --- a/src/lib/tauri.ts +++ b/src/lib/tauri.ts @@ -154,16 +154,20 @@ export async function fileFromNativePath(path: string): Promise { /** * Open an external URL. In Tauri the webview won't honour `target="_blank"` - * (Android in particular swallows it), so route through the shell plugin to - * hand the URL to the system browser. On the web, open a new tab as usual. + * (Android in particular swallows it), so hand the URL to the system browser + * via the opener plugin's `openUrl`. On the web, open a new tab as usual. + * + * NB: the shell plugin's `open()` throws "Scoped shell IO error: No such file + * or directory (os error 2)" on Android — it has no native URL handler there. + * The opener plugin routes through the platform's Intent/openURL API instead. */ export async function openExternal(url: string): Promise { if (!isTauri()) { window.open(url, '_blank', 'noopener,noreferrer'); return; } - const { open } = await import('@tauri-apps/plugin-shell'); - await open(url); + const { openUrl } = await import('@tauri-apps/plugin-opener'); + await openUrl(url); } /** diff --git a/vite.config.ts b/vite.config.ts index 078deab..3d713e1 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -138,8 +138,8 @@ export default defineConfig(({ mode }) => ({ '@tauri-apps/api', '@tauri-apps/plugin-dialog', '@tauri-apps/plugin-fs', + '@tauri-apps/plugin-opener', '@tauri-apps/plugin-os', - '@tauri-apps/plugin-shell', ], }, }));