feat(plugin): expose app metadata (#38179)
This commit is contained in:
parent
2ed8fe5960
commit
8de40be6ea
71 changed files with 477 additions and 286 deletions
|
|
@ -1,5 +1,11 @@
|
|||
import { createComponent, createContext, type JSX, useContext } from "solid-js"
|
||||
|
||||
export type TuiApp = Readonly<{
|
||||
name: string
|
||||
version: string
|
||||
channel: string
|
||||
}>
|
||||
|
||||
export type TuiPaths = Readonly<{
|
||||
cwd: string
|
||||
home: string
|
||||
|
|
@ -23,6 +29,7 @@ export type TuiLifecycle = Readonly<{
|
|||
}>
|
||||
|
||||
const PathsContext = createContext<TuiPaths>()
|
||||
const AppContext = createContext<TuiApp>()
|
||||
const TerminalEnvironmentContext = createContext<TuiTerminalEnvironment>()
|
||||
const StartupContext = createContext<TuiStartup>()
|
||||
const LifecycleContext = createContext<TuiLifecycle>()
|
||||
|
|
@ -40,6 +47,10 @@ export function TuiPathsProvider(props: { value: TuiPaths; children: JSX.Element
|
|||
return provider(PathsContext, props.value, () => props.children)
|
||||
}
|
||||
|
||||
export function TuiAppProvider(props: { value: TuiApp; children: JSX.Element }) {
|
||||
return provider(AppContext, props.value, () => props.children)
|
||||
}
|
||||
|
||||
export function TuiTerminalEnvironmentProvider(props: { value: TuiTerminalEnvironment; children: JSX.Element }) {
|
||||
return provider(TerminalEnvironmentContext, props.value, () => props.children)
|
||||
}
|
||||
|
|
@ -62,6 +73,10 @@ export function useTuiPaths() {
|
|||
return required(PathsContext, "TuiPathsProvider")
|
||||
}
|
||||
|
||||
export function useTuiApp() {
|
||||
return required(AppContext, "TuiAppProvider")
|
||||
}
|
||||
|
||||
export function useTuiTerminalEnvironment() {
|
||||
return required(TerminalEnvironmentContext, "TuiTerminalEnvironmentProvider")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue