mirror of
https://github.com/SteamDeckHomebrew/decky-frontend-lib.git
synced 2026-05-26 04:48:52 +02:00
Initial commit
This commit is contained in:
33
src/plugin.ts
Normal file
33
src/plugin.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
export interface Plugin {
|
||||
title: JSX.Element;
|
||||
tab: JSX.Element;
|
||||
panel: JSX.Element;
|
||||
onDismount?(): void;
|
||||
}
|
||||
|
||||
interface ServerResponseSuccess<TRes> {
|
||||
success: true;
|
||||
result: TRes;
|
||||
}
|
||||
|
||||
interface ServerResponseError {
|
||||
success: false;
|
||||
result: string;
|
||||
}
|
||||
|
||||
type ServerResponse<TRes> = ServerResponseSuccess<TRes> | ServerResponseError;
|
||||
|
||||
export interface ServerAPI {
|
||||
callPluginMethod<TArgs = {}, TRes = {}>(methodName: string, args: TArgs): Promise<ServerResponse<TRes>>;
|
||||
callServerMethod<TArgs = {}, TRes = {}>(methodName: string, args: TArgs): Promise<ServerResponse<TRes>>;
|
||||
fetchNoCors<TRes = {}>(url: string, request: RequestInfo): Promise<ServerResponse<TRes>>;
|
||||
executeInTab(tab: string, runAsync: boolean, code: string): Promise<unknown>;
|
||||
removeCssFromTab(tab: string, cssId: string): Promise<unknown>;
|
||||
}
|
||||
|
||||
type DefinePluginFn = (serverAPI: ServerAPI) => Plugin;
|
||||
|
||||
// TypeScript helper function
|
||||
export const definePlugin = (fn: DefinePluginFn) => {
|
||||
return fn;
|
||||
};
|
||||
Reference in New Issue
Block a user