From 0198955f7dd1b232c33fa468c576509619c7bdd1 Mon Sep 17 00:00:00 2001 From: hippoz <10706925-hippoz@users.noreply.gitlab.com> Date: Thu, 5 May 2022 21:49:25 +0300 Subject: [PATCH] frontend: extend debugging/plugin api --- frontend/src/debuggingapi.js | 22 ++++++++++++++++++++++ frontend/src/main.js | 8 +++----- frontend/src/stores.js | 11 +++++++++++ 3 files changed, 36 insertions(+), 5 deletions(-) create mode 100644 frontend/src/debuggingapi.js diff --git a/frontend/src/debuggingapi.js b/frontend/src/debuggingapi.js new file mode 100644 index 0000000..a8c0d43 --- /dev/null +++ b/frontend/src/debuggingapi.js @@ -0,0 +1,22 @@ +import gateway from './gateway'; +import { getItem, init, setItem, removeItem } from './storage'; +import { allStores } from './stores'; +import { authWithToken, logOut } from './auth'; + +export function useDebuggingApi() { + window.__waffle = { + gateway, + storage: { + getItem, + setItem, + removeItem, + init + }, + auth: { + authWithToken, + logOut + }, + stores: allStores, + app: null + }; +} \ No newline at end of file diff --git a/frontend/src/main.js b/frontend/src/main.js index a6a7562..c59bd50 100644 --- a/frontend/src/main.js +++ b/frontend/src/main.js @@ -1,14 +1,11 @@ import Main from './components/Main.svelte'; -import gateway from './gateway'; import { getItem, init } from './storage'; import { authWithToken, useAuthHandlers } from './auth'; import { initResponsiveHandlers } from './responsive'; - -window.__waffle = { - gateway -}; +import { useDebuggingApi } from './debuggingapi'; init(); +useDebuggingApi(); initResponsiveHandlers(); useAuthHandlers(); authWithToken(getItem("auth:token")); @@ -22,5 +19,6 @@ if (loadingElement) { const app = new Main({ target: document.body }); +window.__waffle.app = app; export default app; \ No newline at end of file diff --git a/frontend/src/stores.js b/frontend/src/stores.js index f1967c2..45c2fa4 100644 --- a/frontend/src/stores.js +++ b/frontend/src/stores.js @@ -295,3 +295,14 @@ export const gatewayStatus = new GatewayStatusStore(); export const messagesStoreProvider = new MessagesStoreProvider(); export const userInfoStore = new UserInfoStore(); export const overlayStore = new OverlayStore(); +export const allStores = { + selectedChannel, + showSidebar, + showChannelView, + smallViewport, + channels, + gatewayStatus, + messagesStoreProvider, + userInfoStore, + overlayStore, +};