diff options
| author | AAGaming <aagaming@riseup.net> | 2026-11-21 22:23:03 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-11-21 22:23:03 -0500 |
| commit | 24082fe63cdcdf41993f9e1430d1405152a2c930 (patch) | |
| tree | 59454b25fc5cffcbce82e7947d8e3803952fc5ba /frontend/src/index.ts | |
| parent | ffd103b9c1a4ce5bf305e7c0998eda6e05457dad (diff) | |
| download | decky-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/index.ts')
| -rw-r--r-- | frontend/src/index.ts | 82 |
1 files changed, 56 insertions, 26 deletions
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'); })(); |
