-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Implement a Patcher Rewrite #1964
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: development
Are you sure you want to change the base?
Implement a Patcher Rewrite #1964
Conversation
Adds 2 new options * `displayName`: A string that represents the name of that given patch. This will be shown when an exception is thrown within the patch (default is the function name or `Anonymous`) * `priority`: A number that defines the priority of that patch, higher number increases the priority and lower number number lowers the priority (default is 0) Also fixes typos and adds the patch details to the handler object of the proxy
Adds a option to prevent the patch being unpatched via `unpatchAll`. To unpatch you must manually unpatch via the returned function or the once option
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements a complete rewrite of the Patcher module with enhanced memory safety and new functionality. The rewrite introduces a new getOriginal function to retrieve unpatched functions and adds options for more granular patching behavior.
- Complete rewrite of the patcher implementation using WeakMaps for better memory management
- Added
getOriginalfunction to access original unpatched functions - Introduced options system with
once,forcePatch,displayName,priority, anddetachedparameters
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| src/betterdiscord/modules/patcher.ts | Complete rewrite of the core patcher logic with new hook-based system and enhanced type safety |
| src/betterdiscord/api/patcher.ts | Updated API wrapper to support new options parameter and integrate with rewritten patcher |
|
I think this is something that could use more testing before merging |
Because the checking is only done on the plugin api, its possible for patcher to throw a exception for bd internally
Hopefully more memory safe version of the patcher.
Also adds a new function called
getOriginalwhen called it'll return the original functionAdds options when patching
once: Whentrue(default isfalse) it will instantly unpatch after the callback is ranforcePatch: Whenfalse(default istrue) and when you go to patch a function that doesn't exist on the module, it will not add the function