feat(tui): add v2 plugin runtime
This commit is contained in:
parent
5c5579e90c
commit
4a93972a78
63 changed files with 1722 additions and 1701 deletions
|
|
@ -86,26 +86,36 @@ export interface Data {
|
|||
}
|
||||
}
|
||||
|
||||
export interface RouteDefinition {
|
||||
export type Route =
|
||||
| { readonly type: "home" }
|
||||
| { readonly type: "session"; readonly sessionID: string }
|
||||
| {
|
||||
readonly type: "plugin"
|
||||
readonly id: string
|
||||
readonly name: string
|
||||
readonly data?: Record<string, any>
|
||||
}
|
||||
|
||||
export type Destination = Route | Omit<Extract<Route, { readonly type: "plugin" }>, "id">
|
||||
|
||||
export interface Page {
|
||||
readonly name: string
|
||||
readonly render: (input: { readonly params: any }) => JSX.Element
|
||||
readonly render: (input: { readonly data?: Record<string, any> }) => JSX.Element
|
||||
}
|
||||
|
||||
export interface Route {
|
||||
register(definition: RouteDefinition): () => void
|
||||
navigate(input: { readonly name: string; readonly params?: any }): void
|
||||
current(): {
|
||||
readonly name: string
|
||||
readonly params: any
|
||||
}
|
||||
}
|
||||
export type Slot = (props: Record<string, any>) => JSX.Element
|
||||
|
||||
export interface UI {
|
||||
readonly route: Route
|
||||
readonly router: {
|
||||
register(page: Page): () => void
|
||||
navigate(destination: Destination): void
|
||||
current(): Route
|
||||
}
|
||||
readonly slot: (name: string, render: Slot) => () => void
|
||||
}
|
||||
|
||||
export interface Context {
|
||||
readonly options: Readonly<Record<string, unknown>>
|
||||
readonly options: Readonly<Record<string, any>>
|
||||
readonly client: OpenCodeClient
|
||||
readonly data: Data
|
||||
readonly ui: UI
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue