From a84a13c76d99f1e6f4505d43108a4111749e5035 Mon Sep 17 00:00:00 2001 From: AAGaming Date: Sat, 25 May 2024 19:14:54 -0400 Subject: Custom error handler and some misc fixes --- frontend/src/plugin-loader.tsx | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) (limited to 'frontend/src/plugin-loader.tsx') diff --git a/frontend/src/plugin-loader.tsx b/frontend/src/plugin-loader.tsx index df3a9609..9726b3f2 100644 --- a/frontend/src/plugin-loader.tsx +++ b/frontend/src/plugin-loader.tsx @@ -21,6 +21,7 @@ import PluginUninstallModal from './components/modals/PluginUninstallModal'; import NotificationBadge from './components/NotificationBadge'; import PluginView from './components/PluginView'; import WithSuspense from './components/WithSuspense'; +import ErrorBoundaryHook from './errorboundary-hook'; import { FrozenPluginService } from './frozen-plugins-service'; import { HiddenPluginsService } from './hidden-plugins-service'; import Logger from './logger'; @@ -61,6 +62,7 @@ const callPluginMethod = DeckyBackend.callable<[pluginName: string, method: stri class PluginLoader extends Logger { private plugins: Plugin[] = []; + private errorBoundaryHook: ErrorBoundaryHook = new ErrorBoundaryHook(); private tabsHook: TabsHook = new TabsHook(); private routerHook: RouterHook = new RouterHook(); public toaster: Toaster = new Toaster(); @@ -79,6 +81,8 @@ class PluginLoader extends Logger { constructor() { super(PluginLoader.name); + this.errorBoundaryHook.init(); + DeckyBackend.addEventListener('loader/notify_updates', this.notifyUpdates.bind(this)); DeckyBackend.addEventListener('loader/import_plugin', this.importPlugin.bind(this)); DeckyBackend.addEventListener('loader/unload_plugin', this.unloadPlugin.bind(this)); @@ -185,12 +189,12 @@ class PluginLoader extends Logger { this.deckyState.setHasLoaderUpdate(true); if (this.notificationService.shouldNotify('deckyUpdates')) { this.toaster.toast({ - title: , + title: , body: ( ), onClick: () => Router.Navigate('/decky/settings'), @@ -213,12 +217,12 @@ class PluginLoader extends Logger { const updates = await this.checkPluginUpdates(); if (updates?.size > 0 && this.notificationService.shouldNotify('pluginUpdates')) { this.toaster.toast({ - title: , + title: , body: ( ), onClick: () => Router.Navigate('/decky/settings/plugins'), @@ -294,6 +298,10 @@ class PluginLoader extends Logger { this.routerHook.removeRoute('/decky/settings'); deinitSteamFixes(); deinitFilepickerPatches(); + this.routerHook.deinit(); + this.tabsHook.deinit(); + this.toaster.deinit(); + this.errorBoundaryHook.deinit(); } public unloadPlugin(name: string) { @@ -365,7 +373,9 @@ class PluginLoader extends Logger { }, }); if (res.ok) { - let plugin_export: (serverAPI: any) => Plugin = await eval(await res.text()); + let plugin_export: (serverAPI: any) => Plugin = await eval( + (await res.text()) + `\n//# sourceURL=decky://decky/legacy_plugin/${encodeURIComponent(name)}/index.js`, + ); let plugin = plugin_export(this.createLegacyPluginAPI(name)); this.plugins.push({ ...plugin, @@ -384,7 +394,7 @@ class PluginLoader extends Logger {
- +
@@ -395,9 +405,9 @@ class PluginLoader extends Logger {
@@ -412,9 +422,9 @@ class PluginLoader extends Logger { this.toaster.toast({ title: ( ), body: '' + e, -- cgit v1.2.3