Skip to content

Commit

Permalink
add cef console button to developer settings (#441)
Browse files Browse the repository at this point in the history
* add cef console button

* Small fix: handle missing localization in backend plus a small typo in the english language (#443)

* Hotfix for i18n where the detector was overriding localStorage

* Please, pnpm, cooperate

* Small fix regarding the backend getting hammered when switching to not supported languages plus a small english typo

* Add a get_tab_id function to utilities

* Go straight to SharedJSContext into console button

* clean up some log statements, and some extra parentheses

---------

Co-authored-by: Marco Rodolfi <marco.rodolfi@tuta.io>
Co-authored-by: Party Wumpus <48649272+PartyWumpus@users.noreply.github.com>
  • Loading branch information
3 people committed Jun 1, 2023
1 parent d3584a9 commit f4c0a8b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
5 changes: 5 additions & 0 deletions backend/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@
}
},
"SettingsDeveloperIndex": {
"cef_console": {
"button": "Open Console",
"desc": "Opens the CEF Console. Only useful for debugging purposes. Stuff here is potentially dangerous and should only be used if you are a plugin dev, or are directed here by one.",
"label": "CEF Console"
},
"header": "Other",
"react_devtools": {
"desc": "Enables connection to a computer running React DevTools. Changing this setting will reload Steam. Set the IP address before enabling.",
Expand Down
8 changes: 6 additions & 2 deletions backend/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from aiohttp import ClientSession, web

from logging import getLogger
from injector import inject_to_tab, get_gamepadui_tab, close_old_tabs
from injector import inject_to_tab, get_gamepadui_tab, close_old_tabs, get_tab
import helpers
import subprocess
from localplatform import service_stop, service_start
Expand All @@ -32,7 +32,8 @@ def __init__(self, context) -> None:
"get_setting": self.get_setting,
"filepicker_ls": self.filepicker_ls,
"disable_rdt": self.disable_rdt,
"enable_rdt": self.enable_rdt
"enable_rdt": self.enable_rdt,
"get_tab_id": self.get_tab_id
}

self.logger = getLogger("Utilities")
Expand Down Expand Up @@ -287,3 +288,6 @@ async def disable_rdt(self):
await close_old_tabs()
await tab.evaluate_js("location.reload();", False, True, False)
self.logger.info("React DevTools disabled")

async def get_tab_id(self, name):
return (await get_tab(name)).id
20 changes: 19 additions & 1 deletion frontend/src/components/settings/pages/developer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import {
DialogControlsSection,
DialogControlsSectionHeader,
Field,
Navigation,
TextField,
Toggle,
} from 'decky-frontend-lib';
import { useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { FaFileArchive, FaLink, FaReact, FaSteamSymbol } from 'react-icons/fa';
import { FaFileArchive, FaLink, FaReact, FaSteamSymbol, FaTerminal } from 'react-icons/fa';

import { setShouldConnectToReactDevTools, setShowValveInternal } from '../../../../developer';
import { installFromURL } from '../../../../store';
Expand Down Expand Up @@ -75,6 +76,23 @@ export default function DeveloperSettings() {
</DialogControlsSection>
<DialogControlsSection>
<DialogControlsSectionHeader>{t('SettingsDeveloperIndex.header')}</DialogControlsSectionHeader>
<Field
label={t('SettingsDeveloperIndex.cef_console.label')}
description={<span style={{ whiteSpace: 'pre-line' }}>{t('SettingsDeveloperIndex.cef_console.desc')}</span>}
icon={<FaTerminal style={{ display: 'block' }} />}
>
<DialogButton onClick={async () => {
let res = await window.DeckyPluginLoader.callServerMethod('get_tab_id', { "name": "SharedJSContext" });
if (res.success) {
Navigation.NavigateToExternalWeb("localhost:8080/devtools/inspector.html?ws=localhost:8080/devtools/page/"+res.result);
} else {
console.error('Unable to find ID for SharedJSContext tab ', res.result);
Navigation.NavigateToExternalWeb("localhost:8080");
}
}}>
{t('SettingsDeveloperIndex.cef_console.button')}
</DialogButton>
</Field>
<RemoteDebuggingSettings />
<Field
label={t('SettingsDeveloperIndex.valve_internal.label')}
Expand Down

0 comments on commit f4c0a8b

Please sign in to comment.