diff options
| author | TrainDoctor <traindoctor@protonmail.com> | 2023-01-15 17:40:47 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-15 17:40:47 -0800 |
| commit | 5fdcc56409a0bc75171df25ca50b6e09ffe7bf3a (patch) | |
| tree | 2e35f9fe6246dca82ac415298af5c2bfe9c879b5 | |
| parent | 915997d1495cc47f60e148252df3e4878a1179a5 (diff) | |
| download | decky-loader-5fdcc56409a0bc75171df25ca50b6e09ffe7bf3a.tar.gz decky-loader-5fdcc56409a0bc75171df25ca50b6e09ffe7bf3a.zip | |
Aa/bump dfl navigation fix jan2023 (#341)v2.4.10-pre1
* fix React DevTools
* bump DFL to fix Navigation
* Bump DFL and add shims
* fix shims not applying due to timing issue
Co-authored-by: AAGaming <aa@mail.catvibers.me>
| -rw-r--r-- | backend/injector.py | 13 | ||||
| -rw-r--r-- | backend/main.py | 9 | ||||
| -rw-r--r-- | backend/utilities.py | 6 | ||||
| -rw-r--r-- | frontend/package.json | 2 | ||||
| -rw-r--r-- | frontend/pnpm-lock.yaml | 8 | ||||
| -rw-r--r-- | frontend/src/index.tsx | 18 |
6 files changed, 41 insertions, 15 deletions
diff --git a/backend/injector.py b/backend/injector.py index f4dfd384..d77de13a 100644 --- a/backend/injector.py +++ b/backend/injector.py @@ -394,9 +394,12 @@ async def get_tab_lambda(test) -> Tab: raise ValueError(f"Tab not found by lambda") return tab +def tab_is_gamepadui(t: Tab) -> bool: + return "https://steamloopback.host/routes/" in t.url and (t.title == "Steam Shared Context presented by Valve™" or t.title == "Steam" or t.title == "SP") + async def get_gamepadui_tab() -> Tab: tabs = await get_tabs() - tab = next((i for i in tabs if ("https://steamloopback.host/routes/" in i.url and (i.title == "Steam Shared Context presented by Valve™" or i.title == "Steam" or i.title == "SP"))), None) + tab = next((i for i in tabs if tab_is_gamepadui(i)), None) if not tab: raise ValueError(f"GamepadUI Tab not found") return tab @@ -405,3 +408,11 @@ async def inject_to_tab(tab_name, js, run_async=False): tab = await get_tab(tab_name) return await tab.evaluate_js(js, run_async) + +async def close_old_tabs(): + tabs = await get_tabs() + for t in tabs: + if not t.title or (t.title != "Steam Shared Context presented by Valve™" and t.title != "Steam" and t.title != "SP"): + logger.debug("Closing tab: " + getattr(t, "title", "Untitled")) + await t.close() + await sleep(0.5)
\ No newline at end of file diff --git a/backend/main.py b/backend/main.py index b99e7df1..44311cf3 100644 --- a/backend/main.py +++ b/backend/main.py @@ -22,7 +22,7 @@ from helpers import (REMOTE_DEBUGGER_UNIT, csrf_middleware, get_csrf_token, get_home_path, get_homebrew_path, get_user, get_user_group, set_user, set_user_group, stop_systemd_unit, start_systemd_unit) -from injector import get_gamepadui_tab, Tab, get_tabs +from injector import get_gamepadui_tab, Tab, get_tabs, close_old_tabs from loader import Loader from settings import SettingsManager from updater import Updater @@ -170,12 +170,7 @@ class PluginManager: try: if first: if await tab.has_global_var("deckyHasLoaded", False): - tabs = await get_tabs() - for t in tabs: - if not t.title or (t.title != "Steam" and t.title != "SP"): - logger.debug("Closing tab: " + getattr(t, "title", "Untitled")) - await t.close() - await sleep(0.5) + await close_old_tabs() await tab.evaluate_js("try{if (window.deckyHasLoaded){setTimeout(() => location.reload(), 100)}else{window.deckyHasLoaded = true;(async()=>{try{while(!window.SP_REACT){await new Promise(r => setTimeout(r, 10))};await import('http://localhost:1337/frontend/index.js')}catch(e){console.error(e)};})();}}catch(e){console.error(e)}", False, False, False) except: logger.info("Failed to inject JavaScript into tab\n" + format_exc()) diff --git a/backend/utilities.py b/backend/utilities.py index 0723402f..88e7d0bf 100644 --- a/backend/utilities.py +++ b/backend/utilities.py @@ -7,7 +7,7 @@ from asyncio import sleep, start_server, gather, open_connection from aiohttp import ClientSession, web from logging import getLogger -from injector import inject_to_tab, get_gamepadui_tab +from injector import inject_to_tab, get_gamepadui_tab, close_old_tabs import helpers import subprocess @@ -251,6 +251,7 @@ class Utilities: self.logger.info("Connected to React DevTools, loading script") tab = await get_gamepadui_tab() # RDT needs to load before React itself to work. + await close_old_tabs() result = await tab.reload_and_evaluate(script) self.logger.info(result) @@ -262,5 +263,6 @@ class Utilities: self.logger.info("Disabling React DevTools") tab = await get_gamepadui_tab() self.rdt_script_id = None - await tab.evaluate_js("SteamClient.User.StartRestart();", False, True, False) + await close_old_tabs() + await tab.evaluate_js("location.reload();", False, True, False) self.logger.info("React DevTools disabled") diff --git a/frontend/package.json b/frontend/package.json index 3e45e49a..d76289aa 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -41,7 +41,7 @@ } }, "dependencies": { - "decky-frontend-lib": "^3.18.4", + "decky-frontend-lib": "^3.18.8", "react-file-icon": "^1.2.0", "react-icons": "^4.4.0", "react-markdown": "^8.0.3", diff --git a/frontend/pnpm-lock.yaml b/frontend/pnpm-lock.yaml index 58fa64ce..721c3a8d 100644 --- a/frontend/pnpm-lock.yaml +++ b/frontend/pnpm-lock.yaml @@ -10,7 +10,7 @@ specifiers: '@types/react-file-icon': ^1.0.1 '@types/react-router': 5.1.18 '@types/webpack': ^5.28.0 - decky-frontend-lib: ^3.18.4 + decky-frontend-lib: ^3.18.8 husky: ^8.0.1 import-sort-style-module: ^6.0.0 inquirer: ^8.2.4 @@ -30,7 +30,7 @@ specifiers: typescript: ^4.7.4 dependencies: - decky-frontend-lib: 3.18.4 + decky-frontend-lib: 3.18.8 react-file-icon: 1.2.0_wcqkhtmu7mswc6yz4uyexck3ty react-icons: 4.4.0_react@16.14.0 react-markdown: 8.0.3_vshvapmxg47tngu7tvrsqpq55u @@ -944,8 +944,8 @@ packages: dependencies: ms: 2.1.2 - /decky-frontend-lib/3.18.4: - resolution: {integrity: sha512-i3TAe3RJtT1TK0rJgW9Ek5jxMWZRCYLDvqHDylGVieUvuyI7c8X+cogz30pP4cqeGOaA1d/MxBEbhlpD3JhVvg==} + /decky-frontend-lib/3.18.8: + resolution: {integrity: sha512-tgN35XgfsAePpmlxdCXnJ/TswmDoP2Dh9Ddl49bHbZMX2GV/H+7jT532Rrs/q8D4xX1LN1qA4alZ8Rr4q61PVg==} dev: false /decode-named-character-reference/1.0.2: diff --git a/frontend/src/index.tsx b/frontend/src/index.tsx index 03010e13..86dd90e1 100644 --- a/frontend/src/index.tsx +++ b/frontend/src/index.tsx @@ -1,3 +1,5 @@ +import { Navigation, Router, sleep } from 'decky-frontend-lib'; + import PluginLoader from './plugin-loader'; import { DeckyUpdater } from './updater'; @@ -15,6 +17,22 @@ declare global { } (async () => { + try { + if (!Router.NavigateToAppProperties || !Router.NavigateToLibraryTab || !Router.NavigateToInvites) { + while (!Navigation.NavigateToAppProperties) await sleep(100); + const shims = { + NavigateToAppProperties: Navigation.NavigateToAppProperties, + NavigateToInvites: Navigation.NavigateToInvites, + NavigateToLibraryTab: Navigation.NavigateToLibraryTab, + }; + Object.assign(Router, shims); + } + } catch (e) { + console.error('[DECKY]: Error initializing Navigation interface shims', e); + } +})(); + +(async () => { window.deckyAuthToken = await fetch('http://127.0.0.1:1337/auth/token').then((r) => r.text()); window.DeckyPluginLoader?.dismountAll(); |
