Export DesktopInterface from desktop and add PlatformContext
parent
923bf36593
commit
d531dff8d3
|
|
@ -23,6 +23,6 @@
|
|||
</script>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
<div id="root"></div>
|
||||
<script src="/src/index.tsx" type="module"></script>
|
||||
<script src="/src/entry.tsx" type="module"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
"description": "",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": "./src/index.tsx",
|
||||
".": "./src/index.ts",
|
||||
"./vite": "./vite.js"
|
||||
},
|
||||
"scripts": {
|
||||
|
|
|
|||
|
|
@ -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!,
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
@ -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
|
||||
}
|
||||
|
|
@ -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!,
|
||||
)
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
export { PlatformProvider, type Platform } from "./PlatformContext"
|
||||
export { DesktopInterface } from "./DesktopInterface"
|
||||
|
|
@ -23,6 +23,6 @@
|
|||
</script>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
<div id="root"></div>
|
||||
<script src="/src/index.ts" type="module"></script>
|
||||
<script src="/src/index.tsx" type="module"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use std::{
|
|||
sync::{Arc, Mutex},
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
use tauri::{App, AppHandle, Manager, RunEvent, WebviewUrl, WebviewWindow};
|
||||
use tauri::{AppHandle, Manager, RunEvent, WebviewUrl, WebviewWindow};
|
||||
use tauri_plugin_dialog::{DialogExt, MessageDialogButtons, MessageDialogResult};
|
||||
use tauri_plugin_shell::process::{CommandChild, CommandEvent};
|
||||
use tauri_plugin_shell::ShellExt;
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
import "@opencode-ai/desktop"
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
// @refresh reload
|
||||
import { render } from "solid-js/web"
|
||||
import { DesktopInterface, PlatformProvider, Platform } from "@opencode-ai/desktop"
|
||||
|
||||
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!,
|
||||
)
|
||||
|
|
@ -17,7 +17,10 @@
|
|||
"strict": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"noFallthroughCasesInSwitch": true
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
|
||||
"jsx": "preserve",
|
||||
"jsxImportSource": "solid-js"
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue