1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
// @refresh reload
import { render } from "solid-js/web"
import { App, PlatformProvider, Platform } from "@opencode-ai/desktop"
import { runUpdater } from "./updater"
import { onMount } from "solid-js"
import { open, save } from "@tauri-apps/plugin-dialog"
import { open as shellOpen } from "@tauri-apps/plugin-shell"
import { type as ostype } from "@tauri-apps/plugin-os"
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 = {
platform: "tauri",
async openDirectoryPickerDialog(opts) {
const result = await open({
directory: true,
multiple: opts?.multiple ?? false,
title: opts?.title ?? "Choose a folder",
})
return result
},
async openFilePickerDialog(opts) {
const result = await open({
directory: false,
multiple: opts?.multiple ?? false,
title: opts?.title ?? "Choose a file",
})
return result
},
async saveFilePickerDialog(opts) {
const result = await save({
title: opts?.title ?? "Save file",
defaultPath: opts?.defaultPath,
})
return result
},
openLink(url: string) {
shellOpen(url)
},
}
render(() => {
onMount(() => {
if (window.__OPENCODE__?.updaterEnabled) runUpdater()
})
return (
<PlatformProvider value={platform}>
{ostype() === "macos" && (
<div class="bg-background-base border-b border-border-weak-base h-8" data-tauri-drag-region />
)}
<App />
</PlatformProvider>
)
}, root!)
|