mirror of
https://github.com/SteamDeckHomebrew/decky-frontend-lib.git
synced 2026-05-22 02:48:48 +02:00
Compare commits
4 Commits
v3.18.3
...
aa/menu-ho
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d6e399fa46 | ||
|
|
e48c7bbadd | ||
|
|
727fcc8186 | ||
|
|
fd94842647 |
@@ -1,3 +1,10 @@
|
||||
## [3.18.4](https://github.com/SteamDeckHomebrew/decky-frontend-lib/compare/v3.18.3...v3.18.4) (2022-12-16)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **modals:** fix ModalRoot again ([fd94842](https://github.com/SteamDeckHomebrew/decky-frontend-lib/commit/fd94842647e51dd9a104e170e0c5ee2bebce12d6))
|
||||
|
||||
## [3.18.3](https://github.com/SteamDeckHomebrew/decky-frontend-lib/compare/v3.18.2...v3.18.3) (2022-12-12)
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "decky-frontend-lib",
|
||||
"version": "3.18.3",
|
||||
"version": "3.18.4",
|
||||
"description": "A library for building decky plugins",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { CSSProperties, FC } from 'react';
|
||||
import { CSSProperties, FC, ReactNode } from 'react';
|
||||
|
||||
import { findModuleChild } from '../webpack';
|
||||
|
||||
@@ -12,7 +12,7 @@ export interface MarqueeProps {
|
||||
resetOnPause?: boolean;
|
||||
style?: CSSProperties;
|
||||
className?: string;
|
||||
children: React.ReactNode;
|
||||
children: ReactNode;
|
||||
}
|
||||
|
||||
export const Marquee: FC<MarqueeProps> = findModuleChild((m) => {
|
||||
|
||||
@@ -38,7 +38,7 @@ const showModalRaw:
|
||||
unknown1?: unknown,
|
||||
hideActions?: { bHideActions?: boolean },
|
||||
modalManager?: unknown,
|
||||
) => Promise<ShowModalResult>)
|
||||
) => ShowModalResult)
|
||||
| void = findModuleChild((m) => {
|
||||
if (typeof m !== 'object') return undefined;
|
||||
for (let prop in m) {
|
||||
@@ -52,16 +52,15 @@ const showModalRaw:
|
||||
}
|
||||
});
|
||||
|
||||
const oldShowModalRaw:
|
||||
| ((modal: ReactNode, parent?: EventTarget, props?: ShowModalProps) => Promise<ShowModalResult>)
|
||||
| void = findModuleChild((m) => {
|
||||
if (typeof m !== 'object') return undefined;
|
||||
for (let prop in m) {
|
||||
if (typeof m[prop] === 'function' && m[prop].toString().includes('bHideMainWindowForPopouts:!0')) {
|
||||
return m[prop];
|
||||
const oldShowModalRaw: ((modal: ReactNode, parent?: EventTarget, props?: ShowModalProps) => ShowModalResult) | void =
|
||||
findModuleChild((m) => {
|
||||
if (typeof m !== 'object') return undefined;
|
||||
for (let prop in m) {
|
||||
if (typeof m[prop] === 'function' && m[prop].toString().includes('bHideMainWindowForPopouts:!0')) {
|
||||
return m[prop];
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
export const showModal = (
|
||||
modal: ReactNode,
|
||||
@@ -70,7 +69,7 @@ export const showModal = (
|
||||
strTitle: 'Decky Dialog',
|
||||
bHideMainWindowForPopouts: false,
|
||||
},
|
||||
): Promise<ShowModalResult> => {
|
||||
): ShowModalResult => {
|
||||
if (showModalRaw) {
|
||||
return showModalRaw(modal, parent || findSP(), props.strTitle, props, undefined, {
|
||||
bHideActions: props.bHideActionIcons,
|
||||
@@ -118,13 +117,13 @@ export const ConfirmModal = findModuleChild((m) => {
|
||||
}
|
||||
}) as FC<ConfirmModalProps>;
|
||||
|
||||
// new
|
||||
// new as of december 2022 on beta
|
||||
export const ModalRoot = (Object.values(
|
||||
findModule((m: any) => {
|
||||
if (typeof m !== 'object') return false;
|
||||
|
||||
for (let prop in m) {
|
||||
if (m[prop]?.toString()?.includes('"ModalManager","DialogWrapper"')) {
|
||||
if (m[prop]?.m_mapModalManager) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -132,6 +131,20 @@ export const ModalRoot = (Object.values(
|
||||
return false;
|
||||
}) || {},
|
||||
)?.find((x: any) => x?.type?.toString()?.includes('((function(){')) ||
|
||||
// before december 2022 beta
|
||||
Object.values(
|
||||
findModule((m: any) => {
|
||||
if (typeof m !== 'object') return false;
|
||||
|
||||
for (let prop in m) {
|
||||
if (m[prop]?.toString()?.includes('"ModalManager","DialogWrapper"')) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}) || {},
|
||||
)?.find((x: any) => x?.type?.toString()?.includes('((function(){')) ||
|
||||
// old
|
||||
findModuleChild((m) => {
|
||||
if (typeof m !== 'object') return undefined;
|
||||
|
||||
@@ -21,6 +21,52 @@ interface ServerResponseError {
|
||||
|
||||
export type ServerResponse<TRes> = ServerResponseSuccess<TRes> | ServerResponseError;
|
||||
|
||||
export interface MainMenuItem {
|
||||
/** Called when clicking this menu item, useful if you do not want to navigate to a route.
|
||||
* For navigating to a route, use route instead. */
|
||||
action?: () => void;
|
||||
/** The route this menu item navigates to @example "/steamweb" */
|
||||
route?: string;
|
||||
/** Props for the route this item navigates to. Currently only used for /steamweb to determine what webpack to navigate to @example {url: 'https://store.steampowered.com/'} */
|
||||
routeState?: any;
|
||||
/** Label for this menu item, @example "Store" */
|
||||
label: ReactNode;
|
||||
/** Runs when this item is selected. Defaults to setting the focused app to null.
|
||||
* If you override this you must also call the original to retain proper behaivour */
|
||||
onFocus?: () => void;
|
||||
/** Icon of this menu item, you probably want a react SVG node */
|
||||
children: ReactNode;
|
||||
}
|
||||
|
||||
export interface CustomMainMenuItem extends MainMenuItem {
|
||||
index: number;
|
||||
}
|
||||
|
||||
export interface MainMenuItemReactNode {
|
||||
props: MainMenuItem;
|
||||
type: ComponentType;
|
||||
key: any;
|
||||
}
|
||||
|
||||
export interface OverlayReactNode {
|
||||
props: MainMenuItem;
|
||||
type: ComponentType;
|
||||
}
|
||||
|
||||
export type ItemPatch = (item: MainMenuItemReactNode) => MainMenuItemReactNode;
|
||||
export type OverlayPatch = (overlay: OverlayReactNode) => OverlayReactNode;
|
||||
|
||||
export interface MenuHook {
|
||||
addItem(item: CustomMainMenuItem): CustomMainMenuItem;
|
||||
addPatch(path: string, patch: ItemPatch): ItemPatch;
|
||||
addOverlayPatch(patch: OverlayPatch): OverlayPatch;
|
||||
addOverlayComponent(component: ReactNode): ReactNode;
|
||||
removePatch(path: string, patch: ItemPatch): void;
|
||||
removeOverlayPatch(patch: OverlayPatch): void;
|
||||
removeOverlayComponent(component: ReactNode): void;
|
||||
removeItem(item: CustomMainMenuItem): void;
|
||||
}
|
||||
|
||||
export type RoutePatch = (route: RouteProps) => RouteProps;
|
||||
|
||||
export interface RouterHook {
|
||||
@@ -59,6 +105,7 @@ export interface FilePickerRes {
|
||||
|
||||
export interface ServerAPI {
|
||||
routerHook: RouterHook;
|
||||
menuHook: MenuHook;
|
||||
toaster: Toaster;
|
||||
openFilePicker(startPath: string, includeFiles?: boolean, regex?: RegExp): Promise<FilePickerRes>;
|
||||
callPluginMethod<TArgs = {}, TRes = {}>(methodName: string, args: TArgs): Promise<ServerResponse<TRes>>;
|
||||
|
||||
Reference in New Issue
Block a user