summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Dellinger <jonas@dellinger.dev>2022-05-25 21:35:03 +0200
committerJonas Dellinger <jonas@dellinger.dev>2022-05-25 21:35:03 +0200
commitd23f1ac56c6749e214303c01adec20f2d4a2d0dd (patch)
tree9f29438eb86b89a40c28adcfd8846094345de105
parent74438a31458af8bddd08d90eacc6d63677bab844 (diff)
downloaddecky-loader-d23f1ac56c6749e214303c01adec20f2d4a2d0dd.tar.gz
decky-loader-d23f1ac56c6749e214303c01adec20f2d4a2d0dd.zip
Added support for static assets, remove frontend_bundle field
-rw-r--r--backend/loader.py9
-rw-r--r--backend/plugin.py1
2 files changed, 8 insertions, 2 deletions
diff --git a/backend/loader.py b/backend/loader.py
index e68842e2..9357b4ce 100644
--- a/backend/loader.py
+++ b/backend/loader.py
@@ -76,6 +76,7 @@ class Loader:
web.get("/plugins", self.handle_plugins),
web.get("/plugins/{plugin_name}/frontend_bundle", self.handle_frontend_bundle),
web.post("/plugins/{plugin_name}/methods/{method_name}", self.handle_plugin_method_call),
+ web.get("/plugins/{plugin_name}/assets/{path:.*}", self.handle_frontend_assets),
web.post("/methods/{method_name}", self.handle_server_method_call)
])
@@ -83,10 +84,16 @@ class Loader:
plugins = list(map(lambda kv: dict([("name", kv[0])]), self.plugins.items()))
return web.json_response(plugins)
+ def handle_frontend_assets(self, request):
+ plugin = self.plugins[request.match_info["plugin_name"]]
+ file = path.join(self.plugin_path, plugin.plugin_directory, "dist/assets", request.match_info["path"])
+
+ return web.FileResponse(file)
+
def handle_frontend_bundle(self, request):
plugin = self.plugins[request.match_info["plugin_name"]]
- with open(path.join(self.plugin_path, plugin.plugin_directory, plugin.frontend_bundle), 'r') as bundle:
+ with open(path.join(self.plugin_path, plugin.plugin_directory, "dist/index.js"), 'r') as bundle:
return web.Response(text=bundle.read(), content_type="application/javascript")
def import_plugin(self, file, plugin_directory, refresh=False):
diff --git a/backend/plugin.py b/backend/plugin.py
index db335225..7d3f36f3 100644
--- a/backend/plugin.py
+++ b/backend/plugin.py
@@ -26,7 +26,6 @@ class PluginWrapper:
self.name = json["name"]
self.author = json["author"]
- self.frontend_bundle = json["frontend_bundle"]
self.flags = json["flags"]
self.passive = not path.isfile(self.file)