Initial commit: RomM Companion desktop v0.1.0
This commit is contained in:
commit
238a23c528
41 files changed
+17214
No files matched your search
@@ -0,0 +1,137 @@
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { open } from "@tauri-apps/plugin-dialog";
|
||||
import { openUrl } from "@tauri-apps/plugin-opener";
|
||||
import type {
|
||||
AppStateSnapshot,
|
||||
BackupEntry,
|
||||
DetectedNextUiVolume,
|
||||
DeviceAuthInitResponse,
|
||||
DiscoveredSaveItem,
|
||||
EmulatorPresetInfo,
|
||||
EmulatorRule,
|
||||
LocalRomScanResult,
|
||||
NextUiCardInspection,
|
||||
PlatformSchema,
|
||||
RemoteSavesAndStates,
|
||||
RomPageResponse,
|
||||
SyncRunSummary,
|
||||
UserSchema,
|
||||
WatcherSettings,
|
||||
} from "./types";
|
||||
|
||||
export const api = {
|
||||
getAppState: () => invoke<AppStateSnapshot>("get_app_state"),
|
||||
testServer: (serverUrl: string) => invoke<unknown>("test_server", { serverUrl }),
|
||||
startDeviceAuth: (serverUrl: string, deviceName: string) =>
|
||||
invoke<DeviceAuthInitResponse>("start_device_auth", { serverUrl, deviceName }),
|
||||
pollDeviceAuth: (serverUrl: string, deviceCode: string) =>
|
||||
invoke<UserSchema | null>("poll_device_auth", { serverUrl, deviceCode }),
|
||||
exchangePairCode: (serverUrl: string, code: string) =>
|
||||
invoke<UserSchema>("exchange_pair_code", { serverUrl, code }),
|
||||
connectWithToken: (serverUrl: string, token: string) =>
|
||||
invoke<UserSchema>("connect_with_token", { serverUrl, token }),
|
||||
loginWithPassword: (serverUrl: string, username: string, password: string) =>
|
||||
invoke<UserSchema>("login_with_password", { serverUrl, username, password }),
|
||||
disconnect: () => invoke<AppStateSnapshot>("disconnect"),
|
||||
|
||||
getEmulatorPresets: () => invoke<EmulatorPresetInfo[]>("get_emulator_presets"),
|
||||
autoPopulateDetectedEmulators: () =>
|
||||
invoke<AppStateSnapshot>("auto_populate_detected_emulators"),
|
||||
upsertEmulatorRule: (rule: EmulatorRule) =>
|
||||
invoke<AppStateSnapshot>("upsert_emulator_rule", { rule }),
|
||||
deleteEmulatorRule: (emulatorId: string) =>
|
||||
invoke<AppStateSnapshot>("delete_emulator_rule", { emulatorId }),
|
||||
|
||||
fetchPlatforms: () => invoke<PlatformSchema[]>("fetch_platforms"),
|
||||
fetchRoms: (params: {
|
||||
platformId?: number | null;
|
||||
searchTerm?: string | null;
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
}) => invoke<RomPageResponse>("fetch_roms", params),
|
||||
refreshRomCache: () => invoke<number>("refresh_rom_cache"),
|
||||
scanLocalRomFolder: (folderPath: string, useHashLookup: boolean) =>
|
||||
invoke<LocalRomScanResult[]>("scan_local_rom_folder", { folderPath, useHashLookup }),
|
||||
downloadRomToFolder: (params: {
|
||||
romId: number;
|
||||
fileName: string;
|
||||
destFolder?: string | null;
|
||||
platformSlug?: string | null;
|
||||
platformFsSlug?: string | null;
|
||||
}) => invoke<string>("download_rom_to_folder", params),
|
||||
|
||||
fetchRemoteSavesAndStates: (romId?: number | null) =>
|
||||
invoke<RemoteSavesAndStates>("fetch_remote_saves_and_states", { romId: romId ?? null }),
|
||||
downloadSingleSave: (params: {
|
||||
saveId: number;
|
||||
romId: number;
|
||||
fileName: string;
|
||||
platformSlug: string;
|
||||
platformFsSlug?: string | null;
|
||||
emulatorHint?: string | null;
|
||||
destOverride?: string | null;
|
||||
}) => invoke<string>("download_single_save", params),
|
||||
downloadSingleState: (params: {
|
||||
stateId: number;
|
||||
romId: number;
|
||||
fileName: string;
|
||||
platformSlug: string;
|
||||
platformFsSlug?: string | null;
|
||||
emulatorHint?: string | null;
|
||||
destOverride?: string | null;
|
||||
}) => invoke<string>("download_single_state", params),
|
||||
uploadSingleSave: (params: {
|
||||
localPath: string;
|
||||
fileName: string;
|
||||
romId: number;
|
||||
emulatorId: string;
|
||||
slot: string;
|
||||
isDirectory: boolean;
|
||||
isState: boolean;
|
||||
}) => invoke<void>("upload_single_save", params),
|
||||
|
||||
discoverLocalSaves: () => invoke<DiscoveredSaveItem[]>("discover_local_saves"),
|
||||
linkSaveToRom: (params: {
|
||||
localPath: string;
|
||||
romId: number;
|
||||
romName: string;
|
||||
emulatorId: string;
|
||||
slot: string;
|
||||
isState: boolean;
|
||||
}) => invoke<void>("link_save_to_rom", params),
|
||||
unlinkSave: (localPath: string) => invoke<void>("unlink_save", { localPath }),
|
||||
|
||||
runFullSync: () => invoke<SyncRunSummary>("run_full_sync"),
|
||||
resolveSyncConflict: (conflictId: string, resolution: "keep_local" | "keep_server") =>
|
||||
invoke<void>("resolve_sync_conflict", { conflictId, resolution }),
|
||||
|
||||
listBackups: () => invoke<BackupEntry[]>("list_backups"),
|
||||
restoreBackup: (backupPath: string, targetPath: string, isDirectory: boolean) =>
|
||||
invoke<void>("restore_backup", { backupPath, targetPath, isDirectory }),
|
||||
|
||||
saveSettings: (settings: WatcherSettings, deviceName?: string) =>
|
||||
invoke<AppStateSnapshot>("save_settings", { settings, deviceName }),
|
||||
clearSyncLogs: () => invoke<void>("clear_sync_logs"),
|
||||
restartWatcher: () => invoke<AppStateSnapshot>("restart_watcher"),
|
||||
|
||||
detectNextUiVolumes: () => invoke<DetectedNextUiVolume[]>("detect_nextui_volumes"),
|
||||
inspectNextUiCard: (sdRoot: string) =>
|
||||
invoke<NextUiCardInspection>("inspect_nextui_card", { sdRoot }),
|
||||
renameNextUiHandheld: (sdRoot: string, deviceName: string) =>
|
||||
invoke<void>("rename_nextui_handheld", { sdRoot, deviceName }),
|
||||
syncNextUiCard: (sdRoot: string, syncStates: boolean) =>
|
||||
invoke<SyncRunSummary>("sync_nextui_card", { sdRoot, syncStates }),
|
||||
downloadRomToNextUi: (params: {
|
||||
sdRoot: string;
|
||||
romId: number;
|
||||
fileName: string;
|
||||
platformSlug: string;
|
||||
platformDisplayName: string;
|
||||
}) => invoke<string>("download_rom_to_nextui", params),
|
||||
|
||||
pickFolder: async (title = "Select Folder"): Promise<string | null> => {
|
||||
const selected = await open({ directory: true, multiple: false, title });
|
||||
return typeof selected === "string" ? selected : null;
|
||||
},
|
||||
openExternalUrl: (url: string) => openUrl(url),
|
||||
};
|
||||
Reference in new issue
Block a user