[main] Hacky backwards compat :3
This commit is contained in:
parent
7d77a34a4f
commit
1179ca7baf
7 changed files with 51 additions and 15 deletions
|
|
@ -47,4 +47,10 @@ export default function initSettings() {
|
|||
}
|
||||
]
|
||||
});
|
||||
|
||||
// Compat for plugins which injects into the settings
|
||||
registerSection({
|
||||
name: "Vendetta",
|
||||
items: []
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,14 +29,28 @@ export const initVendettaObject = (): any => {
|
|||
modules: window.modules,
|
||||
find: (filter: (m: any) => boolean) => metro.find(filter),
|
||||
findAll: (filter: (m: any) => boolean) => metro.findAll(filter),
|
||||
findByProps: (...props: any) => metro.findByProps(...props),
|
||||
findByProps: (...props: any) => {
|
||||
// TypingAvatars polyfill
|
||||
if (props.length === 1 && props[0] === "KeyboardAwareScrollView") {
|
||||
props.push("listenToKeyboardEvents");
|
||||
}
|
||||
|
||||
return metro.findByProps(...props);
|
||||
},
|
||||
findByPropsAll: (...props: any) => metro.findByPropsAll(...props),
|
||||
findByName: (name: string, defaultExp?: boolean | undefined) => metro.findByName(name, defaultExp),
|
||||
findByNameAll: (name: string, defaultExp?: boolean | undefined) => metro.findByNameAll(name, defaultExp),
|
||||
findByDisplayName: (displayName: string, defaultExp?: boolean | undefined) => metro.findByDisplayName(displayName, defaultExp),
|
||||
findByDisplayNameAll: (displayName: string, defaultExp?: boolean | undefined) => metro.findByDisplayNameAll(displayName, defaultExp),
|
||||
findByTypeName: (typeName: string, defaultExp?: boolean | undefined) => metro.findByTypeName(typeName, defaultExp),
|
||||
findByTypeNameAll: (typeName: string, defaultExp?: boolean | undefined) => metro.findByTypeNameAll(typeName, defaultExp),
|
||||
findByName: (name: string, defaultExp?: boolean | undefined) => {
|
||||
// Decor polyfill
|
||||
if (name === "create" && typeof defaultExp === "undefined") {
|
||||
return metro.findByName("create", false).default;
|
||||
}
|
||||
|
||||
return metro.findByName(name, defaultExp ?? true);
|
||||
},
|
||||
findByNameAll: (name: string, defaultExp: boolean = true) => metro.findByNameAll(name, defaultExp),
|
||||
findByDisplayName: (displayName: string, defaultExp: boolean = true) => metro.findByDisplayName(displayName, defaultExp),
|
||||
findByDisplayNameAll: (displayName: string, defaultExp: boolean = true) => metro.findByDisplayNameAll(displayName, defaultExp),
|
||||
findByTypeName: (typeName: string, defaultExp: boolean = true) => metro.findByTypeName(typeName, defaultExp),
|
||||
findByTypeNameAll: (typeName: string, defaultExp: boolean = true) => metro.findByTypeNameAll(typeName, defaultExp),
|
||||
findByStoreName: (name: string) => metro.findByStoreName(name),
|
||||
common: {
|
||||
constants: common.constants,
|
||||
|
|
@ -79,7 +93,7 @@ export const initVendettaObject = (): any => {
|
|||
findInReactTree: (tree: { [key: string]: any; }, filter: any) => utils.findInReactTree(tree, filter),
|
||||
findInTree: (tree: any, filter: any, options: any) => utils.findInTree(tree, filter, options),
|
||||
safeFetch: (input: RequestInfo | URL, options?: RequestInit | undefined, timeout?: number | undefined) => utils.safeFetch(input, options, timeout),
|
||||
unfreeze: (obj: object) => ({ ...obj }),
|
||||
unfreeze: (obj: object) => Object.isFrozen(obj) ? ({ ...obj }) : obj,
|
||||
without: (object: any, ...keys: any) => utils.without(object, ...keys)
|
||||
},
|
||||
debug: {
|
||||
|
|
|
|||
|
|
@ -52,7 +52,15 @@ function polyfillVendettaLoaderIdentity() {
|
|||
};
|
||||
|
||||
Object.defineProperty(globalThis, "__vendetta_theme", {
|
||||
get: () => getStoredTheme(),
|
||||
// get: () => getStoredTheme(),
|
||||
get: () => {
|
||||
// PyonXposed only returns keys it parses, making custom keys like Themes+' to gone
|
||||
const id = getStoredTheme()?.id;
|
||||
if (!id) return null;
|
||||
|
||||
const { themes } = require("@lib/managers/themes");
|
||||
return themes[id] ?? getStoredTheme() ?? null;
|
||||
},
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ export interface Theme {
|
|||
export const color = findByProps("SemanticColor");
|
||||
|
||||
const appearanceManager = findByProps("updateTheme");
|
||||
const mmkvStorage = findByProps("storage");
|
||||
const mmkvStorage = findByProps("storage")?.parseResolve ? findByProps("storage") : findByProps("impl").impl;
|
||||
const ThemeStore = findByStoreName("ThemeStore");
|
||||
const formDividerModule = findByProps("DIVIDER_COLORS");
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ export const semanticColors = (color?.default?.colors ?? constants?.ThemeColorMa
|
|||
export const rawColors = (color?.default?.unsafe_rawColors ?? constants?.Colors) as Record<string, string>;
|
||||
|
||||
const ThemeStore = findByStoreName("ThemeStore");
|
||||
const colorResolver = color.default.internal ??= color.default.meta;
|
||||
const colorResolver = color.default.meta ??= color.default.internal;
|
||||
|
||||
export function isSemanticColor(sym: any): boolean {
|
||||
return colorResolver.isSemanticColor(sym);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
import { find, findByProps } from "@lib/metro";
|
||||
import { RedesignModuleKeys } from "@lib/ui/types";
|
||||
import { useEffect } from "react";
|
||||
import { View } from "react-native";
|
||||
|
||||
const findSingular = (prop: string) => find(m => m[prop] && Object.keys(m).length === 1)?.[prop];
|
||||
|
||||
|
|
@ -10,6 +12,13 @@ export const CompatfulRedesign = findByProps("ActionSheetRow") as unknown as {
|
|||
[key: string]: any;
|
||||
};
|
||||
|
||||
// Funny polyfill, hopefully same props :3
|
||||
CompatfulRedesign.ActionSheetTitleHeader ??= CompatfulRedesign.BottomSheetTitleHeader;
|
||||
CompatfulRedesign.ActionSheetContentContainer ??= ({ children }: any) => {
|
||||
useEffect(() => console.warn("Discord has removed 'ActionSheetContentContainer', please move into something else. It has been temporarily replaced with View"), []);
|
||||
return <View>{children}</View>;
|
||||
};
|
||||
|
||||
export const FormSwitch = findSingular("FormSwitch");
|
||||
export const FormRadio = findSingular("FormRadio");
|
||||
export const FormCheckbox = findSingular("FormCheckbox");
|
||||
|
|
@ -111,12 +120,10 @@ export const {
|
|||
AccessibilityViewAnimated,
|
||||
ActionSheet,
|
||||
ActionSheetCloseButton,
|
||||
ActionSheetContentContainer,
|
||||
ActionSheetIconHeader,
|
||||
ActionSheetPresenter,
|
||||
ActionSheetRow,
|
||||
ActionSheetSwitchRow,
|
||||
ActionSheetTitleHeader,
|
||||
AnimatedEnterExitItem,
|
||||
BottomSheetTextInput,
|
||||
Dialog,
|
||||
|
|
@ -18,7 +18,7 @@ function useIsFirstRender() {
|
|||
export function patchTabsUI(unpatches: (() => void | boolean)[]) {
|
||||
settingConstants.SETTING_RENDERER_CONFIG.VendettaCustomPage = {
|
||||
type: "route",
|
||||
title: () => "Bnuuy",
|
||||
title: () => "Bunny",
|
||||
screen: {
|
||||
route: "VendettaCustomPage",
|
||||
getComponent: () => CustomPageRenderer
|
||||
|
|
@ -29,7 +29,7 @@ export function patchTabsUI(unpatches: (() => void | boolean)[]) {
|
|||
.flatMap(sect => sect.map(row => ({
|
||||
[row.key]: {
|
||||
type: "pressable",
|
||||
title: row.title(),
|
||||
title: row.title,
|
||||
icon: row.icon,
|
||||
usePredicate: row.usePredicate,
|
||||
onPress: wrapOnPress(row.onPress, null, row.render, row.title()),
|
||||
|
|
@ -60,6 +60,7 @@ export function patchTabsUI(unpatches: (() => void | boolean)[]) {
|
|||
Object.keys(registeredSections).forEach(sect => {
|
||||
sections.splice(index++, 0, {
|
||||
label: sect,
|
||||
title: sect,
|
||||
settings: registeredSections[sect].map(a => a.key)
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue