feat(FN-3398): update desktop README with multi-project setup and troublesh

The merge lands Step 7 of FN-3398, adding documentation and delivery artifacts across the mobile and desktop packages with updated READMEs, mobile-specific docs, and architecture references.

Fusion-Task-Id: FN-3398
This commit is contained in:
Fusion
2026-05-04 21:41:52 -07:00
committed by gsxdsm
parent 9699c3f2b6
commit 3feeb9026a
43 changed files with 2025 additions and 398 deletions

View File

@@ -0,0 +1,55 @@
import { createContext, useContext, useEffect, useMemo, useState, type PropsWithChildren } from "react";
import type { FusionShellApi, ShellConnectionState } from "../types/native-shell";
interface ShellContextValue {
shellApi: FusionShellApi | null;
state: ShellConnectionState;
ready: boolean;
}
const DEFAULT_STATE: ShellConnectionState = {
host: "web",
activeProfileId: null,
profiles: [],
};
const ShellContext = createContext<ShellContextValue>({
shellApi: null,
state: DEFAULT_STATE,
ready: true,
});
export function ShellProvider({ children }: PropsWithChildren) {
const shellApi = useMemo(() => (typeof window !== "undefined" ? window.fusionShell ?? null : null), []);
const [state, setState] = useState<ShellConnectionState>(DEFAULT_STATE);
const [ready, setReady] = useState(!shellApi);
useEffect(() => {
if (!shellApi) {
return;
}
let cancelled = false;
void shellApi.getState().then((value) => {
if (!cancelled) {
setState(value);
setReady(true);
}
});
const unsubscribe = shellApi.subscribe((nextState) => {
setState(nextState);
});
return () => {
cancelled = true;
unsubscribe();
};
}, [shellApi]);
return <ShellContext.Provider value={{ shellApi, state, ready }}>{children}</ShellContext.Provider>;
}
export function useShellContext(): ShellContextValue {
return useContext(ShellContext);
}