total restructure: isolate functionality to core so web works
This commit is contained in:
32
src/core/PluginRegistry.js
Normal file
32
src/core/PluginRegistry.js
Normal file
@@ -0,0 +1,32 @@
|
||||
export default class PluginRegistry {
|
||||
constructor(environment = 'web') {
|
||||
this.plugins = new Map()
|
||||
this.environment = environment
|
||||
}
|
||||
|
||||
register(plugin) {
|
||||
if (!plugin.id) {
|
||||
throw new Error('Plugin must have an id')
|
||||
}
|
||||
|
||||
const environments = plugin.environments || ['electron', 'web']
|
||||
if (!environments.includes(this.environment)) {
|
||||
return
|
||||
}
|
||||
|
||||
this.plugins.set(plugin.id, plugin)
|
||||
}
|
||||
|
||||
get(id) {
|
||||
return this.plugins.get(id)
|
||||
}
|
||||
|
||||
list() {
|
||||
return Array.from(this.plugins.values()).map((plugin) => ({
|
||||
id: plugin.id,
|
||||
name: plugin.name,
|
||||
description: plugin.description,
|
||||
configSchema: plugin.configSchema,
|
||||
}))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user