diff --git a/src/core/i18n/default.json b/src/core/i18n/default.json
index 15268af..466be29 100644
--- a/src/core/i18n/default.json
+++ b/src/core/i18n/default.json
@@ -35,7 +35,9 @@
"COPY_URL": "Copy URL",
"DEBUG": "Debug",
"DEBUGGER_URL": "Debugger URL",
+ "AUTO_DEBUGGER": "Automatically connect to Debugger",
"DEVTOOLS_URL": "DevTools URL",
+ "AUTO_DEVTOOLS": "Automatically connect to Devtools",
"DELETE": "Delete",
"DESC_EXTRACT_FONTS_FROM_THEME": "Looks out for \"fonts\" field in your currently applied theme and install it.",
"DEVELOPER": "Developer",
diff --git a/src/core/ui/settings/pages/Developer/index.tsx b/src/core/ui/settings/pages/Developer/index.tsx
index 788f0b1..4e9e23c 100644
--- a/src/core/ui/settings/pages/Developer/index.tsx
+++ b/src/core/ui/settings/pages/Developer/index.tsx
@@ -60,12 +60,20 @@ export default function Developer() {
borderTopRightRadius: 16,
overflow: 'hidden'
}}>
- }
- onPress={() => connectToDebugger(settings.debuggerUrl)}
- />
+ }
+ value={settings.autoDebugger}
+ onValueChange={(v: boolean) => {
+ settings.autoDebugger = v;
+ }}
+ />
+ }
+ onPress={() => connectToDebugger(settings.debuggerUrl)}
+ />
{isReactDevToolsPreloaded() && <>
@@ -84,14 +92,23 @@ export default function Developer() {
borderTopRightRadius: 16,
overflow: 'hidden'
}}>
- }
- onPress={async () => {
- if (!settings.devToolsUrl?.trim()) {
- showToast("Invalid devTools URL!", findAssetId("Small"));
- return;
- }
+ value={settings.autoDevTools}
+ onValueChange={(v: boolean) => {
+ settings.autoDevTools = v;
+ }}
+ />
+
+ }
+ onPress={async () => {
+ if (!settings.devToolsUrl?.trim()) {
+ showToast("Invalid devTools URL!", findAssetId("Small"));
+ return;
+ }
try {
const devTools = window[getReactDevToolsProp() || "__vendetta_rdc"];
@@ -110,8 +127,7 @@ export default function Developer() {
}
}}
- />
-
+ />
>}
{isLoaderConfigSupported() && <>
diff --git a/src/index.ts b/src/index.ts
index 89aaccf..340ab31 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -13,6 +13,7 @@ import { injectFluxInterceptor } from "@lib/api/flux";
import { patchJsx } from "@lib/api/react/jsx";
import { logger } from "@lib/utils/logger";
import { patchSettings } from "@ui/settings";
+import { initDebugger } from "@lib/api/debug";
import * as lib from "./lib";
@@ -40,6 +41,8 @@ export default async () => {
u => u.forEach(f => f && lib.unload.push(f))
);
+ initDebugger()
+
// Assign window object
window.bunny = lib;
diff --git a/src/lib/api/debug.ts b/src/lib/api/debug.ts
index 8d301c2..870739b 100644
--- a/src/lib/api/debug.ts
+++ b/src/lib/api/debug.ts
@@ -1,6 +1,6 @@
import { getThemeFromLoader, selectTheme, themes } from "@lib/addons/themes";
import { findAssetId } from "@lib/api/assets";
-import { getLoaderName, getLoaderVersion, isThemeSupported } from "@lib/api/native/loader";
+import { getLoaderName, getLoaderVersion, isThemeSupported, getReactDevToolsProp } from "@lib/api/native/loader";
import { BundleUpdaterManager, NativeClientInfoModule, NativeDeviceModule } from "@lib/api/native/modules";
import { after } from "@lib/api/patcher";
import { settings } from "@lib/api/settings";
@@ -8,6 +8,7 @@ import { logger } from "@lib/utils/logger";
import { showToast } from "@ui/toasts";
import { version } from "bunny-build-info";
import { Platform, type PlatformConstants } from "react-native";
+import { StyleSheet } from "react-native";
export interface RNConstants extends PlatformConstants {
// Android
@@ -164,3 +165,37 @@ export function getDebugInfo() {
)!
};
}
+
+
+/**
+ * @internal
+ */
+export function initDebugger() {
+ if (settings.autoDebugger) {
+ try {
+ connectToDebugger(settings.debuggerUrl);
+ } catch (e) {
+ logger.error("Failed to connect to Debugger during startup:", e);
+ }
+ }
+ if (settings.autoDevTools) {
+ try {
+ (async () => {
+ const devTools = window[getReactDevToolsProp() || "__vendetta_rdc"];
+
+ if (!devTools?.connectToDevTools) {
+ showToast("Invalid devTools URL!", findAssetId("Small"));
+ return;
+ }
+
+ await devTools.connectToDevTools({
+ host: settings.devToolsUrl.split(":")?.[0],
+ resolveRNStyle: StyleSheet.flatten,
+ });
+ })();
+ } catch (e) {
+ logger.error("Failed to connect to ReactDevTools during startup:", e);
+ }
+ }
+
+}
diff --git a/src/lib/api/settings.ts b/src/lib/api/settings.ts
index 85e5eeb..6d8ffb7 100644
--- a/src/lib/api/settings.ts
+++ b/src/lib/api/settings.ts
@@ -4,6 +4,8 @@ import { getLoaderConfigPath } from "@lib/api/native/loader";
export interface Settings {
debuggerUrl: string;
devToolsUrl: string;
+ autoDebugger: boolean;
+ autoDevTools: boolean;
developerSettings: boolean;
enableDiscordDeveloperSettings: boolean;
safeMode?: {