mirror of
https://github.com/SteamDeckHomebrew/decky-frontend-lib.git
synced 2026-05-22 02:48:48 +02:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e48c7bbadd | ||
|
|
727fcc8186 | ||
|
|
dc196d53f5 | ||
|
|
f0379e5d19 | ||
|
|
fd94842647 | ||
|
|
ef6be8c6ec | ||
|
|
767dc2fcee | ||
|
|
52305987c5 | ||
|
|
6f14da152a |
28
CHANGELOG.md
28
CHANGELOG.md
@@ -1,3 +1,31 @@
|
|||||||
|
## [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)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **Router:** update Router interface to SteamOS3.4 and add Navigation ([#52](https://github.com/SteamDeckHomebrew/decky-frontend-lib/issues/52)) ([f0379e5](https://github.com/SteamDeckHomebrew/decky-frontend-lib/commit/f0379e5d19279863b571e66918bc9107efedb612))
|
||||||
|
|
||||||
|
## [3.18.2](https://github.com/SteamDeckHomebrew/decky-frontend-lib/compare/v3.18.1...v3.18.2) (2022-12-11)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **useQuickAccessVisible:** remove invalid prop access ([#66](https://github.com/SteamDeckHomebrew/decky-frontend-lib/issues/66)) ([767dc2f](https://github.com/SteamDeckHomebrew/decky-frontend-lib/commit/767dc2fcee97d8b6c2d331ae29704d9b469de51a))
|
||||||
|
|
||||||
|
## [3.18.1](https://github.com/SteamDeckHomebrew/decky-frontend-lib/compare/v3.18.0...v3.18.1) (2022-12-11)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **findSP:** fallback to last active context ([#53](https://github.com/SteamDeckHomebrew/decky-frontend-lib/issues/53)) ([6f14da1](https://github.com/SteamDeckHomebrew/decky-frontend-lib/commit/6f14da152acc4757b814844f1b77bf83dd98d77e))
|
||||||
|
|
||||||
# [3.18.0](https://github.com/SteamDeckHomebrew/decky-frontend-lib/compare/v3.17.0...v3.18.0) (2022-12-11)
|
# [3.18.0](https://github.com/SteamDeckHomebrew/decky-frontend-lib/compare/v3.17.0...v3.18.0) (2022-12-11)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "decky-frontend-lib",
|
"name": "decky-frontend-lib",
|
||||||
"version": "3.18.0",
|
"version": "3.18.4",
|
||||||
"description": "A library for building decky plugins",
|
"description": "A library for building decky plugins",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ declare global {
|
|||||||
|
|
||||||
function getQuickAccessWindow(): Window | null {
|
function getQuickAccessWindow(): Window | null {
|
||||||
try {
|
try {
|
||||||
const navTrees = FocusNavController?.m_ActiveContext?.m_rgGamepadNavigationTrees || FocusNavController?.m_rgGamepadNavigationTrees;
|
const context = FocusNavController?.m_ActiveContext || FocusNavController?.m_LastActiveContext;
|
||||||
|
const navTrees = context?.m_rgGamepadNavigationTrees || FocusNavController?.m_rgGamepadNavigationTrees;
|
||||||
return navTrees?.find((tree: any) => tree?.id === "QuickAccess-NA")?.m_Root?.m_element?.ownerDocument.defaultView ?? null;
|
return navTrees?.find((tree: any) => tree?.id === "QuickAccess-NA")?.m_Root?.m_element?.ownerDocument.defaultView ?? null;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ const showModalRaw:
|
|||||||
unknown1?: unknown,
|
unknown1?: unknown,
|
||||||
hideActions?: { bHideActions?: boolean },
|
hideActions?: { bHideActions?: boolean },
|
||||||
modalManager?: unknown,
|
modalManager?: unknown,
|
||||||
) => Promise<ShowModalResult>)
|
) => ShowModalResult)
|
||||||
| void = findModuleChild((m) => {
|
| void = findModuleChild((m) => {
|
||||||
if (typeof m !== 'object') return undefined;
|
if (typeof m !== 'object') return undefined;
|
||||||
for (let prop in m) {
|
for (let prop in m) {
|
||||||
@@ -52,16 +52,15 @@ const showModalRaw:
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const oldShowModalRaw:
|
const oldShowModalRaw: ((modal: ReactNode, parent?: EventTarget, props?: ShowModalProps) => ShowModalResult) | void =
|
||||||
| ((modal: ReactNode, parent?: EventTarget, props?: ShowModalProps) => Promise<ShowModalResult>)
|
findModuleChild((m) => {
|
||||||
| void = findModuleChild((m) => {
|
if (typeof m !== 'object') return undefined;
|
||||||
if (typeof m !== 'object') return undefined;
|
for (let prop in m) {
|
||||||
for (let prop in m) {
|
if (typeof m[prop] === 'function' && m[prop].toString().includes('bHideMainWindowForPopouts:!0')) {
|
||||||
if (typeof m[prop] === 'function' && m[prop].toString().includes('bHideMainWindowForPopouts:!0')) {
|
return m[prop];
|
||||||
return m[prop];
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
|
|
||||||
export const showModal = (
|
export const showModal = (
|
||||||
modal: ReactNode,
|
modal: ReactNode,
|
||||||
@@ -70,7 +69,7 @@ export const showModal = (
|
|||||||
strTitle: 'Decky Dialog',
|
strTitle: 'Decky Dialog',
|
||||||
bHideMainWindowForPopouts: false,
|
bHideMainWindowForPopouts: false,
|
||||||
},
|
},
|
||||||
): Promise<ShowModalResult> => {
|
): ShowModalResult => {
|
||||||
if (showModalRaw) {
|
if (showModalRaw) {
|
||||||
return showModalRaw(modal, parent || findSP(), props.strTitle, props, undefined, {
|
return showModalRaw(modal, parent || findSP(), props.strTitle, props, undefined, {
|
||||||
bHideActions: props.bHideActionIcons,
|
bHideActions: props.bHideActionIcons,
|
||||||
@@ -118,13 +117,13 @@ export const ConfirmModal = findModuleChild((m) => {
|
|||||||
}
|
}
|
||||||
}) as FC<ConfirmModalProps>;
|
}) as FC<ConfirmModalProps>;
|
||||||
|
|
||||||
// new
|
// new as of december 2022 on beta
|
||||||
export const ModalRoot = (Object.values(
|
export const ModalRoot = (Object.values(
|
||||||
findModule((m: any) => {
|
findModule((m: any) => {
|
||||||
if (typeof m !== 'object') return false;
|
if (typeof m !== 'object') return false;
|
||||||
|
|
||||||
for (let prop in m) {
|
for (let prop in m) {
|
||||||
if (m[prop]?.toString()?.includes('"ModalManager","DialogWrapper"')) {
|
if (m[prop]?.m_mapModalManager) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -132,6 +131,20 @@ export const ModalRoot = (Object.values(
|
|||||||
return false;
|
return false;
|
||||||
}) || {},
|
}) || {},
|
||||||
)?.find((x: any) => x?.type?.toString()?.includes('((function(){')) ||
|
)?.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
|
// old
|
||||||
findModuleChild((m) => {
|
findModuleChild((m) => {
|
||||||
if (typeof m !== 'object') return undefined;
|
if (typeof m !== 'object') return undefined;
|
||||||
|
|||||||
@@ -63,28 +63,38 @@ export type AppOverview = {
|
|||||||
sort_as: string;
|
sort_as: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface Router {
|
export interface MenuStore {
|
||||||
CloseSideMenus(): void;
|
|
||||||
OpenQuickAccessMenu(quickAccessTab?: QuickAccessTab): void;
|
|
||||||
GetQuickAccessTab(): QuickAccessTab;
|
|
||||||
Navigate(path: string): void;
|
|
||||||
NavigateBackOrOpenMenu(): void;
|
|
||||||
NavigateToAppProperties(): void;
|
|
||||||
NavigateToBugForum(): void;
|
|
||||||
NavigateToExternalWeb(url: string): void;
|
|
||||||
NavigateToHelp(): void;
|
|
||||||
NavigateToInvites(): void;
|
|
||||||
NavigateToRunningApp(replace?: boolean): void;
|
|
||||||
NavigateToStorage(): void;
|
|
||||||
NavigateToStore(): void;
|
|
||||||
NavigateToStoreApp(appId: number | string): void;
|
|
||||||
NavigateToStoreFreeToPlay(): void;
|
|
||||||
NavigateToStoreManual(): void;
|
|
||||||
NavigateToStoreNewReleases(): void;
|
|
||||||
NavigateToStoreOnSale(): void;
|
|
||||||
ToggleSideMenu(sideMenu: SideMenu): void;
|
|
||||||
CloseSideMenus(): void;
|
|
||||||
OpenSideMenu(sideMenu: SideMenu): void;
|
OpenSideMenu(sideMenu: SideMenu): void;
|
||||||
|
OpenQuickAccessMenu(quickAccessTab?: QuickAccessTab): void;
|
||||||
|
OpenMainMenu(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface WindowRouter {
|
||||||
|
BrowserWindow: Window;
|
||||||
|
MenuStore: MenuStore;
|
||||||
|
Navigate(path: string): void;
|
||||||
|
NavigateToChat(): void;
|
||||||
|
NavigateToSteamWeb(url: string): void;
|
||||||
|
NavigateBack(): void;
|
||||||
|
NavigateToWebRoute(unknown?: any, unknown2?: any): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface WindowStore {
|
||||||
|
GamepadUIMainWindowInstance?: WindowRouter; // Current
|
||||||
|
SteamUIWindows: WindowRouter[];
|
||||||
|
OverlayWindows: WindowRouter[]; // Used by desktop GamepadUI
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Router {
|
||||||
|
WindowStore?: WindowStore;
|
||||||
|
CloseSideMenus(): void;
|
||||||
|
Navigate(path: string): void;
|
||||||
|
NavigateToAppProperties(): void;
|
||||||
|
NavigateToExternalWeb(url: string): void;
|
||||||
|
NavigateToInvites(): void;
|
||||||
|
NavigateToChat(): void;
|
||||||
|
NavigateToLibraryTab(): void;
|
||||||
|
NavigateToLayoutPreview(e: unknown): void;
|
||||||
OpenPowerMenu(unknown?: any): void;
|
OpenPowerMenu(unknown?: any): void;
|
||||||
get RunningApps(): AppOverview[];
|
get RunningApps(): AppOverview[];
|
||||||
get MainRunningApp(): AppOverview | undefined;
|
get MainRunningApp(): AppOverview | undefined;
|
||||||
@@ -96,3 +106,51 @@ export const Router = findModuleChild((m: Module) => {
|
|||||||
if (m[prop]?.Navigate && m[prop]?.NavigationManager) return m[prop];
|
if (m[prop]?.Navigate && m[prop]?.NavigationManager) return m[prop];
|
||||||
}
|
}
|
||||||
}) as Router;
|
}) as Router;
|
||||||
|
|
||||||
|
export interface Navigation {
|
||||||
|
Navigate(path: string): void;
|
||||||
|
NavigateBack(): void;
|
||||||
|
NavigateToAppProperties(): void;
|
||||||
|
NavigateToExternalWeb(url: string): void;
|
||||||
|
NavigateToInvites(): void;
|
||||||
|
NavigateToChat(): void;
|
||||||
|
NavigateToLibraryTab(): void;
|
||||||
|
NavigateToLayoutPreview(e: unknown): void;
|
||||||
|
NavigateToSteamWeb(url: string): void;
|
||||||
|
NavigateToWebRoute(unknown?: any, unknown2?: any): void;
|
||||||
|
OpenSideMenu(sideMenu: SideMenu): void;
|
||||||
|
OpenQuickAccessMenu(quickAccessTab?: QuickAccessTab): void;
|
||||||
|
OpenMainMenu(): void;
|
||||||
|
OpenPowerMenu(unknown?: any): void;
|
||||||
|
CloseSideMenus(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const Navigation = {
|
||||||
|
Navigate: Router.Navigate.bind(Router),
|
||||||
|
NavigateBack: Router.WindowStore?.GamepadUIMainWindowInstance?.NavigateBack.bind(
|
||||||
|
Router.WindowStore.GamepadUIMainWindowInstance,
|
||||||
|
),
|
||||||
|
NavigateToAppProperties: Router.NavigateToAppProperties.bind(Router),
|
||||||
|
NavigateToExternalWeb: Router.NavigateToExternalWeb.bind(Router),
|
||||||
|
NavigateToInvites: Router.NavigateToInvites.bind(Router),
|
||||||
|
NavigateToChat: Router.NavigateToChat.bind(Router),
|
||||||
|
NavigateToLibraryTab: Router.NavigateToLibraryTab.bind(Router),
|
||||||
|
NavigateToLayoutPreview: Router.NavigateToLayoutPreview.bind(Router),
|
||||||
|
NavigateToSteamWeb: Router.WindowStore?.GamepadUIMainWindowInstance?.NavigateToSteamWeb.bind(
|
||||||
|
Router.WindowStore.GamepadUIMainWindowInstance,
|
||||||
|
),
|
||||||
|
NavigateToWebRoute: Router.WindowStore?.GamepadUIMainWindowInstance?.NavigateToWebRoute.bind(
|
||||||
|
Router.WindowStore.GamepadUIMainWindowInstance,
|
||||||
|
),
|
||||||
|
OpenSideMenu: Router.WindowStore?.GamepadUIMainWindowInstance?.MenuStore.OpenSideMenu.bind(
|
||||||
|
Router.WindowStore.GamepadUIMainWindowInstance.MenuStore,
|
||||||
|
),
|
||||||
|
OpenQuickAccessMenu: Router.WindowStore?.GamepadUIMainWindowInstance?.MenuStore.OpenQuickAccessMenu.bind(
|
||||||
|
Router.WindowStore.GamepadUIMainWindowInstance.MenuStore,
|
||||||
|
),
|
||||||
|
OpenMainMenu: Router.WindowStore?.GamepadUIMainWindowInstance?.MenuStore.OpenMainMenu.bind(
|
||||||
|
Router.WindowStore.GamepadUIMainWindowInstance.MenuStore,
|
||||||
|
),
|
||||||
|
CloseSideMenus: Router.CloseSideMenus.bind(Router),
|
||||||
|
OpenPowerMenu: Router.OpenPowerMenu.bind(Router),
|
||||||
|
} as Navigation;
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ export function findSP(): Window {
|
|||||||
// old (SP as host)
|
// old (SP as host)
|
||||||
if (document.title == 'SP') return window;
|
if (document.title == 'SP') return window;
|
||||||
// new (SP as popup)
|
// new (SP as popup)
|
||||||
return FocusNavController.m_ActiveContext.m_rgGamepadNavigationTrees.find((x: any) => x.m_ID == 'root_1_').Root
|
const context = FocusNavController.m_ActiveContext || FocusNavController.m_LastActiveContext;
|
||||||
|
return context.m_rgGamepadNavigationTrees.find((x: any) => x.m_ID == 'root_1_').Root
|
||||||
.Element.ownerDocument.defaultView;
|
.Element.ownerDocument.defaultView;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user