feat(api): add useQuickAccessVisible to plugin api

This commit is contained in:
AAGaming
2024-07-26 14:17:04 -04:00
parent a5ccc87a46
commit ef0d449fb6
+11 -4
View File
@@ -20,6 +20,7 @@ import PluginInstallModal from './components/modals/PluginInstallModal';
import PluginUninstallModal from './components/modals/PluginUninstallModal'; import PluginUninstallModal from './components/modals/PluginUninstallModal';
import NotificationBadge from './components/NotificationBadge'; import NotificationBadge from './components/NotificationBadge';
import PluginView from './components/PluginView'; import PluginView from './components/PluginView';
import { useQuickAccessVisible } from './components/QuickAccessVisibleState';
import WithSuspense from './components/WithSuspense'; import WithSuspense from './components/WithSuspense';
import ErrorBoundaryHook from './errorboundary-hook'; import ErrorBoundaryHook from './errorboundary-hook';
import { FrozenPluginService } from './frozen-plugins-service'; import { FrozenPluginService } from './frozen-plugins-service';
@@ -567,11 +568,11 @@ class PluginLoader extends Logger {
} }
initPluginBackendAPI() { initPluginBackendAPI() {
// Things will break *very* badly if plugin code touches this outside of @decky/backend, so lets make that clear. // Things will break *very* badly if plugin code touches this outside of @decky/api, so lets make that clear.
window.__DECKY_SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED_deckyLoaderAPIInit = { window.__DECKY_SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED_deckyLoaderAPIInit = {
connect: (version: number, pluginName: string) => { connect: (version: number, pluginName: string) => {
if (version < 1 || version > 1) { if (version < 1 || version > 2) {
throw new Error(`Plugin ${pluginName} requested unsupported backend api version ${version}.`); console.warn(`Plugin ${pluginName} requested unsupported api version ${version}.`);
} }
const eventListeners: listenerMap = new Map(); const eventListeners: listenerMap = new Map();
@@ -611,7 +612,13 @@ class PluginLoader extends Logger {
removeCssFromTab: DeckyBackend.callable<[tab: string, cssId: string]>('utilities/remove_css_from_tab'), removeCssFromTab: DeckyBackend.callable<[tab: string, cssId: string]>('utilities/remove_css_from_tab'),
routerHook: this.routerHook, routerHook: this.routerHook,
toaster: this.toaster, toaster: this.toaster,
}; _version: 1,
} as any;
if (version >= 2) {
backendAPI._version = 2;
backendAPI.useQuickAccessVisible = useQuickAccessVisible;
}
this.debug(`${pluginName} connected to loader API.`); this.debug(`${pluginName} connected to loader API.`);
return backendAPI; return backendAPI;