Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | 1x 2x 2x 2x 2x 2x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2x | import { Switch, Route } from "wouter";
import { queryClient } from "./lib/queryClient";
import { QueryClientProvider } from "@tanstack/react-query";
import { Toaster } from "@/components/ui/toaster";
import { TooltipProvider } from "@/components/ui/tooltip";
import { ErrorBoundary } from "@/components/ui/error-boundary";
import ArduinoSimulator from "@/pages/arduino-simulator";
import NotFound from "@/pages/not-found";
import React from "react";
import { isMac } from "@/lib/platform";
// Settings is opened on demand and has no realtime simulation state.
const SettingsDialog = React.lazy(() => import("@/components/features/settings-dialog"));
function Router() {
return (
<Switch>
<Route path="/" component={ArduinoSimulator} />
<Route component={NotFound} />
</Switch>
);
}
function App() {
const [settingsOpen, setSettingsOpen] = React.useState(false);
const openSettings = React.useCallback(() => setSettingsOpen(true), []);
const disableToasts =
import.meta.env.VITE_DISABLE_TOASTS === "true" ||
(typeof globalThis !== "undefined" &&
(globalThis as any).__DISABLE_TOASTS === true);
React.useEffect(() => {
const onKey = (e: KeyboardEvent) => {
// Open Settings dialog with Meta/Ctrl + , (comma)
const isSettings = (isMac ? e.metaKey : e.ctrlKey) && e.code === "Comma";
Eif (isSettings) {
e.preventDefault();
e.stopPropagation();
openSettings();
}
};
// Also listen to a custom event so other parts of the app can request opening settings
const onOpenSettings = () => openSettings();
document.addEventListener("keydown", onKey, { capture: true });
globalThis.addEventListener("open-settings", onOpenSettings as EventListener);
return () => {
document.removeEventListener("keydown", onKey, { capture: true });
globalThis.removeEventListener(
"open-settings",
onOpenSettings as EventListener,
);
};
}, [openSettings]);
return (
<ErrorBoundary>
<QueryClientProvider client={queryClient}>
<TooltipProvider>
{!disableToasts && <Toaster />}
<React.Suspense fallback={null}>
<SettingsDialog open={settingsOpen} onOpenChange={setSettingsOpen} />
</React.Suspense>
<Router />
</TooltipProvider>
</QueryClientProvider>
</ErrorBoundary>
);
}
export default App;
|