Plugin command API shim (#26564)

This commit is contained in:
Sebastian 2026-05-09 21:56:49 +02:00 committed by GitHub
parent dcdbdb218f
commit 9a8b54fe62
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 225 additions and 0 deletions

View file

@ -77,6 +77,42 @@ export type TuiKeys = {
export type TuiKeymap = Keymap<Renderable, KeyEvent>
/**
* Legacy `api.command` shape kept so v1 plugins can initialize. Remove in v2.
*
* @deprecated Use `api.keymap.registerLayer({ commands, bindings })` instead.
*/
export type TuiCommand = {
title: string
value: string
description?: string
category?: string
keybind?: string
suggested?: boolean
hidden?: boolean
enabled?: boolean
slash?: {
name: string
aliases?: string[]
}
onSelect?: (dialog?: TuiDialogStack) => void | Promise<void>
}
/**
* Legacy `api.command` API kept so v1 plugins can initialize. Remove in v2.
*
* @deprecated Use `api.keymap.registerLayer`, `api.keymap.dispatchCommand`, and
* `api.keymap.dispatchCommand("command.palette.show")` instead.
*/
export type TuiCommandApi = {
/** @deprecated Use `api.keymap.registerLayer({ commands, bindings })` instead. */
register: (cb: () => TuiCommand[]) => () => void
/** @deprecated Use `api.keymap.dispatchCommand(name)` instead. */
trigger: (value: string) => void
/** @deprecated Use `api.keymap.dispatchCommand("command.palette.show")` instead. */
show: () => void
}
export type TuiDialogProps = {
size?: "medium" | "large" | "xlarge"
onClose: () => void
@ -461,6 +497,13 @@ export type TuiWorkspace = {
export type TuiPluginApi = {
app: TuiApp
/**
* Legacy `api.command` API kept so v1 plugins can initialize. Remove in v2.
*
* @deprecated Use `api.keymap.registerLayer`, `api.keymap.dispatchCommand`, and
* `api.keymap.dispatchCommand("command.palette.show")` instead.
*/
command?: TuiCommandApi
keys: TuiKeys
keymap: TuiKeymap
route: {