Skip to content

Commit

Permalink
Merge branch 'StupidityDB:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinRMC authored Dec 11, 2023
2 parents d86fd51 + a500375 commit b3bc8f1
Show file tree
Hide file tree
Showing 73 changed files with 2,264 additions and 181 deletions.
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vencord",
"private": "true",
"version": "1.6.4",
"version": "1.6.5",
"description": "The cutest Discord client mod",
"homepage": "https://github.com/Vendicated/Vencord#readme",
"bugs": {
Expand All @@ -17,7 +17,7 @@
"doc": "docs"
},
"scripts": {
"build": "node scripts/build/build.mjs",
"build": "node --require=./scripts/suppressExperimentalWarnings.js scripts/build/build.mjs",
"buildWeb": "node --require=./scripts/suppressExperimentalWarnings.js scripts/build/buildWeb.mjs",
"generatePluginJson": "tsx scripts/generatePluginList.ts",
"inject": "node scripts/runInstaller.mjs",
Expand All @@ -28,7 +28,7 @@
"testWeb": "pnpm lint && pnpm buildWeb && pnpm testTsc",
"testTsc": "tsc --noEmit",
"uninject": "node scripts/runInstaller.mjs",
"watch": "node scripts/build/build.mjs --watch"
"watch": "node --require=./scripts/suppressExperimentalWarnings.js scripts/build/build.mjs --watch"
},
"dependencies": {
"@sapphi-red/web-noise-suppressor": "0.3.3",
Expand Down Expand Up @@ -68,7 +68,8 @@
"tsx": "^3.12.7",
"type-fest": "^3.9.0",
"typescript": "^5.0.4",
"zip-local": "^0.3.5"
"zip-local": "^0.3.5",
"zustand": "^3.7.2"
},
"packageManager": "[email protected]",
"pnpm": {
Expand Down
21 changes: 17 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion scripts/build/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ const globNativesPlugin = {
if (!await existsAsync(dirPath)) continue;
const plugins = await readdir(dirPath);
for (const p of plugins) {
if (!await existsAsync(join(dirPath, p, "native.ts"))) continue;
const nativePath = join(dirPath, p, "native.ts");
const indexNativePath = join(dirPath, p, "native/index.ts");

if (!(await existsAsync(nativePath)) && !(await existsAsync(indexNativePath)))
continue;

const nameParts = p.split(".");
const namePartsWithoutTarget = nameParts.length === 1 ? nameParts : nameParts.slice(0, -1);
Expand Down
44 changes: 33 additions & 11 deletions scripts/generateReport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,14 @@ async function printReport() {

console.log();

report.otherErrors = report.otherErrors.filter(e => !IGNORED_DISCORD_ERRORS.some(regex => e.match(regex)));
const ignoredErrors = [] as string[];
report.otherErrors = report.otherErrors.filter(e => {
if (IGNORED_DISCORD_ERRORS.some(regex => e.match(regex))) {
ignoredErrors.push(e);
return false;
}
return true;
});

console.log("## Discord Errors");
report.otherErrors.forEach(e => {
Expand All @@ -114,6 +121,13 @@ async function printReport() {

console.log();

console.log("## Ignored Discord Errors");
ignoredErrors.forEach(e => {
console.log(`- ${toCodeBlock(e)}`);
});

console.log();

if (process.env.DISCORD_WEBHOOK) {
await fetch(process.env.DISCORD_WEBHOOK, {
method: "POST",
Expand Down Expand Up @@ -321,15 +335,15 @@ function runTime(token: string) {
await (wreq as any).el(sym);
delete Object.prototype[sym];

const validChunksEntryPoints = [] as string[];
const validChunks = [] as string[];
const invalidChunks = [] as string[];
const validChunksEntryPoints = new Set<string>();
const validChunks = new Set<string>();
const invalidChunks = new Set<string>();

if (!chunks) throw new Error("Failed to get chunks");

chunksLoop:
for (const entryPoint in chunks) {
const chunkIds = chunks[entryPoint];
let invalidEntryPoint = false;

for (const id of chunkIds) {
if (!wreq.u(id)) continue;
Expand All @@ -339,14 +353,16 @@ function runTime(token: string) {
.then(t => t.includes(".module.wasm") || !t.includes("(this.webpackChunkdiscord_app=this.webpackChunkdiscord_app||[]).push"));

if (isWasm) {
invalidChunks.push(id);
continue chunksLoop;
invalidChunks.add(id);
invalidEntryPoint = true;
continue;
}

validChunks.push(id);
validChunks.add(id);
}

validChunksEntryPoints.push(entryPoint);
if (!invalidEntryPoint)
validChunksEntryPoints.add(entryPoint);
}

for (const entryPoint of validChunksEntryPoints) {
Expand All @@ -359,7 +375,7 @@ function runTime(token: string) {
const allChunks = Function("return " + (wreq.u.toString().match(/(?<=\()\{.+?\}/s)?.[0] ?? "null"))() as Record<string | number, string[]> | null;
if (!allChunks) throw new Error("Failed to get all chunks");
const chunksLeft = Object.keys(allChunks).filter(id => {
return !(validChunks.includes(id) || invalidChunks.includes(id));
return !(validChunks.has(id) || invalidChunks.has(id));
});

for (const id of chunksLeft) {
Expand Down Expand Up @@ -406,15 +422,21 @@ function runTime(token: string) {
if (method === "proxyLazyWebpack" || method === "LazyComponentWebpack") {
const [factory] = args;
result = factory();
} else if (method === "extractAndLoadChunks") {
const [code, matcher] = args;

const module = Vencord.Webpack.findModuleFactory(...code);
if (module) result = module.toString().match(Vencord.Util.canonicalizeMatch(matcher));
} else {
// @ts-ignore
result = Vencord.Webpack[method](...args);
}

if (result == null || ("$$get" in result && result.$$get() == null)) throw "a rock at ben shapiro";
if (result == null || ("$$vencordInternal" in result && result.$$vencordInternal() == null)) throw "a rock at ben shapiro";
} catch (e) {
let logMessage = searchType;
if (method === "find" || method === "proxyLazyWebpack" || method === "LazyComponentWebpack") logMessage += `(${args[0].toString().slice(0, 147)}...)`;
else if (method === "extractAndLoadChunks") logMessage += `([${args[0].map(arg => `"${arg}"`).join(", ")}], ${args[1].toString()})`;
else logMessage += `(${args.map(arg => `"${arg}"`).join(", ")})`;

console.log("[PUP_WEBPACK_FIND_FAIL]", logMessage);
Expand Down
4 changes: 2 additions & 2 deletions src/api/Commands/commandHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

import { MessageActions } from "@utils/discord";
import { mergeDefaults } from "@utils/misc";
import { findByPropsLazy } from "@webpack";
import { SnowflakeUtils } from "@webpack/common";
Expand All @@ -25,7 +26,6 @@ import type { PartialDeep } from "type-fest";
import { Argument } from "./types";

const MessageCreator = findByPropsLazy("createBotMessage");
const MessageSender = findByPropsLazy("receiveMessage");

export function generateId() {
return `-${SnowflakeUtils.fromTimestamp(Date.now())}`;
Expand All @@ -40,7 +40,7 @@ export function generateId() {
export function sendBotMessage(channelId: string, message: PartialDeep<Message>): Message {
const botMessage = MessageCreator.createBotMessage({ channelId, content: "", embeds: [] });

MessageSender.receiveMessage(channelId, mergeDefaults(message, botMessage));
MessageActions.receiveMessage(channelId, mergeDefaults(message, botMessage));

return message as Message;
}
Expand Down
20 changes: 18 additions & 2 deletions src/api/Settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,21 @@ export interface Settings {
frameless: boolean;
transparent: boolean;
winCtrlQ: boolean;
macosTranslucency: boolean;
macosVibrancyStyle:
| "content"
| "fullscreen-ui"
| "header"
| "hud"
| "menu"
| "popover"
| "selection"
| "sidebar"
| "titlebar"
| "tooltip"
| "under-page"
| "window"
| undefined;
macosTranslucency: boolean | undefined;
disableMinSize: boolean;
winNativeTitleBar: boolean;
plugins: {
Expand Down Expand Up @@ -74,7 +88,9 @@ const DefaultSettings: Settings = {
frameless: false,
transparent: false,
winCtrlQ: false,
macosTranslucency: false,
// Replaced by macosVibrancyStyle
macosTranslucency: undefined,
macosVibrancyStyle: undefined,
disableMinSize: false,
winNativeTitleBar: false,
plugins: {},
Expand Down
35 changes: 35 additions & 0 deletions src/components/Icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -255,3 +255,38 @@ export function DeleteIcon(props: IconProps) {
</Icon>
);
}

export function PlusIcon(props: IconProps) {
return (
<Icon
{...props}
className={classes(props.className, "vc-plus-icon")}
viewBox="0 0 18 18"
>
<polygon
fill-rule="nonzero"
fill="currentColor"
points="15 10 10 10 10 15 8 15 8 10 3 10 3 8 8 8 8 3 10 3 10 8 15 8"
/>
</Icon>
);
}

export function NoEntrySignIcon(props: IconProps) {
return (
<Icon
{...props}
className={classes(props.className, "vc-no-entry-sign-icon")}
viewBox="0 0 24 24"
>
<path
d="M0 0h24v24H0z"
fill="none"
/>
<path
fill="currentColor"
d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8 0-1.85.63-3.55 1.69-4.9L16.9 18.31C15.55 19.37 13.85 20 12 20zm6.31-3.1L7.1 5.69C8.45 4.63 10.15 4 12 4c4.42 0 8 3.58 8 8 0 1.85-.63 3.55-1.69 4.9z"
/>
</Icon>
);
}
2 changes: 1 addition & 1 deletion src/components/VencordSettings/PatchHelperTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function ReplacementComponent({ module, match, replacement, setReplacementError
function renderDiff() {
return diff?.map(p => {
const color = p.added ? "lime" : p.removed ? "red" : "grey";
return <div style={{ color, userSelect: "text" }}>{p.value}</div>;
return <div style={{ color, userSelect: "text", wordBreak: "break-all", lineBreak: "anywhere" }}>{p.value}</div>;
});
}

Expand Down
Loading

0 comments on commit b3bc8f1

Please sign in to comment.