Merge remote-tracking branch 'upstream/dev'

This commit is contained in:
thororen1234 2024-05-15 10:26:42 -04:00
commit f0f655fa10
29 changed files with 544 additions and 143 deletions

View file

@ -380,10 +380,18 @@ export const Devs = /* #__PURE__*/ Object.freeze({
name: "ProffDea",
id: 609329952180928513n
},
UlyssesZhan: {
name: "UlyssesZhan",
id: 586808226058862623n
},
ant0n: {
name: "ant0n",
id: 145224646868860928n
},
Board: {
name: "BoardTM",
id: 285475344817848320n,
},
philipbry: {
name: "philipbry",
id: 554994003318276106n
@ -479,7 +487,11 @@ export const Devs = /* #__PURE__*/ Object.freeze({
xocherry: {
name: "xocherry",
id: 221288171013406720n
}
},
ScattrdBlade: {
name: "ScattrdBlade",
id: 678007540608532491n
},
} satisfies Record<string, Dev>);
export const EquicordDevs = Object.freeze({

View file

@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { PatchReplacement, ReplaceFn } from "./types";
import { Patch, PatchReplacement, ReplaceFn } from "./types";
export function canonicalizeMatch<T extends RegExp | string>(match: T): T {
if (typeof match === "string") return match;
@ -55,3 +55,9 @@ export function canonicalizeReplacement(replacement: Pick<PatchReplacement, "mat
);
Object.defineProperties(replacement, descriptors);
}
export function canonicalizeFind(patch: Patch) {
const descriptors = Object.getOwnPropertyDescriptors(patch);
descriptors.find = canonicalizeDescriptor(descriptors.find, canonicalizeMatch);
Object.defineProperties(patch, descriptors);
}

View file

@ -29,14 +29,19 @@ export default function definePlugin<P extends PluginDef>(p: P & Record<string,
export type ReplaceFn = (match: string, ...groups: string[]) => string;
export interface PatchReplacement {
/** The match for the patch replacement. If you use a string it will be implicitly converted to a RegExp */
match: string | RegExp;
/** The replacement string or function which returns the string for the patch replacement */
replace: string | ReplaceFn;
/** A function which returns whether this patch replacement should be applied */
predicate?(): boolean;
}
export interface Patch {
plugin: string;
find: string;
/** A string or RegExp which is only include/matched in the module code you wish to patch. Prefer only using a RegExp if a simple string test is not enough */
find: string | RegExp;
/** The replacement(s) for the module being patched */
replacement: PatchReplacement | PatchReplacement[];
/** Whether this patch should apply to multiple modules */
all?: boolean;
@ -44,6 +49,7 @@ export interface Patch {
noWarn?: boolean;
/** Only apply this set of replacements if all of them succeed. Use this if your replacements depend on each other */
group?: boolean;
/** A function which returns whether this patch should be applied */
predicate?(): boolean;
}