@vestra-player/sdk 1.7.8 → 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 +16 -0
- package/dist/api-requests.js +3 -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 +1 -0
- package/dist/commands.d.ts +15 -2
- package/dist/commands.js +7 -1
- package/dist/docs-tree.json.gz +0 -0
- package/dist/host-capabilities.js +53 -0
- package/dist/manifest.js +12 -1
- package/dist/plugin/commands.d.ts +2 -1
- package/dist/plugin/commands.js +131 -4
- 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 +70 -0
- package/dist/plugin/testing/index.js +66 -1
- package/dist/plugin/testing/internals.d.ts +14 -0
- package/dist/plugin/testing/internals.js +14 -1
- package/dist/plugin/types/base.d.ts +8 -5
- package/dist/plugin/types/commands.d.ts +412 -1
- package/dist/wire.d.ts +15 -0
- package/dist/wire.js +6 -0
- package/llms.txt +2 -2
- package/package.json +1 -1
- package/slint/vestra/icons.slint +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.7.9
|
|
4
|
+
|
|
5
|
+
**Who must change: nobody; additions only.** The two new capabilities are for the player's built-in plugins only: a third-party plugin cannot declare them (the player refuses the package at install, the plugin registry refuses it, `vestra-plugin check` reports it, and every call fails with `capability`). A built-in plugin that uses them needs player 0.7.6. `apiVersion` stays `vestra/1`; the API surface snapshot gains the new members.
|
|
6
|
+
|
|
7
|
+
Intended users: the built-in Vestra Player AI's Ask Vestra (the palette's first row runs the commands a sentence asks for). The members are shaped by what they do, not by AI: a calculator or unit converter in the palette's first row, a search over the history, jump to a time or chapter, a macro or remote-control plugin running saved commands, a tutorial that shows a command's key. They stay built-in only because one lead row receives every query and running any plugin's command is a wider boundary than any capability so far (the player's ticket, rate limits and confirmation are the boundary; opening them needs the user's ruling).
|
|
8
|
+
|
|
9
|
+
- **`plugin.commands.list()`** (`commands.run`): the command palette's table (`CommandList`, `CommandInfo`): every listed command, the player's own and every plugin's, with its label, category, path, place, keys, owner, state and whether running it asks first (`dangerous`), and a `revision`.
|
|
10
|
+
- **`plugin.commands.run(id, { ticket, step?, of? })`** (`commands.run`, risky): runs a listed command as the palette does, for the ticket of a user action. Resolves `{ ran: true }`, or `{ ran: false, declined: true }` when the user chose Don't Run in the player's own alert, which comes before a command declared `destructive`, the player's Close and Quit, anything in the Settings and Plugins menus, and every command of a plugin that is not built in. Each run shows an OSD line naming the plugin and the command (`step`/`of`, 1–99 and together, add `1/2`). Fails `ticket` (none, ended or expired), `missing`, `disabled` (with the command's reason), `busy`, `invalid` (`step`/`of`, the palette itself) and `limit` (4 a second and 30 per ticket, 120 a minute per plugin).
|
|
11
|
+
- **`plugin.palette.lead(options)`** (`palette.lead`; `Palette`, `PaletteLead`, `PaletteLeadOptions`, `PaletteLeadRun`): the palette's first row (`title`, `icon`, `placeholder`, `empty`, `note`, `status`, with the player's lengths). One plugin holds it (`conflict` for another); the player keeps it while the plugin is stopped. `onRun` hears Enter / Shift+Enter / a click with `{ query, keep, ticket, status }` (the `palette.lead` event, sent unasked to the holder and waking a stopped one); `update` changes it, `done(ticket)` ends a request's ticket, `dispose` removes the row. A refused row reaches `ready` and `onError` without failing activation, so a development load (not built in) still activates.
|
|
12
|
+
- **`CommandOptions.destructive`** (any plugin): the command cannot be undone; `commands.run` asks the user before running it. Sent only when `true`.
|
|
13
|
+
- **`CAPABILITY_INFO[…].builtinOnly`**, from the player's table (`builtinOnly` in its `capabilities.json`). `vestra-plugin check` (and every other command, through the manifest check) reports a built-in-only capability as an error for an id without the `vestra.` prefix (only built-in plugins have one) and as a hint for a `vestra.` id. The Capabilities reference marks them and has a "Built-in plugins only" section; the Commands reference has "Running commands for the user".
|
|
14
|
+
- **Error codes**: `ticket` is new; `disabled` also means a disabled command for `commands.run`; `conflict` also covers the lead row.
|
|
15
|
+
- **Icons**: `BAR_BUTTON_ICONS` and `BarButtonIcon` gain `search-ai` (the palette's button while a plugin holds the lead row); `BarButtonIcon` also gains `sliders`, which `BAR_BUTTON_ICONS` already had.
|
|
16
|
+
- **`TestHost`**: `startPlugin(…, { builtin: true })` (`host.builtin`) runs the plugin as a built-in one; without it both capabilities fail with `capability`, as in the player. `host.paletteLead` is the row as set; `host.runPaletteLead(query, { keep?, status? })` is the user's Enter and returns the ticket (a new one ends the earlier). `commands.list`/`commands.run` follow the player's table, checks, order of refusals, tickets, rates and OSD line over the core commands and the plugin's own; the alert's answer comes from `dialogAnswers`. Tests: `test/builtin-only.test.ts`.
|
|
17
|
+
- Capability table synced from the player (`commands.run`: `commands.list`, `commands.run`; `palette.lead`: `palette.lead.set`, `.clear`, `.done`); the generated Capabilities, Errors and Messages tables follow.
|
|
18
|
+
|
|
3
19
|
## 1.7.8
|
|
4
20
|
|
|
5
21
|
**Who must change: nobody; additions only.** A plugin that uses them declares the new capability `media.sources` (exports of its files also `media.read` and `media.control`, as any export; `media.sources.open` also `playback.control`, as any open) and needs the player that serves them (`minPlayerVersion` of the first player release after 0.7.6). `apiVersion` stays `vestra/1`; the API surface snapshot gains the new members. Snapshot exports are unchanged.
|
package/dist/api-requests.js
CHANGED
|
@@ -100,6 +100,9 @@ export const API_REQUESTS = Object.freeze({
|
|
|
100
100
|
"Resolvers.add": [{ method: "sourceResolvers.register" }],
|
|
101
101
|
"Commands.add": [{ method: "commands.register" }],
|
|
102
102
|
"Commands.keys": [{ method: "commands.keys" }, listen("commands.keys")],
|
|
103
|
+
"Commands.list": [{ method: "commands.list" }],
|
|
104
|
+
"Commands.run": [{ method: "commands.run" }],
|
|
105
|
+
"Palette.lead": [{ method: "palette.lead.set" }],
|
|
103
106
|
"Host.run": [{ method: "host.run" }],
|
|
104
107
|
"Windows.create": [{ method: "ui.open" }],
|
|
105
108
|
"Dialogs.confirm": [{ method: "dialogs.confirm" }],
|
package/dist/capabilities.d.ts
CHANGED
|
@@ -36,6 +36,15 @@ export interface CapabilityInfo {
|
|
|
36
36
|
* clipboard, every shortcut, the keychain, other plugins).
|
|
37
37
|
*/
|
|
38
38
|
readonly risky: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* `true` when only the player's built-in plugins may declare it
|
|
41
|
+
* (`commands.run`, `palette.lead`): the player refuses a package of any
|
|
42
|
+
* other plugin that declares it, and its calls fail with `capability`.
|
|
43
|
+
* `vestra-plugin check` reports it.
|
|
44
|
+
*
|
|
45
|
+
* @since 1.7.9
|
|
46
|
+
*/
|
|
47
|
+
readonly builtinOnly: boolean;
|
|
39
48
|
}
|
|
40
49
|
/**
|
|
41
50
|
* Every manifest capability the player knows (`vestra/1`), in the player's
|
package/dist/capabilities.js
CHANGED
|
@@ -25,6 +25,8 @@ export interface HostCapability {
|
|
|
25
25
|
readonly name: string;
|
|
26
26
|
readonly label: string;
|
|
27
27
|
readonly risky: boolean;
|
|
28
|
+
/** Only built-in plugins may declare it (absent: `false`). */
|
|
29
|
+
readonly builtinOnly?: boolean;
|
|
28
30
|
readonly requires: readonly string[];
|
|
29
31
|
readonly residency: string;
|
|
30
32
|
readonly methods: readonly HostMethod[];
|
|
@@ -119,4 +121,5 @@ export declare function capabilityInfo(rules?: CapabilityRules): Record<string,
|
|
|
119
121
|
requires: string[];
|
|
120
122
|
label: string;
|
|
121
123
|
risky: boolean;
|
|
124
|
+
builtinOnly: boolean;
|
|
122
125
|
}>;
|
package/dist/capability-rules.js
CHANGED
|
@@ -173,6 +173,7 @@ export function capabilityInfo(rules = RULES) {
|
|
|
173
173
|
requires: [...capability.requires],
|
|
174
174
|
label: capability.label,
|
|
175
175
|
risky: capability.risky,
|
|
176
|
+
builtinOnly: capability.builtinOnly === true,
|
|
176
177
|
};
|
|
177
178
|
for (const [api, requests] of Object.entries(rules.apis))
|
|
178
179
|
for (const request of requests) {
|
package/dist/commands.d.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import type { Json, Transport } from "./wire.ts";
|
|
3
3
|
import type { ListJson, TextJson } from "./i18n.ts";
|
|
4
4
|
import type { ConditionJson } from "./plugin/when.ts";
|
|
5
|
+
import type { CommandList, CommandRunResult } from "./plugin/types.ts";
|
|
5
6
|
/**
|
|
6
7
|
* The player's command registry caps, the same values as the player's own
|
|
7
8
|
* table (the player's tests check that they agree). They are runaway guards,
|
|
@@ -134,7 +135,8 @@ export declare const MENU_IDS: readonly ["open", "playback", "subtitles", "video
|
|
|
134
135
|
* icon of the player's V-Line set, `@vestra/icons.slint` (draw one in your own
|
|
135
136
|
* Slint with `Icon { name: "store"; }`). The player's tests check that this
|
|
136
137
|
* list is its icon set. `"sliders"` (three sliders, the player's Adjustments
|
|
137
|
-
* and Effects button)
|
|
138
|
+
* and Effects button); `"search-ai"` (the magnifier with the AI icon's
|
|
139
|
+
* cross, the palette's button while a plugin holds its lead row).
|
|
138
140
|
*
|
|
139
141
|
* @example Check in a test that the button's icon exists
|
|
140
142
|
* The test fails before release if the plugin's bar button names an icon
|
|
@@ -152,7 +154,7 @@ export declare const MENU_IDS: readonly ["open", "playback", "subtitles", "video
|
|
|
152
154
|
*
|
|
153
155
|
* @category Testing
|
|
154
156
|
*/
|
|
155
|
-
export declare const BAR_BUTTON_ICONS: readonly ["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"];
|
|
157
|
+
export declare const BAR_BUTTON_ICONS: readonly ["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"];
|
|
156
158
|
/**
|
|
157
159
|
* The player's limits on bottom-bar buttons (`CommandOptions.button`), the same
|
|
158
160
|
* values as the player's (its tests check that they agree). A button past
|
|
@@ -344,6 +346,8 @@ export type CommandDeclaration = {
|
|
|
344
346
|
* set, like `category`.
|
|
345
347
|
*/
|
|
346
348
|
home?: string;
|
|
349
|
+
/** The command cannot be undone; sent only when `true`. */
|
|
350
|
+
destructive?: boolean;
|
|
347
351
|
};
|
|
348
352
|
/**
|
|
349
353
|
* `commands.keys`: each of the plugin's own commands, by local id, and each of
|
|
@@ -378,4 +382,13 @@ export declare function commandClient(transport: Transport): {
|
|
|
378
382
|
update: (id: string, revision: number, state: CommandState, when?: CommandWhen) => Promise<{
|
|
379
383
|
revision: number;
|
|
380
384
|
}>;
|
|
385
|
+
/** The palette's table (`commands.run`). */
|
|
386
|
+
list: () => Promise<CommandList>;
|
|
387
|
+
/** Run any listed command for a user action's ticket (`commands.run`). */
|
|
388
|
+
run: (params: {
|
|
389
|
+
id: string;
|
|
390
|
+
ticket: string;
|
|
391
|
+
step?: number;
|
|
392
|
+
of?: number;
|
|
393
|
+
}) => Promise<CommandRunResult>;
|
|
381
394
|
};
|
package/dist/commands.js
CHANGED
|
@@ -139,7 +139,8 @@ export const MENU_IDS = [
|
|
|
139
139
|
* icon of the player's V-Line set, `@vestra/icons.slint` (draw one in your own
|
|
140
140
|
* Slint with `Icon { name: "store"; }`). The player's tests check that this
|
|
141
141
|
* list is its icon set. `"sliders"` (three sliders, the player's Adjustments
|
|
142
|
-
* and Effects button)
|
|
142
|
+
* and Effects button); `"search-ai"` (the magnifier with the AI icon's
|
|
143
|
+
* cross, the palette's button while a plugin holds its lead row).
|
|
143
144
|
*
|
|
144
145
|
* @example Check in a test that the button's icon exists
|
|
145
146
|
* The test fails before release if the plugin's bar button names an icon
|
|
@@ -197,6 +198,7 @@ export const BAR_BUTTON_ICONS = [
|
|
|
197
198
|
"store",
|
|
198
199
|
"ai",
|
|
199
200
|
"sliders",
|
|
201
|
+
"search-ai",
|
|
200
202
|
];
|
|
201
203
|
/**
|
|
202
204
|
* The player's limits on bottom-bar buttons (`CommandOptions.button`), the same
|
|
@@ -670,5 +672,9 @@ export function commandClient(transport) {
|
|
|
670
672
|
state,
|
|
671
673
|
...(when ? { when: when } : {}),
|
|
672
674
|
}),
|
|
675
|
+
/** The palette's table (`commands.run`). */
|
|
676
|
+
list: () => transport.request("commands.list", {}),
|
|
677
|
+
/** Run any listed command for a user action's ticket (`commands.run`). */
|
|
678
|
+
run: (params) => transport.request("commands.run", params),
|
|
673
679
|
};
|
|
674
680
|
}
|
package/dist/docs-tree.json.gz
CHANGED
|
Binary file
|
|
@@ -6,6 +6,7 @@ export const HOST_CAPABILITIES = {
|
|
|
6
6
|
apiVersion: "vestra/1",
|
|
7
7
|
capabilities: [
|
|
8
8
|
{
|
|
9
|
+
builtinOnly: false,
|
|
9
10
|
label: "Provide audio and video it generates itself",
|
|
10
11
|
methods: [
|
|
11
12
|
{ name: "producer.prepare", needs: "producer.av" },
|
|
@@ -21,6 +22,7 @@ export const HOST_CAPABILITIES = {
|
|
|
21
22
|
risky: false,
|
|
22
23
|
},
|
|
23
24
|
{
|
|
25
|
+
builtinOnly: false,
|
|
24
26
|
label: "Read what is playing and the position",
|
|
25
27
|
methods: [
|
|
26
28
|
{ name: "source.state", needs: "playback.read" },
|
|
@@ -36,6 +38,7 @@ export const HOST_CAPABILITIES = {
|
|
|
36
38
|
risky: false,
|
|
37
39
|
},
|
|
38
40
|
{
|
|
41
|
+
builtinOnly: false,
|
|
39
42
|
label: "Open media, control playback, keep the computer awake",
|
|
40
43
|
methods: [
|
|
41
44
|
{ name: "playback.set", needs: "playback.control" },
|
|
@@ -64,6 +67,7 @@ export const HOST_CAPABILITIES = {
|
|
|
64
67
|
risky: false,
|
|
65
68
|
},
|
|
66
69
|
{
|
|
70
|
+
builtinOnly: false,
|
|
67
71
|
label: "Resolve online video addresses",
|
|
68
72
|
methods: [
|
|
69
73
|
{ name: "sourceResolvers.register", needs: "source.resolve" },
|
|
@@ -77,6 +81,7 @@ export const HOST_CAPABILITIES = {
|
|
|
77
81
|
risky: false,
|
|
78
82
|
},
|
|
79
83
|
{
|
|
84
|
+
builtinOnly: false,
|
|
80
85
|
label: "Receive playback changes as they happen",
|
|
81
86
|
methods: [
|
|
82
87
|
{
|
|
@@ -112,6 +117,7 @@ export const HOST_CAPABILITIES = {
|
|
|
112
117
|
risky: false,
|
|
113
118
|
},
|
|
114
119
|
{
|
|
120
|
+
builtinOnly: false,
|
|
115
121
|
label: "Add menu commands and shortcuts",
|
|
116
122
|
methods: [
|
|
117
123
|
{ name: "commands.register", needs: "commands" },
|
|
@@ -126,6 +132,7 @@ export const HOST_CAPABILITIES = {
|
|
|
126
132
|
risky: false,
|
|
127
133
|
},
|
|
128
134
|
{
|
|
135
|
+
builtinOnly: false,
|
|
129
136
|
label: "Open tool windows",
|
|
130
137
|
methods: [
|
|
131
138
|
{ name: "ui.open", needs: "ui.window" },
|
|
@@ -139,6 +146,7 @@ export const HOST_CAPABILITIES = {
|
|
|
139
146
|
risky: false,
|
|
140
147
|
},
|
|
141
148
|
{
|
|
149
|
+
builtinOnly: false,
|
|
142
150
|
label: "Show panels in the bottom bar, the sidebar or behind the video",
|
|
143
151
|
methods: [
|
|
144
152
|
{ name: "ui.mount", needs: "ui.mount" },
|
|
@@ -155,6 +163,7 @@ export const HOST_CAPABILITIES = {
|
|
|
155
163
|
risky: false,
|
|
156
164
|
},
|
|
157
165
|
{
|
|
166
|
+
builtinOnly: false,
|
|
158
167
|
label: "Show file pickers and confirmations",
|
|
159
168
|
methods: [
|
|
160
169
|
{ name: "dialogs.open", needs: "ui.dialog" },
|
|
@@ -166,6 +175,7 @@ export const HOST_CAPABILITIES = {
|
|
|
166
175
|
risky: false,
|
|
167
176
|
},
|
|
168
177
|
{
|
|
178
|
+
builtinOnly: false,
|
|
169
179
|
label: "Install, uninstall and disable other plugins",
|
|
170
180
|
methods: [{ name: "packages.*", needs: "plugins.manage" }],
|
|
171
181
|
name: "plugins.manage",
|
|
@@ -174,6 +184,7 @@ export const HOST_CAPABILITIES = {
|
|
|
174
184
|
risky: true,
|
|
175
185
|
},
|
|
176
186
|
{
|
|
187
|
+
builtinOnly: false,
|
|
177
188
|
label: "Process the picture (filters, shaders)",
|
|
178
189
|
methods: [
|
|
179
190
|
{
|
|
@@ -204,6 +215,7 @@ export const HOST_CAPABILITIES = {
|
|
|
204
215
|
risky: false,
|
|
205
216
|
},
|
|
206
217
|
{
|
|
218
|
+
builtinOnly: false,
|
|
207
219
|
label: "Process the sound",
|
|
208
220
|
methods: [],
|
|
209
221
|
name: "processing.audio",
|
|
@@ -212,6 +224,7 @@ export const HOST_CAPABILITIES = {
|
|
|
212
224
|
risky: false,
|
|
213
225
|
},
|
|
214
226
|
{
|
|
227
|
+
builtinOnly: false,
|
|
215
228
|
label: "Read subtitles",
|
|
216
229
|
methods: [{ name: "subtitles.state", needs: "subtitles.read" }],
|
|
217
230
|
name: "subtitles.read",
|
|
@@ -220,6 +233,7 @@ export const HOST_CAPABILITIES = {
|
|
|
220
233
|
risky: false,
|
|
221
234
|
},
|
|
222
235
|
{
|
|
236
|
+
builtinOnly: false,
|
|
223
237
|
label: "Load and change subtitles",
|
|
224
238
|
methods: [{ name: "subtitles.*", needs: "subtitles.control" }],
|
|
225
239
|
name: "subtitles.control",
|
|
@@ -228,6 +242,7 @@ export const HOST_CAPABILITIES = {
|
|
|
228
242
|
risky: false,
|
|
229
243
|
},
|
|
230
244
|
{
|
|
245
|
+
builtinOnly: false,
|
|
231
246
|
label: "Take snapshots and export clips",
|
|
232
247
|
methods: [
|
|
233
248
|
{ name: "snapshot.state", needs: "media.read" },
|
|
@@ -240,6 +255,7 @@ export const HOST_CAPABILITIES = {
|
|
|
240
255
|
risky: false,
|
|
241
256
|
},
|
|
242
257
|
{
|
|
258
|
+
builtinOnly: false,
|
|
243
259
|
label: "Take snapshots and export clips",
|
|
244
260
|
methods: [
|
|
245
261
|
{ name: "snapshot.*", needs: "media.control" },
|
|
@@ -251,6 +267,7 @@ export const HOST_CAPABILITIES = {
|
|
|
251
267
|
risky: false,
|
|
252
268
|
},
|
|
253
269
|
{
|
|
270
|
+
builtinOnly: false,
|
|
254
271
|
label: "Remember videos you add and export from them later",
|
|
255
272
|
methods: [
|
|
256
273
|
{
|
|
@@ -269,6 +286,7 @@ export const HOST_CAPABILITIES = {
|
|
|
269
286
|
risky: false,
|
|
270
287
|
},
|
|
271
288
|
{
|
|
289
|
+
builtinOnly: false,
|
|
272
290
|
label: "Show messages on the video",
|
|
273
291
|
methods: [
|
|
274
292
|
{ name: "osd.show", needs: "ui.osd" },
|
|
@@ -280,6 +298,7 @@ export const HOST_CAPABILITIES = {
|
|
|
280
298
|
risky: false,
|
|
281
299
|
},
|
|
282
300
|
{
|
|
301
|
+
builtinOnly: false,
|
|
283
302
|
label: "Read and write the clipboard",
|
|
284
303
|
methods: [
|
|
285
304
|
{ name: "clipboard.readText", needs: "clipboard" },
|
|
@@ -292,6 +311,7 @@ export const HOST_CAPABILITIES = {
|
|
|
292
311
|
risky: true,
|
|
293
312
|
},
|
|
294
313
|
{
|
|
314
|
+
builtinOnly: false,
|
|
295
315
|
label: "Adjust the main window (size, on top, picture-in-picture)",
|
|
296
316
|
methods: [
|
|
297
317
|
{ name: "window.setVideoArea", needs: "window.control" },
|
|
@@ -305,6 +325,7 @@ export const HOST_CAPABILITIES = {
|
|
|
305
325
|
risky: false,
|
|
306
326
|
},
|
|
307
327
|
{
|
|
328
|
+
builtinOnly: false,
|
|
308
329
|
label: "Change all shortcuts",
|
|
309
330
|
methods: [
|
|
310
331
|
{ name: "bindings.list", needs: "bindings.manage" },
|
|
@@ -317,6 +338,7 @@ export const HOST_CAPABILITIES = {
|
|
|
317
338
|
risky: true,
|
|
318
339
|
},
|
|
319
340
|
{
|
|
341
|
+
builtinOnly: false,
|
|
320
342
|
label: "Show marks on the progress bar",
|
|
321
343
|
methods: [
|
|
322
344
|
{ name: "timeline.set", needs: "timeline.marks" },
|
|
@@ -328,6 +350,7 @@ export const HOST_CAPABILITIES = {
|
|
|
328
350
|
risky: false,
|
|
329
351
|
},
|
|
330
352
|
{
|
|
353
|
+
builtinOnly: false,
|
|
331
354
|
label: "Receive files dropped on the player",
|
|
332
355
|
methods: [
|
|
333
356
|
{ name: "drops.provide", needs: "ui.drop" },
|
|
@@ -340,6 +363,7 @@ export const HOST_CAPABILITIES = {
|
|
|
340
363
|
risky: false,
|
|
341
364
|
},
|
|
342
365
|
{
|
|
366
|
+
builtinOnly: false,
|
|
343
367
|
label: "Add pages to the Options window",
|
|
344
368
|
methods: [{ name: "settings.*", needs: "ui.settings" }],
|
|
345
369
|
name: "ui.settings",
|
|
@@ -348,6 +372,7 @@ export const HOST_CAPABILITIES = {
|
|
|
348
372
|
risky: false,
|
|
349
373
|
},
|
|
350
374
|
{
|
|
375
|
+
builtinOnly: false,
|
|
351
376
|
label: "Change the player's palette",
|
|
352
377
|
methods: [
|
|
353
378
|
{ name: "appearance.set", needs: "ui.theme" },
|
|
@@ -359,6 +384,7 @@ export const HOST_CAPABILITIES = {
|
|
|
359
384
|
risky: false,
|
|
360
385
|
},
|
|
361
386
|
{
|
|
387
|
+
builtinOnly: false,
|
|
362
388
|
label: "Store sign-in details in the system keychain",
|
|
363
389
|
methods: [
|
|
364
390
|
{ name: "secrets.get", needs: "secrets" },
|
|
@@ -371,6 +397,7 @@ export const HOST_CAPABILITIES = {
|
|
|
371
397
|
risky: true,
|
|
372
398
|
},
|
|
373
399
|
{
|
|
400
|
+
builtinOnly: false,
|
|
374
401
|
label: "Choose GPU or software rendering and restart the player",
|
|
375
402
|
methods: [
|
|
376
403
|
{ name: "rendering.setPreference", needs: "rendering.manage" },
|
|
@@ -382,6 +409,7 @@ export const HOST_CAPABILITIES = {
|
|
|
382
409
|
risky: true,
|
|
383
410
|
},
|
|
384
411
|
{
|
|
412
|
+
builtinOnly: false,
|
|
385
413
|
label: "Upscale the video with the GPU's video upscaler",
|
|
386
414
|
methods: [
|
|
387
415
|
{ name: "video.upscaling.state", needs: "video.upscaling" },
|
|
@@ -392,6 +420,31 @@ export const HOST_CAPABILITIES = {
|
|
|
392
420
|
residency: "live",
|
|
393
421
|
risky: false,
|
|
394
422
|
},
|
|
423
|
+
{
|
|
424
|
+
builtinOnly: true,
|
|
425
|
+
label: "Run any player or plugin command",
|
|
426
|
+
methods: [
|
|
427
|
+
{ name: "commands.list", needs: "commands.run" },
|
|
428
|
+
{ name: "commands.run", needs: "commands.run" },
|
|
429
|
+
],
|
|
430
|
+
name: "commands.run",
|
|
431
|
+
requires: [],
|
|
432
|
+
residency: "none",
|
|
433
|
+
risky: true,
|
|
434
|
+
},
|
|
435
|
+
{
|
|
436
|
+
builtinOnly: true,
|
|
437
|
+
label: "Add the first row of the command palette",
|
|
438
|
+
methods: [
|
|
439
|
+
{ name: "palette.lead.set", needs: "palette.lead" },
|
|
440
|
+
{ name: "palette.lead.clear", needs: "palette.lead" },
|
|
441
|
+
{ name: "palette.lead.done", needs: "palette.lead" },
|
|
442
|
+
],
|
|
443
|
+
name: "palette.lead",
|
|
444
|
+
requires: [],
|
|
445
|
+
residency: "recordable",
|
|
446
|
+
risky: false,
|
|
447
|
+
},
|
|
395
448
|
],
|
|
396
449
|
uncapable: [
|
|
397
450
|
{ name: "packages.list", needs: null },
|
package/dist/manifest.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { existsSync, lstatSync, readFileSync, realpathSync } from "node:fs";
|
|
7
7
|
import { join, sep } from "node:path";
|
|
8
|
-
import { API_VERSION, CAPABILITIES } from "./capabilities.js";
|
|
8
|
+
import { API_VERSION, CAPABILITIES, CAPABILITY_INFO } from "./capabilities.js";
|
|
9
9
|
export const MANIFEST_LIMITS = Object.freeze({
|
|
10
10
|
idBytes: 128,
|
|
11
11
|
name: 64,
|
|
@@ -75,6 +75,17 @@ export function manifestProblems(manifest, directory) {
|
|
|
75
75
|
problem(`unknown capabilities ${unknown.join(", ")}`);
|
|
76
76
|
if (new Set(capabilities).size !== capabilities.length)
|
|
77
77
|
problem("capabilities must be unique");
|
|
78
|
+
// Only a built-in plugin may declare these. Built-in plugins have a
|
|
79
|
+
// `vestra.` id, which the player refuses for any other package: any
|
|
80
|
+
// other id is an error, a `vestra.` id a reminder.
|
|
81
|
+
const builtinOnly = capabilities.filter((c) => CAPABILITY_INFO[c]?.builtinOnly);
|
|
82
|
+
if (builtinOnly.length) {
|
|
83
|
+
const text = `${builtinOnly.join(", ")}: built-in plugins only (the player refuses any other plugin that declares ${builtinOnly.length === 1 ? "it" : "them"}, and its calls fail with code capability)`;
|
|
84
|
+
if (typeof id === "string" && /^vestra\./i.test(id))
|
|
85
|
+
hints.push(text);
|
|
86
|
+
else
|
|
87
|
+
problem(text);
|
|
88
|
+
}
|
|
78
89
|
}
|
|
79
90
|
if (typeof manifest.entry !== "string" || !relative(manifest.entry))
|
|
80
91
|
problem("entry must be a relative path inside the package");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Runtime } from "./runtime.ts";
|
|
2
2
|
import type { ScopeImpl } from "./scope.ts";
|
|
3
|
-
import type { Commands } from "./types.ts";
|
|
3
|
+
import type { Commands, Palette } from "./types.ts";
|
|
4
4
|
/**
|
|
5
5
|
* One per plugin: the SDK's copy of the key labels of the plugin's own
|
|
6
6
|
* commands. Started by the first `keys` read or a `player.on("commands.keys")`: it
|
|
@@ -16,4 +16,5 @@ declare class KeysService {
|
|
|
16
16
|
}
|
|
17
17
|
export declare const keysOf: (runtime: Runtime) => KeysService;
|
|
18
18
|
export declare const commands: (scope: ScopeImpl) => Commands;
|
|
19
|
+
export declare const palette: (scope: ScopeImpl) => Palette;
|
|
19
20
|
export {};
|
package/dist/plugin/commands.js
CHANGED
|
@@ -6,6 +6,7 @@ import { BAR_BUTTON_ICONS, BAR_BUTTON_LIMITS, MENU_IDS } from "../commands.js";
|
|
|
6
6
|
import { ImageHandle } from "./view/image.js";
|
|
7
7
|
import { isTextValue, textProblem } from "../i18n.js";
|
|
8
8
|
import { conditionJson, isCondition } from "./when.js";
|
|
9
|
+
import { shownText } from "./osd.js";
|
|
9
10
|
const value = (item) => typeof item === "function" ? item() : item;
|
|
10
11
|
/**
|
|
11
12
|
* A state field given as a function: the command is evaluated in the update
|
|
@@ -73,6 +74,10 @@ function declare(options) {
|
|
|
73
74
|
// Only when set: players before 0.7.6 refuse the fields.
|
|
74
75
|
if (category !== undefined)
|
|
75
76
|
declaration.category = category;
|
|
77
|
+
if (options.destructive === true)
|
|
78
|
+
declaration.destructive = true;
|
|
79
|
+
else if (options.destructive !== undefined && options.destructive !== false)
|
|
80
|
+
throw failure("invalid", `command ${options.id}: destructive is a boolean`);
|
|
76
81
|
if (options.home !== undefined) {
|
|
77
82
|
if (typeof options.home !== "string")
|
|
78
83
|
throw failure("invalid", `command ${options.id}: home is a command id`);
|
|
@@ -92,15 +97,19 @@ function button(id, value, inMenu) {
|
|
|
92
97
|
order < 0 ||
|
|
93
98
|
order > BAR_BUTTON_LIMITS.maxOrder)
|
|
94
99
|
throw fail(`button order must be an integer 0–${BAR_BUTTON_LIMITS.maxOrder}`);
|
|
100
|
+
return { icon: iconJson(icon, fail, "button"), order };
|
|
101
|
+
}
|
|
102
|
+
/** An icon name of the player's set or an image, checked, in wire form. */
|
|
103
|
+
function iconJson(icon, fail, what) {
|
|
95
104
|
if (icon instanceof ImageHandle) {
|
|
96
105
|
if (icon.released)
|
|
97
|
-
throw fail(
|
|
98
|
-
return
|
|
106
|
+
throw fail(`${what} image ${icon.path} was released with the scope that created it`);
|
|
107
|
+
return icon.toJSON();
|
|
99
108
|
}
|
|
100
109
|
if (typeof icon !== "string" ||
|
|
101
110
|
!BAR_BUTTON_ICONS.includes(icon))
|
|
102
|
-
throw fail(`unknown
|
|
103
|
-
return
|
|
111
|
+
throw fail(`unknown ${what} icon ${JSON.stringify(icon)}: a name of @vestra/icons.slint (BAR_BUTTON_ICONS) or an image from plugin.ui.image`);
|
|
112
|
+
return icon;
|
|
104
113
|
}
|
|
105
114
|
class CommandHandle {
|
|
106
115
|
id;
|
|
@@ -349,4 +358,122 @@ export const commands = (scope) => ({
|
|
|
349
358
|
scope.runtime.depends(KEYS, id);
|
|
350
359
|
return service.get(id);
|
|
351
360
|
},
|
|
361
|
+
list: async () => {
|
|
362
|
+
needs(scope, "commands.run");
|
|
363
|
+
return scope.runtime.host.commands.list();
|
|
364
|
+
},
|
|
365
|
+
async run(id, options) {
|
|
366
|
+
needs(scope, "commands.run");
|
|
367
|
+
if (typeof id !== "string" || id === "")
|
|
368
|
+
throw failure("invalid", "run takes a command id: <plugin>/<id>");
|
|
369
|
+
const { ticket, step, of } = (options ?? {});
|
|
370
|
+
if (typeof ticket !== "string" || ticket === "")
|
|
371
|
+
throw failure("ticket", "run needs the ticket of a user action");
|
|
372
|
+
// As the player: both or neither, 1 <= step <= of <= 99.
|
|
373
|
+
const whole = (value) => Number.isInteger(value) &&
|
|
374
|
+
value >= 1 &&
|
|
375
|
+
value <= 99;
|
|
376
|
+
if ((step === undefined) !== (of === undefined) ||
|
|
377
|
+
(step !== undefined && (!whole(step) || !whole(of) || step > of)))
|
|
378
|
+
throw failure("invalid", "step and of go together, 1 <= step <= of <= 99");
|
|
379
|
+
return scope.runtime.host.commands.run({
|
|
380
|
+
id,
|
|
381
|
+
ticket,
|
|
382
|
+
...(step === undefined ? {} : { step }),
|
|
383
|
+
...(of === undefined ? {} : { of }),
|
|
384
|
+
});
|
|
385
|
+
},
|
|
386
|
+
});
|
|
387
|
+
/** Refuse at once without `capability`, as the player does. */
|
|
388
|
+
function needs(scope, capability) {
|
|
389
|
+
if (!scope.runtime.can(capability))
|
|
390
|
+
throw failure("capability", `${capability} must be declared in manifest`);
|
|
391
|
+
}
|
|
392
|
+
// ---------------------------------------------------------------- palette lead
|
|
393
|
+
/** `PaletteLeadOptions` checked and in wire form; the player checks lengths. */
|
|
394
|
+
function leadJson(options) {
|
|
395
|
+
if (options === null || typeof options !== "object")
|
|
396
|
+
throw failure("invalid", "lead takes { title, icon, ... }");
|
|
397
|
+
const text = (value, what) => shownText(value, undefined, what);
|
|
398
|
+
const out = {
|
|
399
|
+
title: text(options.title, "title"),
|
|
400
|
+
icon: iconJson(options.icon, (problem) => failure("invalid", problem), "lead"),
|
|
401
|
+
};
|
|
402
|
+
for (const key of ["placeholder", "empty", "note"])
|
|
403
|
+
if (options[key] !== undefined)
|
|
404
|
+
out[key] = text(options[key], key);
|
|
405
|
+
const status = options.status;
|
|
406
|
+
if (status === null)
|
|
407
|
+
out.status = null;
|
|
408
|
+
else if (status !== undefined) {
|
|
409
|
+
if (typeof status !== "object")
|
|
410
|
+
throw failure("invalid", "status is { text, note? } or null");
|
|
411
|
+
out.status = {
|
|
412
|
+
text: text(status.text, "status.text"),
|
|
413
|
+
...(status.note === undefined
|
|
414
|
+
? {}
|
|
415
|
+
: { note: text(status.note, "status.note") }),
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
return out;
|
|
419
|
+
}
|
|
420
|
+
class LeadHandle {
|
|
421
|
+
ready;
|
|
422
|
+
#scope;
|
|
423
|
+
#pump;
|
|
424
|
+
#listeners = new Set();
|
|
425
|
+
#event;
|
|
426
|
+
#disposed = false;
|
|
427
|
+
constructor(scope, options) {
|
|
428
|
+
needs(scope, "palette.lead");
|
|
429
|
+
const first = leadJson(options);
|
|
430
|
+
this.#scope = scope;
|
|
431
|
+
const host = scope.runtime.host.palette;
|
|
432
|
+
this.#pump = new Latest((value) => host.set(value));
|
|
433
|
+
// Not an activation step: a refusal (a development load is not built
|
|
434
|
+
// in) reaches `ready` and onError, and the rest of the plugin runs.
|
|
435
|
+
this.ready = quiet(this.#pump.push(first).then(() => { }));
|
|
436
|
+
this.ready.catch((error) => scope.report(error));
|
|
437
|
+
// Sent to the lead's owner unasked, like `commands.execute`.
|
|
438
|
+
this.#event = scope.runtime.raw("palette.lead", (data) => {
|
|
439
|
+
const raw = (data ?? {});
|
|
440
|
+
const run = {
|
|
441
|
+
query: String(raw.query ?? ""),
|
|
442
|
+
keep: raw.keep === true,
|
|
443
|
+
ticket: String(raw.ticket ?? ""),
|
|
444
|
+
status: raw.status === true,
|
|
445
|
+
};
|
|
446
|
+
for (const listener of [...this.#listeners])
|
|
447
|
+
scope.run(listener, run);
|
|
448
|
+
});
|
|
449
|
+
scope.add(this);
|
|
450
|
+
}
|
|
451
|
+
async update(options) {
|
|
452
|
+
if (this.#disposed)
|
|
453
|
+
return;
|
|
454
|
+
await this.#pump.push(leadJson(options));
|
|
455
|
+
}
|
|
456
|
+
onRun(listener) {
|
|
457
|
+
this.#listeners.add(listener);
|
|
458
|
+
return { dispose: async () => void this.#listeners.delete(listener) };
|
|
459
|
+
}
|
|
460
|
+
async done(ticket) {
|
|
461
|
+
if (typeof ticket !== "string" || ticket === "")
|
|
462
|
+
throw failure("invalid", "done takes a ticket");
|
|
463
|
+
await this.#scope.runtime.host.palette.done(ticket);
|
|
464
|
+
}
|
|
465
|
+
async dispose() {
|
|
466
|
+
if (this.#disposed)
|
|
467
|
+
return;
|
|
468
|
+
this.#disposed = true;
|
|
469
|
+
this.#scope.forget(this);
|
|
470
|
+
this.#listeners.clear();
|
|
471
|
+
await this.#event.dispose();
|
|
472
|
+
this.#pump.stop();
|
|
473
|
+
if (await this.ready.then(() => true, () => false))
|
|
474
|
+
await this.#scope.runtime.host.palette.clear().catch(() => { });
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
export const palette = (scope) => ({
|
|
478
|
+
lead: (options) => new LeadHandle(scope, options),
|
|
352
479
|
});
|
package/dist/plugin/scope.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ export declare class ScopeImpl implements Plugin {
|
|
|
36
36
|
readonly resolvers: import("./types.ts").Resolvers;
|
|
37
37
|
readonly packages: import("./types.ts").Packages;
|
|
38
38
|
readonly osd: import("./types.ts").Osd;
|
|
39
|
+
readonly palette: import("./types.ts").Palette;
|
|
39
40
|
readonly host: import("./types.ts").Host;
|
|
40
41
|
readonly clipboard: import("./types.ts").Clipboard;
|
|
41
42
|
readonly power: import("./types.ts").Power;
|
package/dist/plugin/scope.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Scopes own handles. Disposal runs newest first and never throws. */
|
|
2
2
|
import { failure, toError } from "./errors.js";
|
|
3
|
-
import { commands, keysOf } from "./commands.js";
|
|
3
|
+
import { commands, keysOf, palette } from "./commands.js";
|
|
4
4
|
import { WHEN } from "./when.js";
|
|
5
5
|
import { dialogs } from "./services/dialogs.js";
|
|
6
6
|
import { ui } from "./view/image.js";
|
|
@@ -88,6 +88,7 @@ export class ScopeImpl {
|
|
|
88
88
|
resolvers = resolvers(this);
|
|
89
89
|
packages = packages(this);
|
|
90
90
|
osd = osd(this);
|
|
91
|
+
palette = palette(this);
|
|
91
92
|
host = host(this);
|
|
92
93
|
clipboard = clipboard(this);
|
|
93
94
|
power = power(this);
|
|
@@ -62,3 +62,10 @@ export declare function press(host: TestHost, inner: Internals, binding: string,
|
|
|
62
62
|
export declare function barButtons(host: TestHost, _inner: Internals): readonly FakeBarButton[];
|
|
63
63
|
/** The default handlers of this area's wire methods, by method name. */
|
|
64
64
|
export declare function commandsHandlers(host: TestHost, inner: Internals): Record<string, Handler>;
|
|
65
|
+
/** The default handlers of `commands.run` and `palette.lead`. */
|
|
66
|
+
export declare function builtinHandlers(host: TestHost, inner: Internals): Record<string, Handler>;
|
|
67
|
+
/** Implements `TestHost.runPaletteLead`. */
|
|
68
|
+
export declare function runPaletteLead(host: TestHost, inner: Internals, query: string, options: {
|
|
69
|
+
keep?: boolean;
|
|
70
|
+
status?: boolean;
|
|
71
|
+
}): Promise<string>;
|