From aa07721269170bad332760828b5c246a1b7741d8 Mon Sep 17 00:00:00 2001 From: tralwdwd <79791517+tralwdwd@users.noreply.github.com> Date: Sat, 13 Dec 2025 16:16:53 +0000 Subject: [PATCH] feat(plugins/developer-kit): improve UI for JS eval Currently the eval is done in a modal which makes it hard to use and means any code written is discarded after pressing evaluate and also it is hard to read output from an alert. This commit improves it by instead having it as a page instead where the code remains after evaluation and outputs the result in a box in the page rather than in an alert. Eval results are also selectable now, and have display options. And inspecting with zero depth is now possible. --------- Co-authored-by: PalmDevs --- src/plugins/start/developer-kit/constants.ts | 1 + .../definitions/EvalJSSetting.tsx | 140 +---------------- .../screens/EvalJSSettingScreen.tsx | 148 ++++++++++++++++++ 3 files changed, 156 insertions(+), 133 deletions(-) create mode 100644 src/plugins/start/developer-kit/screens/EvalJSSettingScreen.tsx diff --git a/src/plugins/start/developer-kit/constants.ts b/src/plugins/start/developer-kit/constants.ts index a59027c..3c9cac9 100644 --- a/src/plugins/start/developer-kit/constants.ts +++ b/src/plugins/start/developer-kit/constants.ts @@ -21,5 +21,6 @@ export const Setting = { export const RouteNames = { [Setting.RevengeDeveloper]: 'Revenge Developer', [Setting.AssetBrowser]: 'Asset Browser', + [Setting.EvalJS]: 'Evaluate JavaScript', [Setting.TestErrorBoundary]: 'Test ErrorBoundary', } as const diff --git a/src/plugins/start/developer-kit/definitions/EvalJSSetting.tsx b/src/plugins/start/developer-kit/definitions/EvalJSSetting.tsx index 19e2613..fa46a0f 100644 --- a/src/plugins/start/developer-kit/definitions/EvalJSSetting.tsx +++ b/src/plugins/start/developer-kit/definitions/EvalJSSetting.tsx @@ -1,144 +1,18 @@ -import TableRowAssetIcon from '@revenge-mod/components/TableRowAssetIcon' -import { AlertActionCreators } from '@revenge-mod/discord/actions' -import { Design } from '@revenge-mod/discord/design' -import { nodeUtil } from '@revenge-mod/externals/browserify' -import { getErrorStack } from '@revenge-mod/utils/error' -import { sleep } from '@revenge-mod/utils/promise' -import { useRef, useState } from 'react' -import { api } from '..' -import { Setting } from '../constants' +import { TableRowAssetIcon } from '@revenge-mod/components' +import { RouteNames, Setting } from '../constants' +import EvalJSSettingScreen from '../screens/EvalJSSettingScreen' import type { SettingsItem } from '@revenge-mod/discord/modules/settings' -const AlertKey = 'evaluate-javascript' - const EvalJSSetting: SettingsItem = { parent: Setting.RevengeDeveloper, + type: 'route', IconComponent: () => , title: () => 'Evaluate JavaScript', useDescription: () => 'Runs a JavaScript code snippet.', - onPress: () => { - AlertActionCreators.openAlert(AlertKey, ) + screen: { + route: RouteNames[Setting.EvalJS], + getComponent: () => EvalJSSettingScreen, }, - type: 'pressable', -} - -const { - AlertActionButton, - AlertModal, - Button, - Slider, - Stack, - TableRow, - TableRowGroup, - TableSwitchRow, - Text, - TextArea, -} = Design - -function EvalJSAlert() { - const code = useRef('') - const [awaitResult, setAwaitResult] = useState(true) - const [inspectDepth, setInspectDepth] = useState(3) - const [showHidden, setShowHidden] = useState(true) - - return ( - -