import React, { useEffect, useState } from "react"; import type { Client } from "revolt.js"; import { UIProvider } from "./context"; import { Masks } from "../components/common/Masks"; export const mockClient = () => (window as any).mock as Client; export const InjectMockClient = ({ children: Child, }: { children: React.FC<{ client: Client }>; }) => { const [exists, setExists] = useState(typeof mockClient() === "object"); // Poll for client to exist. useEffect(() => { if (typeof mockClient() === "undefined") { const int = setInterval(() => { if (typeof mockClient() === "object") { setExists(true); } }, 100); return () => clearInterval(int); } }, [exists]); if (!exists) return (

Loading mock client from Revolt.js...

); return ; }; export const MaskDecorator = (Story: React.FC) => ( <> ); export const ContextDecorator = (Story: React.FC) => ( ( alert(`Navigate to ${to}!`)}>{children} ), Text: ({ id }) => <>{id}, Trigger: ({ children }) => (
alert("CTX MENU")}>{children}
), emitAction: (action) => console.info(action), }}>
);