summaryrefslogtreecommitdiff
path: root/frontend/src
diff options
context:
space:
mode:
authorAAGaming <aagaming@riseup.net>2026-11-21 22:23:03 -0500
committerGitHub <noreply@github.com>2026-11-21 22:23:03 -0500
commit24082fe63cdcdf41993f9e1430d1405152a2c930 (patch)
tree59454b25fc5cffcbce82e7947d8e3803952fc5ba /frontend/src
parentffd103b9c1a4ce5bf305e7c0998eda6e05457dad (diff)
downloaddecky-loader-d020af9f7fd305e666db36650e41b40af1c0db8a.tar.gz
decky-loader-d020af9f7fd305e666db36650e41b40af1c0db8a.zip
feat: Support new Steam Betas (only) and Frame (#1019)v4.0.0-pre1
Diffstat (limited to 'frontend/src')
-rw-r--r--frontend/src/components/NotificationBadge.tsx55
-rw-r--r--frontend/src/components/PluginView.tsx40
-rw-r--r--frontend/src/components/QuickAccessVisibleState.tsx17
-rw-r--r--frontend/src/components/Toast.tsx47
-rw-r--r--frontend/src/components/settings/pages/developer/index.tsx33
-rw-r--r--frontend/src/components/settings/pages/general/index.tsx3
-rw-r--r--frontend/src/components/store/Store.tsx8
-rw-r--r--frontend/src/developer.tsx25
-rw-r--r--frontend/src/errorboundary-hook.tsx5
-rw-r--r--frontend/src/hooks/router.tsx (renamed from frontend/src/router-hook.tsx)27
-rw-r--r--frontend/src/hooks/tabs.tsx (renamed from frontend/src/tabs-hook.tsx)8
-rw-r--r--frontend/src/hooks/toaster.tsx (renamed from frontend/src/toaster.tsx)11
-rw-r--r--frontend/src/hooks/vr-dashboard-bar.tsx106
-rw-r--r--frontend/src/index.ts82
-rw-r--r--frontend/src/plugin-loader.tsx58
-rw-r--r--frontend/src/updater.ts1
16 files changed, 379 insertions, 147 deletions
diff --git a/frontend/src/components/NotificationBadge.tsx b/frontend/src/components/NotificationBadge.tsx
index 3c5d8215..1d14d576 100644
--- a/frontend/src/components/NotificationBadge.tsx
+++ b/frontend/src/components/NotificationBadge.tsx
@@ -2,23 +2,52 @@ import { CSSProperties, FunctionComponent } from 'react';
interface NotificationBadgeProps {
show?: boolean;
+ vr?: boolean;
style?: CSSProperties;
}
-const NotificationBadge: FunctionComponent<NotificationBadgeProps> = ({ show, style }) => {
+const NotificationBadge: FunctionComponent<NotificationBadgeProps> = ({ show, style, vr }) => {
return show ? (
- <div
- style={{
- position: 'absolute',
- top: '8px',
- right: '8px',
- height: '10px',
- width: '10px',
- background: 'orange',
- borderRadius: '50%',
- ...style,
- }}
- />
+ vr ? (
+ // whoever made transform:scale completely break absolute positioning goes straight to super turbo hell this took me an hour
+ <div
+ style={{
+ top: 0,
+ left: 0,
+ marginLeft: 'auto',
+ width: 0,
+ height: 0,
+ overflow: 'visible',
+ transform: 'translate(0px, 0px)',
+ }}
+ >
+ <div
+ style={{
+ position: 'fixed',
+ top: '-18px',
+ right: '-6px',
+ width: '10px',
+ height: '10px',
+ background: 'orange',
+ borderRadius: '50%',
+ ...style,
+ }}
+ />
+ </div>
+ ) : (
+ <div
+ style={{
+ position: 'absolute',
+ top: '8px',
+ right: '8px',
+ height: '10px',
+ width: '10px',
+ background: 'orange',
+ borderRadius: '50%',
+ ...style,
+ }}
+ />
+ )
) : null;
};
diff --git a/frontend/src/components/PluginView.tsx b/frontend/src/components/PluginView.tsx
index fbafaf05..27c1f2f1 100644
--- a/frontend/src/components/PluginView.tsx
+++ b/frontend/src/components/PluginView.tsx
@@ -1,4 +1,12 @@
-import { ButtonItem, ErrorBoundary, Focusable, PanelSection, PanelSectionRow } from '@decky/ui';
+import {
+ ButtonItem,
+ ErrorBoundary,
+ Focusable,
+ PanelSection,
+ PanelSectionRow,
+ joinClassNames,
+ vrDashboardClasses,
+} from '@decky/ui';
import { FC, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { FaBan, FaEyeSlash } from 'react-icons/fa';
@@ -8,7 +16,7 @@ import NotificationBadge from './NotificationBadge';
import { useQuickAccessVisible } from './QuickAccessVisibleState';
import TitleView from './TitleView';
-const PluginView: FC = () => {
+const PluginView: FC<{ vr?: boolean }> = ({ vr }) => {
const {
plugins,
disabledPlugins,
@@ -40,20 +48,38 @@ const PluginView: FC = () => {
if (activePlugin) {
return (
- <Focusable onCancelButton={closeActivePlugin}>
+ <Focusable
+ onCancelButton={closeActivePlugin}
+ className={
+ (vr && joinClassNames(vrDashboardClasses.QuickAccessPopupPanel, vrDashboardClasses.BottomFade)) || ''
+ }
+ style={{
+ display: 'flex',
+ flexDirection: 'column',
+ paddingBottom: '20px', // override bottomfade, there is prolly a better way
+ }}
+ >
<TitleView />
- <div style={{ height: '100%', paddingTop: '16px' }}>
+ <div style={{ paddingTop: '16px', overflowY: vr ? 'auto' : undefined }}>
<ErrorBoundary>{(visible || activePlugin.alwaysRender) && activePlugin.content}</ErrorBoundary>
</div>
</Focusable>
);
}
return (
- <>
+ <div
+ className={(vr && joinClassNames(vrDashboardClasses.QuickAccessPopupPanel, vrDashboardClasses.BottomFade)) || ''}
+ style={{
+ display: 'flex',
+ flexDirection: 'column',
+ paddingBottom: '20px', // override bottomfade, there is prolly a better way
+ }}
+ >
<TitleView />
<div
style={{
- paddingTop: '16px',
+ paddingTop: vr ? '16px' : '16px',
+ overflowY: vr ? 'auto' : undefined,
}}
>
<PanelSection>
@@ -92,7 +118,7 @@ const PluginView: FC = () => {
</div>
</PanelSection>
</div>
- </>
+ </div>
);
};
diff --git a/frontend/src/components/QuickAccessVisibleState.tsx b/frontend/src/components/QuickAccessVisibleState.tsx
index f90c24b4..83e45177 100644
--- a/frontend/src/components/QuickAccessVisibleState.tsx
+++ b/frontend/src/components/QuickAccessVisibleState.tsx
@@ -1,16 +1,21 @@
import { FC, PropsWithChildren, createContext, useContext, useState } from 'react';
-const QuickAccessVisibleState = createContext<boolean>(false);
+export const QuickAccessVisibleState = createContext<boolean>(false);
export const useQuickAccessVisible = () => useContext(QuickAccessVisibleState);
-export const QuickAccessVisibleStateProvider: FC<PropsWithChildren<{ tab: any }>> = ({ children, tab }) => {
- const initial = tab.initialVisibility;
+export const QuickAccessVisibleStateProvider: FC<PropsWithChildren<{ tab?: any; initialVal?: boolean }>> = ({
+ children,
+ tab,
+ initialVal,
+}) => {
+ const initial = initialVal || tab?.initialVisibility;
const [visible, setVisible] = useState<boolean>(initial);
// HACK but i can't think of a better way to do this
- tab.qAMVisibilitySetter = (val: boolean) => {
- if (val != visible) setVisible(val);
- };
+ if (tab)
+ tab.qAMVisibilitySetter = (val: boolean) => {
+ if (val != visible) setVisible(val);
+ };
return <QuickAccessVisibleState.Provider value={visible}>{children}</QuickAccessVisibleState.Provider>;
};
diff --git a/frontend/src/components/Toast.tsx b/frontend/src/components/Toast.tsx
index e86e9337..8b6b9d63 100644
--- a/frontend/src/components/Toast.tsx
+++ b/frontend/src/components/Toast.tsx
@@ -1,5 +1,5 @@
import type { ToastData } from '@decky/api';
-import { Focusable, Navigation, findClassModule, joinClassNames } from '@decky/ui';
+import { Focusable, Navigation, joinClassNames, toastClasses } from '@decky/ui';
import { FC, memo } from 'react';
import Logger from '../logger';
@@ -23,7 +23,14 @@ interface ToastRendererProps extends ToastProps {
location: ToastLocation;
}
-const templateClasses = findClassModule((m) => m.ShortTemplate) || {};
+const popupClasses = {
+ ShortTemplate: 'kg8VJS07NZk-',
+ Content: 'vjeKRorxqWY-',
+ Header: 'UWjdKshdhD8-',
+ Icon: 'q9vQBNOskjU-',
+ Title: 'RZ1644uUH-k-',
+ Body: '_5LTIC-a3DVw-',
+};
// These are memoized as they like to randomly rerender
@@ -32,15 +39,15 @@ const GamepadUIPopupToast: FC<Omit<ToastProps, 'newIndicator'>> = memo(({ toast
<div
style={{ '--toast-duration': `${toast.duration}ms` } as React.CSSProperties}
onClick={toast.onClick}
- className={joinClassNames(templateClasses.ShortTemplate, toast.className || '', 'DeckyGamepadUIPopupToast')}
+ className={joinClassNames(popupClasses.ShortTemplate, toast.className || '', 'DeckyGamepadUIPopupToast')}
>
- {toast.logo && <div className={templateClasses.StandardLogoDimensions}>{toast.logo}</div>}
- <div className={joinClassNames(templateClasses.Content, toast.contentClassName || '')}>
- <div className={templateClasses.Header}>
- {toast.icon && <div className={templateClasses.Icon}>{toast.icon}</div>}
- <div className={templateClasses.Title}>{toast.title}</div>
+ {toast.logo && <div className={toastClasses.StandardLogoDimensions}>{toast.logo}</div>}
+ <div className={joinClassNames(popupClasses.Content, toast.contentClassName || '')}>
+ <div className={popupClasses.Header}>
+ {toast.icon && <div className={popupClasses.Icon}>{toast.icon}</div>}
+ <div className={popupClasses.Title}>{toast.title}</div>
</div>
- <div className={templateClasses.Body}>{toast.body}</div>
+ <div className={popupClasses.Body}>{toast.body}</div>
</div>
</div>
);
@@ -55,30 +62,30 @@ const GamepadUIQAMToast: FC<ToastProps> = memo(({ toast, newIndicator }) => {
Navigation.CloseSideMenus();
}}
className={joinClassNames(
- templateClasses.StandardTemplateContainer,
+ toastClasses.StandardTemplateContainer,
toast.className || '',
'DeckyGamepadUIQAMToast',
)}
>
- <div className={templateClasses.StandardTemplate}>
- {toast.logo && <div className={templateClasses.StandardLogoDimensions}>{toast.logo}</div>}
- <div className={joinClassNames(templateClasses.Content, toast.contentClassName || '')}>
- <div className={templateClasses.Header}>
- {toast.icon && <div className={templateClasses.Icon}>{toast.icon}</div>}
- {toast.title && <div className={templateClasses.Title}>{toast.title}</div>}
+ <div className={toastClasses.StandardTemplate}>
+ {toast.logo && <div className={toastClasses.StandardLogoDimensions}>{toast.logo}</div>}
+ <div className={joinClassNames(toastClasses.Content, toast.contentClassName || '')}>
+ <div className={toastClasses.Header}>
+ {toast.icon && <div className={toastClasses.Icon}>{toast.icon}</div>}
+ {toast.title && <div className={toastClasses.Title}>{toast.title}</div>}
{/* timestamp should always be defined by toaster */}
{/* TODO check how valve does this */}
{toast.timestamp && (
- <div className={templateClasses.Timestamp}>
+ <div className={toastClasses.Timestamp}>
{toast.timestamp.toLocaleTimeString(undefined, { timeStyle: 'short' })}
</div>
)}
</div>
- {toast.body && <div className={templateClasses.StandardNotificationDescription}>{toast.body}</div>}
- {toast.subtext && <div className={templateClasses.StandardNotificationSubText}>{toast.subtext}</div>}
+ {toast.body && <div className={toastClasses.StandardNotificationDescription}>{toast.body}</div>}
+ {toast.subtext && <div className={toastClasses.StandardNotificationSubText}>{toast.subtext}</div>}
</div>
{newIndicator && (
- <div className={templateClasses.NewIndicator}>
+ <div className={toastClasses.NewIndicator}>
<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="0 0 50 50" fill="none">
<circle fill="currentColor" cx="25" cy="25" r="25"></circle>
</svg>
diff --git a/frontend/src/components/settings/pages/developer/index.tsx b/frontend/src/components/settings/pages/developer/index.tsx
index 17187675..b6a337f0 100644
--- a/frontend/src/components/settings/pages/developer/index.tsx
+++ b/frontend/src/components/settings/pages/developer/index.tsx
@@ -9,7 +9,7 @@ import {
Toggle,
showModal,
} from '@decky/ui';
-import { useRef, useState } from 'react';
+import { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { FaFileArchive, FaLink, FaReact, FaSteamSymbol, FaTerminal } from 'react-icons/fa';
@@ -49,7 +49,6 @@ export default function DeveloperSettings() {
const [acceptedWarning, setAcceptedWarning] = useSetting<boolean>('developer.warn.third_party', false);
const waitTime = acceptedWarning ? 0 : 5;
const [pluginURL, setPluginURL] = useState('');
- const textRef = useRef<HTMLDivElement>(null);
const { t } = useTranslation();
return (
@@ -82,13 +81,6 @@ export default function DeveloperSettings() {
</Field>
<Field
label={t('SettingsDeveloperIndex.third_party_plugins.label_url')}
- description={
- <TextField
- label={t('SettingsDeveloperIndex.third_party_plugins.label_desc')}
- value={pluginURL}
- onChange={(e) => setPluginURL(e?.target.value)}
- />
- }
icon={<FaLink style={{ display: 'block' }} />}
>
<DialogButton
@@ -114,6 +106,11 @@ export default function DeveloperSettings() {
{t('SettingsDeveloperIndex.third_party_plugins.button_install')}
</DialogButton>
</Field>
+ <TextField
+ label={t('SettingsDeveloperIndex.third_party_plugins.label_desc')}
+ value={pluginURL}
+ onChange={(e) => setPluginURL(e?.target.value)}
+ />
</DialogControlsSection>
<DialogControlsSection>
<DialogControlsSectionHeader>{t('SettingsDeveloperIndex.header')}</DialogControlsSectionHeader>
@@ -160,18 +157,7 @@ export default function DeveloperSettings() {
<Field
label={t('SettingsDeveloperIndex.react_devtools.label')}
description={
- <>
- <span style={{ whiteSpace: 'pre-line' }}>{t('SettingsDeveloperIndex.react_devtools.desc')}</span>
- <br />
- <br />
- <div ref={textRef}>
- <TextField
- label={t('SettingsDeveloperIndex.react_devtools.ip_label')}
- value={reactDevtoolsIP}
- onChange={(e) => setReactDevtoolsIP(e?.target.value)}
- />
- </div>
- </>
+ <span style={{ whiteSpace: 'pre-line' }}>{t('SettingsDeveloperIndex.react_devtools.desc')}</span>
}
icon={<FaReact style={{ display: 'block' }} />}
>
@@ -184,6 +170,11 @@ export default function DeveloperSettings() {
}}
/>
</Field>
+ <TextField
+ label={t('SettingsDeveloperIndex.react_devtools.ip_label')}
+ value={reactDevtoolsIP}
+ onChange={(e) => setReactDevtoolsIP(e?.target.value)}
+ />
</DialogControlsSection>
</DialogBody>
);
diff --git a/frontend/src/components/settings/pages/general/index.tsx b/frontend/src/components/settings/pages/general/index.tsx
index 401da1d2..215d392c 100644
--- a/frontend/src/components/settings/pages/general/index.tsx
+++ b/frontend/src/components/settings/pages/general/index.tsx
@@ -58,7 +58,8 @@ export default function GeneralSettings({
<DialogControlsSectionHeader>{t('SettingsGeneralIndex.about.header')}</DialogControlsSectionHeader>
<Field label={t('SettingsGeneralIndex.about.decky_version')} focusable={true}>
<div style={{ color: 'var(--gpSystemLighterGrey)' }}>
- {versionInfo?.current} ({versionInfo?.repo}#{versionInfo?.gitBranch})
+ {versionInfo?.current} ({versionInfo?.repo}#{versionInfo?.gitBranch}
+ {versionInfo?.gitPR ? ` (#${versionInfo.gitPR})` : ''})
</div>
</Field>
</DialogControlsSection>
diff --git a/frontend/src/components/store/Store.tsx b/frontend/src/components/store/Store.tsx
index cfa83aff..e66899be 100644
--- a/frontend/src/components/store/Store.tsx
+++ b/frontend/src/components/store/Store.tsx
@@ -7,7 +7,7 @@ import {
SteamSpinner,
Tabs,
TextField,
- findModule,
+ tabsClasses,
} from '@decky/ui';
import { Dispatch, FC, SetStateAction, useEffect, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
@@ -32,10 +32,6 @@ const logger = new Logger('Store');
const StorePage: FC<{}> = () => {
const [currentTabRoute, setCurrentTabRoute] = useState<string>('browse');
const [pluginCount, setPluginCount] = useState<number | null>(null);
- const { TabCount } = findModule((m) => {
- if (m?.TabCount && m?.TabTitle) return true;
- return false;
- });
const { t } = useTranslation();
@@ -58,7 +54,7 @@ const StorePage: FC<{}> = () => {
title: t('Store.store_tabs.title'),
content: <BrowseTab setPluginCount={setPluginCount} />,
id: 'browse',
- renderTabAddon: () => <span className={TabCount}>{pluginCount}</span>,
+ renderTabAddon: () => <span className={tabsClasses.TabCount}>{pluginCount}</span>,
},
{
title: t('Store.store_tabs.about'),
diff --git a/frontend/src/developer.tsx b/frontend/src/developer.tsx
index 67d9c4b8..6e1b9599 100644
--- a/frontend/src/developer.tsx
+++ b/frontend/src/developer.tsx
@@ -30,17 +30,18 @@ export async function setShowValveInternal(show: boolean) {
}
}
-export async function setShouldConnectToReactDevTools(enable: boolean) {
- DeckyPluginLoader.toaster.toast({
- title: enable ? (
- <TranslationHelper transClass={TranslationClass.DEVELOPER} transText={'enabling'} />
- ) : (
- <TranslationHelper transClass={TranslationClass.DEVELOPER} transText={'disabling'} />
- ),
- body: <TranslationHelper transClass={TranslationClass.DEVELOPER} transText={'5secreload'} />,
- icon: <FaReact />,
- });
- await sleep(5000);
+export async function setShouldConnectToReactDevTools(enable: boolean, skipWait?: boolean) {
+ skipWait ||
+ DeckyPluginLoader.toaster.toast({
+ title: enable ? (
+ <TranslationHelper transClass={TranslationClass.DEVELOPER} transText={'enabling'} />
+ ) : (
+ <TranslationHelper transClass={TranslationClass.DEVELOPER} transText={'disabling'} />
+ ),
+ body: <TranslationHelper transClass={TranslationClass.DEVELOPER} transText={'5secreload'} />,
+ icon: <FaReact />,
+ });
+ skipWait || (await sleep(5000));
return enable ? DeckyBackend.call('utilities/enable_rdt') : DeckyBackend.call('utilities/disable_rdt');
}
@@ -51,5 +52,5 @@ export async function startup() {
if (isValveInternalEnabled) setShowValveInternal(isValveInternalEnabled);
if ((isRDTEnabled && !window.deckyHasConnectedRDT) || (!isRDTEnabled && window.deckyHasConnectedRDT))
- setShouldConnectToReactDevTools(isRDTEnabled);
+ setShouldConnectToReactDevTools(isRDTEnabled, true);
}
diff --git a/frontend/src/errorboundary-hook.tsx b/frontend/src/errorboundary-hook.tsx
index 9dbe9dcd..0c98c6ff 100644
--- a/frontend/src/errorboundary-hook.tsx
+++ b/frontend/src/errorboundary-hook.tsx
@@ -26,7 +26,10 @@ class ErrorBoundaryHook extends Logger {
// valve writes only the sanest of code
const exp = /^\(\)=>\([\w$]+\|\|(?:[\w$]+\(|\([\w$]+=)new [\w$]+\),[\w$]+\)$/;
const initErrorReportingStore = findModuleExport(
- (e) => typeof e == 'function' && e?.toString && exp.test(e.toString()),
+ (e) =>
+ typeof e == 'function' &&
+ e?.toString &&
+ (exp.test(e.toString()) || e.toString() == '()=>(store||=new CErrorReportingStore,store)'),
);
if (!initErrorReportingStore) {
diff --git a/frontend/src/router-hook.tsx b/frontend/src/hooks/router.tsx
index a7b6ec92..95fd8eeb 100644
--- a/frontend/src/router-hook.tsx
+++ b/frontend/src/hooks/router.tsx
@@ -5,7 +5,7 @@ import {
afterPatch,
findInReactTree,
findInTree,
- findModuleByExport,
+ findVar,
getReactRoot,
sleep,
} from '@decky/ui';
@@ -16,15 +16,15 @@ import {
DeckyGlobalComponentsState,
DeckyGlobalComponentsStateContextProvider,
useDeckyGlobalComponentsState,
-} from './components/DeckyGlobalComponentsState';
+} from '../components/DeckyGlobalComponentsState';
import {
DeckyRouterState,
DeckyRouterStateContextProvider,
RoutePatch,
RouterEntry,
useDeckyRouterState,
-} from './components/DeckyRouterState';
-import Logger from './logger';
+} from '../components/DeckyRouterState';
+import Logger from '../logger';
declare global {
interface Window {
@@ -56,20 +56,9 @@ class RouterHook extends Logger {
window.__ROUTER_HOOK_INSTANCE?.deinit?.();
window.__ROUTER_HOOK_INSTANCE = this;
- const reactRouterStackModule = findModuleByExport((e) => typeof e == 'string' && e == 'router-backstack', 20);
- if (reactRouterStackModule) {
- this.Route =
- Object.values(reactRouterStackModule).find(
- (e) => typeof e == 'function' && /routePath:[\w$]+\.match\?\.path./.test(e.toString()),
- ) ||
- Object.values(reactRouterStackModule).find(
- (e) => typeof e == 'function' && /routePath:null===\(.=.\.match\)/.test(e.toString()),
- );
- if (!this.Route) {
- this.error('Failed to find Route component');
- }
- } else {
- this.error('Failed to find router stack module');
+ this.Route = findVar((e) => typeof e == 'function' && /routePath:[\w$]+\.match\?\.path./.test(e.toString()));
+ if (!this.Route) {
+ this.error('Failed to find Route component');
}
this.modeChangeRegistration = SteamClient.UI.RegisterForUIModeChanged((mode: EUIMode) => {
@@ -83,7 +72,7 @@ class RouterHook extends Logger {
this.patchGamepadRouter();
break;
// Not fully implemented yet
- // case UIMode.Desktop:
+ // case EUIMode.Desktop:
// this.debug("Patching desktop router");
// this.patchDesktopRouter();
// break;
diff --git a/frontend/src/tabs-hook.tsx b/frontend/src/hooks/tabs.tsx
index ecb60f30..35f05472 100644
--- a/frontend/src/tabs-hook.tsx
+++ b/frontend/src/hooks/tabs.tsx
@@ -6,12 +6,12 @@ import {
afterPatch,
createReactTreePatcher,
findInReactTree,
- findModuleByExport,
+ findModuleScopeByVar,
getReactRoot,
} from '@decky/ui';
-import { QuickAccessVisibleStateProvider } from './components/QuickAccessVisibleState';
-import Logger from './logger';
+import { QuickAccessVisibleStateProvider } from '../components/QuickAccessVisibleState';
+import Logger from '../logger';
declare global {
interface Window {
@@ -41,7 +41,7 @@ class TabsHook extends Logger {
}
init() {
- const qamModule = findModuleByExport((e) => e?.type?.toString?.()?.includes('QuickAccessMenuBrowserView'));
+ const qamModule = findModuleScopeByVar((e) => e?.type?.toString?.()?.includes('QuickAccessMenuBrowserView'));
const qamBrowserViewRenderer = Object.values(qamModule).find((e: any) =>
e?.type?.toString?.()?.includes('QuickAccessMenuBrowserView'),
);
diff --git a/frontend/src/toaster.tsx b/frontend/src/hooks/toaster.tsx
index e5b2d986..cc604d0f 100644
--- a/frontend/src/toaster.tsx
+++ b/frontend/src/hooks/toaster.tsx
@@ -4,13 +4,13 @@ import {
ErrorBoundary,
Patch,
callOriginal,
- findModuleExport,
+ findVar,
injectFCTrampoline,
replacePatch,
} from '@decky/ui';
-import Toast from './components/Toast';
-import Logger from './logger';
+import Toast from '../components/Toast';
+import Logger from '../logger';
declare global {
interface Window {
@@ -27,7 +27,10 @@ class Toaster extends Logger {
window.__TOASTER_INSTANCE?.deinit?.();
window.__TOASTER_INSTANCE = this;
- const ValveToastRenderer = findModuleExport((e) => e?.toString?.()?.includes(`controller:"notification",method:`));
+ // TODO regex?
+ const ValveToastRenderer = findVar(
+ (e) => typeof e == 'function' && e?.toString?.()?.includes(`controller:\`notification\`,method:`),
+ );
// TODO find a way to undo this if possible?
const patchedRenderer = injectFCTrampoline(ValveToastRenderer);
this.toastPatch = replacePatch(patchedRenderer, 'component', (args: any[]) => {
diff --git a/frontend/src/hooks/vr-dashboard-bar.tsx b/frontend/src/hooks/vr-dashboard-bar.tsx
new file mode 100644
index 00000000..3fe1ad73
--- /dev/null
+++ b/frontend/src/hooks/vr-dashboard-bar.tsx
@@ -0,0 +1,106 @@
+// Hook the SteamVR Hotbar
+import { ErrorBoundary, Patch, afterPatch, findInReactTree, findVar, getReactRoot } from '@decky/ui';
+import { ReactNode, createElement } from 'react';
+
+import Logger from '../logger';
+
+declare global {
+ interface Window {
+ __VR_DASHBAORD_BAR_HOOK_INSTANCE: any;
+ }
+}
+
+// TODO kinda dumb
+enum VRDashboardBarButtonID {
+ Decky = 999,
+}
+
+export interface VRDashboardBarButton {
+ id: VRDashboardBarButtonID | number;
+ active?: boolean;
+ children?: ReactNode;
+ tooltip?: ReactNode;
+ popupContents?: ReactNode;
+ onActivate?: () => void;
+ refBarPopupHandle?: any; // TODO idk
+ onPopupVisibilityChanged?: (visible: boolean) => void;
+}
+
+class VRDashboardBarHook extends Logger {
+ rightSideButtons: VRDashboardBarButton[] = [];
+ private rendererdRightSideButtons: ReactNode[] = [];
+ private barPatch?: Patch;
+ private barButton?: any;
+
+ constructor() {
+ super('VRDashboardBarHook');
+
+ this.log('Initialized');
+ window.__VR_DASHBAORD_BAR_HOOK_INSTANCE?.deinit?.();
+ window.__VR_DASHBAORD_BAR_HOOK_INSTANCE = this;
+ }
+
+ init() {
+ this.barButton = findVar((e) => e?.render?.toString()?.includes('VRDashboardBarSmallButtonActive'));
+ const barComponent = findVar((e) => e?.type?.toString()?.includes('vrLocation==`dashboard-bar`'));
+
+ this.barPatch = afterPatch(barComponent, 'type', (_, ret) => {
+ const nodes = findInReactTree(ret, (x) => x?.length > 6);
+ if (!window?.securitystore?.IsLockScreenActive?.()) nodes.splice(4, 0, this.rendererdRightSideButtons);
+ return ret;
+ });
+
+ // Patch already rendered bar
+ // THIS DOES NOT WORK so frame needs a lockscreen for now :/
+ const root = getReactRoot(document.getElementById('root') as any);
+ const barNode =
+ root &&
+ findInReactTree(
+ root,
+ (n: any) => n.elementType == barComponent || (barComponent != null && n.elementType == barComponent),
+ ); // need elementType, because case where type is actually mobx wrapper
+ if (barNode) {
+ // Only affects this fiber node so we don't need to unpatch here
+ barNode.type = barNode.elementType.type;
+ if (barNode?.alternate) {
+ barNode.alternate.type = barNode.type;
+ }
+ }
+ }
+
+ deinit() {
+ this.barPatch?.unpatch();
+ }
+
+ addRightSideButton(button: VRDashboardBarButton) {
+ this.debug('Adding RSB', button.id, 'to render array');
+ this.rightSideButtons.push(button);
+ this.renderRightSideButtons();
+ }
+
+ removeRightSideButton(id: number) {
+ this.debug('Removing RSB', id);
+ this.rightSideButtons = this.rightSideButtons.filter((button) => button.id !== id);
+ this.renderRightSideButtons();
+ }
+
+ renderRightSideButtons() {
+ const arr = [];
+ for (const button of this.rightSideButtons) {
+ arr.push(
+ createElement(this.barButton, {
+ active: button.active,
+ children: <ErrorBoundary>{button.children}</ErrorBoundary>,
+ tooltip: button.tooltip,
+ popupContents: <ErrorBoundary>{button.popupContents}</ErrorBoundary>,
+ onActivate: button.onActivate,
+ refBarPopupHandle: button.refBarPopupHandle,
+ onPopupVisibilityChanged: button.onPopupVisibilityChanged,
+ }),
+ );
+ }
+ this.rendererdRightSideButtons = arr;
+ }
+}
+
+export default VRDashboardBarHook;
diff --git a/frontend/src/index.ts b/frontend/src/index.ts
index 67b30d15..f21c4802 100644
--- a/frontend/src/index.ts
+++ b/frontend/src/index.ts
@@ -1,5 +1,12 @@
// Sets up DFL, then loads start.ts which starts up the loader
+interface Window {
+ _deckyModuleResolverInternals: {
+ scopes: Map<string, Record<string, any>>;
+ scopedObjects: Map<number, any>;
+ };
+}
+
interface SteamAppInitialization {
BFinishedInitBeforeLogin?: () => boolean;
BFinishedInitStageOne?: () => boolean;
@@ -13,42 +20,65 @@ const isSteamAppInitialized = () => {
(async () => {
console.debug('[Decky:Boot] Frontend init');
+ console.debug('[Decky:Boot] Authenticating with Decky backend...');
+ window.deckyAuthToken = await fetch('http://127.0.0.1:1337/auth/token').then((r) => r.text());
+ console.debug('[Decky:Boot] Connecting to Decky backend...');
+ const ws = (window.DeckyBackend = new (await import('./wsrouter')).WSRouter());
+ await ws.connect();
+
console.time('[Decky:Boot] Waiting for SteamApp init stage 1 to finish...');
while (!isSteamAppInitialized()) {
await new Promise((r) => setTimeout(r, 0)); // Can't use DFL sleep here.
}
- console.timeEnd('[Decky:Boot] Waiting for SteamApp init stage 1 to finish...');
-
- if (!window.SP_REACT) {
- console.debug('[Decky:Boot] Setting up Webpack & React globals...');
- // deliberate partial import
- const DFLWebpack = await import('@decky/ui/dist/webpack');
- window.SP_REACT = DFLWebpack.findModule((m) => m.Component && m.PureComponent && m.useLayoutEffect);
- window.SP_REACTDOM =
- DFLWebpack.findModule((m) => m.createPortal && m.createRoot) ||
- DFLWebpack.findModule((m) => m.createPortal && m.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE);
-
- console.debug('[Decky:Boot] Setting up JSX internals...');
- const jsxModule = DFLWebpack.findModule((m) => (m.jsx && m.jsxs) || (m.jsx && Object.keys(m).length == 1));
- if (jsxModule.jsxs) {
- window.SP_JSX = jsxModule;
- } else {
- window.SP_JSX = {
- jsx: jsxModule.jsx,
- jsxs: jsxModule.jsx,
- Fragment: window.SP_REACT.Fragment,
- };
+ console.debug('[Decky:Boot] Setting up Module System & React globals...');
+
+ let moduleId = 0;
+ const int = (window._deckyModuleResolverInternals = {
+ scopes: new Map(),
+ scopedObjects: new Map(),
+ });
+ const resolveThroughBackend = ws.callable<[objectKey: number]>('instrumentation/resolve_scope');
+ async function resolveModuleScope(objectFromScope: any, moduleForDebug?: string) {
+ let ret;
+ const id = ++moduleId;
+ try {
+ int.scopedObjects.set(id, objectFromScope);
+ await resolveThroughBackend(id);
+ ret = int.scopes.get(id);
+ } catch (e) {
+ console.debug(`[Decky:Instrumentation] Scope resolution failed for module ${moduleForDebug}`, e);
+ } finally {
+ int.scopes.delete(id);
+ int.scopedObjects.delete(id);
}
+ return ret;
+ }
+
+ // deliberate partial import
+ const DFLModules = await import('@decky/ui/dist/module-system');
+ await DFLModules.initModules(resolveModuleScope);
+ // @ts-ignore
+ window.DFLModules = DFLModules;
+ window.SP_REACT = DFLModules.findModule((m) => m.Component && m.PureComponent && m.useLayoutEffect);
+ window.SP_REACTDOM =
+ DFLModules.findModule((m) => m.createPortal && m.createRoot) ||
+ DFLModules.findModule((m) => m.createPortal && m.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE);
+
+ console.debug('[Decky:Boot] Setting up JSX internals...');
+ const jsxModule = DFLModules.findModule((m) => (m.jsx && m.jsxs) || (m.jsx && Object.keys(m).length == 1));
+ if (jsxModule?.jsxs) {
+ window.SP_JSX = jsxModule;
+ } else {
+ window.SP_JSX = {
+ jsx: jsxModule.jsx,
+ jsxs: jsxModule.jsx,
+ Fragment: window.SP_REACT.Fragment,
+ };
}
console.debug('[Decky:Boot] Setting up @decky/ui...');
window.DFL = await import('@decky/ui');
- console.debug('[Decky:Boot] Authenticating with Decky backend...');
- window.deckyAuthToken = await fetch('http://127.0.0.1:1337/auth/token').then((r) => r.text());
- console.debug('[Decky:Boot] Connecting to Decky backend...');
- window.DeckyBackend = new (await import('./wsrouter')).WSRouter();
- await DeckyBackend.connect();
console.debug('[Decky:Boot] Starting Decky!');
await import('./start');
})();
diff --git a/frontend/src/plugin-loader.tsx b/frontend/src/plugin-loader.tsx
index 81b96dcc..b16e1bb1 100644
--- a/frontend/src/plugin-loader.tsx
+++ b/frontend/src/plugin-loader.tsx
@@ -7,9 +7,11 @@ import {
PanelSectionRow,
QuickAccessTab,
findSP,
+ joinClassNames,
quickAccessMenuClasses,
showModal,
sleep,
+ vrDashboardClasses,
} from '@decky/ui';
import { FC, lazy } from 'react';
import { FaDownload, FaExclamationCircle, FaExclamationTriangle, FaPlug } from 'react-icons/fa';
@@ -24,19 +26,20 @@ import PluginInstallModal from './components/modals/PluginInstallModal';
import PluginUninstallModal from './components/modals/PluginUninstallModal';
import NotificationBadge from './components/NotificationBadge';
import PluginView from './components/PluginView';
-import { useQuickAccessVisible } from './components/QuickAccessVisibleState';
+import { QuickAccessVisibleStateProvider, useQuickAccessVisible } from './components/QuickAccessVisibleState';
import WithSuspense from './components/WithSuspense';
import ErrorBoundaryHook from './errorboundary-hook';
import { FrozenPluginService } from './frozen-plugins-service';
import { HiddenPluginsService } from './hidden-plugins-service';
+import RouterHook from './hooks/router';
+import TabsHook from './hooks/tabs';
+import Toaster from './hooks/toaster';
+import VRDashboardBarHook from './hooks/vr-dashboard-bar';
import Logger from './logger';
import { NotificationService } from './notification-service';
import { DisabledPlugin, InstallType, Plugin, PluginLoadType } from './plugin';
-import RouterHook from './router-hook';
import { deinitSteamFixes, initSteamFixes } from './steamfixes';
import { PluginUpdateMapping, checkForPluginUpdates } from './store';
-import TabsHook from './tabs-hook';
-import Toaster from './toaster';
import { getVersionInfo } from './updater';
import { getPluginDisplayName } from './utils/pluginHelpers';
import { getSetting, setSetting } from './utils/settings';
@@ -70,6 +73,7 @@ class PluginLoader extends Logger {
private plugins: Plugin[] = [];
public errorBoundaryHook: ErrorBoundaryHook = new ErrorBoundaryHook();
private tabsHook: TabsHook = new TabsHook();
+ private vrDashboardBarHook: VRDashboardBarHook = new VRDashboardBarHook(); // TODO public? unsure
public routerHook: RouterHook = new RouterHook();
public toaster: Toaster = new Toaster();
private deckyState: DeckyState = new DeckyState();
@@ -105,10 +109,11 @@ class PluginLoader extends Logger {
DeckyBackend.addEventListener(`loader/plugin_event`, this.pluginEventListener);
this.tabsHook.init();
+ this.vrDashboardBarHook.init();
- const TabBadge = () => {
+ const TabBadge = ({ vr }: { vr?: boolean }) => {
const { updates, hasLoaderUpdate } = useDeckyState();
- return <NotificationBadge show={(updates && updates.size > 0) || hasLoaderUpdate} />;
+ return <NotificationBadge vr={vr} show={(updates && updates.size > 0) || hasLoaderUpdate} />;
};
this.tabsHook.add({
@@ -127,6 +132,44 @@ class PluginLoader extends Logger {
),
});
+ this.vrDashboardBarHook.addRightSideButton({
+ id: 999,
+ tooltip: 'Decky',
+ popupContents: (
+ <QuickAccessVisibleStateProvider initialVal={true}>
+ {' '}
+ {/*for compat only, these don't render when inactive*/}
+ <DeckyStateContextProvider deckyState={this.deckyState}>
+ <div className={joinClassNames(vrDashboardClasses.DashboardBarPopupContents)}>
+ <PluginView vr={true} />
+ </div>
+ </DeckyStateContextProvider>
+ </QuickAccessVisibleStateProvider>
+ ),
+ children: (
+ <DeckyStateContextProvider deckyState={this.deckyState}>
+ <div
+ style={{
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ }}
+ className={'deckyVRIcon'}
+ >
+ <FaPlug style={{ marginRight: '0px' }} />
+ <TabBadge vr={true} />
+ <style>
+ {`
+ div:has(>.deckyVRIcon) {
+ overflow: visible !important;
+ }
+ `}
+ </style>
+ </div>
+ </DeckyStateContextProvider>
+ ),
+ });
+
this.routerHook.addRoute('/decky/store', () => (
<DeckyStateContextProvider deckyState={this.deckyState}>
<WithSuspense route={true}>
@@ -399,6 +442,7 @@ class PluginLoader extends Logger {
deinitFilepickerPatches();
this.routerHook.deinit();
this.tabsHook.deinit();
+ this.vrDashboardBarHook.deinit();
this.toaster.deinit();
this.errorBoundaryHook.deinit();
}
@@ -554,7 +598,7 @@ class PluginLoader extends Logger {
</pre>
</PanelSectionRow>
<PanelSectionRow>
- <div className={quickAccessMenuClasses.Text}>
+ <div>
<TranslationHelper
transClass={TranslationClass.PLUGIN_LOADER}
transText="plugin_error_uninstall"
diff --git a/frontend/src/updater.ts b/frontend/src/updater.ts
index c4b9034f..ba81ffb8 100644
--- a/frontend/src/updater.ts
+++ b/frontend/src/updater.ts
@@ -20,6 +20,7 @@ export interface VerInfo {
current: string;
repo: string;
gitBranch: string;
+ gitPR: string | null;
remote: RemoteVerInfo | null;
all: RemoteVerInfo[] | null;
updatable: boolean;