1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-06-27 21:05:53 +00:00
* API Added: Certain methods will now log warnings when in developer mode if being called incorrectly. For example, if an add-on registers new badge data without including its add-on ID as the data source. Expect these to be expanded over time.
* API Added: Add-on modules and sub-modules will all have an `addon_id` property containing their source add-on's ID, as well as an `addon_root` property with a reference to the add-on's root module.
* API Changed: The `ffz_user_class` property of chat messages should now be a `Set`, if it is defined.
* API Changed: Add-on module proxies are now cached.
This commit is contained in:
SirStendec 2023-11-03 14:40:58 -04:00
parent 04969cc57e
commit 71f347ab70
12 changed files with 202 additions and 45 deletions

View file

@ -599,6 +599,54 @@ export default class Emotes extends Module {
this.animLeave = this.animLeave.bind(this);
}
getAddonProxy(addon_id, addon, module) {
if ( ! addon_id )
return this;
const overrides = {};
if ( addon?.dev ) {
overrides.addDefaultSet = (provider, ...args) => {
if ( ! provider.includes(addon_id) )
module.log.warn('[DEV-CHECK] Call to emotes.addDefaultSet did not include addon ID in provider:', provider);
return this.addDefaultSet(provider, ...args);
}
overrides.removeDefaultSet = (provider, ...args) => {
if ( ! provider.includes(addon_id) )
module.log.warn('[DEV-CHECK] Call to emotes.removeDefaultSet did not include addon ID in provider:', provider);
return this.removeDefaultSet(provider, ...args);
}
overrides.addSubSet = (provider, ...args) => {
if ( ! provider.includes(addon_id) )
module.log.warn('[DEV-CHECK] Call to emotes.addSubSet did not include addon ID in provider:', provider);
return this.addSubSet(provider, ...args);
}
overrides.removeSubSet = (provider, ...args) => {
if ( ! provider.includes(addon_id) )
module.log.warn('[DEV-CHECK] Call to emotes.removeSubSet did not include addon ID in provider:', provider);
return this.removeSubSet(provider, ...args);
}
}
return new Proxy(this, {
get(obj, prop) {
const thing = overrides[prop];
if ( thing )
return thing;
return Reflect.get(...arguments);
}
});
}
onEnable() {
this.style = new ManagedStyle('emotes');
this.effect_style = new ManagedStyle('effects');