remove legacy compatibility code
This commit is contained in:
parent
5a9c3786bd
commit
e0efe846bd
12 changed files with 15 additions and 89 deletions
|
|
@ -183,7 +183,7 @@ export const startPlugin = traceFunction("startPlugin", function startPlugin(p:
|
|||
const {
|
||||
name, commands, contextMenus, managedStyle, userProfileBadge,
|
||||
onBeforeMessageEdit, onBeforeMessageSend, onMessageClick,
|
||||
renderChatBarButton, chatBarButton, renderMemberListDecorator, renderMessageAccessory, renderMessageDecoration, renderMessagePopoverButton, messagePopoverButton
|
||||
chatBarButton, renderMemberListDecorator, renderMessageAccessory, renderMessageDecoration, messagePopoverButton
|
||||
} = p;
|
||||
|
||||
if (p.start) {
|
||||
|
|
@ -234,14 +234,10 @@ export const startPlugin = traceFunction("startPlugin", function startPlugin(p:
|
|||
if (onMessageClick) addMessageClickListener(onMessageClick);
|
||||
|
||||
if (chatBarButton) addChatBarButton(name, chatBarButton.render, chatBarButton.icon);
|
||||
// @ts-expect-error: legacy code doesn't have icon
|
||||
else if (renderChatBarButton) addChatBarButton(name, renderChatBarButton);
|
||||
if (renderMemberListDecorator) addMemberListDecorator(name, renderMemberListDecorator);
|
||||
if (renderMessageDecoration) addMessageDecoration(name, renderMessageDecoration);
|
||||
if (renderMessageAccessory) addMessageAccessory(name, renderMessageAccessory);
|
||||
if (messagePopoverButton) addMessagePopoverButton(name, messagePopoverButton.render, messagePopoverButton.icon);
|
||||
// @ts-expect-error: legacy code doesn't have icon
|
||||
else if (renderMessagePopoverButton) addMessagePopoverButton(name, renderMessagePopoverButton);
|
||||
|
||||
return true;
|
||||
}, p => `startPlugin ${p.name}`);
|
||||
|
|
@ -250,7 +246,7 @@ export const stopPlugin = traceFunction("stopPlugin", function stopPlugin(p: Plu
|
|||
const {
|
||||
name, commands, contextMenus, managedStyle, userProfileBadge,
|
||||
onBeforeMessageEdit, onBeforeMessageSend, onMessageClick,
|
||||
renderChatBarButton, chatBarButton, renderMemberListDecorator, renderMessageAccessory, renderMessageDecoration, renderMessagePopoverButton, messagePopoverButton
|
||||
chatBarButton, renderMemberListDecorator, renderMessageAccessory, renderMessageDecoration, messagePopoverButton
|
||||
} = p;
|
||||
|
||||
if (p.stop) {
|
||||
|
|
@ -298,11 +294,11 @@ export const stopPlugin = traceFunction("stopPlugin", function stopPlugin(p: Plu
|
|||
if (onBeforeMessageSend) removeMessagePreSendListener(onBeforeMessageSend);
|
||||
if (onMessageClick) removeMessageClickListener(onMessageClick);
|
||||
|
||||
if (chatBarButton || renderChatBarButton) removeChatBarButton(name);
|
||||
if (chatBarButton) removeChatBarButton(name);
|
||||
if (renderMemberListDecorator) removeMemberListDecorator(name);
|
||||
if (renderMessageDecoration) removeMessageDecoration(name);
|
||||
if (renderMessageAccessory) removeMessageAccessory(name);
|
||||
if (messagePopoverButton || renderMessagePopoverButton) removeMessagePopoverButton(name);
|
||||
if (messagePopoverButton) removeMessagePopoverButton(name);
|
||||
|
||||
return true;
|
||||
}, p => `stopPlugin ${p.name}`);
|
||||
|
|
@ -313,7 +309,7 @@ export const initPluginManager = onlyOnce(function init() {
|
|||
|
||||
const pluginKeysToBind: Array<keyof PluginDef & `${"on" | "render"}${string}`> = [
|
||||
"onBeforeMessageEdit", "onBeforeMessageSend", "onMessageClick",
|
||||
"renderChatBarButton", "renderMemberListDecorator", "renderMessageAccessory", "renderMessageDecoration", "renderMessagePopoverButton"
|
||||
"renderMemberListDecorator", "renderMessageAccessory", "renderMessageDecoration"
|
||||
];
|
||||
|
||||
const neededApiPlugins = new Set<string>();
|
||||
|
|
@ -343,11 +339,11 @@ export const initPluginManager = onlyOnce(function init() {
|
|||
|
||||
if (p.commands?.length) neededApiPlugins.add("CommandsAPI");
|
||||
if (p.onBeforeMessageEdit || p.onBeforeMessageSend || p.onMessageClick) neededApiPlugins.add("MessageEventsAPI");
|
||||
if (p.chatBarButton || p.renderChatBarButton) neededApiPlugins.add("ChatInputButtonAPI");
|
||||
if (p.chatBarButton) neededApiPlugins.add("ChatInputButtonAPI");
|
||||
if (p.renderMemberListDecorator) neededApiPlugins.add("MemberListDecoratorsAPI");
|
||||
if (p.renderMessageAccessory) neededApiPlugins.add("MessageAccessoriesAPI");
|
||||
if (p.renderMessageDecoration) neededApiPlugins.add("MessageDecorationsAPI");
|
||||
if (p.messagePopoverButton || p.renderMessagePopoverButton) neededApiPlugins.add("MessagePopoverAPI");
|
||||
if (p.messagePopoverButton) neededApiPlugins.add("MessagePopoverAPI");
|
||||
if (p.userProfileBadge) neededApiPlugins.add("BadgeAPI");
|
||||
|
||||
for (const key of pluginKeysToBind) {
|
||||
|
|
|
|||
|
|
@ -52,12 +52,6 @@ export default definePlugin({
|
|||
{
|
||||
find: "#{intl::COMMANDS_OPTIONAL_COUNT}",
|
||||
replacement: [
|
||||
{
|
||||
// ...children: p?.name
|
||||
match: /(?<=:(\i)\.displayDescription\}.{0,200}children:).{0,50}\.name(?=\}\))/,
|
||||
replace: "$1.plugin||($&)",
|
||||
noWarn: true // TODO: remove legacy compatibility code in the future
|
||||
},
|
||||
{
|
||||
match: /children:(?=\i\?\?\i\?\.name)(?<=command:(\i),.+?)/,
|
||||
replace: "children:$1.plugin??"
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ export default definePlugin({
|
|||
description: "Allows you to omit either width or height when opening an image modal",
|
||||
patches: [
|
||||
{
|
||||
// TODO: bundler compat
|
||||
find: ".renderLinkComponent",
|
||||
replacement: {
|
||||
// widthAndHeightPassed = w != null && w !== 0 && h == null || h === 0
|
||||
|
|
|
|||
|
|
@ -35,12 +35,6 @@ export default definePlugin({
|
|||
{
|
||||
match: /(?<=,NOTICE_DISMISS:function\(\i\){)return null!=(\i)/,
|
||||
replace: (m, notice) => `if(${notice}?.id=="VencordNotice")return(${notice}=null,Vencord.Api.Notices.nextNotice(),true);${m}`
|
||||
},
|
||||
// FIXME(Bundler agressive inline): Remove the non used compability once enough time has passed
|
||||
{
|
||||
match: /(?<=function (\i)\(\i\){)return null!=(\i)(?=.+?NOTICE_DISMISS:\1)/,
|
||||
replace: (m, _, notice) => `if(${notice}?.id=="VencordNotice")return(${notice}=null,Vencord.Api.Notices.nextNotice(),true);${m}`,
|
||||
noWarn: true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,16 +92,6 @@ const settings = definePluginSettings({
|
|||
}
|
||||
});
|
||||
|
||||
const settingsSectionMap: [string, string][] = [
|
||||
["VencordSettings", "vencord_main_panel"],
|
||||
["VencordPlugins", "vencord_plugins_panel"],
|
||||
["VencordThemes", "vencord_themes_panel"],
|
||||
["VencordUpdater", "vencord_updater_panel"],
|
||||
["VencordCloud", "vencord_cloud_panel"],
|
||||
["VencordBackupAndRestore", "vencord_backup_restore_panel"],
|
||||
["VencordPatchHelper", "vencord_patch_helper_panel"]
|
||||
];
|
||||
|
||||
export default definePlugin({
|
||||
name: "Settings",
|
||||
description: "Adds Settings UI and debug info",
|
||||
|
|
@ -109,7 +99,6 @@ export default definePlugin({
|
|||
required: true,
|
||||
|
||||
settings,
|
||||
settingsSectionMap,
|
||||
|
||||
patches: [
|
||||
{
|
||||
|
|
@ -122,13 +111,6 @@ export default definePlugin({
|
|||
return `${m},$self.makeInfoElements(${component},${props}).map(e=>${makeRow}e})),`;
|
||||
}
|
||||
},
|
||||
{
|
||||
match: /"text-xs\/normal".{0,300}?\[\(0,\i\.jsxs?\)\((.{1,10}),(\{[^{}}]+\{.{0,20}className:\i.\i,.+?\})\)," "/,
|
||||
replace: (m, component, props) => {
|
||||
props = props.replace(/children:\[.+\]/, "");
|
||||
return `${m},$self.makeInfoElements(${component},${props})`;
|
||||
}
|
||||
},
|
||||
{
|
||||
match: /copyValue:\i\.join\(" "\)/g,
|
||||
replace: "$& + $self.getInfoString()"
|
||||
|
|
@ -141,13 +123,6 @@ export default definePlugin({
|
|||
match: /(\i)\.buildLayout\(\)(?=\.map)/,
|
||||
replace: "$self.buildLayout($1)"
|
||||
}
|
||||
},
|
||||
{
|
||||
find: "getWebUserSettingFromSection",
|
||||
replacement: {
|
||||
match: /new Map\(\[(?=\[.{0,10}\.ACCOUNT,.{0,10}\.ACCOUNT_PANEL)/,
|
||||
replace: "new Map([...$self.getSettingsSectionMappings(),"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
|
|
@ -179,10 +154,6 @@ export default definePlugin({
|
|||
});
|
||||
},
|
||||
|
||||
getSettingsSectionMappings() {
|
||||
return settingsSectionMap;
|
||||
},
|
||||
|
||||
buildLayout(originalLayoutBuilder: SettingsLayoutBuilder) {
|
||||
const layout = originalLayoutBuilder.buildLayout();
|
||||
if (originalLayoutBuilder.key !== "$Root") return layout;
|
||||
|
|
|
|||
|
|
@ -101,8 +101,7 @@ export default definePlugin({
|
|||
find: "Clear Treatment ",
|
||||
replacement: [
|
||||
{
|
||||
// TODO: stable compat optional chaining remove once some time has passed
|
||||
match: /\i\??\.isStaff\(\)/,
|
||||
match: /\i\?\.isStaff\(\)/,
|
||||
replace: "true"
|
||||
},
|
||||
// Fix some tricky experiments name causing a client crash
|
||||
|
|
|
|||
|
|
@ -137,8 +137,7 @@ export default definePlugin({
|
|||
{
|
||||
find: "MessageReactions.render:",
|
||||
replacement: {
|
||||
// FIXME: (?:medium|normal) is for stable compat
|
||||
match: /tag:"strong",variant:"text-md\/(?:medium|normal)"(?<=onContextMenu:.{0,15}\((\i),(\i),\i\).+?)/,
|
||||
match: /tag:"strong",variant:"text-md\/medium"(?<=onContextMenu:.{0,15}\((\i),(\i),\i\).+?)/,
|
||||
replace: "$&,style:$self.getColorStyle($2?.id,$1?.channel?.id)"
|
||||
},
|
||||
predicate: () => settings.store.reactorsList,
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
import { ClockIcon } from "@components/Icons";
|
||||
import SettingsPlugin from "@plugins/_core/settings";
|
||||
import { Devs } from "@utils/constants";
|
||||
import { removeFromArray } from "@utils/misc";
|
||||
import definePlugin from "@utils/types";
|
||||
|
||||
import StartupTimingPage from "./StartupTimingPage";
|
||||
|
|
@ -34,14 +35,8 @@ export default definePlugin({
|
|||
Component: StartupTimingPage,
|
||||
Icon: ClockIcon
|
||||
});
|
||||
SettingsPlugin.settingsSectionMap.push(["VencordStartupTimings", "vencord_startup_timings"]);
|
||||
},
|
||||
stop() {
|
||||
function removeFromArray<T>(arr: T[], predicate: (e: T) => boolean) {
|
||||
const idx = arr.findIndex(predicate);
|
||||
if (idx !== -1) arr.splice(idx, 1);
|
||||
}
|
||||
removeFromArray(SettingsPlugin.customEntries, e => e.key === "vencord_startup_timings");
|
||||
removeFromArray(SettingsPlugin.settingsSectionMap, entry => entry[1] === "vencord_startup_timings");
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -46,17 +46,6 @@ export default definePlugin({
|
|||
// if (inlinedCalculatePlayingCount(a,b) >= limit) return;
|
||||
match: /(BURST_REACTION_EFFECT_PLAY:\i=>{.+?if\()(\(\(\i,\i\)=>.+?\(\i,\i\))>=5+?(?=\))/,
|
||||
replace: (_, rest, playingCount) => `${rest}!$self.shouldPlayBurstReaction(${playingCount})`
|
||||
},
|
||||
// FIXME(Bundler agressive inline): Remove the non used compability once enough time has passed
|
||||
{
|
||||
/*
|
||||
* var limit = 5
|
||||
* ...
|
||||
* if (calculatePlayingCount(a,b) >= limit) return;
|
||||
*/
|
||||
match: /((\i)=5.+?)if\((.{0,20}?)>=\2\)return;/,
|
||||
replace: (_, rest, playingCount) => `${rest}if(!$self.shouldPlayBurstReaction(${playingCount}))return;`,
|
||||
noWarn: true
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
|||
|
|
@ -46,11 +46,6 @@ export default definePlugin({
|
|||
{
|
||||
find: "ReferencedMessageStore",
|
||||
replacement: [
|
||||
{
|
||||
match: /constructor\(\)\{\i\(this,"_channelCaches",new Map\)/,
|
||||
replace: "$&;$self.setReplyStore(this);",
|
||||
noWarn: true // TODO: remove legacy compatibility code in the future
|
||||
},
|
||||
{
|
||||
match: /_channelCaches=new Map;/,
|
||||
replace: "$&_=$self.setReplyStore(this);"
|
||||
|
|
|
|||
|
|
@ -97,3 +97,8 @@ export function tryOrElse<T>(func: () => T, fallback: T): T {
|
|||
return fallback;
|
||||
}
|
||||
}
|
||||
|
||||
export function removeFromArray<T>(arr: T[], predicate: (e: T) => boolean) {
|
||||
const idx = arr.findIndex(predicate);
|
||||
if (idx !== -1) arr.splice(idx, 1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -197,16 +197,6 @@ export interface PluginDef {
|
|||
renderMessageDecoration?: MessageDecorationFactory;
|
||||
|
||||
renderMemberListDecorator?: MemberListDecoratorFactory;
|
||||
|
||||
// TODO: Remove eventually
|
||||
/**
|
||||
* @deprecated Use {@link chatBarButton} instead
|
||||
*/
|
||||
renderChatBarButton?: never;
|
||||
/**
|
||||
* @deprecated Use {@link messagePopoverButton} instead
|
||||
*/
|
||||
renderMessagePopoverButton?: never;
|
||||
}
|
||||
|
||||
export const enum StartAt {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue