27 lines
571 B
JavaScript
27 lines
571 B
JavaScript
export default class PluginRegistry {
|
|
constructor() {
|
|
this.plugins = new Map()
|
|
}
|
|
|
|
register(plugin) {
|
|
if (!plugin.id) {
|
|
throw new Error('Plugin must have an id')
|
|
}
|
|
|
|
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,
|
|
}))
|
|
}
|
|
}
|