import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; import { createStore, Provider } from "jotai"; import { LazyMotion, MotionConfig } from "motion/react"; import { HotkeyProvider } from "@yaakapp-internal/ui"; import { type ReactNode, StrictMode } from "react"; import { createRoot } from "react-dom/client"; import { ProxyLayout } from "./components/ProxyLayout"; import { SettingsWindowContent } from "./components/Settings"; import { useHotkeyContextValue } from "./lib/hotkeys"; import { syncSettingsValues } from "./lib/interfaceSettings"; import { syncNavigation, syncSidebarSelection } from "./lib/navigation"; import { syncFlows, syncProxyState } from "./lib/store"; import { currentWindowLabel } from "./lib/tauri"; import { syncUpdates } from "./lib/updates"; import { syncFromOtherWindows } from "./lib/windowSync"; import { windowKind } from "./lib/windows"; import "./main.css"; const queryClient = new QueryClient(); const jotaiStore = createStore(); // Each window's page is the same; its label says which part of the app it holds const settingsWindow = windowKind(currentWindowLabel()) === "settings"; syncProxyState(jotaiStore); syncSettingsValues(jotaiStore); // Either window shows the updates it checks for; the app's window also checks in the background syncUpdates(jotaiStore, { background: !settingsWindow }).catch(console.error); syncFromOtherWindows(jotaiStore, queryClient); // Only the app's window lists traffic and navigates it if (!settingsWindow) { // Before the flows load, so they load for the filter it restores await syncNavigation(jotaiStore); syncFlows(jotaiStore); syncSidebarSelection(jotaiStore); } function Hotkeys({ children }: { children: ReactNode }) { return {children}; } const motionFeatures = () => import("framer-motion").then((mod) => mod.domAnimation); createRoot(document.getElementById("root") as HTMLElement).render( {settingsWindow ? ( // The app's hotkeys act on traffic, and their confirmations live in its window ) : ( )} , );