Skip to content

Commit

Permalink
feat(plugins/developer-settings): alert errors on `Evaluate JavaScrip…
Browse files Browse the repository at this point in the history
…t` tool
  • Loading branch information
PalmDevs committed Jan 11, 2025
1 parent c5fc531 commit 28e3424
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions src/plugins/developer-settings/pages/Developer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ import {
import { BundleUpdaterManager, FileModule } from '@revenge-mod/modules/native'
import { storageContextSymbol, useObserveStorage } from '@revenge-mod/storage'

import { settings } from '@revenge-mod/preferences'
import { PluginsDirectoryPath } from '@revenge-mod/shared/paths'

import { getErrorStack } from '@revenge-mod/utils/errors'

import PageWrapper from '../../../plugins/settings/pages/(Wrapper)'

import {
Expand All @@ -30,11 +35,11 @@ import {
disconnectFromDevTools,
} from '../devtools'

import { settings } from '@revenge-mod/preferences'
import { PluginsDirectoryPath } from '@revenge-mod/shared/paths'
import { PluginContext } from '..'

import { useContext, useEffect, useRef, useState } from 'react'
import { ScrollView } from 'react-native'
import { PluginContext } from '..'


export default function DeveloperSettingsPage() {
const context = useContext(PluginContext)
Expand Down Expand Up @@ -239,13 +244,6 @@ export default function DeveloperSettingsPage() {
}
/>
</TableRowGroup>
<TableRowGroup title="Performance">
<TableRow
label="Show Debug Performance Times"
icon={<TableRowIcon source={assets.getIndexByName('TimerIcon')!} />}
onPress={() => navigation.navigate('RevengeDebugPerformanceTimes')}
/>
</TableRowGroup>
<TableRowGroup title="Caches">
<TableRow
variant="danger"
Expand Down Expand Up @@ -298,15 +296,19 @@ function DeveloperSettingsPageEvaluateJavaScriptAlert() {
text="Evaluate"
variant="primary"
onPress={async () => {
// biome-ignore lint/security/noGlobalEval: This is intentional
const res = globalThis.eval(codeRef.current)
try {
// biome-ignore lint/security/noGlobalEval: This is intentional
const res = globalThis.eval(codeRef.current)

alert(
modules.findProp<(val: unknown, opts?: { depth?: number }) => string>('inspect')!(
res instanceof Promise && evalAwaitResult ? await res : res,
{ depth: 5 },
),
)
alert(
modules.findProp<(val: unknown, opts?: { depth?: number }) => string>('inspect')!(
res instanceof Promise && evalAwaitResult ? await res : res,
{ depth: 5 },
),
)
} catch (e) {
alert(getErrorStack(e))
}
}}
/>
<AlertActionButton text="Cancel" variant="secondary" />
Expand Down

0 comments on commit 28e3424

Please sign in to comment.