update developer settings
This commit is contained in:
parent
57804aad2f
commit
c8bd5a4303
1 changed files with 41 additions and 6 deletions
|
|
@ -3,8 +3,18 @@ import { CheckState, useFileExists } from "@core/ui/hooks/useFS";
|
||||||
import AssetBrowser from "@core/ui/settings/pages/Developer/AssetBrowser";
|
import AssetBrowser from "@core/ui/settings/pages/Developer/AssetBrowser";
|
||||||
import { useProxy } from "@core/vendetta/storage";
|
import { useProxy } from "@core/vendetta/storage";
|
||||||
import { findAssetId } from "@lib/api/assets";
|
import { findAssetId } from "@lib/api/assets";
|
||||||
import { connectToDebugger, disconnectFromDebugger, isConnectedToDebugger } from "@lib/api/debug";
|
import {
|
||||||
import { getReactDevToolsProp, getReactDevToolsVersion, isLoaderConfigSupported, isReactDevToolsPreloaded, isVendettaLoader } from "@lib/api/native/loader";
|
connectToDebugger,
|
||||||
|
disconnectFromDebugger,
|
||||||
|
isConnectedToDebugger,
|
||||||
|
} from "@lib/api/debug";
|
||||||
|
import {
|
||||||
|
getReactDevToolsProp,
|
||||||
|
getReactDevToolsVersion,
|
||||||
|
isLoaderConfigSupported,
|
||||||
|
isReactDevToolsPreloaded,
|
||||||
|
isVendettaLoader,
|
||||||
|
} from "@lib/api/native/loader";
|
||||||
import { loaderConfig, settings } from "@lib/api/settings";
|
import { loaderConfig, settings } from "@lib/api/settings";
|
||||||
import { lazyDestructure } from "@lib/utils/lazy";
|
import { lazyDestructure } from "@lib/utils/lazy";
|
||||||
import { NavigationNative } from "@metro/common";
|
import { NavigationNative } from "@metro/common";
|
||||||
|
|
@ -40,7 +50,8 @@ const { AlertModal, AlertActionButton } = lazyDestructure(() =>
|
||||||
findByProps("AlertModal", "AlertActions"),
|
findByProps("AlertModal", "AlertActions"),
|
||||||
);
|
);
|
||||||
|
|
||||||
const RDT_EMBED_LINK = "https://codeberg.org/raincord/raindevtools/raw/branch/dev/dist/index.bundle";
|
const RDT_EMBED_LINK =
|
||||||
|
"https://codeberg.org/raincord/raindevtools/raw/branch/dev/dist/index.bundle";
|
||||||
|
|
||||||
const useStyles = createStyles({
|
const useStyles = createStyles({
|
||||||
leadingText: {
|
leadingText: {
|
||||||
|
|
@ -57,8 +68,10 @@ const useStyles = createStyles({
|
||||||
});
|
});
|
||||||
|
|
||||||
export default function Developer() {
|
export default function Developer() {
|
||||||
const [rdtFileExists, fs] = useFileExists("preloads/reactDevtools.js");
|
const [rdtFileExists, fs] = useFileExists("preloads/reactDevtools.js");
|
||||||
const [isDebuggerConnected, setIsDebuggerConnected] = useState(isConnectedToDebugger());
|
const [isDebuggerConnected, setIsDebuggerConnected] = useState(
|
||||||
|
isConnectedToDebugger(),
|
||||||
|
);
|
||||||
|
|
||||||
const styles = useStyles();
|
const styles = useStyles();
|
||||||
const navigation = NavigationNative.useNavigation();
|
const navigation = NavigationNative.useNavigation();
|
||||||
|
|
@ -66,6 +79,23 @@ export default function Developer() {
|
||||||
useProxy(settings);
|
useProxy(settings);
|
||||||
useProxy(loaderConfig);
|
useProxy(loaderConfig);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const interval = setInterval(() => {
|
||||||
|
setIsDebuggerConnected(isConnectedToDebugger());
|
||||||
|
}, 1000);
|
||||||
|
return () => clearInterval(interval);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const handleDebuggerConnect = () => {
|
||||||
|
if (isDebuggerConnected) {
|
||||||
|
disconnectFromDebugger();
|
||||||
|
setIsDebuggerConnected(false);
|
||||||
|
} else {
|
||||||
|
connectToDebugger(settings.debuggerUrl);
|
||||||
|
setTimeout(() => setIsDebuggerConnected(isConnectedToDebugger()), 100);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ErrorBoundary>
|
<ErrorBoundary>
|
||||||
<ScrollView
|
<ScrollView
|
||||||
|
|
@ -245,6 +275,11 @@ export default function Developer() {
|
||||||
fs.downloadFile(
|
fs.downloadFile(
|
||||||
RDT_EMBED_LINK,
|
RDT_EMBED_LINK,
|
||||||
"preloads/reactDevtools.js",
|
"preloads/reactDevtools.js",
|
||||||
|
).then(() =>
|
||||||
|
showToast(
|
||||||
|
"Successfully installed! A reload is required",
|
||||||
|
findAssetId("DownloadIcon"),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
} else if (rdtFileExists === CheckState.TRUE) {
|
} else if (rdtFileExists === CheckState.TRUE) {
|
||||||
fs.removeFile("preloads/reactDevtools.js");
|
fs.removeFile("preloads/reactDevtools.js");
|
||||||
|
|
@ -252,7 +287,7 @@ export default function Developer() {
|
||||||
}}
|
}}
|
||||||
icon={findAssetId(
|
icon={findAssetId(
|
||||||
rdtFileExists === CheckState.TRUE
|
rdtFileExists === CheckState.TRUE
|
||||||
? "ic_message_delete"
|
? "TrashIcon"
|
||||||
: "DownloadIcon",
|
: "DownloadIcon",
|
||||||
)}
|
)}
|
||||||
style={{ marginLeft: 8 }}
|
style={{ marginLeft: 8 }}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue