fix PatchHelper

This commit is contained in:
Vendicated 2026-05-12 18:15:06 +02:00
parent 3b9292d3bc
commit 5f474ae9bc
No known key found for this signature in database
GPG key ID: D66986BAF75ECF18
3 changed files with 8 additions and 5 deletions

View file

@ -11,8 +11,8 @@ import { ReplaceFn } from "@utils/types";
import { Button, Forms, Parser, useMemo, useState } from "@webpack/common";
import type { Change } from "diff";
// Do not include diff in non dev builds (side effects import)
if (IS_DEV) {
// Do not include diff in standalone builds (side effects import)
if (!IS_STANDALONE) {
var differ = require("diff") as typeof import("diff");
}
@ -128,7 +128,10 @@ export function PatchPreview({ module, match, replacement, setReplacementError }
className={Margins.top20}
onClick={() => {
try {
Function(patchedCode.replace(/^(?=function\()/, "0,"));
const isArrowFunction = patchedCode.startsWith("(");
const wrappedCode = "0," + (!isArrowFunction ? "function" : "") + patchedCode.slice(patchedCode.indexOf("("));
Function(wrappedCode.replace(/^(?=function\()/, "0,"));
setCompileResult([true, "Compiled successfully"]);
} catch (err) {
setCompileResult([false, (err as Error).message]);

View file

@ -164,4 +164,4 @@ function PatchHelper() {
);
}
export default IS_DEV ? wrapTab(PatchHelper, "PatchHelper") : null;
export default !IS_STANDALONE ? wrapTab(PatchHelper, "PatchHelper") : null;

View file

@ -208,7 +208,7 @@ export default definePlugin({
Component: BackupAndRestoreTab,
Icon: BackupRestoreIcon
}),
IS_DEV && PatchHelperTab && buildEntry({
!IS_STANDALONE && PatchHelperTab && buildEntry({
key: "vencord_patch_helper",
title: "Patch Helper",
Component: PatchHelperTab,