diff options
Diffstat (limited to 'backend')
| -rw-r--r-- | backend/decky_loader/loader.py | 13 | ||||
| -rw-r--r-- | backend/decky_loader/plugin/plugin.py | 7 |
2 files changed, 8 insertions, 12 deletions
diff --git a/backend/decky_loader/loader.py b/backend/decky_loader/loader.py index f1a9488f..550638a3 100644 --- a/backend/decky_loader/loader.py +++ b/backend/decky_loader/loader.py @@ -142,7 +142,12 @@ class Loader: def import_plugin(self, file: str, plugin_directory: str, refresh: bool | None = False, batch: bool | None = False): try: - plugin = PluginWrapper(file, plugin_directory, self.plugin_path) + async def plugin_emitted_event(event: str, data: Any): + self.logger.debug(f"PLUGIN EMITTED EVENT: {str(event)} {data}") + event_data = PluginEvent(plugin_name=plugin.name, event=event, data=data) + await self.ws.emit("plugin_event", event_data) + + plugin = PluginWrapper(file, plugin_directory, self.plugin_path, plugin_emitted_event) if plugin.name in self.plugins: if not "debug" in plugin.flags and refresh: self.logger.info(f"Plugin {plugin.name} is already loaded and has requested to not be re-loaded") @@ -153,12 +158,6 @@ class Loader: if plugin.passive: self.logger.info(f"Plugin {plugin.name} is passive") - async def plugin_emitted_event(event: str, data: Any): - self.logger.debug(f"PLUGIN EMITTED EVENT: {str(event)} {data}") - event_data = PluginEvent(plugin_name=plugin.name, event=event, data=data) - await self.ws.emit("plugin_event", event_data) - - self.plugins[plugin.name].set_emitted_event_callback(plugin_emitted_event) self.plugins[plugin.name] = plugin.start() self.logger.info(f"Loaded {plugin.name}") if not batch: diff --git a/backend/decky_loader/plugin/plugin.py b/backend/decky_loader/plugin/plugin.py index ce7d2581..47d3d7b0 100644 --- a/backend/decky_loader/plugin/plugin.py +++ b/backend/decky_loader/plugin/plugin.py @@ -14,7 +14,7 @@ from typing import Any, Callable, Coroutine, Dict, List EmittedEventCallbackType = Callable[[str, Any], Coroutine[Any, Any, Any]] class PluginWrapper: - def __init__(self, file: str, plugin_directory: str, plugin_path: str) -> None: + def __init__(self, file: str, plugin_directory: str, plugin_path: str, emit_callback: EmittedEventCallbackType) -> None: self.file = file self.plugin_path = plugin_path self.plugin_directory = plugin_directory @@ -41,7 +41,7 @@ class PluginWrapper: self._listener_task: Task[Any] self._method_call_requests: Dict[str, MethodCallRequest] = {} - self.emitted_event_callback: EmittedEventCallbackType + self.emitted_event_callback: EmittedEventCallbackType = emit_callback self.legacy_method_warning = False @@ -61,9 +61,6 @@ class PluginWrapper: except: pass - def set_emitted_event_callback(self, callback: EmittedEventCallbackType): - self.emitted_event_callback = callback - async def execute_legacy_method(self, method_name: str, kwargs: Dict[Any, Any]): if not self.legacy_method_warning: self.legacy_method_warning = True |
