diff --git a/src/core/ui/settings/pages/Developer/index.tsx b/src/core/ui/settings/pages/Developer/index.tsx index 217e0aa..4e9e23c 100644 --- a/src/core/ui/settings/pages/Developer/index.tsx +++ b/src/core/ui/settings/pages/Developer/index.tsx @@ -4,337 +4,244 @@ import AssetBrowser from "@core/ui/settings/pages/Developer/AssetBrowser"; import { useProxy } from "@core/vendetta/storage"; import { findAssetId } from "@lib/api/assets"; import { connectToDebugger } from "@lib/api/debug"; -import { - getReactDevToolsProp, - getReactDevToolsVersion, - isLoaderConfigSupported, - isReactDevToolsPreloaded, - isVendettaLoader, -} from "@lib/api/native/loader"; +import { getReactDevToolsProp, getReactDevToolsVersion, isLoaderConfigSupported, isReactDevToolsPreloaded, isVendettaLoader } from "@lib/api/native/loader"; import { loaderConfig, settings } from "@lib/api/settings"; import { lazyDestructure } from "@lib/utils/lazy"; import { NavigationNative } from "@metro/common"; -import { - Button, - LegacyFormText, - Stack, - TableRow, - TableRowGroup, - TableSwitchRow, - TextInput, -} from "@metro/common/components"; +import { Button, LegacyFormText, Stack, TableRow, TableRowGroup, TableSwitchRow, TextInput } from "@metro/common/components"; import { findByProps } from "@metro/wrappers"; import { semanticColors } from "@ui/color"; import { ErrorBoundary } from "@ui/components"; -import ErrorBoundaryScreen from "@core/ui/reporter/components/ErrorBoundaryScreen"; import { createStyles, TextStyleSheet } from "@ui/styles"; import { NativeModules } from "react-native"; import { ScrollView, StyleSheet } from "react-native"; import { showToast } from "@ui/toasts"; -const { hideActionSheet } = lazyDestructure(() => - findByProps("openLazy", "hideActionSheet"), -); -const { showSimpleActionSheet } = lazyDestructure(() => - findByProps("showSimpleActionSheet"), -); -const { openAlert } = lazyDestructure(() => - findByProps("openAlert", "dismissAlert"), -); -const { AlertModal, AlertActionButton } = lazyDestructure(() => - findByProps("AlertModal", "AlertActions"), -); +const { hideActionSheet } = lazyDestructure(() => findByProps("openLazy", "hideActionSheet")); +const { showSimpleActionSheet } = lazyDestructure(() => findByProps("showSimpleActionSheet")); +const { openAlert } = lazyDestructure(() => findByProps("openAlert", "dismissAlert")); +const { AlertModal, AlertActionButton } = lazyDestructure(() => findByProps("AlertModal", "AlertActions")); const RDT_EMBED_LINK = "https://cdn.bwlok.dev/rdt/devTools.js"; const useStyles = createStyles({ - leadingText: { - ...TextStyleSheet["heading-md/semibold"], - color: semanticColors.TEXT_MUTED, - marginRight: -4, - }, - inputGroup: { - marginTop: 4, - borderTopLeftRadius: 16, - borderTopRightRadius: 16, - overflow: "hidden", - }, + leadingText: { + ...TextStyleSheet["heading-md/semibold"], + color: semanticColors.TEXT_MUTED, + marginRight: -4 + }, }); export default function Developer() { - const [rdtFileExists, fs] = useFileExists("preloads/reactDevtools.js"); + const [rdtFileExists, fs] = useFileExists("preloads/reactDevtools.js"); - const styles = useStyles(); - const navigation = NavigationNative.useNavigation(); + const styles = useStyles(); + const navigation = NavigationNative.useNavigation(); - useProxy(settings); - useProxy(loaderConfig); + useProxy(settings); + useProxy(loaderConfig); - return ( - - - - - ( - - ws:// - - )} - defaultValue={settings.debuggerUrl} - onChange={(v: string) => (settings.debuggerUrl = v)} - /> - - } - onPress={() => connectToDebugger(settings.debuggerUrl)} - /> - - + return ( + + + - {isReactDevToolsPreloaded() && ( - - ( - - ws:// - - )} - defaultValue={settings.devToolsUrl} - onChange={(v: string) => (settings.devToolsUrl = v)} - /> - - - } - onPress={async () => { - if (!settings.devToolsUrl?.trim()) { - showToast("Invalid devTools URL!", findAssetId("Small")); - return; - } - - try { - const devTools = - window[getReactDevToolsProp() || "__vendetta_rdc"]; - - if (!devTools?.connectToDevTools) { - showToast( - "React DevTools not available", - findAssetId("Small"), - ); - return; - } - - await devTools.connectToDevTools({ - host: settings.devToolsUrl.split(":")?.[0], - resolveRNStyle: StyleSheet.flatten, - }); - } catch (error) { - showToast( - "Failed to connect to React DevTools", - findAssetId("Small"), - ); - } - }} - /> - - - {isLoaderConfigSupported() && isVendettaLoader() && ( - - } - value={loaderConfig.loadReactDevTools} - onValueChange={(v: boolean) => { - loaderConfig.loadReactDevTools = v; - }} - /> - )} - - )} - - {isLoaderConfigSupported() && ( - - } - value={loaderConfig.customLoadUrl.enabled} - onValueChange={(v: boolean) => { - loaderConfig.customLoadUrl.enabled = v; - }} - /> - {loaderConfig.customLoadUrl.enabled && ( - - (loaderConfig.customLoadUrl.url = v) - } - placeholder="http://localhost:4040/shiggycord.js" - label={Strings.SHIGGYCORD_URL} - /> - } - /> - )} - - )} - - - } - trailing={TableRow.Arrow} - onPress={() => - navigation.push("SHIGGYCORD_CUSTOM_PAGE", { - title: Strings.ASSET_BROWSER, - render: AssetBrowser, - }) - } - /> - } - trailing={ -