frontend: extend debugging/plugin api

This commit is contained in:
hippoz 2022-05-05 21:49:25 +03:00
parent 06e081d785
commit 0198955f7d
Signed by: hippoz
GPG key ID: 7C52899193467641
3 changed files with 36 additions and 5 deletions

View file

@ -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
};
}

View file

@ -1,14 +1,11 @@
import Main from './components/Main.svelte'; import Main from './components/Main.svelte';
import gateway from './gateway';
import { getItem, init } from './storage'; import { getItem, init } from './storage';
import { authWithToken, useAuthHandlers } from './auth'; import { authWithToken, useAuthHandlers } from './auth';
import { initResponsiveHandlers } from './responsive'; import { initResponsiveHandlers } from './responsive';
import { useDebuggingApi } from './debuggingapi';
window.__waffle = {
gateway
};
init(); init();
useDebuggingApi();
initResponsiveHandlers(); initResponsiveHandlers();
useAuthHandlers(); useAuthHandlers();
authWithToken(getItem("auth:token")); authWithToken(getItem("auth:token"));
@ -22,5 +19,6 @@ if (loadingElement) {
const app = new Main({ const app = new Main({
target: document.body target: document.body
}); });
window.__waffle.app = app;
export default app; export default app;

View file

@ -295,3 +295,14 @@ export const gatewayStatus = new GatewayStatusStore();
export const messagesStoreProvider = new MessagesStoreProvider(); export const messagesStoreProvider = new MessagesStoreProvider();
export const userInfoStore = new UserInfoStore(); export const userInfoStore = new UserInfoStore();
export const overlayStore = new OverlayStore(); export const overlayStore = new OverlayStore();
export const allStores = {
selectedChannel,
showSidebar,
showChannelView,
smallViewport,
channels,
gatewayStatus,
messagesStoreProvider,
userInfoStore,
overlayStore,
};