summaryrefslogtreecommitdiff
path: root/frontend/src
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src')
-rw-r--r--frontend/src/components/Toast.tsx47
-rw-r--r--frontend/src/components/store/Store.tsx8
-rw-r--r--frontend/src/errorboundary-hook.tsx2
-rw-r--r--frontend/src/index.ts82
-rw-r--r--frontend/src/plugin-loader.tsx2
-rw-r--r--frontend/src/router-hook.tsx19
-rw-r--r--frontend/src/tabs-hook.tsx4
-rw-r--r--frontend/src/toaster.tsx5
8 files changed, 96 insertions, 73 deletions
diff --git a/frontend/src/components/Toast.tsx b/frontend/src/components/Toast.tsx
index e86e9337..aa2e665f 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/store/Store.tsx b/frontend/src/components/store/Store.tsx
index cfa83aff..da909fd7 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/errorboundary-hook.tsx b/frontend/src/errorboundary-hook.tsx
index 9dbe9dcd..2bbecc58 100644
--- a/frontend/src/errorboundary-hook.tsx
+++ b/frontend/src/errorboundary-hook.tsx
@@ -26,7 +26,7 @@ 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/index.ts b/frontend/src/index.ts
index 67b30d15..162e8f36 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..49f5734b 100644
--- a/frontend/src/plugin-loader.tsx
+++ b/frontend/src/plugin-loader.tsx
@@ -554,7 +554,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/router-hook.tsx b/frontend/src/router-hook.tsx
index a7b6ec92..bf1198fc 100644
--- a/frontend/src/router-hook.tsx
+++ b/frontend/src/router-hook.tsx
@@ -5,7 +5,7 @@ import {
afterPatch,
findInReactTree,
findInTree,
- findModuleByExport,
+ findVar,
getReactRoot,
sleep,
} from '@decky/ui';
@@ -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) => /routePath:[\w$]+\.match\?\.path./.test(e.toString()))
+ if (!this.Route) {
+ this.error('Failed to find Route component');
}
this.modeChangeRegistration = SteamClient.UI.RegisterForUIModeChanged((mode: EUIMode) => {
diff --git a/frontend/src/tabs-hook.tsx b/frontend/src/tabs-hook.tsx
index ecb60f30..5098834c 100644
--- a/frontend/src/tabs-hook.tsx
+++ b/frontend/src/tabs-hook.tsx
@@ -6,7 +6,7 @@ import {
afterPatch,
createReactTreePatcher,
findInReactTree,
- findModuleByExport,
+ findModuleScopeByVar,
getReactRoot,
} from '@decky/ui';
@@ -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/toaster.tsx
index e5b2d986..572a1bba 100644
--- a/frontend/src/toaster.tsx
+++ b/frontend/src/toaster.tsx
@@ -4,7 +4,7 @@ import {
ErrorBoundary,
Patch,
callOriginal,
- findModuleExport,
+ findVar,
injectFCTrampoline,
replacePatch,
} from '@decky/ui';
@@ -27,7 +27,8 @@ 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) => 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[]) => {