feat: add deep link support

This commit introduces the deep link functionality, allowing the application to handle deep links from extensions.
This commit is contained in:
ByteAtATime 2025-06-19 14:11:52 -07:00
parent 3c3566136a
commit 887838bec6
No known key found for this signature in database
8 changed files with 170 additions and 3 deletions

View file

@ -18,6 +18,7 @@
"@raycast-linux/protocol": "workspace:*",
"@tauri-apps/api": "^2",
"@tauri-apps/plugin-clipboard-manager": "~2.2.2",
"@tauri-apps/plugin-deep-link": "~2",
"@tauri-apps/plugin-global-shortcut": "~2.2.1",
"@tauri-apps/plugin-opener": "~2",
"@tauri-apps/plugin-shell": "~2.2.1",

View file

@ -134,7 +134,7 @@ export const PluginInfoSchema = z.object({
pluginPath: z.string(),
icon: z.string().optional(),
preferences: z.array(PreferenceSchema).optional(),
mode: z.enum(['view', 'no-view']).optional()
mode: z.enum(['view', 'no-view', 'menu-bar']).optional()
});
export type PluginInfo = z.infer<typeof PluginInfoSchema>;

10
pnpm-lock.yaml generated
View file

@ -17,6 +17,9 @@ importers:
'@tauri-apps/plugin-clipboard-manager':
specifier: ~2.2.2
version: 2.2.2
'@tauri-apps/plugin-deep-link':
specifier: ~2
version: 2.3.0
'@tauri-apps/plugin-global-shortcut':
specifier: ~2.2.1
version: 2.2.1
@ -1005,6 +1008,9 @@ packages:
'@tauri-apps/plugin-clipboard-manager@2.2.2':
resolution: {integrity: sha512-bZvDLMqfcNmsw7Ag8I49jlaCjdpDvvlJHnpp6P+Gg/3xtpSERdwlDxm7cKGbs2mj46dsw4AuG3RoAgcpwgioUA==}
'@tauri-apps/plugin-deep-link@2.3.0':
resolution: {integrity: sha512-Jsbu3vfUcD1jR+gx1P8wOe5x/WoXw/K4qp0ALaDjOM2vNIflyLowhQhZ8fUxTHNe1+N+mIBrwvb3hXIWRI5iuw==}
'@tauri-apps/plugin-global-shortcut@2.2.1':
resolution: {integrity: sha512-b64/TI1t5LIi2JY4OWlYjZpPRq60T5GVVL/no27sUuxaNUZY8dVtwsMtDUgxUpln2yR+P2PJsYlqY5V8sLSxEw==}
@ -3532,6 +3538,10 @@ snapshots:
dependencies:
'@tauri-apps/api': 2.5.0
'@tauri-apps/plugin-deep-link@2.3.0':
dependencies:
'@tauri-apps/api': 2.5.0
'@tauri-apps/plugin-global-shortcut@2.2.1':
dependencies:
'@tauri-apps/api': 2.5.0

98
src-tauri/Cargo.lock generated
View file

@ -698,6 +698,26 @@ dependencies = [
"crossbeam-utils",
]
[[package]]
name = "const-random"
version = "0.1.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87e00182fe74b066627d63b85fd550ac2998d4b0bd86bfed477a0ae4c7c71359"
dependencies = [
"const-random-macro",
]
[[package]]
name = "const-random-macro"
version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e"
dependencies = [
"getrandom 0.2.16",
"once_cell",
"tiny-keccak",
]
[[package]]
name = "constant_time_eq"
version = "0.3.1"
@ -872,6 +892,12 @@ version = "0.8.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
[[package]]
name = "crunchy"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43da5946c66ffcc7745f48db692ffbb10a83bfe0afd96235c5c2a4fb23994929"
[[package]]
name = "crypto-common"
version = "0.1.6"
@ -1114,6 +1140,15 @@ dependencies = [
"syn 2.0.103",
]
[[package]]
name = "dlv-list"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "442039f5147480ba31067cb00ada1adae6892028e40e45fc5de7b7df6dcc1b5f"
dependencies = [
"const-random",
]
[[package]]
name = "downcast-rs"
version = "1.2.1"
@ -1888,6 +1923,12 @@ version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
[[package]]
name = "hashbrown"
version = "0.14.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
[[package]]
name = "hashbrown"
version = "0.15.4"
@ -3128,6 +3169,16 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
[[package]]
name = "ordered-multimap"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49203cdcae0030493bad186b28da2fa25645fa276a51b6fec8010d281e02ef79"
dependencies = [
"dlv-list",
"hashbrown 0.14.5",
]
[[package]]
name = "ordered-stream"
version = "0.2.0"
@ -3693,6 +3744,7 @@ dependencies = [
"tauri",
"tauri-build",
"tauri-plugin-clipboard-manager",
"tauri-plugin-deep-link",
"tauri-plugin-global-shortcut",
"tauri-plugin-opener",
"tauri-plugin-shell",
@ -3862,6 +3914,17 @@ dependencies = [
"windows-sys 0.52.0",
]
[[package]]
name = "rust-ini"
version = "0.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e310ef0e1b6eeb79169a1171daf9abcb87a2e17c03bee2c4bb100b55c75409f"
dependencies = [
"cfg-if",
"ordered-multimap",
"trim-in-place",
]
[[package]]
name = "rustc-demangle"
version = "0.1.25"
@ -4725,6 +4788,26 @@ dependencies = [
"thiserror 2.0.12",
]
[[package]]
name = "tauri-plugin-deep-link"
version = "2.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e4976ac728ebc0487515aa956cfdf200abcc52b784e441493fc544bc6ce369c8"
dependencies = [
"dunce",
"rust-ini",
"serde",
"serde_json",
"tauri",
"tauri-plugin",
"tauri-utils",
"thiserror 2.0.12",
"tracing",
"url",
"windows-registry",
"windows-result 0.3.4",
]
[[package]]
name = "tauri-plugin-global-shortcut"
version = "2.2.1"
@ -5008,6 +5091,15 @@ dependencies = [
"time-core",
]
[[package]]
name = "tiny-keccak"
version = "2.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237"
dependencies = [
"crunchy",
]
[[package]]
name = "tinystr"
version = "0.8.1"
@ -5266,6 +5358,12 @@ dependencies = [
"petgraph",
]
[[package]]
name = "trim-in-place"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "343e926fc669bc8cde4fa3129ab681c63671bae288b1f1081ceee6d9d37904fc"
[[package]]
name = "try-lock"
version = "0.2.5"

View file

@ -20,6 +20,7 @@ tauri-build = { version = "2", features = [] }
[dependencies]
tauri = { version = "2", features = ["protocol-asset"] }
tauri-plugin-opener = "2"
tauri-plugin-deep-link = "2"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
tauri-plugin-clipboard-manager = "2"

View file

@ -13,7 +13,8 @@ use selection::get_text;
use std::process::Command;
use std::thread;
use std::time::Duration;
use tauri::Manager;
use tauri::{Manager, Emitter};
use tauri_plugin_deep_link::DeepLinkExt;
#[tauri::command]
fn get_installed_apps() -> Vec<App> {
@ -98,7 +99,16 @@ fn setup_global_shortcut(app: &mut tauri::App) -> Result<(), Box<dyn std::error:
pub fn run() {
tauri::Builder::default()
.manage(WsState::default())
.plugin(tauri_plugin_single_instance::init(|app, _args, _cwd| {
.plugin(tauri_plugin_single_instance::init(|app, args, _cwd| {
if args.len() > 1 && args[1].starts_with("raycast://") {
if let Some(window) = app.get_webview_window("main") {
let _ = window.emit("deep-link", args[1].to_string());
window.show().unwrap();
}
return;
}
if let Some(window) = app.get_webview_window("main") {
if let Ok(true) = window.is_visible() {
let _ = window.hide();
@ -108,6 +118,7 @@ pub fn run() {
}
}
}))
.plugin(tauri_plugin_deep_link::init())
.plugin(tauri_plugin_global_shortcut::Builder::new().build())
.plugin(tauri_plugin_shell::init())
.plugin(tauri_plugin_clipboard_manager::init())

View file

@ -44,5 +44,12 @@
"icons/icon.ico"
],
"externalBin": ["binaries/app"]
},
"plugins": {
"deep-link": {
"desktop": {
"schemes": ["raycast"]
}
}
}
}

View file

@ -5,6 +5,8 @@
import SettingsView from '$lib/components/SettingsView.svelte';
import type { PluginInfo } from '@raycast-linux/protocol';
import { invoke } from '@tauri-apps/api/core';
import { listen } from '@tauri-apps/api/event';
import { onMount } from 'svelte';
import CommandPalette from '$lib/components/CommandPalette.svelte';
import PluginRunner from '$lib/components/PluginRunner.svelte';
import Extensions from '$lib/components/Extensions.svelte';
@ -45,6 +47,43 @@
});
});
onMount(() => {
const unlisten = listen<string>('deep-link', (event) => {
console.log('Received deep link:', event.payload);
const url = event.payload;
handleDeepLink(url);
});
return () => {
unlisten.then((fn) => fn());
};
});
function handleDeepLink(url: string) {
try {
const urlObj = new URL(url);
console.log('Processing deep link:', {
protocol: urlObj.protocol,
host: urlObj.host,
pathname: urlObj.pathname,
search: urlObj.search
});
if (urlObj.protocol === 'raycast:') {
switch (urlObj.host) {
case 'extensions':
viewState = 'extensions-store';
break;
default:
viewState = 'plugin-list';
}
}
} catch (error) {
console.error('Error parsing deep link:', error);
viewState = 'plugin-list';
}
}
function handleKeydown(event: KeyboardEvent) {
if (viewState === 'plugin-list' && event.key === ',' && (event.metaKey || event.ctrlKey)) {
event.preventDefault();