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:
5
src/deck-components/Backdrop.tsx
Normal file
5
src/deck-components/Backdrop.tsx
Normal file
@@ -0,0 +1,5 @@
|
||||
import { ReactNode } from 'react';
|
||||
|
||||
import { BackdropModule } from '../modules';
|
||||
|
||||
export const openBackdrop: (children: ReactNode) => void = BackdropModule.a;
|
||||
46
src/deck-components/Controls.tsx
Normal file
46
src/deck-components/Controls.tsx
Normal file
@@ -0,0 +1,46 @@
|
||||
import { FC, VFC } from 'react';
|
||||
|
||||
import { ControlsModule } from '../modules';
|
||||
|
||||
interface ButtonProps {
|
||||
label?: string;
|
||||
description?: string;
|
||||
layout?: 'below';
|
||||
onClick?(): void;
|
||||
disabled?: boolean;
|
||||
bottomSeparator?: boolean;
|
||||
}
|
||||
|
||||
export const Button: FC<ButtonProps> = ControlsModule.a;
|
||||
|
||||
interface SwitchProps {
|
||||
label?: string;
|
||||
description?: string;
|
||||
checked: boolean;
|
||||
icon?: JSX.Element;
|
||||
disabled?: boolean;
|
||||
onChange?(checked: boolean): void;
|
||||
}
|
||||
|
||||
export const Switch: VFC<SwitchProps> = ControlsModule.j;
|
||||
|
||||
interface NotchLabel {
|
||||
notchIndex: number;
|
||||
label: string;
|
||||
value: number;
|
||||
}
|
||||
|
||||
interface SliderProps {
|
||||
label?: string;
|
||||
value: number;
|
||||
layout?: 'below';
|
||||
icon?: JSX.Element;
|
||||
min?: number;
|
||||
max?: number;
|
||||
step?: number;
|
||||
notchCount?: number;
|
||||
notchLabels?: NotchLabel[];
|
||||
onChange?(value: number): void;
|
||||
}
|
||||
|
||||
export const Slider: VFC<SliderProps> = ControlsModule.l;
|
||||
20
src/deck-components/Dialogs.tsx
Normal file
20
src/deck-components/Dialogs.tsx
Normal file
@@ -0,0 +1,20 @@
|
||||
import { FC, VFC } from 'react';
|
||||
|
||||
import { DialogModule } from '../modules';
|
||||
|
||||
export const Dialog: FC = DialogModule.a;
|
||||
|
||||
export const DialogTitle: FC = DialogModule.u;
|
||||
|
||||
export const DialogBody: FC = DialogModule.d;
|
||||
|
||||
export const DialogActions: FC = DialogModule.r;
|
||||
|
||||
interface DialogConfirmButtonsProps {
|
||||
focusButton: 'primary';
|
||||
strOKText: string;
|
||||
onOK?(): void;
|
||||
onCancel?(): void;
|
||||
}
|
||||
|
||||
export const DialogConfirmButtons: VFC<DialogConfirmButtonsProps> = DialogModule.A;
|
||||
17
src/deck-components/Menus.tsx
Normal file
17
src/deck-components/Menus.tsx
Normal file
@@ -0,0 +1,17 @@
|
||||
import { FC } from 'react';
|
||||
|
||||
import { MenuModule } from '../modules';
|
||||
|
||||
interface SimpleMenuProps {
|
||||
label: string;
|
||||
onCancel?(): void;
|
||||
cancelText?: string;
|
||||
}
|
||||
|
||||
export const SimpleMenu: FC<SimpleMenuProps> = MenuModule.c;
|
||||
|
||||
interface MenuItemProps {
|
||||
onSelected?(): void;
|
||||
}
|
||||
|
||||
export const MenuItem: FC<MenuItemProps> = MenuModule.e;
|
||||
13
src/deck-components/Panels.tsx
Normal file
13
src/deck-components/Panels.tsx
Normal file
@@ -0,0 +1,13 @@
|
||||
import { FC } from 'react';
|
||||
|
||||
import { PanelModule } from '../modules';
|
||||
|
||||
interface PanelSectionProps {
|
||||
title?: string;
|
||||
}
|
||||
|
||||
export const PanelSection: FC<PanelSectionProps> = PanelModule.a;
|
||||
|
||||
interface PanelSectionRowProps {}
|
||||
|
||||
export const PanelSectionRow: FC<PanelSectionRowProps> = PanelModule.b;
|
||||
13
src/deck-components/Tabs.tsx
Normal file
13
src/deck-components/Tabs.tsx
Normal file
@@ -0,0 +1,13 @@
|
||||
import { DetailedHTMLProps, FC, HTMLAttributes } from 'react';
|
||||
|
||||
export const TabTitle: FC<DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>> = ({
|
||||
children,
|
||||
className,
|
||||
...props
|
||||
}) => {
|
||||
return (
|
||||
<div className={`quickaccessmenu_Title_34nl5 ${className}`} {...props}>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
6
src/deck-components/index.ts
Normal file
6
src/deck-components/index.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
export * from './Backdrop';
|
||||
export * from './Controls';
|
||||
export * from './Dialogs';
|
||||
export * from './Menus';
|
||||
export * from './Panels';
|
||||
export * from './Tabs';
|
||||
8
src/deck-libs/Navigation.ts
Normal file
8
src/deck-libs/Navigation.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { NavigationModule } from '../modules';
|
||||
|
||||
interface Navigation {
|
||||
NavigateToExternalWeb(url: string): void;
|
||||
OpenQuickAccessMenu(key?: number): void;
|
||||
}
|
||||
|
||||
export const Navigation: Navigation = NavigationModule.b;
|
||||
1
src/deck-libs/index.ts
Normal file
1
src/deck-libs/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from './Navigation';
|
||||
3
src/index.ts
Normal file
3
src/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export * from './deck-components';
|
||||
export * from './deck-libs';
|
||||
export * from './plugin';
|
||||
10
src/modules.ts
Normal file
10
src/modules.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import ModuleRaid from 'moduleraid';
|
||||
|
||||
const moduleraid = new ModuleRaid();
|
||||
|
||||
export const ControlsModule = moduleraid.modules['qu8K'].exports;
|
||||
export const NavigationModule = moduleraid.modules['sUK7'].exports;
|
||||
export const DialogModule = moduleraid.modules['Mgs7'].exports;
|
||||
export const BackdropModule = moduleraid.modules['TtDX'].exports;
|
||||
export const MenuModule = moduleraid.modules['y+6m'].exports;
|
||||
export const PanelModule = moduleraid.modules['jYUt'].exports;
|
||||
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