mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-19 07:53:54 +01:00
Introduces yaak-rpc (shared RPC infrastructure) and yaak-proxy-lib (proxy app logic decoupled from any frontend). A single Tauri command dispatches all RPC calls through a typed router, with TypeScript types auto-generated via ts-rs and a generic rpc() function for type-safe calls from the frontend. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
13 lines
411 B
TypeScript
13 lines
411 B
TypeScript
import { invoke } from "@tauri-apps/api/core";
|
|
import type { RpcSchema } from "../../crates-proxy/yaak-proxy-lib/bindings/gen_rpc";
|
|
|
|
type Req<K extends keyof RpcSchema> = RpcSchema[K][0];
|
|
type Res<K extends keyof RpcSchema> = RpcSchema[K][1];
|
|
|
|
export async function rpc<K extends keyof RpcSchema>(
|
|
cmd: K,
|
|
payload: Req<K>,
|
|
): Promise<Res<K>> {
|
|
return invoke("rpc", { cmd, payload }) as Promise<Res<K>>;
|
|
}
|