fix PatchHelper
This commit is contained in:
parent
3b9292d3bc
commit
5f474ae9bc
3 changed files with 8 additions and 5 deletions
|
|
@ -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]);
|
||||
|
|
|
|||
|
|
@ -164,4 +164,4 @@ function PatchHelper() {
|
|||
);
|
||||
}
|
||||
|
||||
export default IS_DEV ? wrapTab(PatchHelper, "PatchHelper") : null;
|
||||
export default !IS_STANDALONE ? wrapTab(PatchHelper, "PatchHelper") : null;
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue