mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-15 09:33:03 -04:00
refactor: identifier escapes + "self" group (#339)
Co-authored-by: Ven <vendicated@riseup.net>
This commit is contained in:
parent
4974c53f9c
commit
989bd36eeb
10 changed files with 157 additions and 30 deletions
|
@ -18,6 +18,8 @@
|
|||
|
||||
import { WEBPACK_CHUNK } from "@utils/constants";
|
||||
import Logger from "@utils/Logger";
|
||||
import { canonicalizeReplacement } from "@utils/patches";
|
||||
import { PatchReplacement } from "@utils/types";
|
||||
|
||||
import { _initWebpack } from ".";
|
||||
|
||||
|
@ -135,15 +137,17 @@ function patchPush() {
|
|||
if (code.includes(patch.find)) {
|
||||
patchedBy.add(patch.plugin);
|
||||
|
||||
// @ts-ignore we change all patch.replacement to array in plugins/index
|
||||
for (const replacement of patch.replacement) {
|
||||
// we change all patch.replacement to array in plugins/index
|
||||
for (const replacement of patch.replacement as PatchReplacement[]) {
|
||||
if (replacement.predicate && !replacement.predicate()) continue;
|
||||
const lastMod = mod;
|
||||
const lastCode = code;
|
||||
|
||||
canonicalizeReplacement(replacement, patch.plugin);
|
||||
|
||||
try {
|
||||
const newCode = code.replace(replacement.match, replacement.replace);
|
||||
if (newCode === code && !replacement.noWarn) {
|
||||
const newCode = code.replace(replacement.match, replacement.replace as string);
|
||||
if (newCode === code && !patch.noWarn) {
|
||||
logger.warn(`Patch by ${patch.plugin} had no effect (Module id is ${id}): ${replacement.match}`);
|
||||
if (IS_DEV) {
|
||||
logger.debug("Function Source:\n", code);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue