Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
refactor(desktop): harden window chrome and client mount guards
Richie McIlroyad5d36d8d2a4
diff --git a/apps/desktop/src/entry-client.tsx b/apps/desktop/src/entry-client.tsxindex 801872019..a44f61bdc 100644--- a/apps/desktop/src/entry-client.tsx+++ b/apps/desktop/src/entry-client.tsx@@ -10,7 +10,10 @@ async function initApp() {console.error("Failed to get OS type:", error);}- mount(() => <StartClient />, document.getElementById("app")!);+ const app = document.getElementById("app");+ if (!app) throw new Error("App root element not found");++ mount(() => <StartClient />, app);}initApp();diff --git a/apps/desktop/src/routes/(window-chrome).tsx b/apps/desktop/src/routes/(window-chrome).tsxindex 49b6b3bc7..64b53baf0 100644--- a/apps/desktop/src/routes/(window-chrome).tsx+++ b/apps/desktop/src/routes/(window-chrome).tsx@@ -20,8 +20,10 @@ export default function (props: RouteSectionProps) {onMount(async () => {console.log("window chrome mounted");unlistenResize = await initializeTitlebar();- const capContext = (window as any).__CAP__;- const hasInitialTargetMode = capContext?.initialTargetMode != null;+ const { __CAP__ } = window as typeof window & {+ __CAP__?: { initialTargetMode?: unknown };+ };+ const hasInitialTargetMode = __CAP__?.initialTargetMode != null;if (location.pathname === "/" && !hasInitialTargetMode)getCurrentWindow().show();});@@ -50,25 +52,9 @@ export default function (props: RouteSectionProps) {enterClass="opacity-0"exitToClass="opacity-0"> */}- <Suspense- fallback={- (() => {- console.log("Outer window chrome suspense fallback");- return <AbsoluteInsetLoader />;- }) as any- }- >+ <Suspense fallback={<AbsoluteInsetLoader />}><Inner>- {/* prevents flicker idk */}- <Suspense- fallback={- (() => {- console.log("Inner window chrome suspense fallback");- }) as any- }- >- {props.children}- </Suspense>+ <Suspense fallback={null}>{props.children}</Suspense></Inner></Suspense>{/* </Transition> */}@@ -78,7 +64,11 @@ export default function (props: RouteSectionProps) {}function Header() {- const ctx = useWindowChromeContext()!;+ const ctx = useWindowChromeContext();+ if (!ctx)+ throw new Error(+ "useWindowChrome must be used within a WindowChromeContext",+ );const isWindows = ostype() === "windows";const isMacOS = ostype() === "macos";