platform.tsx 878 B

12345678910111213141516171819202122232425
  1. import { createSimpleContext } from "@opencode-ai/ui/context"
  2. export type Platform = {
  3. /** Platform discriminator */
  4. platform: "web" | "tauri"
  5. /** Open native directory picker dialog (Tauri only) */
  6. openDirectoryPickerDialog?(opts?: { title?: string; multiple?: boolean }): Promise<string | string[] | null>
  7. /** Open native file picker dialog (Tauri only) */
  8. openFilePickerDialog?(opts?: { title?: string; multiple?: boolean }): Promise<string | string[] | null>
  9. /** Save file picker dialog (Tauri only) */
  10. saveFilePickerDialog?(opts?: { title?: string; defaultPath?: string }): Promise<string | null>
  11. /** Open a URL in the default browser */
  12. openLink(url: string): void
  13. }
  14. export const { use: usePlatform, provider: PlatformProvider } = createSimpleContext({
  15. name: "Platform",
  16. init: (props: { value: Platform }) => {
  17. return props.value
  18. },
  19. })