mirror of
https://github.com/SteamDeckHomebrew/decky-loader.git
synced 2026-06-17 00:37:49 +00:00
5e3de747d3
* Add services and updated installer files * Loader updates service file during update! * Testing update branch doesn't exist lol * Update to dfl 3.7.12 * Fix services and add working service updater * Revert services but replace their aliases * Fix install scripts as well * Move leftover service files to .systemd dir * No wonder it's not trimming the file... * fix whitespace * Remove unused imports * Remove another un-used import Co-authored-by: AAGaming <aa@mail.catvibers.me>
100 lines
3.0 KiB
TypeScript
100 lines
3.0 KiB
TypeScript
import { Plugin } from './plugin';
|
|
|
|
export enum Store {
|
|
Default,
|
|
Testing,
|
|
Custom,
|
|
}
|
|
|
|
export interface StorePluginVersion {
|
|
name: string;
|
|
hash: string;
|
|
}
|
|
|
|
export interface StorePlugin {
|
|
id: number;
|
|
name: string;
|
|
versions: StorePluginVersion[];
|
|
author: string;
|
|
description: string;
|
|
tags: string[];
|
|
image_url: string;
|
|
}
|
|
|
|
// name: version
|
|
export type PluginUpdateMapping = Map<string, StorePluginVersion>;
|
|
|
|
export async function getPluginList(): Promise<StorePlugin[]> {
|
|
let version = await window.DeckyPluginLoader.updateVersion();
|
|
return fetch('https://plugins.deckbrew.xyz/plugins', {
|
|
method: 'GET',
|
|
headers: {
|
|
'X-Decky-Version': version.current,
|
|
},
|
|
}).then((r) => r.json());
|
|
// let store = await getSetting<Store>('store', Store.Default);
|
|
// let customURL = await getSetting<string>('store-url', 'https://plugins.deckbrew.xyz/plugins');
|
|
// let storeURL;
|
|
// if (!store) {
|
|
// console.log('Could not get a default store, using Default.');
|
|
// await setSetting('store-url', Store.Default);
|
|
// return fetch('https://plugins.deckbrew.xyz/plugins', {
|
|
// method: 'GET',
|
|
// headers: {
|
|
// 'X-Decky-Version': version.current,
|
|
// },
|
|
// }).then((r) => r.json());
|
|
// } else {
|
|
// switch (+store) {
|
|
// case Store.Default:
|
|
// storeURL = 'https://plugins.deckbrew.xyz/plugins';
|
|
// break;
|
|
// case Store.Testing:
|
|
// storeURL = 'https://testing.deckbrew.xyz/plugins';
|
|
// break;
|
|
// case Store.Custom:
|
|
// storeURL = customURL;
|
|
// break;
|
|
// default:
|
|
// console.error('Somehow you ended up without a standard URL, using the default URL.');
|
|
// storeURL = 'https://plugins.deckbrew.xyz/plugins';
|
|
// break;
|
|
// }
|
|
// return fetch(storeURL, {
|
|
// method: 'GET',
|
|
// headers: {
|
|
// 'X-Decky-Version': version.current,
|
|
// },
|
|
// }).then((r) => r.json());
|
|
// }
|
|
}
|
|
|
|
export async function installFromURL(url: string) {
|
|
const splitURL = url.split('/');
|
|
await window.DeckyPluginLoader.callServerMethod('install_plugin', {
|
|
name: splitURL[splitURL.length - 1].replace('.zip', ''),
|
|
artifact: url,
|
|
});
|
|
}
|
|
|
|
export async function requestPluginInstall(plugin: string, selectedVer: StorePluginVersion) {
|
|
await window.DeckyPluginLoader.callServerMethod('install_plugin', {
|
|
name: plugin,
|
|
artifact: `https://cdn.tzatzikiweeb.moe/file/steam-deck-homebrew/versions/${selectedVer.hash}.zip`,
|
|
version: selectedVer.name,
|
|
hash: selectedVer.hash,
|
|
});
|
|
}
|
|
|
|
export async function checkForUpdates(plugins: Plugin[]): Promise<PluginUpdateMapping> {
|
|
const serverData = await getPluginList();
|
|
const updateMap = new Map<string, StorePluginVersion>();
|
|
for (let plugin of plugins) {
|
|
const remotePlugin = serverData?.find((x) => x.name == plugin.name);
|
|
if (remotePlugin && remotePlugin.versions?.length > 0 && plugin.version != remotePlugin?.versions?.[0]?.name) {
|
|
updateMap.set(plugin.name, remotePlugin.versions[0]);
|
|
}
|
|
}
|
|
return updateMap;
|
|
}
|