diff options
Diffstat (limited to 'packages/desktop/src')
| -rw-r--r-- | packages/desktop/src/DesktopInterface.tsx (renamed from packages/desktop/src/index.tsx) | 18 | ||||
| -rw-r--r-- | packages/desktop/src/PlatformContext.tsx | 14 | ||||
| -rw-r--r-- | packages/desktop/src/entry.tsx | 22 | ||||
| -rw-r--r-- | packages/desktop/src/index.ts | 2 |
4 files changed, 42 insertions, 14 deletions
diff --git a/packages/desktop/src/index.tsx b/packages/desktop/src/DesktopInterface.tsx index 3c21b9a37..c4de3e089 100644 --- a/packages/desktop/src/index.tsx +++ b/packages/desktop/src/DesktopInterface.tsx @@ -1,6 +1,4 @@ -/* @refresh reload */ import "@/index.css" -import { render } from "solid-js/web" import { Router, Route, Navigate } from "@solidjs/router" import { MetaProvider } from "@solidjs/meta" import { Font } from "@opencode-ai/ui/font" @@ -27,15 +25,8 @@ const url = ? `http://${host}:${port}` : "/") -const root = document.getElementById("root") -if (import.meta.env.DEV && !(root instanceof HTMLElement)) { - throw new Error( - "Root element not found. Did you forget to add it to your index.html? Or maybe the id attribute got misspelled?", - ) -} - -render( - () => ( +export function DesktopInterface() { + return ( <MarkedProvider> <DiffComponentProvider component={Diff}> <GlobalSDKProvider url={url}> @@ -72,6 +63,5 @@ render( </GlobalSDKProvider> </DiffComponentProvider> </MarkedProvider> - ), - root!, -) + ) +} diff --git a/packages/desktop/src/PlatformContext.tsx b/packages/desktop/src/PlatformContext.tsx new file mode 100644 index 000000000..5b510a8d4 --- /dev/null +++ b/packages/desktop/src/PlatformContext.tsx @@ -0,0 +1,14 @@ +import { createContext } from "solid-js" +import { useContext } from "solid-js" + +export interface Platform {} + +const PlatformContext = createContext<Platform>() + +export const PlatformProvider = PlatformContext.Provider + +export function usePlatform() { + const ctx = useContext(PlatformContext) + if (!ctx) throw new Error("usePlatform must be used within a PlatformProvider") + return ctx +} diff --git a/packages/desktop/src/entry.tsx b/packages/desktop/src/entry.tsx new file mode 100644 index 000000000..82c5dd331 --- /dev/null +++ b/packages/desktop/src/entry.tsx @@ -0,0 +1,22 @@ +// @refresh reload +import { render } from "solid-js/web" +import { DesktopInterface } from "@/DesktopInterface" +import { Platform, PlatformProvider } from "@/PlatformContext" + +const root = document.getElementById("root") +if (import.meta.env.DEV && !(root instanceof HTMLElement)) { + throw new Error( + "Root element not found. Did you forget to add it to your index.html? Or maybe the id attribute got misspelled?", + ) +} + +const platform: Platform = {} + +render( + () => ( + <PlatformProvider value={platform}> + <DesktopInterface /> + </PlatformProvider> + ), + root!, +) diff --git a/packages/desktop/src/index.ts b/packages/desktop/src/index.ts new file mode 100644 index 000000000..2142e4886 --- /dev/null +++ b/packages/desktop/src/index.ts @@ -0,0 +1,2 @@ +export { PlatformProvider, type Platform } from "./PlatformContext" +export { DesktopInterface } from "./DesktopInterface" |
