Files
friendolls-desktop/src/lib/bindings.ts

314 lines
14 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 getAppData() : Promise<UserData> {
return await TAURI_INVOKE("get_app_data");
},
async getAppState() : Promise<AppState> {
return await TAURI_INVOKE("get_app_state");
},
async getNekoPositions() : Promise<NekoPositionsDto> {
return await TAURI_INVOKE("get_neko_positions");
},
async getActiveDollSpriteBase64() : Promise<string | null> {
return await TAURI_INVOKE("get_active_doll_sprite_base64");
},
async getFriendActiveDollSpritesBase64() : Promise<FriendActiveDollSpritesDto> {
return await TAURI_INVOKE("get_friend_active_doll_sprites_base64");
},
async refreshAppData() : Promise<UserData> {
return await TAURI_INVOKE("refresh_app_data");
},
async listFriends() : Promise<FriendshipResponseDto[]> {
return await TAURI_INVOKE("list_friends");
},
async searchUsers(username: string | null) : Promise<UserBasicDto[]> {
return await TAURI_INVOKE("search_users", { username });
},
async sendFriendRequest(request: SendFriendRequestDto) : Promise<FriendRequestResponseDto> {
return await TAURI_INVOKE("send_friend_request", { request });
},
async receivedFriendRequests() : Promise<FriendRequestResponseDto[]> {
return await TAURI_INVOKE("received_friend_requests");
},
async sentFriendRequests() : Promise<FriendRequestResponseDto[]> {
return await TAURI_INVOKE("sent_friend_requests");
},
async acceptFriendRequest(requestId: string) : Promise<FriendRequestResponseDto> {
return await TAURI_INVOKE("accept_friend_request", { requestId });
},
async denyFriendRequest(requestId: string) : Promise<FriendRequestResponseDto> {
return await TAURI_INVOKE("deny_friend_request", { requestId });
},
async unfriend(friendId: string) : Promise<null> {
return await TAURI_INVOKE("unfriend", { friendId });
},
async getDolls() : Promise<DollDto[]> {
return await TAURI_INVOKE("get_dolls");
},
async getDoll(id: string) : Promise<DollDto> {
return await TAURI_INVOKE("get_doll", { id });
},
async createDoll(dto: CreateDollDto) : Promise<DollDto> {
return await TAURI_INVOKE("create_doll", { dto });
},
async updateDoll(id: string, dto: UpdateDollDto) : Promise<DollDto> {
return await TAURI_INVOKE("update_doll", { id, dto });
},
async deleteDoll(id: string) : Promise<null> {
return await TAURI_INVOKE("delete_doll", { id });
},
async setActiveDoll(dollId: string) : Promise<null> {
return await TAURI_INVOKE("set_active_doll", { dollId });
},
async removeActiveDoll() : Promise<null> {
return await TAURI_INVOKE("remove_active_doll");
},
async recolorGifBase64(whiteColorHex: string, blackColorHex: string, applyTexture: boolean) : Promise<string> {
return await TAURI_INVOKE("recolor_gif_base64", { whiteColorHex, blackColorHex, applyTexture });
},
async encodePetDollGifBase64(doll: DollDto) : Promise<string> {
return await TAURI_INVOKE("encode_pet_doll_gif_base64", { doll });
},
async quitApp() : Promise<null> {
return await TAURI_INVOKE("quit_app");
},
async restartApp() : Promise<void> {
await TAURI_INVOKE("restart_app");
},
/**
* Attempt to re-establish the user session without restarting the app.
*
* Validates server health, checks for a valid session token,
* then reconstructs the user session (re-fetches app data + WebSocket).
*/
async retryConnection() : Promise<null> {
return await TAURI_INVOKE("retry_connection");
},
async getClientConfig() : Promise<AppConfig> {
return await TAURI_INVOKE("get_client_config");
},
async saveClientConfig(config: AppConfig) : Promise<null> {
return await TAURI_INVOKE("save_client_config", { config });
},
async openClientConfig() : Promise<null> {
return await TAURI_INVOKE("open_client_config");
},
async openDollEditorWindow(dollId: string | null) : Promise<void> {
await TAURI_INVOKE("open_doll_editor_window", { dollId });
},
async getSceneInteractive() : Promise<boolean> {
return await TAURI_INVOKE("get_scene_interactive");
},
async setSceneInteractive(interactive: boolean, shouldClick: boolean) : Promise<void> {
await TAURI_INVOKE("set_scene_interactive", { interactive, shouldClick });
},
async setPetMenuState(id: string, open: boolean) : Promise<void> {
await TAURI_INVOKE("set_pet_menu_state", { id, open });
},
async startGoogleAuth() : Promise<null> {
return await TAURI_INVOKE("start_google_auth");
},
async startDiscordAuth() : Promise<null> {
return await TAURI_INVOKE("start_discord_auth");
},
async logoutAndRestart() : Promise<null> {
return await TAURI_INVOKE("logout_and_restart");
},
async sendInteractionCmd(dto: SendInteractionDto) : Promise<null> {
return await TAURI_INVOKE("send_interaction_cmd", { dto });
},
async getModules() : Promise<ModuleMetadata[]> {
return await TAURI_INVOKE("get_modules");
},
async setSceneSetupNekosPosition(nekosPosition: NekoPosition | null) : Promise<void> {
await TAURI_INVOKE("set_scene_setup_nekos_position", { nekosPosition });
},
async setSceneSetupNekosOpacity(nekosOpacity: number) : Promise<void> {
await TAURI_INVOKE("set_scene_setup_nekos_opacity", { nekosOpacity });
},
async setSceneSetupNekosScale(nekosScale: number) : Promise<void> {
await TAURI_INVOKE("set_scene_setup_nekos_scale", { nekosScale });
}
}
/** user-defined events **/
export const events = __makeEvents__<{
activeDollSpriteChanged: ActiveDollSpriteChanged,
appDataRefreshed: AppDataRefreshed,
appStateChanged: AppStateChanged,
authFlowUpdated: AuthFlowUpdated,
createDoll: CreateDoll,
editDoll: EditDoll,
friendActiveDollChanged: FriendActiveDollChanged,
friendActiveDollSpritesUpdated: FriendActiveDollSpritesUpdated,
friendDisconnected: FriendDisconnected,
friendRequestAccepted: FriendRequestAccepted,
friendRequestDenied: FriendRequestDenied,
friendRequestReceived: FriendRequestReceived,
friendUserStatusChanged: FriendUserStatusChanged,
interactionDeliveryFailed: InteractionDeliveryFailed,
interactionReceived: InteractionReceived,
nekoPositionsUpdated: NekoPositionsUpdated,
sceneInteractiveChanged: SceneInteractiveChanged,
setInteractionOverlay: SetInteractionOverlay,
unfriended: Unfriended,
userStatusChanged: UserStatusChanged
}>({
activeDollSpriteChanged: "active-doll-sprite-changed",
appDataRefreshed: "app-data-refreshed",
appStateChanged: "app-state-changed",
authFlowUpdated: "auth-flow-updated",
createDoll: "create-doll",
editDoll: "edit-doll",
friendActiveDollChanged: "friend-active-doll-changed",
friendActiveDollSpritesUpdated: "friend-active-doll-sprites-updated",
friendDisconnected: "friend-disconnected",
friendRequestAccepted: "friend-request-accepted",
friendRequestDenied: "friend-request-denied",
friendRequestReceived: "friend-request-received",
friendUserStatusChanged: "friend-user-status-changed",
interactionDeliveryFailed: "interaction-delivery-failed",
interactionReceived: "interaction-received",
nekoPositionsUpdated: "neko-positions-updated",
sceneInteractiveChanged: "scene-interactive-changed",
setInteractionOverlay: "set-interaction-overlay",
unfriended: "unfriended",
userStatusChanged: "user-status-changed"
})
/** user-defined constants **/
/** user-defined types **/
export type AcceleratorAction = "scene_interactivity"
export type AcceleratorKey = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z" | "num_0" | "num_1" | "num_2" | "num_3" | "num_4" | "num_5" | "num_6" | "num_7" | "num_8" | "num_9" | "f1" | "f2" | "f3" | "f4" | "f5" | "f6" | "f7" | "f8" | "f9" | "f10" | "f11" | "f12" | "enter" | "space" | "escape" | "tab" | "backspace" | "delete" | "insert" | "home" | "end" | "page_up" | "page_down" | "arrow_up" | "arrow_down" | "arrow_left" | "arrow_right" | "minus" | "equal" | "left_bracket" | "right_bracket" | "back_slash" | "semicolon" | "apostrophe" | "comma" | "dot" | "slash" | "grave"
export type AcceleratorModifier = "cmd" | "alt" | "ctrl" | "shift"
export type ActiveDollSpriteChanged = string | null
export type AppConfig = { api_base_url: string | null; debug_mode: boolean; accelerators?: Partial<{ [key in AcceleratorAction]: KeyboardAccelerator }> }
export type AppDataRefreshed = UserData
export type AppState = { sceneSetup: SceneSetup }
export type AppStateChanged = AppState
export type AuthFlowStatus = "started" | "succeeded" | "failed" | "cancelled"
export type AuthFlowUpdated = AuthFlowUpdatedPayload
export type AuthFlowUpdatedPayload = { provider: string; status: AuthFlowStatus; message: string | null }
export type CreateDoll = null
export type CreateDollDto = { name: string; configuration: DollConfigurationDto | null }
export type CursorPosition = { x: number; y: number }
export type CursorPositions = { raw: CursorPosition; mapped: CursorPosition }
export type DisplayData = { screen_width: number; screen_height: number; monitor_scale_factor: number }
export type DollColorSchemeDto = { outline: string; body: string }
export type DollConfigurationDto = { colorScheme: DollColorSchemeDto }
export type DollDto = { id: string; name: string; configuration: DollConfigurationDto; createdAt: string; updatedAt: string }
export type EditDoll = string
export type FriendActiveDollChanged = FriendActiveDollChangedPayload
export type FriendActiveDollChangedPayload = { friendId: string; doll: DollDto | null }
export type FriendActiveDollSpritesDto = Partial<{ [key in string]: string }>
export type FriendActiveDollSpritesUpdated = FriendActiveDollSpritesDto
export type FriendDisconnected = FriendDisconnectedPayload
export type FriendDisconnectedPayload = { userId: string }
export type FriendRequestAccepted = FriendRequestAcceptedPayload
export type FriendRequestAcceptedPayload = { id: string; friend: UserBasicDto; acceptedAt: string }
export type FriendRequestDenied = FriendRequestDeniedPayload
export type FriendRequestDeniedPayload = { id: string; denier: UserBasicDto; deniedAt: string }
export type FriendRequestReceived = FriendRequestReceivedPayload
export type FriendRequestReceivedPayload = { id: string; sender: UserBasicDto; createdAt: string }
export type FriendRequestResponseDto = { id: string; sender: UserBasicDto; receiver: UserBasicDto; status: string; createdAt: string; updatedAt: string }
export type FriendUserStatusChanged = FriendUserStatusPayload
export type FriendUserStatusPayload = { userId: string; status: UserStatusPayload }
export type FriendshipResponseDto = { id: string; friend: UserBasicDto | null; createdAt: string }
export type InteractionDeliveryFailed = InteractionDeliveryFailedDto
export type InteractionDeliveryFailedDto = { recipientUserId: string; reason: string }
export type InteractionPayloadDto = { senderUserId: string; senderName: string; content: string; type: string; timestamp: string }
export type InteractionReceived = InteractionPayloadDto
export type KeyboardAccelerator = { modifiers?: AcceleratorModifier[]; key?: AcceleratorKey | null }
export type ModuleMetadata = { id: string; name: string; version: string; description: string | null }
export type NekoPosition = "top-left" | "top" | "top-right" | "left" | "right" | "bottom-left" | "bottom" | "bottom-right"
export type NekoPositionDto = { userId: string; isSelf: boolean; cursor: CursorPositions; target: CursorPosition; overrideApplied: boolean }
export type NekoPositionsDto = Partial<{ [key in string]: NekoPositionDto }>
export type NekoPositionsUpdated = NekoPositionsDto
export type PresenceStatus = { title: string | null; subtitle: string | null; graphicsB64: string | null }
export type SceneData = { display: DisplayData; grid_size: number }
export type SceneInteractiveChanged = boolean
export type SceneSetup = { nekosPosition: NekoPosition | null; nekosOpacity: number; nekosScale: number }
export type SendFriendRequestDto = { receiverId: string }
export type SendInteractionDto = { recipientUserId: string; content: string; type: string }
export type SetInteractionOverlay = boolean
export type Unfriended = UnfriendedPayload
export type UnfriendedPayload = { friendId: string }
export type UpdateDollDto = { name: string | null; configuration: DollConfigurationDto | null }
export type UserBasicDto = { id: string; name: string; username: string | null; activeDoll: DollDto | null }
export type UserData = { user: UserProfile | null; friends: FriendshipResponseDto[] | null; dolls: DollDto[] | null; scene: SceneData }
export type UserProfile = { id: string; name: string; email: string; username: string | null; roles: string[]; createdAt: string; updatedAt: string; lastLoginAt: string | null; activeDollId: string | null }
export type UserStatusChanged = UserStatusPayload
export type UserStatusPayload = { presenceStatus: PresenceStatus; state: UserStatusState }
export type UserStatusState = "idle" | "resting"
/** 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);
}
},
});
},
},
);
}