diff --git a/scripts/build.mjs b/scripts/build.mjs index 66a755b..c4d344a 100644 --- a/scripts/build.mjs +++ b/scripts/build.mjs @@ -77,7 +77,7 @@ const config = { constModules: { globals: { "bunny-build-info": { - version: `"1.1.6"`, + version: `"1.1.6-1"`, }, }, }, diff --git a/src/core/ui/settings/pages/Developer/AssetDisplay.tsx b/src/core/ui/settings/pages/Developer/AssetDisplay.tsx index 090c526..56de923 100644 --- a/src/core/ui/settings/pages/Developer/AssetDisplay.tsx +++ b/src/core/ui/settings/pages/Developer/AssetDisplay.tsx @@ -4,62 +4,138 @@ import { findByProps } from "@metro"; import { clipboard } from "@metro/common"; import { Stack, TableRow, Text } from "@metro/common/components"; import { showToast } from "@ui/toasts"; -import { Image } from "react-native"; +import { Image, ScrollView } from "react-native"; +import { requireModule } from "@metro/internals/modules"; -const { openAlert } = lazyDestructure(() => findByProps("openAlert", "dismissAlert")); -const { AlertModal, AlertActionButton } = lazyDestructure(() => findByProps("AlertModal", "AlertActions")); +const { openAlert } = lazyDestructure(() => + findByProps("openAlert", "dismissAlert"), +); +const { AlertModal, AlertActionButton } = lazyDestructure(() => + findByProps("AlertModal", "AlertActions"), +); -const displayable = new Set(['png', 'jpg', 'svg']); +// More robust, normalized type checks and preview support. +// - Image types: standard raster/vector images +// - Text-like preview types: JSONA/JSON and Lottie (show raw JSON when possible) +const DISPLAYABLE_IMAGE_TYPES = new Set(["png", "jpg", "jpeg", "svg", "gif"]); +const DISPLAYABLE_TEXT_TYPES = new Set(["jsona", "json", "lottie"]); -const iconMap = { - jsona: 'ic_file_text', - lottie: 'ic_image', - webm: 'CirclePlayIcon-primary', - ttf: 'ic_add_text', - default: 'UnknownGameIcon' +// icon map uses lowercased keys +const iconMap: Record = { + jsona: "ic_file_text", + lottie: "ic_image", + webm: "CirclePlayIcon-primary", + ttf: "ic_add_text", + default: "UnknownGameIcon", }; -interface AssetDisplayProps { asset: Asset; } +interface AssetDisplayProps { + asset: Asset; +} export default function AssetDisplay({ asset }: AssetDisplayProps) { + // Normalize type checks to lowercase and guard against undefined + const type = String(asset.type ?? "").toLowerCase(); + const isImage = DISPLAYABLE_IMAGE_TYPES.has(type); + const isTextPreview = DISPLAYABLE_TEXT_TYPES.has(type); - return ( - - : + return ( + + ) : ( + + ) + } + onPress={() => + openAlert( + "revenge-asset-display-details", + + ) : isTextPreview ? ( + // For JSON-like assets (jsona, json, lottie) attempt to require the module + // and show a readable JSON/text preview. If loading fails, show a helpful message. + (() => { + try { + const moduleExport = requireModule(asset.moduleId); + const printable = + typeof moduleExport === "object" + ? JSON.stringify(moduleExport, null, 2) + : String(moduleExport); + return ( + + + {printable} + + + ); + } catch (e) { + return ( + + Could not load preview for {type.toUpperCase()}. + + ); + } + })() + ) : ( + + Asset type {String(asset.type).toUpperCase()} is not supported + for preview. + + ) } - onPress={() => - openAlert("revenge-asset-display-details", - : ( - Asset type {asset.type.toUpperCase()} is not supported for preview. - ) - } - actions={ - - copyToClipboard(asset.name)} /> - copyToClipboard(asset.id.toString())} /> - - } - />) + actions={ + + copyToClipboard(asset.name)} + /> + copyToClipboard(asset.id.toString())} + /> + } - /> - ); + />, + ) + } + /> + ); } const copyToClipboard = (text: string) => { - clipboard.setString(text); - showToast.showCopyToClipboard(); -}; \ No newline at end of file + clipboard.setString(text); + showToast.showCopyToClipboard(); +}; diff --git a/src/core/ui/settings/pages/General/index.tsx b/src/core/ui/settings/pages/General/index.tsx index f6dc8e4..3a73fea 100644 --- a/src/core/ui/settings/pages/General/index.tsx +++ b/src/core/ui/settings/pages/General/index.tsx @@ -18,13 +18,10 @@ import { TableRow, TableRowGroup, TableSwitchRow, - Button, - Text, } from "@metro/common/components"; import { Linking, ScrollView } from "react-native"; -// Fetch latest commits from GitHub for Changelog -import React, { useState } from "react"; +import React from "react"; export default function General() { useProxy(settings); @@ -32,93 +29,6 @@ export default function General() { const debugInfo = getDebugInfo(); const navigation = NavigationNative.useNavigation(); - // Remove modal state, use openAlert for both modals - const [loadingCommits, setLoadingCommits] = useState(false); - const [commits, setCommits] = useState([]); - const [commitsError, setCommitsError] = useState(null); - - // Handler for Changelog - const handleShowChangelog = () => { - setLoadingCommits(true); - setCommitsError(null); - fetch( - "https://api.github.com/repos/kmmiio99o/ShiggyCord/commits?per_page=10", - ) - .then((res) => { - if (!res.ok) throw new Error("Failed to fetch commits"); - return res.json(); - }) - .then((data) => { - setCommits(data); - setLoadingCommits(false); - openAlert( - "shiggycord-changelog", - Loading latest commits... - ) : commitsError ? ( - {commitsError} - ) : ( - - {data.map((entry: any) => ( - - - {new Date( - entry.commit.author.date, - ).toLocaleDateString()}{" "} - — {entry.commit.author.name} - - {entry.commit.message.split("\n")[0]} -