feat(ui): add $store to window in dev mode

Helpful for troubleshooting.
This commit is contained in:
psychedelicious 2024-01-03 08:54:01 +11:00
parent 06245bc761
commit ebe717099e
2 changed files with 16 additions and 0 deletions

View File

@ -143,6 +143,15 @@ const InvokeAIUI = ({
useEffect(() => { useEffect(() => {
$store.set(store); $store.set(store);
if (import.meta.env.MODE === 'development') {
window.$store = $store;
}
() => {
$store.set(undefined);
if (import.meta.env.MODE === 'development') {
window.$store = undefined;
}
};
}, [store]); }, [store]);
return ( return (

View File

@ -1,6 +1,13 @@
import type { createStore } from 'app/store/store'; import type { createStore } from 'app/store/store';
import { atom } from 'nanostores'; import { atom } from 'nanostores';
// Inject socket options and url into window for debugging
declare global {
interface Window {
$store?: typeof $store;
}
}
export const $store = atom< export const $store = atom<
Readonly<ReturnType<typeof createStore>> | undefined Readonly<ReturnType<typeof createStore>> | undefined
>(); >();