Plugins are switched on and off in a Plugins tab, the server keeps the state in data/plugins/plugins.json, and switched-off plugins are never delivered (#114)
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
57a97ba94f
commit
c17b2b5426
17 files changed
+994
-129
No files matched your search
@@ -18,6 +18,32 @@ export interface PluginHost {
|
||||
/** Whether a tab of this id exists already, built in or added by a plugin. */
|
||||
hasTab(id: string): boolean;
|
||||
addTab(id: string, label: string, content: Widget): void;
|
||||
/** Takes a plugin's tab away again, its content with it. */
|
||||
removeTab(id: string): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* The host as one plugin sees it: every listener it subscribes and every tab it adds is written
|
||||
* into `scope`, so switching the plugin off can take them away. An unsubscribe the plugin calls
|
||||
* itself stays harmless when the scope calls it again.
|
||||
*/
|
||||
export function scopedHost(host: PluginHost, scope: { add(cleanup: () => void): void }): PluginHost {
|
||||
return {
|
||||
...host,
|
||||
onProjectChange(listener) {
|
||||
let off: (() => void) | null = host.onProjectChange(listener);
|
||||
const unsubscribe = () => {
|
||||
off?.();
|
||||
off = null;
|
||||
};
|
||||
scope.add(unsubscribe);
|
||||
return unsubscribe;
|
||||
},
|
||||
addTab(id, label, content) {
|
||||
host.addTab(id, label, content);
|
||||
scope.add(() => host.removeTab(id));
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/** A change of the asset list, as `project.on('change')` sees it: ids, names and types in order. */
|
||||
|
||||
Reference in new issue
Block a user