Refactor desktop app into separate client and proxy apps

This commit is contained in:
Gregory Schier
2026-03-06 09:23:19 -08:00
parent e26705f016
commit 6915778c06
613 changed files with 1356 additions and 812 deletions

View File

@@ -0,0 +1,8 @@
# Generated by Cargo
# will have compiled files and executables
target/
gen/*
**/permissions/autogenerated
**/permissions/schemas

View File

@@ -0,0 +1,18 @@
[package]
name = "yaak-app-proxy"
version = "0.0.0"
edition = "2024"
authors = ["Gregory Schier"]
publish = false
[lib]
name = "tauri_app_proxy_lib"
crate-type = ["staticlib", "cdylib", "lib"]
[build-dependencies]
tauri-build = { version = "2.5.3", features = [] }
[dependencies]
serde = { workspace = true, features = ["derive"] }
tauri = { workspace = true }
yaak-proxy = { workspace = true }

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1,3 @@
fn main() {
tauri_build::build()
}

View File

@@ -0,0 +1,10 @@
{
"identifier": "default",
"description": "Default capabilities for the Yaak Proxy app",
"windows": [
"*"
],
"permissions": [
"core:default"
]
}

View File

@@ -0,0 +1,6 @@
{
"name": "@yaakapp-internal/tauri-proxy",
"private": true,
"version": "1.0.0",
"main": "bindings/index.ts"
}

View File

@@ -0,0 +1,63 @@
use serde::Serialize;
use std::sync::Mutex;
use tauri::State;
use yaak_proxy::ProxyHandle;
#[derive(Serialize)]
#[serde(rename_all = "camelCase")]
struct ProxyMetadata {
name: String,
version: String,
}
#[derive(Default)]
struct ProxyState {
handle: Mutex<Option<ProxyHandle>>,
}
#[derive(Serialize)]
#[serde(rename_all = "camelCase")]
struct ProxyStartResult {
port: u16,
already_running: bool,
}
#[tauri::command]
fn proxy_metadata(app_handle: tauri::AppHandle) -> ProxyMetadata {
ProxyMetadata {
name: app_handle.package_info().name.clone(),
version: app_handle.package_info().version.to_string(),
}
}
#[tauri::command]
fn proxy_start(
state: State<'_, ProxyState>,
port: Option<u16>,
) -> Result<ProxyStartResult, String> {
let mut handle = state.handle.lock().map_err(|_| "failed to lock proxy state".to_string())?;
if let Some(existing) = handle.as_ref() {
return Ok(ProxyStartResult { port: existing.port, already_running: true });
}
let proxy_handle = yaak_proxy::start_proxy(port.unwrap_or(0))?;
let started_port = proxy_handle.port;
*handle = Some(proxy_handle);
Ok(ProxyStartResult { port: started_port, already_running: false })
}
#[tauri::command]
fn proxy_stop(state: State<'_, ProxyState>) -> Result<bool, String> {
let mut handle = state.handle.lock().map_err(|_| "failed to lock proxy state".to_string())?;
Ok(handle.take().is_some())
}
pub fn run() {
tauri::Builder::default()
.manage(ProxyState::default())
.invoke_handler(tauri::generate_handler![proxy_metadata, proxy_start, proxy_stop])
.run(tauri::generate_context!())
.expect("error while running yaak proxy tauri application");
}

View File

@@ -0,0 +1,5 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
fn main() {
tauri_app_proxy_lib::run();
}

View File

@@ -0,0 +1,13 @@
{
"productName": "Yaak Proxy Dev",
"identifier": "app.yaak.proxy.dev",
"bundle": {
"icon": [
"../yaak-app-client/icons/dev/32x32.png",
"../yaak-app-client/icons/dev/128x128.png",
"../yaak-app-client/icons/dev/128x128@2x.png",
"../yaak-app-client/icons/dev/icon.icns",
"../yaak-app-client/icons/dev/icon.ico"
]
}
}

View File

@@ -0,0 +1,5 @@
{
"build": {
"features": []
}
}

View File

@@ -0,0 +1,9 @@
[Desktop Entry]
Categories={{categories}}
Comment={{comment}}
Exec={{exec}}
Icon={{icon}}
Name={{name}}
StartupWMClass={{exec}}
Terminal=false
Type=Application