| import { createSimpleContext } from "@opencode-ai/ui/context" |
| import type { AsyncStorage, SyncStorage } from "@solid-primitives/storage" |
| import type { Accessor } from "solid-js" |
| import type { DesktopMenuAction } from "../desktop-menu" |
| import { ServerConnection } from "./server" |
| import type { WslServersPlatform } from "../wsl/types" |
| import type { UpdaterPlatform } from "../updater" |
| import type { DraftStore } from "@/utils/draft-store" |
|
|
| type PickerPaths = string | string[] | null |
| type OpenDirectoryPickerOptions = { title?: string; multiple?: boolean } |
| type OpenAttachmentPickerOptions = { |
| title?: string |
| multiple?: boolean |
| accept?: string[] |
| extensions?: string[] |
| defaultPath?: string |
| } |
| type SaveFilePickerOptions = { title?: string; defaultPath?: string } |
| type PlatformName = "web" | "desktop" |
| type DesktopOS = "macos" | "windows" | "linux" |
|
|
| export type FatalRendererErrorLog = { |
| error: string |
| url: string |
| version?: string |
| platform: PlatformName |
| os?: DesktopOS |
| } |
|
|
| type PlatformBase = { |
| |
| version?: string |
|
|
| |
| openExternal(url: string): void |
|
|
| |
| openPath?(path: string, app?: string): Promise<void> |
|
|
| |
| openLocalFile?(url: string): void |
|
|
| |
| revealPath?(path: string): Promise<boolean> |
|
|
| |
| restart(): Promise<void> |
|
|
| |
| notify(title: string, description?: string, onClick?: () => void): Promise<void> |
|
|
| |
| openAttachmentPickerDialog?( |
| opts: OpenAttachmentPickerOptions, |
| onFile: (file: File) => Promise<unknown>, |
| ): Promise<void> |
|
|
| |
| getPathForFile?(file: File): string |
|
|
| |
| saveFilePickerDialog?(opts?: SaveFilePickerOptions): Promise<string | null> |
|
|
| |
| storage?: (name?: string) => SyncStorage | AsyncStorage |
|
|
| |
| draftStore?: DraftStore |
|
|
| |
| windowID?: string |
|
|
| |
| updater?: UpdaterPlatform |
|
|
| |
| fetch?: typeof fetch |
|
|
| |
| getDefaultServer?(): Promise<ServerConnection.Key | null> |
|
|
| |
| setDefaultServer?(url: ServerConnection.Key | null): Promise<void> | void |
|
|
| |
| wslServers?: WslServersPlatform |
|
|
| |
| getDisplayBackend?(): Promise<DisplayBackend | null> | DisplayBackend | null |
|
|
| |
| setDisplayBackend?(backend: DisplayBackend): Promise<void> |
|
|
| |
| webviewZoom?: Accessor<number> |
|
|
| |
| windowFullscreen?: Accessor<boolean> |
|
|
| |
| getPinchZoomEnabled?(): Promise<boolean> | boolean |
|
|
| |
| setPinchZoomEnabled?(enabled: boolean): Promise<void> | void |
|
|
| |
| runDesktopMenuAction?(action: DesktopMenuAction): Promise<void> | void |
|
|
| |
| checkAppExists?(appName: string): Promise<boolean> |
|
|
| |
| readClipboardImage?(): Promise<File | null> |
|
|
| |
| exportDebugLogs?(): Promise<string> |
|
|
| |
| setForceFocus?(enabled: boolean): Promise<void> |
|
|
| |
| recordFatalRendererError?(error: FatalRendererErrorLog): Promise<void> |
| } |
|
|
| export type Platform = PlatformBase & |
| ( |
| | { platform: "web"; os?: never } |
| | { |
| platform: "desktop" |
| os?: DesktopOS |
| openDirectoryPickerDialog(opts?: OpenDirectoryPickerOptions): Promise<PickerPaths> |
| } |
| ) |
|
|
| export type DisplayBackend = "auto" | "wayland" |
|
|
| export const { use: usePlatform, provider: PlatformProvider } = createSimpleContext({ |
| name: "Platform", |
| init: (props: { value: Platform }) => { |
| return props.value |
| }, |
| }) |
|
|