mirror of
https://github.com/SteamDeckHomebrew/decky-loader.git
synced 2026-06-17 08:47:49 +00:00
Aa/bump dfl navigation fix jan2023 (#341)
* 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>
This commit is contained in:
+12
-1
@@ -394,9 +394,12 @@ async def get_tab_lambda(test) -> Tab:
|
|||||||
raise ValueError(f"Tab not found by lambda")
|
raise ValueError(f"Tab not found by lambda")
|
||||||
return tab
|
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:
|
async def get_gamepadui_tab() -> Tab:
|
||||||
tabs = await get_tabs()
|
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:
|
if not tab:
|
||||||
raise ValueError(f"GamepadUI Tab not found")
|
raise ValueError(f"GamepadUI Tab not found")
|
||||||
return tab
|
return tab
|
||||||
@@ -405,3 +408,11 @@ async def inject_to_tab(tab_name, js, run_async=False):
|
|||||||
tab = await get_tab(tab_name)
|
tab = await get_tab(tab_name)
|
||||||
|
|
||||||
return await tab.evaluate_js(js, run_async)
|
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)
|
||||||
+2
-7
@@ -22,7 +22,7 @@ from helpers import (REMOTE_DEBUGGER_UNIT, csrf_middleware, get_csrf_token,
|
|||||||
get_home_path, get_homebrew_path, get_user,
|
get_home_path, get_homebrew_path, get_user,
|
||||||
get_user_group, set_user, set_user_group,
|
get_user_group, set_user, set_user_group,
|
||||||
stop_systemd_unit, start_systemd_unit)
|
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 loader import Loader
|
||||||
from settings import SettingsManager
|
from settings import SettingsManager
|
||||||
from updater import Updater
|
from updater import Updater
|
||||||
@@ -170,12 +170,7 @@ class PluginManager:
|
|||||||
try:
|
try:
|
||||||
if first:
|
if first:
|
||||||
if await tab.has_global_var("deckyHasLoaded", False):
|
if await tab.has_global_var("deckyHasLoaded", False):
|
||||||
tabs = await get_tabs()
|
await close_old_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 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)
|
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:
|
except:
|
||||||
logger.info("Failed to inject JavaScript into tab\n" + format_exc())
|
logger.info("Failed to inject JavaScript into tab\n" + format_exc())
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ from asyncio import sleep, start_server, gather, open_connection
|
|||||||
from aiohttp import ClientSession, web
|
from aiohttp import ClientSession, web
|
||||||
|
|
||||||
from logging import getLogger
|
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 helpers
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
@@ -251,6 +251,7 @@ class Utilities:
|
|||||||
self.logger.info("Connected to React DevTools, loading script")
|
self.logger.info("Connected to React DevTools, loading script")
|
||||||
tab = await get_gamepadui_tab()
|
tab = await get_gamepadui_tab()
|
||||||
# RDT needs to load before React itself to work.
|
# RDT needs to load before React itself to work.
|
||||||
|
await close_old_tabs()
|
||||||
result = await tab.reload_and_evaluate(script)
|
result = await tab.reload_and_evaluate(script)
|
||||||
self.logger.info(result)
|
self.logger.info(result)
|
||||||
|
|
||||||
@@ -262,5 +263,6 @@ class Utilities:
|
|||||||
self.logger.info("Disabling React DevTools")
|
self.logger.info("Disabling React DevTools")
|
||||||
tab = await get_gamepadui_tab()
|
tab = await get_gamepadui_tab()
|
||||||
self.rdt_script_id = None
|
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")
|
self.logger.info("React DevTools disabled")
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"decky-frontend-lib": "^3.18.4",
|
"decky-frontend-lib": "^3.18.8",
|
||||||
"react-file-icon": "^1.2.0",
|
"react-file-icon": "^1.2.0",
|
||||||
"react-icons": "^4.4.0",
|
"react-icons": "^4.4.0",
|
||||||
"react-markdown": "^8.0.3",
|
"react-markdown": "^8.0.3",
|
||||||
|
|||||||
Generated
+4
-4
@@ -10,7 +10,7 @@ specifiers:
|
|||||||
'@types/react-file-icon': ^1.0.1
|
'@types/react-file-icon': ^1.0.1
|
||||||
'@types/react-router': 5.1.18
|
'@types/react-router': 5.1.18
|
||||||
'@types/webpack': ^5.28.0
|
'@types/webpack': ^5.28.0
|
||||||
decky-frontend-lib: ^3.18.4
|
decky-frontend-lib: ^3.18.8
|
||||||
husky: ^8.0.1
|
husky: ^8.0.1
|
||||||
import-sort-style-module: ^6.0.0
|
import-sort-style-module: ^6.0.0
|
||||||
inquirer: ^8.2.4
|
inquirer: ^8.2.4
|
||||||
@@ -30,7 +30,7 @@ specifiers:
|
|||||||
typescript: ^4.7.4
|
typescript: ^4.7.4
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
decky-frontend-lib: 3.18.4
|
decky-frontend-lib: 3.18.8
|
||||||
react-file-icon: 1.2.0_wcqkhtmu7mswc6yz4uyexck3ty
|
react-file-icon: 1.2.0_wcqkhtmu7mswc6yz4uyexck3ty
|
||||||
react-icons: 4.4.0_react@16.14.0
|
react-icons: 4.4.0_react@16.14.0
|
||||||
react-markdown: 8.0.3_vshvapmxg47tngu7tvrsqpq55u
|
react-markdown: 8.0.3_vshvapmxg47tngu7tvrsqpq55u
|
||||||
@@ -944,8 +944,8 @@ packages:
|
|||||||
dependencies:
|
dependencies:
|
||||||
ms: 2.1.2
|
ms: 2.1.2
|
||||||
|
|
||||||
/decky-frontend-lib/3.18.4:
|
/decky-frontend-lib/3.18.8:
|
||||||
resolution: {integrity: sha512-i3TAe3RJtT1TK0rJgW9Ek5jxMWZRCYLDvqHDylGVieUvuyI7c8X+cogz30pP4cqeGOaA1d/MxBEbhlpD3JhVvg==}
|
resolution: {integrity: sha512-tgN35XgfsAePpmlxdCXnJ/TswmDoP2Dh9Ddl49bHbZMX2GV/H+7jT532Rrs/q8D4xX1LN1qA4alZ8Rr4q61PVg==}
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/decode-named-character-reference/1.0.2:
|
/decode-named-character-reference/1.0.2:
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { Navigation, Router, sleep } from 'decky-frontend-lib';
|
||||||
|
|
||||||
import PluginLoader from './plugin-loader';
|
import PluginLoader from './plugin-loader';
|
||||||
import { DeckyUpdater } from './updater';
|
import { DeckyUpdater } from './updater';
|
||||||
|
|
||||||
@@ -14,6 +16,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 () => {
|
(async () => {
|
||||||
window.deckyAuthToken = await fetch('http://127.0.0.1:1337/auth/token').then((r) => r.text());
|
window.deckyAuthToken = await fetch('http://127.0.0.1:1337/auth/token').then((r) => r.text());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user