@vestra-player/sdk 1.7.7 → 1.7.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -0
- package/dist/api-requests.js +18 -0
- package/dist/capabilities.d.ts +9 -0
- package/dist/capabilities.js +1 -0
- package/dist/capability-rules.d.ts +3 -0
- package/dist/capability-rules.js +47 -21
- package/dist/commands.d.ts +27 -6
- package/dist/commands.js +19 -5
- package/dist/docs-tree.json.gz +0 -0
- package/dist/host-capabilities.js +71 -0
- package/dist/manifest.js +12 -1
- package/dist/media.d.ts +108 -1
- package/dist/media.js +20 -0
- package/dist/player-runtime.d.ts +1 -0
- package/dist/player-runtime.js +1 -0
- package/dist/plugin/commands.d.ts +2 -1
- package/dist/plugin/commands.js +131 -4
- package/dist/plugin/media.d.ts +26 -0
- package/dist/plugin/media.js +166 -0
- package/dist/plugin/player.d.ts +7 -1
- package/dist/plugin/player.js +3 -1
- package/dist/plugin/scope.d.ts +1 -0
- package/dist/plugin/scope.js +2 -1
- package/dist/plugin/testing/commands.d.ts +7 -0
- package/dist/plugin/testing/commands.js +211 -0
- package/dist/plugin/testing/index.d.ts +170 -3
- package/dist/plugin/testing/index.js +120 -4
- package/dist/plugin/testing/internals.d.ts +27 -0
- package/dist/plugin/testing/internals.js +14 -1
- package/dist/plugin/testing/jobs.js +348 -1
- package/dist/plugin/testing/media.js +29 -0
- package/dist/plugin/types/base.d.ts +10 -7
- package/dist/plugin/types/commands.d.ts +412 -1
- package/dist/plugin/types/snapshots.d.ts +511 -1
- package/dist/wire.d.ts +43 -0
- package/dist/wire.js +6 -0
- package/llms.txt +3 -3
- package/package.json +1 -1
- package/slint/vestra/icons.slint +4 -0
|
@@ -284,7 +284,7 @@ export type MenuId = "open" | "playback" | "subtitles" | "video" | "audio" | "sc
|
|
|
284
284
|
*
|
|
285
285
|
* @category Commands
|
|
286
286
|
*/
|
|
287
|
-
export type BarButtonIcon = "play" | "pause" | "stop" | "back" | "forward" | "open" | "volume" | "mute" | "playlist" | "detach" | "attach" | "close" | "failed" | "move-top" | "move-up" | "move-down" | "move-bottom" | "search" | "chapter" | "bookmark" | "check-task" | "check-box" | "menu-check" | "submenu" | "scroll-up" | "scroll-down" | "caret-down" | "sort-asc" | "sort-desc" | "tag-remove" | "preview-play" | "add" | "remove" | "sort" | "fullscreen" | "exit-fullscreen" | "store" | "ai";
|
|
287
|
+
export type BarButtonIcon = "play" | "pause" | "stop" | "back" | "forward" | "open" | "volume" | "mute" | "playlist" | "detach" | "attach" | "close" | "failed" | "move-top" | "move-up" | "move-down" | "move-bottom" | "search" | "chapter" | "bookmark" | "check-task" | "check-box" | "menu-check" | "submenu" | "scroll-up" | "scroll-down" | "caret-down" | "sort-asc" | "sort-desc" | "tag-remove" | "preview-play" | "add" | "remove" | "sort" | "fullscreen" | "exit-fullscreen" | "store" | "ai" | "sliders" | "search-ai";
|
|
288
288
|
/**
|
|
289
289
|
* A command's button on the bottom bar: {@link CommandOptions.button}.
|
|
290
290
|
*
|
|
@@ -563,6 +563,16 @@ export interface CommandOptions {
|
|
|
563
563
|
* 0–999 or a button without a path.
|
|
564
564
|
*/
|
|
565
565
|
button?: CommandButton;
|
|
566
|
+
/**
|
|
567
|
+
* The command cannot be undone: it deletes or clears the user's data,
|
|
568
|
+
* closes what is open or quits (default false). When another plugin runs
|
|
569
|
+
* it through {@link Commands.run}, the player asks the user first; a menu
|
|
570
|
+
* pick, a key or the command palette runs it as before.
|
|
571
|
+
*
|
|
572
|
+
* @player 0.7.6
|
|
573
|
+
* @since 1.7.9
|
|
574
|
+
*/
|
|
575
|
+
destructive?: boolean;
|
|
566
576
|
/**
|
|
567
577
|
* Whether the command can run (default true): a value, a function, or a
|
|
568
578
|
* {@link Condition} the player evaluates (`plugin.when`).
|
|
@@ -831,6 +841,407 @@ export interface Commands {
|
|
|
831
841
|
* @since 1.6.6
|
|
832
842
|
*/
|
|
833
843
|
keys(id: string): readonly string[];
|
|
844
|
+
/**
|
|
845
|
+
* List every command the command palette lists, the player's own and
|
|
846
|
+
* every plugin's, with its state now. **Built-in plugins only.**
|
|
847
|
+
*
|
|
848
|
+
* @remarks
|
|
849
|
+
* The palette's table as data: for a plugin that runs commands for the
|
|
850
|
+
* user (an assistant, a macro recorder, a remote control) or shows how to
|
|
851
|
+
* reach them (a tutorial that says which key opens a window). `revision`
|
|
852
|
+
* changes whenever a command is added, removed or changes state, so a copy
|
|
853
|
+
* with the same revision is still current.
|
|
854
|
+
*
|
|
855
|
+
* @example Find the key that opens a window
|
|
856
|
+
* A tutorial panel tells the user which key opens Subtitle Tuning. `list`
|
|
857
|
+
* returns the palette's rows with their places and current keys; the
|
|
858
|
+
* panel picks the row by its global id and shows its first key.
|
|
859
|
+
* ```ts
|
|
860
|
+
* try {
|
|
861
|
+
* const { commands } = await plugin.commands.list();
|
|
862
|
+
* const row = commands.find((each) => each.id === "vestra.subtitles/tuning");
|
|
863
|
+
* if (row?.keys[0]) await plugin.osd.show("Press {}", [row.keys[0]]);
|
|
864
|
+
* } catch (error) {
|
|
865
|
+
* // `capability`: not a built-in plugin, or `commands.run` not declared.
|
|
866
|
+
* if ((error as PluginError).code !== "capability") throw error;
|
|
867
|
+
* }
|
|
868
|
+
* ```
|
|
869
|
+
*
|
|
870
|
+
* @capability commands.run (built-in plugins only)
|
|
871
|
+
* @throws `capability` (rejects) The manifest does not declare
|
|
872
|
+
* `commands.run`, or the plugin is not built into the player.
|
|
873
|
+
* @player 0.7.6
|
|
874
|
+
* @since 1.7.9
|
|
875
|
+
*/
|
|
876
|
+
list(): Promise<CommandList>;
|
|
877
|
+
/**
|
|
878
|
+
* Run any command the palette lists, as the palette runs it, for a request
|
|
879
|
+
* the user made. **Built-in plugins only.**
|
|
880
|
+
*
|
|
881
|
+
* @remarks
|
|
882
|
+
* Every run needs a ticket: the player mints one only for a user action
|
|
883
|
+
* ({@link PaletteLeadRun.ticket}, Enter on the palette's lead row), so a
|
|
884
|
+
* plugin cannot run commands on its own. The ticket ends with
|
|
885
|
+
* {@link PaletteLead.done}, with the plugin's next lead run, when the
|
|
886
|
+
* plugin stops, or 120 s after it was given or last used. The player
|
|
887
|
+
* applies the palette's checks (enabled, not busy), shows an on-screen
|
|
888
|
+
* line naming the plugin and the command (`Vestra Player AI · 1/2 ·
|
|
889
|
+
* Playback: Mute`), and asks the user first (Run / Don't Run) before a
|
|
890
|
+
* command declared {@link CommandOptions.destructive}, the player's Close
|
|
891
|
+
* and Quit, anything in the Settings and Plugins menus, and every command
|
|
892
|
+
* of a plugin that is not built in. Runs are limited to 4 a second and 30
|
|
893
|
+
* per ticket, and 120 a minute per plugin. The run is not added to the
|
|
894
|
+
* palette's recent list.
|
|
895
|
+
*
|
|
896
|
+
* @param id - The command's global id, as {@link CommandInfo.id}:
|
|
897
|
+
* `<manifest id>/<local id>`, `host/<id>` for the player's own.
|
|
898
|
+
* @param options - `ticket`: from the user action this run is for.
|
|
899
|
+
* `step` and `of`: this is step `step` of `of` (1-based), shown in the
|
|
900
|
+
* on-screen line.
|
|
901
|
+
* @returns `{ ran: true }` once the command was started, or
|
|
902
|
+
* `{ ran: false, declined: true }` when the user chose Don't Run.
|
|
903
|
+
*
|
|
904
|
+
* @example Run the commands of one request
|
|
905
|
+
* The user typed "fullscreen and mute" into the palette's lead row; the
|
|
906
|
+
* plugin runs the two commands it chose for it. The ticket comes with the
|
|
907
|
+
* lead's run event and covers every run of this request; `done` ends it.
|
|
908
|
+
* A declined confirmation or a failure stops the request.
|
|
909
|
+
* ```ts
|
|
910
|
+
* declare const lead: PaletteLead;
|
|
911
|
+
* // ---cut---
|
|
912
|
+
* lead.onRun(async ({ ticket }) => {
|
|
913
|
+
* const ids = ["host/fullscreen", "host/mute"]; // chosen for the request
|
|
914
|
+
* try {
|
|
915
|
+
* for (const [index, id] of ids.entries()) {
|
|
916
|
+
* const result = await plugin.commands.run(id, { ticket, step: index + 1, of: ids.length });
|
|
917
|
+
* if (!result.ran) break; // the user chose Don't Run
|
|
918
|
+
* }
|
|
919
|
+
* } catch (error) {
|
|
920
|
+
* // `disabled`, `busy`, `missing`, `ticket` (expired), `limit` (rate).
|
|
921
|
+
* await plugin.osd.show("Stopped: {}", [(error as PluginError).message]);
|
|
922
|
+
* } finally {
|
|
923
|
+
* await lead.done(ticket);
|
|
924
|
+
* }
|
|
925
|
+
* });
|
|
926
|
+
* ```
|
|
927
|
+
*
|
|
928
|
+
* @capability commands.run (built-in plugins only)
|
|
929
|
+
* @throws `capability` (rejects) The manifest does not declare
|
|
930
|
+
* `commands.run`, or the plugin is not built into the player.
|
|
931
|
+
* @throws `ticket` (rejects) No ticket, or it ended or expired.
|
|
932
|
+
* @throws `missing` (rejects) No command has this id.
|
|
933
|
+
* @throws `disabled` (rejects) The command is disabled now; `message` has
|
|
934
|
+
* its reason.
|
|
935
|
+
* @throws `busy` (rejects) The command is busy, or its confirmation
|
|
936
|
+
* cannot be shown while another alert is open.
|
|
937
|
+
* @throws `limit` (rejects) Over the rate limits above.
|
|
938
|
+
* @throws `invalid` (rejects) Only one of `step` and `of`, or not
|
|
939
|
+
* whole numbers with 1 ≤ `step` ≤ `of` ≤ 99; or `id` is the command
|
|
940
|
+
* palette itself (`host/palette`).
|
|
941
|
+
* @player 0.7.6
|
|
942
|
+
* @since 1.7.9
|
|
943
|
+
*/
|
|
944
|
+
run(id: string, options: CommandRunOptions): Promise<CommandRunResult>;
|
|
945
|
+
}
|
|
946
|
+
/**
|
|
947
|
+
* How {@link Commands.run} runs a command.
|
|
948
|
+
*
|
|
949
|
+
* @since 1.7.9
|
|
950
|
+
* @category Commands
|
|
951
|
+
*/
|
|
952
|
+
export interface CommandRunOptions {
|
|
953
|
+
/** The ticket of the user action the run is for ({@link PaletteLeadRun.ticket}). */
|
|
954
|
+
ticket: string;
|
|
955
|
+
/** This run's step number (1–99), for the on-screen line; with `of`. */
|
|
956
|
+
step?: number;
|
|
957
|
+
/** The request's number of steps (`step`–99); with `step`. */
|
|
958
|
+
of?: number;
|
|
959
|
+
}
|
|
960
|
+
/**
|
|
961
|
+
* The outcome of {@link Commands.run}: the command started, or the user
|
|
962
|
+
* declined the confirmation.
|
|
963
|
+
*
|
|
964
|
+
* @since 1.7.9
|
|
965
|
+
* @category Commands
|
|
966
|
+
*/
|
|
967
|
+
export type CommandRunResult = {
|
|
968
|
+
/** The command was started. */
|
|
969
|
+
ran: true;
|
|
970
|
+
} | {
|
|
971
|
+
/** The command was not started. */
|
|
972
|
+
ran: false;
|
|
973
|
+
/** The user chose Don't Run in the confirmation. */
|
|
974
|
+
declined: true;
|
|
975
|
+
};
|
|
976
|
+
/**
|
|
977
|
+
* The command palette's table, from {@link Commands.list}.
|
|
978
|
+
*
|
|
979
|
+
* @since 1.7.9
|
|
980
|
+
* @category Commands
|
|
981
|
+
*/
|
|
982
|
+
export interface CommandList {
|
|
983
|
+
/** The table's revision: the same number means the same table. */
|
|
984
|
+
revision: number;
|
|
985
|
+
/**
|
|
986
|
+
* Every command the palette lists, in no particular order: not a
|
|
987
|
+
* panel-only command, nor a disabled one without a reason.
|
|
988
|
+
*/
|
|
989
|
+
commands: CommandInfo[];
|
|
990
|
+
}
|
|
991
|
+
/**
|
|
992
|
+
* One command of the palette's table ({@link CommandList}), with its texts
|
|
993
|
+
* as the palette shows them in the interface language.
|
|
994
|
+
*
|
|
995
|
+
* @since 1.7.9
|
|
996
|
+
* @category Commands
|
|
997
|
+
*/
|
|
998
|
+
export interface CommandInfo {
|
|
999
|
+
/** The global id: `<manifest id>/<local id>`, `host/<id>` for the player's own. */
|
|
1000
|
+
id: string;
|
|
1001
|
+
/** The row's text, `Category: Title`, as shown. */
|
|
1002
|
+
label: string;
|
|
1003
|
+
/** The same in English source text. */
|
|
1004
|
+
labelSource: string;
|
|
1005
|
+
/** The command's title as shown. */
|
|
1006
|
+
title: string;
|
|
1007
|
+
/**
|
|
1008
|
+
* The row's category as shown: the declared category, else the menu path
|
|
1009
|
+
* above the command (`Video ▸ Snapshot`), else the plugin's name.
|
|
1010
|
+
*/
|
|
1011
|
+
category: string;
|
|
1012
|
+
/** Its menu path as shown, empty for a command outside the menus. */
|
|
1013
|
+
path: string[];
|
|
1014
|
+
/**
|
|
1015
|
+
* Where it lives: the window its `home` command opens, `Menu`, the menu
|
|
1016
|
+
* above it (`Video ▸`), or `""` outside the menus.
|
|
1017
|
+
*/
|
|
1018
|
+
place: string;
|
|
1019
|
+
/** Its current keys as the menus write them. */
|
|
1020
|
+
keys: string[];
|
|
1021
|
+
/** The owning plugin's name as shown, `Vestra Player` for the player's own. */
|
|
1022
|
+
plugin: string;
|
|
1023
|
+
/** The owner is the player or a built-in plugin. */
|
|
1024
|
+
builtin: boolean;
|
|
1025
|
+
/** It can run now. */
|
|
1026
|
+
enabled: boolean;
|
|
1027
|
+
/** Why it is disabled, as shown (only while disabled). */
|
|
1028
|
+
reason?: string;
|
|
1029
|
+
/** It has a check mark or a radio dot. */
|
|
1030
|
+
checkable: boolean;
|
|
1031
|
+
/** The check mark now (with `checkable`). */
|
|
1032
|
+
checked?: boolean;
|
|
1033
|
+
/** The mark is a radio dot. */
|
|
1034
|
+
radio: boolean;
|
|
1035
|
+
/** Its separator group in the menu. */
|
|
1036
|
+
group: string;
|
|
1037
|
+
/** It is busy now. */
|
|
1038
|
+
busy: boolean;
|
|
1039
|
+
/** {@link Commands.run} asks the user before running it. */
|
|
1040
|
+
dangerous: boolean;
|
|
1041
|
+
}
|
|
1042
|
+
/**
|
|
1043
|
+
* `plugin.palette`: the command palette's lead row.
|
|
1044
|
+
*
|
|
1045
|
+
* @remarks
|
|
1046
|
+
* The palette's first row hands what the user typed to a plugin: a
|
|
1047
|
+
* calculator ("3.5 GB in MB"), a library or history search, jump to a time,
|
|
1048
|
+
* an assistant that runs commands for a sentence. There is one lead in the
|
|
1049
|
+
* player, and only a built-in plugin can hold it.
|
|
1050
|
+
*
|
|
1051
|
+
* @capability palette.lead (built-in plugins only)
|
|
1052
|
+
*
|
|
1053
|
+
* @example Answer typed time stamps from the palette
|
|
1054
|
+
* The palette's first row reads "Go to: 12:30"; Enter seeks there. `lead`
|
|
1055
|
+
* puts the row up; the player sends the typed text with Enter, and the
|
|
1056
|
+
* plugin ends the request with `done`.
|
|
1057
|
+
* ```ts
|
|
1058
|
+
* // Put up the row once, in activate: the player keeps it while stopped.
|
|
1059
|
+
* const lead = plugin.palette.lead({ title: "Go to", icon: "search" });
|
|
1060
|
+
* lead.onRun(async ({ query, ticket }) => {
|
|
1061
|
+
* const [minutes = 0, seconds = 0] = query.split(":").map(Number); // "12:30"
|
|
1062
|
+
* await plugin.player.seek(minutes * 60 + seconds);
|
|
1063
|
+
* await lead.done(ticket); // this request needs no command runs
|
|
1064
|
+
* });
|
|
1065
|
+
* ```
|
|
1066
|
+
*
|
|
1067
|
+
* @player 0.7.6
|
|
1068
|
+
* @since 1.7.9
|
|
1069
|
+
* @category Commands
|
|
1070
|
+
*/
|
|
1071
|
+
export interface Palette {
|
|
1072
|
+
/**
|
|
1073
|
+
* Put up the palette's lead row. **Built-in plugins only.**
|
|
1074
|
+
*
|
|
1075
|
+
* The player keeps the row while the plugin is stopped and starts the
|
|
1076
|
+
* plugin for a run, so call it in `activate`. Disposing the handle (or
|
|
1077
|
+
* its scope) removes the row.
|
|
1078
|
+
*
|
|
1079
|
+
* @example See Palette
|
|
1080
|
+
* {@link Palette}
|
|
1081
|
+
*
|
|
1082
|
+
* @capability palette.lead (built-in plugins only)
|
|
1083
|
+
* @throws `capability` (through `ready`) The manifest does not declare
|
|
1084
|
+
* `palette.lead`, or the plugin is not built into the player.
|
|
1085
|
+
* @throws `conflict` (through `ready`) Another plugin holds the lead.
|
|
1086
|
+
* @throws `invalid` (through `ready`) A text over its length.
|
|
1087
|
+
* @player 0.7.6
|
|
1088
|
+
* @since 1.7.9
|
|
1089
|
+
*/
|
|
1090
|
+
lead(options: PaletteLeadOptions): PaletteLead;
|
|
1091
|
+
}
|
|
1092
|
+
/**
|
|
1093
|
+
* What the palette's lead row shows ({@link Palette.lead}). Texts are
|
|
1094
|
+
* English source text or a {@link Text}, translated like command titles.
|
|
1095
|
+
*
|
|
1096
|
+
* @since 1.7.9
|
|
1097
|
+
* @category Commands
|
|
1098
|
+
*/
|
|
1099
|
+
export interface PaletteLeadOptions {
|
|
1100
|
+
/** The row reads `title: <typed text>`, or `title` alone with nothing typed (1–40 characters). */
|
|
1101
|
+
title: string | Text;
|
|
1102
|
+
/** A name of the player's icon set ({@link BarButtonIcon}) or an image from {@link Ui.image}. */
|
|
1103
|
+
icon: BarButtonIcon | ImageRef;
|
|
1104
|
+
/** The search field's placeholder (up to 60 characters). */
|
|
1105
|
+
placeholder?: string | Text;
|
|
1106
|
+
/** Dimmed after `title` while nothing is typed (up to 80 characters). */
|
|
1107
|
+
empty?: string | Text;
|
|
1108
|
+
/** On the right of the row ("Set up a model first"; up to 40 characters). */
|
|
1109
|
+
note?: string | Text;
|
|
1110
|
+
/**
|
|
1111
|
+
* Replaces the row while nothing is typed (a running request; the cursor
|
|
1112
|
+
* starts on it); `null` or absent: none. Its run event has `status: true`.
|
|
1113
|
+
*/
|
|
1114
|
+
status?: {
|
|
1115
|
+
/** The status text (up to 80 characters). */
|
|
1116
|
+
text: string | Text;
|
|
1117
|
+
/** On the right of the row (up to 40 characters). */
|
|
1118
|
+
note?: string | Text;
|
|
1119
|
+
} | null;
|
|
1120
|
+
}
|
|
1121
|
+
/**
|
|
1122
|
+
* The user activated the lead row: the data of {@link PaletteLead.onRun}.
|
|
1123
|
+
*
|
|
1124
|
+
* @since 1.7.9
|
|
1125
|
+
* @category Commands
|
|
1126
|
+
*/
|
|
1127
|
+
export interface PaletteLeadRun {
|
|
1128
|
+
/** What was typed in the palette. */
|
|
1129
|
+
query: string;
|
|
1130
|
+
/** Shift+Enter: the palette stays open. */
|
|
1131
|
+
keep: boolean;
|
|
1132
|
+
/**
|
|
1133
|
+
* The ticket of this user action, for {@link Commands.run} and
|
|
1134
|
+
* {@link PaletteLead.done}.
|
|
1135
|
+
*/
|
|
1136
|
+
ticket: string;
|
|
1137
|
+
/** The user activated the status row ({@link PaletteLeadOptions.status}), for example to stop. */
|
|
1138
|
+
status: boolean;
|
|
1139
|
+
}
|
|
1140
|
+
/**
|
|
1141
|
+
* The palette's lead row, from {@link Palette.lead}. Disposing it removes
|
|
1142
|
+
* the row.
|
|
1143
|
+
*
|
|
1144
|
+
* @remarks
|
|
1145
|
+
* Holds the row while the scope lives. `update` changes what it shows (a
|
|
1146
|
+
* status while a request runs, a note while it cannot run); `onRun` hears
|
|
1147
|
+
* each activation; `done` ends the ticket of a finished request.
|
|
1148
|
+
*
|
|
1149
|
+
* @capability palette.lead (built-in plugins only)
|
|
1150
|
+
*
|
|
1151
|
+
* @example Show a status while a request runs
|
|
1152
|
+
* While the plugin works on a request the row shows "Working… (Enter to
|
|
1153
|
+
* stop)"; Enter on it stops the work. The status row replaces the lead
|
|
1154
|
+
* while nothing is typed; its run event has `status: true`.
|
|
1155
|
+
* ```ts
|
|
1156
|
+
* const lead = plugin.palette.lead({ title: "Ask", icon: "search" });
|
|
1157
|
+
* let stop = new AbortController();
|
|
1158
|
+
* lead.onRun(async ({ query, ticket, status }) => {
|
|
1159
|
+
* if (status) return stop.abort(); // Enter on the status row
|
|
1160
|
+
* stop = new AbortController();
|
|
1161
|
+
* await lead.update({ title: "Ask", icon: "search", status: { text: "Working… (Enter to stop)" } });
|
|
1162
|
+
* try {
|
|
1163
|
+
* await plugin.osd.show("Asked: {}", [query]);
|
|
1164
|
+
* } finally {
|
|
1165
|
+
* await lead.update({ title: "Ask", icon: "search" });
|
|
1166
|
+
* await lead.done(ticket);
|
|
1167
|
+
* }
|
|
1168
|
+
* });
|
|
1169
|
+
* ```
|
|
1170
|
+
*
|
|
1171
|
+
* @player 0.7.6
|
|
1172
|
+
* @since 1.7.9
|
|
1173
|
+
* @category Commands
|
|
1174
|
+
*/
|
|
1175
|
+
export interface PaletteLead extends Disposable {
|
|
1176
|
+
/**
|
|
1177
|
+
* Settles when the player has the row.
|
|
1178
|
+
*
|
|
1179
|
+
* @throws `capability` (rejects) Not declared, or not a built-in plugin.
|
|
1180
|
+
* @throws `conflict` (rejects) Another plugin holds the lead.
|
|
1181
|
+
* @throws `invalid` (rejects) A text over its length.
|
|
1182
|
+
*/
|
|
1183
|
+
readonly ready: Promise<void>;
|
|
1184
|
+
/**
|
|
1185
|
+
* Replace what the row shows.
|
|
1186
|
+
*
|
|
1187
|
+
* @example See PaletteLead
|
|
1188
|
+
* {@link PaletteLead}
|
|
1189
|
+
*
|
|
1190
|
+
* @capability palette.lead (built-in plugins only)
|
|
1191
|
+
* @throws `invalid` (rejects) A text over its length.
|
|
1192
|
+
* @throws `capability` (rejects) The row was refused (see `ready`).
|
|
1193
|
+
* @since 1.7.9
|
|
1194
|
+
*/
|
|
1195
|
+
update(options: PaletteLeadOptions): Promise<void>;
|
|
1196
|
+
/**
|
|
1197
|
+
* Listen to the user activating the row (Enter, Shift+Enter or a click).
|
|
1198
|
+
* The player starts a stopped plugin for it.
|
|
1199
|
+
*
|
|
1200
|
+
* @example Keep the palette open for another conversion
|
|
1201
|
+
* A unit converter shows its answer and, after Shift+Enter, leaves the
|
|
1202
|
+
* palette open for the next one. The listener gets the typed text and
|
|
1203
|
+
* `keep`; the player closes the palette on Enter by itself.
|
|
1204
|
+
* ```ts
|
|
1205
|
+
* declare const lead: PaletteLead;
|
|
1206
|
+
* // ---cut---
|
|
1207
|
+
* lead.onRun(async ({ query, keep, ticket }) => {
|
|
1208
|
+
* const gigabytes = Number.parseFloat(query); // "3.5 GB in MB"
|
|
1209
|
+
* await plugin.osd.show("{} MB", [gigabytes * 1024]);
|
|
1210
|
+
* if (keep) await plugin.osd.show("Type the next value");
|
|
1211
|
+
* await lead.done(ticket);
|
|
1212
|
+
* });
|
|
1213
|
+
* ```
|
|
1214
|
+
*
|
|
1215
|
+
* @capability palette.lead (built-in plugins only)
|
|
1216
|
+
* @since 1.7.9
|
|
1217
|
+
*/
|
|
1218
|
+
onRun(listener: (run: PaletteLeadRun) => void): Disposable;
|
|
1219
|
+
/**
|
|
1220
|
+
* End a request's ticket: {@link Commands.run} refuses it from now on.
|
|
1221
|
+
*
|
|
1222
|
+
* @example End a request when it fails
|
|
1223
|
+
* A macro plugin stops at the first command that fails and ends the
|
|
1224
|
+
* ticket, so nothing more runs for this request. `done` ends the ticket
|
|
1225
|
+
* at once; without it the ticket would end 120 s after its last run.
|
|
1226
|
+
* ```ts
|
|
1227
|
+
* declare const lead: PaletteLead;
|
|
1228
|
+
* // ---cut---
|
|
1229
|
+
* lead.onRun(async ({ ticket }) => {
|
|
1230
|
+
* try {
|
|
1231
|
+
* await plugin.commands.run("host/mute", { ticket });
|
|
1232
|
+
* } catch {
|
|
1233
|
+
* await plugin.osd.show("Macro stopped"); // ticket, limit, disabled…
|
|
1234
|
+
* } finally {
|
|
1235
|
+
* await lead.done(ticket);
|
|
1236
|
+
* }
|
|
1237
|
+
* });
|
|
1238
|
+
* ```
|
|
1239
|
+
*
|
|
1240
|
+
* @capability palette.lead (built-in plugins only)
|
|
1241
|
+
* @throws `capability` (rejects) The manifest does not declare `palette.lead`.
|
|
1242
|
+
* @since 1.7.9
|
|
1243
|
+
*/
|
|
1244
|
+
done(ticket: string): Promise<void>;
|
|
834
1245
|
}
|
|
835
1246
|
/**
|
|
836
1247
|
* The core's basic playback actions (menu commands owned by the player),
|