()
| 10 | import { createSlots, type HostSlots } from "./slots" |
| 11 | |
| 12 | export function createPluginRuntime() { |
| 13 | const [commands, setCommands] = createSignal<PluginRuntimeCommands>(emptyCommands) |
| 14 | const [status, setStatus] = createSignal<ReadonlyArray<TuiPluginStatus>>([]) |
| 15 | const slots = createSlots() |
| 16 | |
| 17 | return { |
| 18 | Slot: slots.Slot, |
| 19 | routes: createPluginRoutes(), |
| 20 | commands, |
| 21 | status, |
| 22 | update(input: { commands?: PluginRuntimeCommands; status?: ReadonlyArray<TuiPluginStatus> }) { |
| 23 | if (input.commands) setCommands(input.commands) |
| 24 | if (input.status) setStatus(input.status) |
| 25 | }, |
| 26 | clear() { |
| 27 | setCommands(emptyCommands) |
| 28 | setStatus([]) |
| 29 | slots.clear() |
| 30 | }, |
| 31 | setupSlots(api: TuiPluginApi): HostSlots { |
| 32 | return slots.setup(api) |
| 33 | }, |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | export type PluginRuntimeCommands = { |
| 38 | activate: (id: string) => Promise<boolean> |
no test coverage detected