Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apps/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@inlang/paraglide-sveltekit": "0.16.0",
"@kksh/drizzle": "workspace:*",
"@kksh/extension": "workspace:*",
"@kksh/raycast": "workspace:*",
"@kksh/svelte5": "^0.1.15",
"@kksh/ui": "workspace:*",
"@kksh/utils": "workspace:*",
Expand All @@ -30,6 +31,7 @@
"@tauri-apps/plugin-shell": "^2.2.0",
"@tauri-apps/plugin-sql": "^2.2.0",
"@tauri-apps/plugin-stronghold": "^2.2.0",
"@tauri-apps/plugin-websocket": "^2.3.0",
"@tauri-store/svelte": "^2.1.1",
"dompurify": "^3.2.4",
"drizzle-orm": "^0.41.0",
Expand Down
1 change: 1 addition & 0 deletions apps/desktop/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ obfstr = { workspace = true }
base64 = { workspace = true }
tauri-plugin-stronghold = "2.2.0"
tauri-plugin-sql = "2"
tauri-plugin-websocket = "2"


[target."cfg(target_os = \"macos\")".dependencies]
Expand Down
13 changes: 12 additions & 1 deletion apps/desktop/src-tauri/capabilities/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
"system-info:allow-all",
"user-input:default",
"shell:default",
"shell:allow-stdin-write",
"keyring:default",
"stronghold:default",
{
Expand All @@ -143,12 +144,22 @@
"validator": ".+"
}
]
},
{
"name": "node",
"cmd": "node",
"args": [
{
"validator": ".+"
}
]
}
]
},
"deep-link:default",
"autostart:allow-enable",
"autostart:allow-disable",
"autostart:allow-is-enabled"
"autostart:allow-is-enabled",
"websocket:default"
]
}
1 change: 1 addition & 0 deletions apps/desktop/src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ pub fn run() {
.plugin(tauri_plugin_keyring::init())
.plugin(tauri_plugin_network::init())
.plugin(tauri_plugin_system_info::init())
.plugin(tauri_plugin_websocket::init())
.invoke_handler(tauri::generate_handler![
commands::keyring::get_stronghold_key,
]);
Expand Down
59 changes: 59 additions & 0 deletions apps/desktop/src/lib/cmds/ext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,3 +207,62 @@ export async function onCustomUiCmdSelect(
}
appState.clearSearchTerm()
}

export async function onRaycastCmdSelect(
ext: ExtPackageJsonExtra,
cmd: CustomUiCmd,
{ isDev, hmr }: { isDev: boolean; hmr: boolean }
) {
// console.log("onCustomUiCmdSelect", ext, cmd, isDev, hmr)
await createExtSupportDir(ext.extPath)
let url = cmd.main
const useDevMain = hmr && isDev && cmd.devMain
if (useDevMain) {
url = cmd.devMain
} else {
url = cmd.main.startsWith("http")
? cmd.main
: decodeURIComponent(convertFileSrc(`${trimSlash(cmd.main)}`, "ext"))
}
let url2 = `/app/extension/raycast?url=${encodeURIComponent(url)}&extPath=${encodeURIComponent(ext.extPath)}`
// url2 = `/dev?url=${encodeURIComponent(url)}&extPath=${encodeURIComponent(ext.extPath)}`

setIframeExtParams(ext.extPath, url)
if (cmd.window) {
const winLabel = await winExtMap.registerExtensionWithWindow({
extPath: ext.extPath,
dist: cmd.dist
})
if (platform() === "windows" && !useDevMain) {
const addr = await spawnExtensionFileServer(winLabel)
const newUrl = `http://${addr}`
url2 = `/app/extension/raycast?url=${encodeURIComponent(newUrl)}&extPath=${encodeURIComponent(ext.extPath)}`
setIframeExtParams(ext.extPath, newUrl)
}
localStorage.setItem(
"kunkun-iframe-ext-params",
JSON.stringify({ url, extPath: ext.extPath } satisfies KunkunIframeExtParams)
)
const window = launchNewExtWindow(winLabel, url2, cmd.window)
window.onCloseRequested(async (event) => {
await winExtMap.unregisterExtensionFromWindow(winLabel)
})
} else {
console.log("Launch main window")
const winLabel = await winExtMap.registerExtensionWithWindow({
windowLabel: "main",
extPath: ext.extPath,
dist: cmd.dist
})
const _platform = platform()
if ((_platform === "windows" || _platform === "linux") && !useDevMain) {
const addr = await spawnExtensionFileServer(winLabel) // addr has format "127.0.0.1:<port>"
console.log("Extension file server address: ", addr)
const newUrl = `http://${addr}`
url2 = `/app/extension/raycast?url=${encodeURIComponent(newUrl)}&extPath=${encodeURIComponent(ext.extPath)}`
setIframeExtParams(ext.extPath, newUrl)
}
goto(i18n.resolveRoute(url2))
}
appState.clearSearchTerm()
}
10 changes: 9 additions & 1 deletion apps/desktop/src/lib/cmds/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ import {
} from "@kksh/api/models"
import type { CommandLaunchers, OnExtCmdSelect } from "@kksh/ui/types"
import * as v from "valibot"
import { onCustomUiCmdSelect, onHeadlessCmdSelect, onTemplateUiCmdSelect } from "./ext"
import {
onCustomUiCmdSelect,
onHeadlessCmdSelect,
onRaycastCmdSelect,
onTemplateUiCmdSelect
} from "./ext"
import { onQuickLinkSelect } from "./quick-links"

const onExtCmdSelect: OnExtCmdSelect = (
Expand All @@ -25,6 +30,9 @@ const onExtCmdSelect: OnExtCmdSelect = (
case CmdTypeEnum.HeadlessWorker:
onHeadlessCmdSelect(ext, v.parse(HeadlessCmd, cmd), { isDev, hmr })
break
case CmdTypeEnum.Raycast:
onRaycastCmdSelect(ext, v.parse(CustomUiCmd, cmd), { isDev, hmr })
break
default:
console.error("Unknown command type", cmd.type)
}
Expand Down
Loading