mirror of https://github.com/vizality/vizality
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.2 KiB
41 lines
1.2 KiB
import { resolve } from 'path';
|
|
|
|
import { Directories } from '@vizality/constants';
|
|
|
|
import AddonManager from './Addon';
|
|
|
|
export default class BuiltinManager extends AddonManager {
|
|
constructor (type, dir) {
|
|
type = 'builtin';
|
|
dir = Directories.BUILTINS;
|
|
super(type, dir);
|
|
delete this._requiredManifestKeys;
|
|
}
|
|
|
|
async mount (addonId) {
|
|
try {
|
|
const addonModule = await import(resolve(this.dir, addonId));
|
|
const AddonClass = addonModule && addonModule.__esModule ? addonModule.default : addonModule;
|
|
Object.defineProperties(AddonClass.prototype, {
|
|
addonId: {
|
|
get: () => addonId
|
|
}
|
|
});
|
|
this._items.set(addonId, new AddonClass());
|
|
} catch (err) {
|
|
this._error(`An error occurred while initializing "${addonId}"!`, err);
|
|
}
|
|
}
|
|
|
|
_sortBuiltins (addonA, addonB) {
|
|
const priority = [ 'privacy', 'router', 'dashboard', 'rpc', 'settings', 'addon-manager', 'commands', 'notices', 'attributes', 'quick-code', 'enhancements', 'updater' ].reverse();
|
|
const priorityA = priority.indexOf(addonA);
|
|
const priorityB = priority.indexOf(addonB);
|
|
return (priorityA === priorityB ? 0 : (priorityA < priorityB ? 1 : -1));
|
|
}
|
|
|
|
_setAddonIcon () {
|
|
return void 0;
|
|
}
|
|
}
|