mirror of
https://github.com/SteamDeckHomebrew/decky-loader.git
synced 2026-07-11 22:01:59 +00:00
hook up plugin events properly
This commit is contained in:
@@ -144,7 +144,7 @@ class Loader:
|
|||||||
try:
|
try:
|
||||||
async def plugin_emitted_event(event: str, args: Any):
|
async def plugin_emitted_event(event: str, args: Any):
|
||||||
self.logger.debug(f"PLUGIN EMITTED EVENT: {event} with args {args}")
|
self.logger.debug(f"PLUGIN EMITTED EVENT: {event} with args {args}")
|
||||||
await self.ws.emit(f"loader/plugin_event", {plugin:plugin.name, event:event, args:args})
|
await self.ws.emit(f"loader/plugin_event", {"plugin": plugin.name, "event": event, "args": args})
|
||||||
|
|
||||||
plugin = PluginWrapper(file, plugin_directory, self.plugin_path, plugin_emitted_event)
|
plugin = PluginWrapper(file, plugin_directory, self.plugin_path, plugin_emitted_event)
|
||||||
if plugin.name in self.plugins:
|
if plugin.name in self.plugins:
|
||||||
|
|||||||
@@ -206,6 +206,8 @@ logging.basicConfig(filename=DECKY_PLUGIN_LOG,
|
|||||||
format='[%(asctime)s][%(levelname)s]: %(message)s',
|
format='[%(asctime)s][%(levelname)s]: %(message)s',
|
||||||
force=True)
|
force=True)
|
||||||
logger: logging.Logger = logging.getLogger()
|
logger: logging.Logger = logging.getLogger()
|
||||||
|
# Also log to stdout
|
||||||
|
logger.addHandler(logging.StreamHandler())
|
||||||
"""The main plugin logger writing to `DECKY_PLUGIN_LOG`."""
|
"""The main plugin logger writing to `DECKY_PLUGIN_LOG`."""
|
||||||
|
|
||||||
logger.setLevel(logging.INFO)
|
logger.setLevel(logging.INFO)
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ class PluginWrapper:
|
|||||||
|
|
||||||
return await request.wait_for_result()
|
return await request.wait_for_result()
|
||||||
|
|
||||||
async def execute_method(self, method_name: str, args: List[Any]):
|
async def execute_method(self, method_name: str, *args: List[Any]):
|
||||||
if self.passive:
|
if self.passive:
|
||||||
raise RuntimeError("This plugin is passive (aka does not implement main.py)")
|
raise RuntimeError("This plugin is passive (aka does not implement main.py)")
|
||||||
|
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ class SandboxedPlugin:
|
|||||||
|
|
||||||
d: SocketResponseDict = {"type": SocketMessageType.RESPONSE, "res": None, "success": True, "id": data["id"]}
|
d: SocketResponseDict = {"type": SocketMessageType.RESPONSE, "res": None, "success": True, "id": data["id"]}
|
||||||
try:
|
try:
|
||||||
if data["legacy"]:
|
if data.get("legacy"):
|
||||||
if self.api_version > 0:
|
if self.api_version > 0:
|
||||||
raise Exception("Legacy methods may not be used on api_version > 0")
|
raise Exception("Legacy methods may not be used on api_version > 0")
|
||||||
# Legacy kwargs
|
# Legacy kwargs
|
||||||
|
|||||||
Generated
+1
-5
@@ -7,7 +7,7 @@ settings:
|
|||||||
dependencies:
|
dependencies:
|
||||||
'@decky/ui':
|
'@decky/ui':
|
||||||
specifier: ^4.0.2
|
specifier: ^4.0.2
|
||||||
version: 4.0.2
|
version: link:../../lib
|
||||||
filesize:
|
filesize:
|
||||||
specifier: ^10.1.2
|
specifier: ^10.1.2
|
||||||
version: 10.1.2
|
version: 10.1.2
|
||||||
@@ -335,10 +335,6 @@ packages:
|
|||||||
resolution: {integrity: sha512-YChHjlk//lOiIM2tlNSd6Qk9aduFJOtG+uRv1JaTzLewPRj4dDeupC+mbJJfarMGYa4nsLnJ6BsubTqboeb+VQ==}
|
resolution: {integrity: sha512-YChHjlk//lOiIM2tlNSd6Qk9aduFJOtG+uRv1JaTzLewPRj4dDeupC+mbJJfarMGYa4nsLnJ6BsubTqboeb+VQ==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/@decky/ui@4.0.2:
|
|
||||||
resolution: {integrity: sha512-sU1Dz2dOyysEcXus3iix/7lgaR3V8H/0VPUHuQkiD7CibPw1ksUDYR2DUwNo48S0Pe4D4nDp9hOEOFyfrWWLDw==}
|
|
||||||
dev: false
|
|
||||||
|
|
||||||
/@esbuild/aix-ppc64@0.20.2:
|
/@esbuild/aix-ppc64@0.20.2:
|
||||||
resolution: {integrity: sha512-D+EBOJHXdNZcLJRBkhENNG8Wji2kgc9AZ9KiPr1JuZjsNtyHzrsfLRrY0tk2H2aoFu6RANO1y1iPPUCDYWkb5g==}
|
resolution: {integrity: sha512-D+EBOJHXdNZcLJRBkhENNG8Wji2kgc9AZ9KiPr1JuZjsNtyHzrsfLRrY0tk2H2aoFu6RANO1y1iPPUCDYWkb5g==}
|
||||||
engines: {node: '>=12'}
|
engines: {node: '>=12'}
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ class Toaster extends Logger {
|
|||||||
};
|
};
|
||||||
instance = findToasterRoot(tree, 0);
|
instance = findToasterRoot(tree, 0);
|
||||||
while (!instance) {
|
while (!instance) {
|
||||||
this.error(
|
this.warn(
|
||||||
'Failed to find Toaster root node, reattempting in 5 seconds. A developer may need to increase the recursion limit.',
|
'Failed to find Toaster root node, reattempting in 5 seconds. A developer may need to increase the recursion limit.',
|
||||||
);
|
);
|
||||||
await sleep(5000);
|
await sleep(5000);
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ export class WSRouter extends Logger {
|
|||||||
if (this.runningCalls.has(data.id)) {
|
if (this.runningCalls.has(data.id)) {
|
||||||
this.runningCalls.get(data.id)!.resolve(data.result);
|
this.runningCalls.get(data.id)!.resolve(data.result);
|
||||||
this.runningCalls.delete(data.id);
|
this.runningCalls.delete(data.id);
|
||||||
this.debug(`Resolved PY call ${data.id} with value`, data.result);
|
this.debug(`[${data.id}] Resolved PY call with value`, data.result);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -145,7 +145,7 @@ export class WSRouter extends Logger {
|
|||||||
let err = new PyError(data.error.name, data.error.error, data.error.traceback);
|
let err = new PyError(data.error.name, data.error.error, data.error.traceback);
|
||||||
this.runningCalls.get(data.id)!.reject(err);
|
this.runningCalls.get(data.id)!.reject(err);
|
||||||
this.runningCalls.delete(data.id);
|
this.runningCalls.delete(data.id);
|
||||||
this.debug(`Rejected PY call ${data.id} with error`, data.error);
|
this.debug(`[${data.id}] Rejected PY call with error`, data.error);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -183,7 +183,7 @@ export class WSRouter extends Logger {
|
|||||||
|
|
||||||
this.runningCalls.set(id, resolver);
|
this.runningCalls.set(id, resolver);
|
||||||
|
|
||||||
this.debug(`Calling PY method ${route} with args`, args);
|
this.debug(`[${id}] Calling PY method ${route} with args`, args);
|
||||||
|
|
||||||
this.write({ type: MessageType.CALL, route, args, id });
|
this.write({ type: MessageType.CALL, route, args, id });
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user