Module loading
This commit is contained in:
parent
d406384dd0
commit
1f1d748687
|
@ -153,7 +153,7 @@ export default class {
|
|||
mainPath
|
||||
}
|
||||
|
||||
const content = await this.loadContent(paths, configs, readConfig.info, readConfig.main);
|
||||
const content = await this.loadContent(paths, configs, readConfig.info, readConfig.main, readConfig.type);
|
||||
if (reload) this.localContent[index] = content;
|
||||
else this.localContent.push(content);
|
||||
return content;
|
||||
|
|
|
@ -20,6 +20,7 @@ export default class {
|
|||
this.stop = this.stop.bind(this);
|
||||
}
|
||||
|
||||
get type() { return 'plugin' }
|
||||
get configs() { return this.__pluginInternals.configs }
|
||||
get info() { return this.__pluginInternals.info }
|
||||
get icon() { return this.info.icon }
|
||||
|
|
|
@ -37,7 +37,16 @@ export default class extends ContentManager {
|
|||
static get refreshPlugins() { return this.refreshContent }
|
||||
|
||||
static get loadContent() { return this.loadPlugin }
|
||||
static async loadPlugin(paths, configs, info, main) {
|
||||
static async loadPlugin(paths, configs, info, main, type) {
|
||||
if (type === 'module') return {
|
||||
paths,
|
||||
configs,
|
||||
info,
|
||||
main,
|
||||
type,
|
||||
module: window.require(paths.mainPath)
|
||||
}
|
||||
|
||||
const plugin = window.require(paths.mainPath)(Plugin, new PluginApi(info), Vendor);
|
||||
const instance = new plugin({ configs, info, main, paths: { contentPath: paths.contentPath, dirName: paths.dirName } });
|
||||
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
module.exports = class {
|
||||
|
||||
constructor() {
|
||||
}
|
||||
|
||||
get foo() {
|
||||
return 'Bar';
|
||||
}
|
||||
|
||||
add(i1, i2) {
|
||||
return i1 + i2;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue