mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-10-13 22:41:57 +00:00
Add-Ons Loader System (#606)
Implements an Add-on Loader so that other add-ons, such as the FFZ Add-on Pack, can be loaded directly by FFZ without requiring the user to install multiple extensions into their browser.
This commit is contained in:
parent
d9f252ee4e
commit
a305d03b2c
20 changed files with 716 additions and 11 deletions
20
src/utilities/addon.js
Normal file
20
src/utilities/addon.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
import Module from 'utilities/module';
|
||||
|
||||
export class Addon extends Module {
|
||||
constructor(...args) {
|
||||
super(...args);
|
||||
|
||||
this.inject('i18n');
|
||||
this.inject('settings');
|
||||
}
|
||||
|
||||
static register(id, info) {
|
||||
const ffz = FrankerFaceZ.get();
|
||||
ffz.register(`addon.${id}`, this);
|
||||
|
||||
if ( info ) {
|
||||
info.id = id;
|
||||
ffz.addons.addAddon(info);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -46,6 +46,8 @@ export class Module extends EventEmitter {
|
|||
this.__load_state = this.onLoad ? State.UNLOADED : State.LOADED;
|
||||
this.__state = this.onLoad || this.onEnable ?
|
||||
State.DISABLED : State.ENABLED;
|
||||
|
||||
this.emit(':registered');
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -204,6 +204,8 @@ export class Tooltip {
|
|||
this.elements.add(target);
|
||||
|
||||
// Set this early in case content uses it early.
|
||||
tip._promises = [];
|
||||
tip.waitForDom = () => tip.element ? Promise.resolve() : new Promise(s => {tip._promises.push(s)});
|
||||
tip.update = () => tip._update(); // tip.popper && tip.popper.scheduleUpdate();
|
||||
tip.show = () => this.show(tip);
|
||||
tip.hide = () => this.hide(tip);
|
||||
|
@ -277,6 +279,11 @@ export class Tooltip {
|
|||
}
|
||||
}
|
||||
|
||||
for(const fn of tip._promises)
|
||||
fn();
|
||||
|
||||
tip._promises = null;
|
||||
|
||||
if ( content instanceof Promise || (content.then && content.toString() === '[object Promise]') ) {
|
||||
inner.innerHTML = '<div class="ffz-i-zreknarf loader"></div>';
|
||||
content.then(content => {
|
||||
|
|
|
@ -16,6 +16,10 @@ import {duration_to_string} from 'utilities/time';
|
|||
// ============================================================================
|
||||
|
||||
export const DEFAULT_TYPES = {
|
||||
tostring(val) {
|
||||
return `${val}`
|
||||
},
|
||||
|
||||
select(val, node, locale, out, ast, data) {
|
||||
const sub_ast = node.o && (node.o[val] || node.o.other);
|
||||
if ( ! sub_ast )
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue