Files
friendolls/src/lib/bindings.ts
T

170 lines
5.7 KiB
TypeScript

// This file was generated by [tauri-specta](https://github.com/oscartbeaumont/tauri-specta). Do not edit this file manually.
/** user-defined commands **/
export const commands = {
async createFriend(friend: User) : Promise<User> {
return await TAURI_INVOKE("create_friend", { friend });
},
async listFriends() : Promise<User[]> {
return await TAURI_INVOKE("list_friends");
},
async getFriend(id: string) : Promise<User | null> {
return await TAURI_INVOKE("get_friend", { id });
},
async deleteFriend(id: string) : Promise<boolean> {
return await TAURI_INVOKE("delete_friend", { id });
},
async createRemote(remote: RemoteInput) : Promise<Remote> {
return await TAURI_INVOKE("create_remote", { remote });
},
async listRemotes() : Promise<Remote[]> {
return await TAURI_INVOKE("list_remotes");
},
async getRemote(id: string) : Promise<Remote | null> {
return await TAURI_INVOKE("get_remote", { id });
},
async updateRemote(id: string, remote: RemoteInput) : Promise<Remote | null> {
return await TAURI_INVOKE("update_remote", { id, remote });
},
async deleteRemote(id: string) : Promise<boolean> {
return await TAURI_INVOKE("delete_remote", { id });
},
async getProfile() : Promise<User> {
return await TAURI_INVOKE("get_profile");
},
async updateProfile(displayName: string) : Promise<User> {
return await TAURI_INVOKE("update_profile", { displayName });
},
async getPublicKey() : Promise<string> {
return await TAURI_INVOKE("get_public_key");
},
async listStatuses() : Promise<ConnectionStatus[]> {
return await TAURI_INVOKE("list_statuses");
},
async updateSceneHitboxes(hitboxes: SceneHitbox[]) : Promise<null> {
return await TAURI_INVOKE("update_scene_hitboxes", { hitboxes });
}
}
/** user-defined events **/
export const events = __makeEvents__<{
cursorPositionChanged: CursorPositionChanged,
foregroundAppChanged: ForegroundAppChanged,
friendForegroundAppChanged: FriendForegroundAppChanged,
friendsChanged: FriendsChanged,
networkStatusChanged: NetworkStatusChanged,
profileChanged: ProfileChanged,
remotesChanged: RemotesChanged
}>({
cursorPositionChanged: "cursor-position-changed",
foregroundAppChanged: "foreground-app-changed",
friendForegroundAppChanged: "friend-foreground-app-changed",
friendsChanged: "friends-changed",
networkStatusChanged: "network-status-changed",
profileChanged: "profile-changed",
remotesChanged: "remotes-changed"
})
/** user-defined constants **/
/** user-defined types **/
/**
* Metadata for the currently active application, including localized and unlocalized names, and an optional base64-encoded icon.
*/
export type AppMeta = { local: string | null; unlocal: string | null; ico: string | null }
export type ConnectionState = "connecting" | "connected" | "disconnected"
export type ConnectionStatus = { remoteId: string; address: string; name: string | null; state: ConnectionState }
export type CursorPosition = { x: number; y: number }
export type CursorPositionChanged = { positions: Partial<{ [key in string]: CursorPositions }> }
export type CursorPositions = {
/**
* Absolute cursor coordinates in physical pixels.
*/
raw: CursorPosition;
/**
* Cursor coordinates normalized to the source monitor for scale-independent projection.
*/
mapped: CursorPosition }
export type ForegroundAppChanged = { meta: AppMeta }
export type FriendForegroundAppChanged = { friendId: string; meta: AppMeta }
export type FriendsChanged = { friends: User[] }
export type NetworkStatusChanged = { statuses: ConnectionStatus[] }
export type ProfileChanged = { profile: User }
export type Remote = { id: string; address: string; name: string | null; port: number | null }
export type RemoteInput = { address: string; name: string | null; port: number | null }
export type RemotesChanged = { remotes: Remote[] }
export type SceneHitbox = { x: number; y: number; width: number; height: number }
/**
* Public user identity exchanged with peers and remote servers. `id` is the
* user's Ed25519 public key and is not persisted as local profile metadata.
*/
export type User = { id: string; displayName: string }
/** tauri-specta globals **/
import {
invoke as TAURI_INVOKE,
Channel as TAURI_CHANNEL,
} from "@tauri-apps/api/core";
import * as TAURI_API_EVENT from "@tauri-apps/api/event";
import { type WebviewWindow as __WebviewWindow__ } from "@tauri-apps/api/webviewWindow";
type __EventObj__<T> = {
listen: (
cb: TAURI_API_EVENT.EventCallback<T>,
) => ReturnType<typeof TAURI_API_EVENT.listen<T>>;
once: (
cb: TAURI_API_EVENT.EventCallback<T>,
) => ReturnType<typeof TAURI_API_EVENT.once<T>>;
emit: null extends T
? (payload?: T) => ReturnType<typeof TAURI_API_EVENT.emit>
: (payload: T) => ReturnType<typeof TAURI_API_EVENT.emit>;
};
export type Result<T, E> =
| { status: "ok"; data: T }
| { status: "error"; error: E };
function __makeEvents__<T extends Record<string, any>>(
mappings: Record<keyof T, string>,
) {
return new Proxy(
{} as unknown as {
[K in keyof T]: __EventObj__<T[K]> & {
(handle: __WebviewWindow__): __EventObj__<T[K]>;
};
},
{
get: (_, event) => {
const name = mappings[event as keyof T];
return new Proxy((() => {}) as any, {
apply: (_, __, [window]: [__WebviewWindow__]) => ({
listen: (arg: any) => window.listen(name, arg),
once: (arg: any) => window.once(name, arg),
emit: (arg: any) => window.emit(name, arg),
}),
get: (_, command: keyof __EventObj__<any>) => {
switch (command) {
case "listen":
return (arg: any) => TAURI_API_EVENT.listen(name, arg);
case "once":
return (arg: any) => TAURI_API_EVENT.once(name, arg);
case "emit":
return (arg: any) => TAURI_API_EVENT.emit(name, arg);
}
},
});
},
},
);
}