import { createSimpleContext } from "@opencode-ai/ui/context" import { AsyncStorage, SyncStorage } from "@solid-primitives/storage" import type { Accessor } from "solid-js" export type Platform = { /** Platform discriminator */ platform: "web" | "desktop" /** Desktop OS (Tauri only) */ os?: "macos" | "windows" | "linux" /** App version */ version?: string /** Open a URL in the default browser */ openLink(url: string): void /** Open a local path in a local app (desktop only) */ openPath?(path: string, app?: string): Promise /** Restart the app */ restart(): Promise /** Navigate back in history */ back(): void /** Navigate forward in history */ forward(): void /** Send a system notification (optional deep link) */ notify(title: string, description?: string, href?: string): Promise /** Open directory picker dialog (native on Tauri, server-backed on web) */ openDirectoryPickerDialog?(opts?: { title?: string; multiple?: boolean }): Promise /** Open native file picker dialog (Tauri only) */ openFilePickerDialog?(opts?: { title?: string; multiple?: boolean }): Promise /** Save file picker dialog (Tauri only) */ saveFilePickerDialog?(opts?: { title?: string; defaultPath?: string }): Promise /** Storage mechanism, defaults to localStorage */ storage?: (name?: string) => SyncStorage | AsyncStorage /** Check for updates (Tauri only) */ checkUpdate?(): Promise<{ updateAvailable: boolean; version?: string }> /** Install updates (Tauri only) */ update?(): Promise /** Fetch override */ fetch?: typeof fetch /** Get the configured default server URL (platform-specific) */ getDefaultServerUrl?(): Promise | string | null /** Set the default server URL to use on app startup (platform-specific) */ setDefaultServerUrl?(url: string | null): Promise | void /** Parse markdown to HTML using native parser (desktop only, returns unprocessed code blocks) */ parseMarkdown?(markdown: string): Promise /** Webview zoom level (desktop only) */ webviewZoom?: Accessor /** Check if an editor app exists (desktop only) */ checkAppExists?(appName: string): Promise /** Read image from clipboard (desktop only) */ readClipboardImage?(): Promise } export const { use: usePlatform, provider: PlatformProvider } = createSimpleContext({ name: "Platform", init: (props: { value: Platform }) => { return props.value }, })