Compare commits

..

3 Commits

Author SHA1 Message Date
AAGaming 5053a52f32 backport webhelper restart logic from websocket 2024-05-29 21:14:22 -04:00
AAGaming 5bfc53231d shut up ts 2024-05-29 21:04:36 -04:00
AAGaming 2b4e3318ca fix latest beta
VALVEEEEE
2024-05-29 21:01:49 -04:00
5 changed files with 26 additions and 9 deletions
+6
View File
@@ -156,6 +156,12 @@ async def service_start(service_name : str) -> bool:
res = run(cmd, stdout=PIPE, stderr=STDOUT)
return res.returncode == 0
async def restart_webhelper() -> bool:
logger.info("Restarting steamwebhelper")
# TODO move to pkill
res = run(["killall", "-s", "SIGTERM", "steamwebhelper"], stdout=DEVNULL, stderr=DEVNULL)
return res.returncode == 0
def get_privileged_path() -> str:
path = os.getenv("PRIVILEGED_PATH")
+6 -6
View File
@@ -2,9 +2,9 @@
import sys
from typing import Dict
from .localplatform import (chmod, chown, service_stop, service_start,
ON_WINDOWS, get_log_level, get_live_reload,
ON_WINDOWS, ON_LINUX, get_log_level, get_live_reload,
get_server_port, get_server_host, get_chown_plugin_path,
get_privileged_path)
get_privileged_path, restart_webhelper)
if hasattr(sys, '_MEIPASS'):
chmod(sys._MEIPASS, 755) # type: ignore
# Full imports
@@ -158,10 +158,10 @@ class PluginManager:
async def inject_javascript(self, tab: Tab, first: bool=False, request: Request|None=None):
logger.info("Loading Decky frontend!")
try:
if first:
if await tab.has_global_var("deckyHasLoaded", False):
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)
# if first:
if ON_LINUX and await tab.has_global_var("deckyHasLoaded", False):
await restart_webhelper()
await tab.evaluate_js("try{if (window.deckyHasLoaded){setTimeout(() => SteamClient.Browser.RestartJSContext(), 100)}else{window.deckyHasLoaded = true;(async()=>{try{while(!window.webpackChunksteamui){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())
pass
+1 -1
View File
@@ -360,7 +360,7 @@ class Utilities:
tab = await get_gamepadui_tab()
self.rdt_script_id = None
await close_old_tabs()
await tab.evaluate_js("location.reload();", False, True, False)
await tab.evaluate_js("SteamClient.Browser.RestartJSContext();", False, True, False)
self.logger.info("React DevTools disabled")
async def get_user_info(self) -> Dict[str, str]:
+11
View File
@@ -1,5 +1,16 @@
// Sets up DFL, then loads start.ts which starts up the loader
interface Window {
SP_REACTDOM: any;
}
(async () => {
if (!window.SP_REACT) {
console.debug('Setting up React globals...');
// deliberate partial import
const DFLWebpack = await import('decky-frontend-lib/dist/webpack');
// TODO move these finds to dfl in v4
window.SP_REACT = DFLWebpack.findModule((m) => m.Component && m.PureComponent && m.useLayoutEffect);
window.SP_REACTDOM = DFLWebpack.findModule((m) => m.createPortal && m.createRoot);
}
console.debug('Setting up decky-frontend-lib...');
window.DFL = await import('decky-frontend-lib');
await import('./start');
+2 -2
View File
@@ -1,4 +1,4 @@
import reloadFix from './reload';
// import reloadFix from './reload';
import restartFix from './restart';
let fixes: Function[] = [];
@@ -7,6 +7,6 @@ export function deinitSteamFixes() {
}
export async function initSteamFixes() {
fixes.push(await reloadFix());
// fixes.push(await reloadFix());
fixes.push(await restartFix());
}