1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
import { callable } from "@decky/api";
import { ConfigurationData } from "../config/configSchema";
// Type definitions for API responses
export interface InstallationResult {
success: boolean;
error?: string;
message?: string;
removed_files?: string[];
}
export interface InstallationStatus {
installed: boolean;
lib_exists: boolean;
json_exists: boolean;
script_exists: boolean;
lib_path: string;
json_path: string;
script_path: string;
error?: string;
}
export interface DllDetectionResult {
detected: boolean;
path?: string;
source?: string;
message?: string;
error?: string;
}
export interface DllStatsResult {
success: boolean;
dll_path?: string;
dll_sha256?: string;
dll_source?: string;
error?: string;
}
// Use centralized configuration data type
export type LsfgConfig = ConfigurationData;
export interface ConfigResult {
success: boolean;
config?: LsfgConfig;
error?: string;
}
export interface ConfigUpdateResult {
success: boolean;
message?: string;
error?: string;
}
export interface ConfigSchemaResult {
field_names: string[];
field_types: Record<string, string>;
defaults: ConfigurationData;
profiles?: string[];
current_profile?: string;
}
export interface UpdateCheckResult {
success: boolean;
update_available: boolean;
current_version: string;
latest_version: string;
release_notes: string;
release_date: string;
download_url: string;
error?: string;
}
export interface UpdateDownloadResult {
success: boolean;
download_path?: string;
error?: string;
}
export interface LaunchOptionResult {
launch_option: string;
instructions: string;
explanation: string;
}
export interface FileContentResult {
success: boolean;
content?: string;
path?: string;
error?: string;
}
// Profile management interfaces
export interface ProfilesResult {
success: boolean;
profiles?: string[];
current_profile?: string;
message?: string;
error?: string;
}
export interface ProfileResult {
success: boolean;
profile_name?: string;
message?: string;
error?: string;
}
// API functions
export const installLsfgVk = callable<[], InstallationResult>("install_lsfg_vk");
export const uninstallLsfgVk = callable<[], InstallationResult>("uninstall_lsfg_vk");
export const checkLsfgVkInstalled = callable<[], InstallationStatus>("check_lsfg_vk_installed");
export const checkLosslessScalingDll = callable<[], DllDetectionResult>("check_lossless_scaling_dll");
export const getDllStats = callable<[], DllStatsResult>("get_dll_stats");
export const getLsfgConfig = callable<[], ConfigResult>("get_lsfg_config");
export const getConfigSchema = callable<[], ConfigSchemaResult>("get_config_schema");
export const getLaunchOption = callable<[], LaunchOptionResult>("get_launch_option");
export const getConfigFileContent = callable<[], FileContentResult>("get_config_file_content");
export const getLaunchScriptContent = callable<[], FileContentResult>("get_launch_script_content");
// Updated config function using object-based configuration (single source of truth)
export const updateLsfgConfig = callable<
[ConfigurationData],
ConfigUpdateResult
>("update_lsfg_config");
// Legacy helper function for backward compatibility
export const updateLsfgConfigFromObject = async (config: ConfigurationData): Promise<ConfigUpdateResult> => {
return updateLsfgConfig(config);
};
// Self-updater API functions
export const checkForPluginUpdate = callable<[], UpdateCheckResult>("check_for_plugin_update");
export const downloadPluginUpdate = callable<[string], UpdateDownloadResult>("download_plugin_update");
// Profile management API functions
export const getProfiles = callable<[], ProfilesResult>("get_profiles");
export const createProfile = callable<[string, string?], ProfileResult>("create_profile");
export const deleteProfile = callable<[string], ProfileResult>("delete_profile");
export const renameProfile = callable<[string, string], ProfileResult>("rename_profile");
export const setCurrentProfile = callable<[string], ProfileResult>("set_current_profile");
export const updateProfileConfig = callable<[string, ConfigurationData], ConfigUpdateResult>("update_profile_config");
|