total restructure: isolate functionality to core so web works

This commit is contained in:
nicwands
2026-03-19 17:25:43 -04:00
parent f9e7fe1208
commit eea1cccf16
20 changed files with 635 additions and 247 deletions

56
src/core/PluginManager.js Normal file
View File

@@ -0,0 +1,56 @@
import PluginRegistry from './PluginRegistry.js'
import IpcAdapter from './IpcAdapter.js'
let registry = null
let activePluginId = null
let adapter = null
export default function createPluginManager(environment, plugins = []) {
registry = new PluginRegistry(environment)
for (const plugin of plugins) {
registry.register(plugin)
}
return {
listPlugins() {
return registry.list()
},
getPlugin(pluginId) {
return registry.get(pluginId)
},
getAdapter(pluginId, adapterConfig = {}) {
const plugin = registry.get(pluginId)
if (environment === 'electron') {
return new IpcAdapter()
}
if (!plugin) {
throw new Error(`Plugin not found: ${pluginId}`)
}
return plugin.createAdapter(adapterConfig)
},
setActivePlugin(pluginId, adapterConfig = {}) {
activePluginId = pluginId
adapter = this.getAdapter(pluginId, adapterConfig)
return adapter
},
getActiveAdapter() {
return adapter
},
getActivePluginId() {
return activePluginId
},
getEnvironment() {
return environment
},
}
}