summaryrefslogtreecommitdiff
path: root/src/api/lsfgApi.ts
blob: 12e284e8a7e8d2476a340c476a456b8b21acbf43 (plain)
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
import { callable } from "@decky/api";
import { ConfigurationData } from "../config/configSchema";

interface ApiResult {
  success: boolean;
  message?: string;
  error?: string | null;
}

export interface FlatpakCleanupResult extends ApiResult {
  removed_branches?: string[];
  preserved_branches?: string[];
  removed_filesystem_grants?: string[];
  preserved_filesystem_grants?: string[];
  ownership_uncertain?: boolean;
}

export interface InstallationResult extends ApiResult {
  removed_files?: string[];
  flatpak_cleanup?: FlatpakCleanupResult;
}

export interface InstallationStatus {
  installed: boolean;
  lossless_scaling_installed: boolean;
  lossless_scaling_status: string;
  error?: string;
}

export interface SteamBranchStatus extends ApiResult {
  message: string;
  installed: boolean;
  manifest_path?: string;
  selected_branch?: string;
  current_branch?: string;
  target_branch: string;
  needs_switch: boolean;
  restart_required: boolean;
}

export type LsfgConfig = ConfigurationData;
export type TargetTransport =
  | { kind: "host" }
  | { kind: "flatpak" };

export interface GameConfigEntry {
  appid: string;
  profile: string;
  config: LsfgConfig;
}

export interface InstalledGame {
  appid: string;
  name: string;
  nonSteam: boolean;
  transport: TargetTransport;
  executable?: string;
  arguments?: string;
  startDir?: string;
}

export interface GlobalConfig {
  dll: string;
  no_fp16: boolean;
}

export interface WorkaroundState {
  dxvkFrameRate: number;
  disableGamescopeWsi: boolean;
  disableHdr: boolean;
  disableSteamdeckMode: boolean;
  disableVkbasalt: boolean;
  enableZink: boolean;
}

export interface WorkaroundStateResult extends ApiResult {
  appid?: string;
  state?: WorkaroundState | null;
  wrapper_path?: string;
  wrapper_owned?: boolean;
  shortcut_exe?: string | null;
  command_token_added?: boolean;
  transport?: TargetTransport | null;
}

export interface GameConfigsResult extends ApiResult {
  global_config?: GlobalConfig;
  games?: GameConfigEntry[];
}

export interface GameConfigResult extends ApiResult {
  appid?: string;
  exists?: boolean;
  config?: LsfgConfig;
}

export interface InstalledGamesResult extends ApiResult {
  games?: InstalledGame[];
}

export interface FileContentResult extends ApiResult {
  content?: string;
  path?: string;
}

export interface DebugFileContent {
  id: string;
  label: string;
  path: string;
  exists: boolean;
  content?: string | null;
  error?: string | null;
}

export interface DebugFileContentsResult extends ApiResult {
  files?: DebugFileContent[];
}

export interface FlatpakExtensionStatus extends ApiResult {
  message: string;
  available: boolean;
  ready: boolean;
  extension_id: string;
  supported_branches: string[];
  installed_branches: string[];
  filesystem_grants: Array<{
    path: string;
    present: boolean;
    read_only: boolean;
  }>;
  missing_filesystem_grants: string[];
  plugin_owned_branches?: string[];
  plugin_owned_filesystems?: string[];
}

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 getLosslessScalingBranchStatus = callable<[], SteamBranchStatus>("get_lossless_scaling_branch_status");
export const getConfigFileContent = callable<[], FileContentResult>("get_config_file_content");
export const getFlatpakSupportStatus = callable<[], FlatpakExtensionStatus>("get_flatpak_support_status");
export const ensureFlatpakSupport = callable<[], FlatpakExtensionStatus>("ensure_flatpak_support");
export const repairFlatpakSupport = callable<[], FlatpakExtensionStatus>("repair_flatpak_support");
export const getGameConfigs = callable<[], GameConfigsResult>("get_game_configs");
export const getInstalledGames = callable<[], InstalledGamesResult>("get_installed_games");
export const updateGameConfig = callable<[string, string, LsfgConfig], GameConfigResult>("update_game_config");
export const resetGameConfig = callable<[string], GameConfigResult>("reset_game_config");
export const resetAllGameConfigs = callable<[], GameConfigsResult>("reset_all_game_configs");
export const getWorkaroundState = callable<[string], WorkaroundStateResult>("get_workaround_state");
export const setWorkaroundState = callable<[
  string,
  WorkaroundState,
  string | null | undefined,
  boolean,
  TargetTransport | null | undefined,
], WorkaroundStateResult>("set_workaround_state");
export const removeWorkaroundState = callable<[string], WorkaroundStateResult>("remove_workaround_state");
export const getDebugFileContents = callable<[], DebugFileContentsResult>("get_debug_file_contents");