1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-06-27 21:05:53 +00:00
* Fixed: When unloading an emote set, also unload its CSS block.
* API Added: `badges.removeBadge()` method for removing a badge from the system.
* API Added: `chat.iterateUsers()` method to iterate all User instances.
* API Added: `getUser().removeAllBadges()` method to remove all badges from a provider.
* API Added: `getRoom().iterateUsers()` method to iterate all User instances on a Room instance.
* API Added: `tooltips.define()` method to add a tool-tip handler to the system.
* API Changed: All core modules now use the add-on proxies to track which add-ons are responsible for injecting content, and to make it easier to unload (and reload) add-ons.
* API Changed: Many core module methods now display warning messages in the console when used improperly. For now, this mainly checks that IDs are correct, but there may be more warnings in the future.
* API Fixed: Calling `resolve()` will now properly use add-on proxies.
* Experiment Changed: Improved handling for server disconnects with the MQTT experiment, as well as handling for topic mapping changes.
This commit is contained in:
SirStendec 2023-11-04 19:00:27 -04:00
parent c4da7fa9d9
commit 675512e811
13 changed files with 1008 additions and 146 deletions

View file

@ -10,6 +10,7 @@ import {has, maybe_call, once} from 'utilities/object';
import Tooltip from 'utilities/tooltip';
import Module from 'utilities/module';
import awaitMD, {getMD} from 'utilities/markdown';
import { DEBUG } from 'src/utilities/constants';
export default class TooltipProvider extends Module {
constructor(...args) {
@ -74,6 +75,41 @@ export default class TooltipProvider extends Module {
this.onFSChange = this.onFSChange.bind(this);
}
getAddonProxy(addon_id, addon, module) {
if ( ! addon_id )
return this;
const overrides = {},
is_dev = DEBUG || addon?.dev;
overrides.define = (key, handler) => {
if ( handler )
handler.__source = addon_id;
return this.define(key, handler);
};
if ( is_dev )
overrides.cleanup = () => {
module.log.warn('[DEV-CHECK] Instead of calling tooltips.cleanup(), you can emit the event "tooltips:cleanup"');
return this.cleanup();
};
return new Proxy(this, {
get(obj, prop) {
const thing = overrides[prop];
if ( thing )
return thing;
if ( prop === 'types' && is_dev )
module.log.warn('[DEV-CHECK] Accessed tooltips.types directly. Please use tooltips.define()');
return Reflect.get(...arguments);
}
});
}
onEnable() {
const container = this.getRoot();
@ -86,8 +122,29 @@ export default class TooltipProvider extends Module {
this.tips = this._createInstance(container);
this.on(':cleanup', this.cleanup);
this.on('addon:fully-unload', addon_id => {
let removed = 0;
for(const [key, handler] of Object.entries(this.types)) {
if ( handler?.__source === addon_id ) {
removed++;
this.types[key] = undefined;
}
}
if ( removed ) {
this.log.debug(`Cleaned up ${removed} entries when unloading addon:`, addon_id);
this.cleanup();
}
});
}
define(key, handler) {
this.types[key] = handler;
}
getRoot() { // eslint-disable-line class-methods-use-this
return document.querySelector('.sunlight-root') ||
//document.querySelector('#root>div') ||