diff --git a/scripts/build.mjs b/scripts/build.mjs index c851521..9f42232 100644 --- a/scripts/build.mjs +++ b/scripts/build.mjs @@ -74,7 +74,7 @@ const config = { constModules: { globals: { "bunny-build-info": { - version: `"v1.4.0"` + version: `"v1.4.1"` } } }, diff --git a/src/lib/addons/themes/colors/patches/background.tsx b/src/lib/addons/themes/colors/patches/background.tsx index 4c337ca..f2ebd00 100644 --- a/src/lib/addons/themes/colors/patches/background.tsx +++ b/src/lib/addons/themes/colors/patches/background.tsx @@ -6,17 +6,18 @@ import { findInReactTree } from "@lib/utils"; import { findByFilePathLazy } from "@metro"; import chroma from "chroma-js"; import { ImageBackground, StyleSheet } from "react-native"; +import { logger } from "@lib/utils/logger"; -const Messages = findByFilePathLazy("components_native/chat/Messages.tsx", true); +const Messages = findByFilePathLazy("modules/messages/native/Messages.tsx", true); -function ThemeBackground({ children }: { children: React.ReactNode }) { +function ThemeBackground({ children }: { children: React.ReactNode; }) { useObservable([colorsPref]); if (!_colorRef.current || colorsPref.customBackground === "hidden" || !_colorRef.current.background?.url || _colorRef.current.background?.blur && (typeof _colorRef.current.background?.blur !== "number") - ){ + ) { return children; } @@ -30,30 +31,36 @@ function ThemeBackground({ children }: { children: React.ReactNode }) { } export default function patchChatBackground() { - const patches = [ - after("render", Messages, (_, ret) => { - if (!_colorRef.current || !_colorRef.current.background?.url) return; - const messagesComponent = findInReactTree( - ret, - x => x && "HACK_fixModalInteraction" in x.props && x?.props?.style - ); + try { + const patches = [ + after("render", Messages, (_, ret) => { + if (!_colorRef.current || !_colorRef.current.background?.url) return; - if (messagesComponent) { - const flattened = StyleSheet.flatten(messagesComponent.props.style); - const backgroundColor = chroma( - flattened.backgroundColor || "black" - ).alpha( - 1 - (_colorRef.current.background?.opacity ?? 1) - ).hex(); + const messagesComponent = findInReactTree( + ret, + x => x && "HACK_fixModalInteraction" in x.props && x?.props?.style + ); - messagesComponent.props.style = StyleSheet.flatten([ - messagesComponent.props.style, - { backgroundColor } - ]); - } + if (messagesComponent) { + const flattened = StyleSheet.flatten(messagesComponent.props.style); + const backgroundColor = chroma( + flattened.backgroundColor || "black" + ).alpha( + 1 - (_colorRef.current.background?.opacity ?? 1) + ).hex(); - return {ret}; - }) - ]; - return () => patches.forEach(x => x()); -} + messagesComponent.props.style = StyleSheet.flatten([ + messagesComponent.props.style, + { backgroundColor } + ]); + } + + return {ret}; + }) + ]; + return () => patches.forEach(x => x()); + } catch (e) { + logger.error("Failed to patch chat background.", e); + return () => { }; + } +} \ No newline at end of file diff --git a/src/lib/api/debug.ts b/src/lib/api/debug.ts index 7bc6f92..8949589 100644 --- a/src/lib/api/debug.ts +++ b/src/lib/api/debug.ts @@ -43,7 +43,6 @@ export async function toggleSafeMode() { setTimeout(BundleUpdaterManager.reload, 400); } -// --- Debugger State & Logic --- let socket: WebSocket | undefined; let originalConsoleLog: any; let originalConsoleError: any; @@ -254,7 +253,6 @@ export function isConnectedToDebugger(): boolean { return socket?.readyState === WebSocket.OPEN; } -// --- React DevTools (RDT) Logic --- const rdtPort = 8097; export let rdtClient: WebSocket | null = null; export let rdtConnected = false; @@ -318,8 +316,6 @@ export function useIsRdtConnected() { return connected; } -// --- Core Utils --- - /** * @internal */