Skip to content

Commit fc95cf5

Browse files
committed
"fix" react-devtools
works well enough lol
1 parent 1781c19 commit fc95cf5

File tree

5 files changed

+1115
-18
lines changed

5 files changed

+1115
-18
lines changed

backend/decky_loader/utilities.py

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -429,25 +429,39 @@ async def _enable_rdt(self):
429429
async with ClientSession() as web:
430430
res = await web.request("GET", "http://" + ip + ":8097", ssl=helpers.get_ssl_context())
431431
script = """
432-
if (!window.deckyHasConnectedRDT) {
433-
window.deckyHasConnectedRDT = true;
434-
// This fixes the overlay when hovering over an element in RDT
435-
Object.defineProperty(window, '__REACT_DEVTOOLS_TARGET_WINDOW__', {
436-
enumerable: true,
437-
configurable: true,
438-
get: function() {
439-
return (GamepadNavTree?.m_context?.m_controller || FocusNavController)?.m_ActiveContext?.ActiveWindow || window;
440-
}
441-
});
442-
""" + await res.text() + "\n}"
432+
try {
433+
if (!window.deckyHasConnectedRDT) {
434+
window.deckyHasConnectedRDT = true;
435+
// This fixes the overlay when hovering over an element in RDT
436+
Object.defineProperty(window, '__REACT_DEVTOOLS_TARGET_WINDOW__', {
437+
enumerable: true,
438+
configurable: true,
439+
get: function() {
440+
return window?.DFL?.findSP?.() || window;
441+
}
442+
});
443+
""" + await res.text() + """
444+
// they broke the script so we have to do this ourselves
445+
ReactDevToolsBackend.initialize({
446+
appendComponentStack: true,
447+
breakOnConsoleErrors: false,
448+
showInlineWarningsAndErrors: true,
449+
hideConsoleLogsInStrictMode: false
450+
});
451+
ReactDevToolsBackend.connectToDevTools({port: 8097, host: 'localhost', useHttps: false});
452+
} } catch(e) {console.error('RDT LOAD ERROR', e);}console.log('LOADED RDT');
453+
"""
443454
if res.status != 200:
444455
self.logger.error("Failed to connect to React DevTools at " + ip)
445456
return False
446457
self.start_rdt_proxy(ip, 8097)
447458
self.logger.info("Connected to React DevTools, loading script")
448459
tab = await get_gamepadui_tab()
449460
# RDT needs to load before React itself to work.
450-
await close_old_tabs()
461+
try:
462+
await close_old_tabs()
463+
except Exception:
464+
pass
451465
result = await tab.reload_and_evaluate(script)
452466
self.logger.info(result)
453467

flake.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
nodePackages.pnpm
4141
poetry
4242
jq
43+
electron_30-bin
4344
# fixes local pyright not being able to see the pythonpath properly.
4445
(pkgs.writeShellScriptBin "pyright" ''
4546
${pkgs.pyright}/bin/pyright --pythonpath `which python3` "$@" '')

frontend/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"lint": "prettier -c src",
1111
"typecheck": "tsc --noEmit",
1212
"format": "prettier -c src -w",
13-
"localize": "i18next"
13+
"localize": "i18next",
14+
"react-devtools": "electron node_modules/react-devtools/app"
1415
},
1516
"devDependencies": {
1617
"@decky/api": "^1.1.1",
@@ -31,6 +32,7 @@
3132
"prettier": "^3.3.2",
3233
"prettier-plugin-import-sort": "^0.0.7",
3334
"react": "18.3.1",
35+
"react-devtools": "^6.0.0",
3436
"react-dom": "18.3.1",
3537
"rollup": "^4.18.0",
3638
"rollup-plugin-delete": "^2.0.0",

0 commit comments

Comments
 (0)