@vestra-player/sdk 1.6.19 → 1.6.21

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.
Files changed (35) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/commands.js +19 -18
  3. package/dist/docs-tree.json.gz +0 -0
  4. package/dist/i18n-tools.js +7 -2
  5. package/dist/plugin/runtime.d.ts +1 -0
  6. package/dist/plugin/runtime.js +3 -0
  7. package/dist/plugin/types/base.d.ts +1097 -0
  8. package/dist/plugin/types/base.js +1 -0
  9. package/dist/plugin/types/commands.d.ts +1189 -0
  10. package/dist/plugin/types/commands.js +1 -0
  11. package/dist/plugin/types/packages.d.ts +661 -0
  12. package/dist/plugin/types/packages.js +1 -0
  13. package/dist/plugin/types/playback.d.ts +1654 -0
  14. package/dist/plugin/types/playback.js +1 -0
  15. package/dist/plugin/types/processing.d.ts +974 -0
  16. package/dist/plugin/types/processing.js +1 -0
  17. package/dist/plugin/types/services.d.ts +1132 -0
  18. package/dist/plugin/types/services.js +1 -0
  19. package/dist/plugin/types/snapshots.d.ts +491 -0
  20. package/dist/plugin/types/snapshots.js +1 -0
  21. package/dist/plugin/types/sources.d.ts +302 -0
  22. package/dist/plugin/types/sources.js +1 -0
  23. package/dist/plugin/types/subtitles.d.ts +327 -0
  24. package/dist/plugin/types/subtitles.js +1 -0
  25. package/dist/plugin/types/ui-content.d.ts +692 -0
  26. package/dist/plugin/types/ui-content.js +1 -0
  27. package/dist/plugin/types/ui-layout.d.ts +1079 -0
  28. package/dist/plugin/types/ui-layout.js +1 -0
  29. package/dist/plugin/types/ui-locale.d.ts +490 -0
  30. package/dist/plugin/types/ui-locale.js +1 -0
  31. package/dist/plugin/types/ui-shell.d.ts +1072 -0
  32. package/dist/plugin/types/ui-shell.js +1 -0
  33. package/dist/plugin/types.d.ts +18 -11072
  34. package/llms.txt +1 -1
  35. package/package.json +1 -1
@@ -0,0 +1,1072 @@
1
+ import type { Scope } from "./base.ts";
2
+ import type { CommandOptions } from "./commands.ts";
3
+ import type { Player } from "./playback.ts";
4
+ import type { Windows } from "./ui-layout.ts";
5
+ import type { Text, TextList } from "./ui-locale.ts";
6
+ import type { Disposable } from "./base.ts";
7
+ import type { View } from "./ui-content.ts";
8
+ import type { Panel, PanelSlot, SidebarSlot } from "./ui-layout.ts";
9
+ import type { TemplateArgs, TextValue } from "./ui-locale.ts";
10
+ /**
11
+ * The categories of the Options window. The tree shows them in this order:
12
+ * General, Playback, Subtitles, Video, Audio, Input, Appearance, Plugins,
13
+ * Other; a category with no pages is hidden.
14
+ *
15
+ * @since 1.0.0
16
+ * @category UI
17
+ */
18
+ export type SettingsCategory = "general" | "playback" | "subtitles" | "video" | "audio" | "input" | "appearance" | "plugins" | "other";
19
+ /**
20
+ * A page in the player's Options window, made by {@link Settings.page}.
21
+ *
22
+ * @remarks
23
+ * A {@link View} like a panel: properties and callbacks live on the file's
24
+ * bridge global, every callback of the global is forwarded, and there is no
25
+ * "bind before show" rule. The page exists from `ready`
26
+ * on, whether or not the Options window is open; property writes while it is
27
+ * closed are kept and applied when it opens. When pages are added or removed
28
+ * while the window is open, the player rebuilds it and restores every page's
29
+ * properties to the values last written, so mirror every user change in the
30
+ * plugin's state (and `bind` it), or it reverts.
31
+ *
32
+ * `dispose()`, disposing the scope or stopping the plugin removes the page;
33
+ * if it was showing, the window shows another page.
34
+ *
35
+ * Testing: `host.settingsPage(id)` of `@vestra-player/sdk/testing` has the
36
+ * page's `props` and `emit(callback, ...args)`.
37
+ *
38
+ * @capability ui.settings
39
+ *
40
+ * @example Put two preferences on a page and keep them in a store
41
+ * Options ▸ Video ▸ Blur shows two check boxes whose values survive
42
+ * restarts. The checkboxes are bound two-way (`<=>`) to `in-out`
43
+ * properties of the bridge global, so the user's clicks show at once; the
44
+ * `toggled` callbacks tell the plugin, which saves the new value, and
45
+ * `bind` writes the stored values when the page opens.
46
+ * ```ts
47
+ * const store = plugin.storage.json("blur", {
48
+ * defaults: { restoreOnStart: false, messages: true },
49
+ * });
50
+ * const page = plugin.settings.page("ui/settings.slint", {
51
+ * id: "blur",
52
+ * category: "video",
53
+ * title: "Blur",
54
+ * });
55
+ * page.bind(() => ({
56
+ * restoreOnStart: store.value.restoreOnStart,
57
+ * messages: store.value.messages,
58
+ * }));
59
+ * // The bridge's `restore-toggled(bool)` callback, in camelCase.
60
+ * page.on("restoreToggled", (on: boolean) =>
61
+ * store.save({ ...store.value, restoreOnStart: on }),
62
+ * );
63
+ * page.on("messagesToggled", (on: boolean) =>
64
+ * store.save({ ...store.value, messages: on }),
65
+ * );
66
+ * ```
67
+ *
68
+ * `ui/settings.slint` exports the bridge global and the layout:
69
+ *
70
+ * ```slint
71
+ * import { CheckBox } from "std-widgets.slint";
72
+ * import { Theme } from "@vestra/theme.slint";
73
+ *
74
+ * // The bridge: what the plugin writes and the callbacks it handles.
75
+ * export global BlurPage {
76
+ * in-out property <bool> restore-on-start;
77
+ * in-out property <bool> messages: true;
78
+ * callback restore-toggled(bool);
79
+ * callback messages-toggled(bool);
80
+ * }
81
+ *
82
+ * export component BlurSettings inherits Rectangle {
83
+ * VerticalLayout {
84
+ * padding: Theme.dialog-padding;
85
+ * spacing: 6px;
86
+ * alignment: start;
87
+ * CheckBox {
88
+ * text: "Turn blur back on when the player starts";
89
+ * checked <=> BlurPage.restore-on-start;
90
+ * toggled => { BlurPage.restore-toggled(self.checked); }
91
+ * }
92
+ * CheckBox {
93
+ * text: "Show on-screen messages";
94
+ * checked <=> BlurPage.messages;
95
+ * toggled => { BlurPage.messages-toggled(self.checked); }
96
+ * }
97
+ * }
98
+ * }
99
+ * ```
100
+ *
101
+ * @see {@link Settings.page}, [Windows, panels, settings pages, dialogs and the OSD](../../../docs/explanation/ui.md)
102
+ * @since 1.0.0
103
+ * @category UI
104
+ */
105
+ export type SettingsPage = View & Disposable & {
106
+ /**
107
+ * Resolves once the player has registered the page; rejects when it
108
+ * refused it.
109
+ *
110
+ * @remarks
111
+ * The player compiles the page on its own at registration, so a broken
112
+ * page fails here and does not affect the Options window. Pages added
113
+ * while `activate` runs must succeed before the plugin is ready: a
114
+ * rejection fails activation. Later failures also go to
115
+ * {@link Scope.onError}.
116
+ *
117
+ * @throws `ui-prepare` (rejects) The Slint file does not compile; `message`
118
+ * has the diagnostics.
119
+ * @throws `invalid` (rejects) The plugin already has 8 pages, or `order`
120
+ * is beyond ±1,000,000.
121
+ * @throws `host` (rejects) The file is missing or outside the package
122
+ * directory.
123
+ * @throws `capability` (rejects) The manifest does not declare
124
+ * `ui.settings`.
125
+ */
126
+ readonly ready: Promise<void>;
127
+ };
128
+ /**
129
+ * Add pages to the player's Options window. `plugin.settings`.
130
+ *
131
+ * @remarks
132
+ * Use a settings page for preferences that change rarely. The player owns
133
+ * the Options window (640×480 by default, at least 600×420, resizable): a
134
+ * category tree on the left, the selected page on the right, a Close button
135
+ * at the bottom. The standard close keys close it, and command key bindings
136
+ * do not fire while it has focus. Opening it does not affect playback.
137
+ *
138
+ * A page file exports **one component and one global**, like a panel: the
139
+ * global (the bridge) declares the properties and callbacks, the component
140
+ * lays the page out and reads them. Pages are 440 logical pixels wide; the
141
+ * window scrolls a taller page.
142
+ *
143
+ * @capability ui.settings
144
+ *
145
+ * @example Add a page that edits a stored setting
146
+ * Options ▸ Playback ▸ Resume shows the plugin's Resume switch. `page`
147
+ * registers the page with the Options window (compiled by the player on
148
+ * its own), `bind` sends the stored value, and the page's callback saves
149
+ * the user's change.
150
+ * ```ts
151
+ * const store = plugin.storage.json("settings", { defaults: { resume: true } });
152
+ * const page = plugin.settings.page("ui/settings.slint", {
153
+ * id: "resume",
154
+ * category: "playback",
155
+ * title: "Resume",
156
+ * });
157
+ * page.bind(() => ({ resume: store.value.resume }));
158
+ * // The bridge's `resume-toggled(bool)`: save, and `bind` sends it back.
159
+ * page.on("resumeToggled", (on: boolean) => store.save({ ...store.value, resume: on }));
160
+ * ```
161
+ *
162
+ * @see {@link SettingsPage}, [Windows, panels, settings pages, dialogs and the OSD](../../../docs/explanation/ui.md)
163
+ * @since 1.0.0
164
+ * @category UI
165
+ */
166
+ export interface Settings {
167
+ /**
168
+ * Add a page to the Options window.
169
+ *
170
+ * @remarks
171
+ * The SDK finds the component and the global from the file's
172
+ * `export component` and `export global` lines; the file must export one
173
+ * of each. In the next microtask it registers the page with every property
174
+ * bound or set so far; `ready` reports the result.
175
+ *
176
+ * Within a category, pages are sorted by `order`, then by plugin id and
177
+ * page id.
178
+ *
179
+ * @capability ui.settings
180
+ *
181
+ * @param file - Path relative to the package directory, for example
182
+ * `"ui/settings.slint"`.
183
+ * @param options - The page's identity and place:
184
+ * `id` (unique in this plugin, 1–64 letters, digits, `.`, `-` or `_`),
185
+ * `category`, `title` (shown in the tree, 1–24 characters) and `order`
186
+ * (an integer within ±1,000,000, default 0; smaller first).
187
+ * @returns A {@link SettingsPage} owned by this scope.
188
+ *
189
+ * @throws `invalid` (throws) A bad `id`, `category`, `title` or `order`, or
190
+ * this plugin already has a page with this `id`.
191
+ * @throws `Error` without a code (throws) The file does not export exactly
192
+ * one component and one global. A file that cannot be read throws Node's
193
+ * file system error (`code` `ENOENT` and so on).
194
+ *
195
+ * @example Register a page and report when the player refuses it
196
+ * An "My plugin" page appears under Plugins, or the reason it could not
197
+ * be added is logged. `page` returns at once; the player compiles the
198
+ * page on its own, and `ready` rejects (for example with `ui-prepare`
199
+ * and the compiler's diagnostics) when it refuses it.
200
+ * ```ts
201
+ * const page = plugin.settings.page("ui/advanced.slint", {
202
+ * id: "advanced",
203
+ * category: "plugins",
204
+ * title: "My plugin",
205
+ * order: 10, // after pages with a smaller order in the category
206
+ * });
207
+ * page.ready.catch((error: PluginError) => console.error(error.message));
208
+ * ```
209
+ *
210
+ * @since 1.0.0
211
+ */
212
+ page(file: string, options: {
213
+ /** Unique in this plugin: 1–64 letters, digits, `.`, `-` or `_`. */
214
+ id: string;
215
+ /** Where the page appears in the tree. */
216
+ category: SettingsCategory;
217
+ /** The page's name in the tree, 1–24 characters. */
218
+ title: string;
219
+ /** An integer within ±1,000,000, smaller first (default 0). */
220
+ order?: number;
221
+ }): SettingsPage;
222
+ /**
223
+ * Open the Options window at one of this plugin's pages, or bring it to
224
+ * the front.
225
+ *
226
+ * @remarks
227
+ * Without `pageId` it shows the page that is selected; when the window
228
+ * first opens, that is the page the user saw last (the player remembers
229
+ * it), else the first one.
230
+ *
231
+ * @capability ui.settings
232
+ *
233
+ * @param pageId - The `id` of one of this plugin's pages.
234
+ * @returns Resolves once the window is shown.
235
+ *
236
+ * @throws `invalid` (rejects) `pageId` is not a page of this plugin.
237
+ * @throws `unavailable` (rejects) The player runs without a user interface.
238
+ * @throws `ui` (rejects) The window could not be built (for example a page
239
+ * wrote a property its file does not declare).
240
+ * @throws `capability` (rejects) The manifest does not declare
241
+ * `ui.settings`.
242
+ *
243
+ * @example Open the plugin's page from an "Options…" button
244
+ * The button in the plugin's window opens the Options window at the
245
+ * plugin's Blur page, or brings it to the front. `show` takes the id the
246
+ * page was registered with and rejects with `invalid` for any other.
247
+ * ```ts
248
+ * const controls = plugin.windows.create("ui/window.slint");
249
+ * controls.on("openOptions", () => plugin.settings.show("blur"));
250
+ * ```
251
+ *
252
+ * @since 1.0.0
253
+ */
254
+ show(pageId?: string): Promise<void>;
255
+ }
256
+ /**
257
+ * The backdrop position (`plugin.panels.backdrop`): whether a backdrop is
258
+ * mounted and whether it is shown now.
259
+ *
260
+ * @remarks
261
+ * The player decides when the backdrop shows: while the source is empty or
262
+ * loading, and while ready media has no video picture (audio files). The
263
+ * plugin decides what to draw, from {@link Player.state} and
264
+ * {@link Player.stats}. With `events`, `state` follows every change; without
265
+ * it, it refreshes only when this plugin mounts.
266
+ *
267
+ * @capability ui.mount; `events` to follow changes.
268
+ *
269
+ * @example React when a video picture appears
270
+ * The OSD says "Video is playing" when the backdrop gives way to a video
271
+ * picture. The player decides when the backdrop shows (nothing open,
272
+ * loading, audio without a picture); `effective` turns false when a video
273
+ * frame replaces it.
274
+ * ```ts
275
+ * plugin.panels.backdrop.onChange((state) => {
276
+ * // `null`: no backdrop is mounted.
277
+ * if (state?.effective === false) void plugin.osd.show("Video is playing");
278
+ * });
279
+ * ```
280
+ *
281
+ * @since 1.0.0
282
+ * @category UI
283
+ */
284
+ export interface BackdropSlot {
285
+ /**
286
+ * `null` while no plugin has a backdrop; otherwise `effective` tells whether
287
+ * it is shown now.
288
+ */
289
+ readonly state: {
290
+ /** The backdrop is shown now (there is no video picture). */
291
+ readonly effective: boolean;
292
+ } | null;
293
+ /**
294
+ * Run code when a backdrop appears or disappears, or when it is shown or
295
+ * hidden.
296
+ *
297
+ * @capability ui.mount and events
298
+ *
299
+ * @param listener - Receives the new state (`null`: no backdrop).
300
+ * @returns A handle that removes the listener.
301
+ *
302
+ * @example Log when the backdrop shows or hides
303
+ * The plugin's log records each change of the backdrop position. The
304
+ * listener runs when the player starts or stops showing the backdrop
305
+ * and with `null` when it is unmounted.
306
+ * ```ts
307
+ * plugin.panels.backdrop.onChange((state) => console.log("backdrop", state));
308
+ * ```
309
+ *
310
+ * @since 1.0.0
311
+ */
312
+ onChange(listener: (state: {
313
+ readonly effective: boolean;
314
+ } | null) => void): Disposable;
315
+ }
316
+ /**
317
+ * Put a panel into the player's main window: the bottom bar, the sidebar or
318
+ * the backdrop. `plugin.panels`.
319
+ *
320
+ * @remarks
321
+ * A panel is part of the player's layout: it resizes with the main window,
322
+ * follows fullscreen and auto-hides with the player's own controls. Use one
323
+ * for content that should stay with the video (a playlist, chapters, a
324
+ * custom control bar, cover art); use a {@link Windows | tool window} for a
325
+ * tool the user opens and closes.
326
+ *
327
+ * A panel file exports **one component and one global**. The global is the
328
+ * bridge: the plugin writes its properties and handles its callbacks. The
329
+ * component lays the panel out and reads and calls the global. The split
330
+ * exists because the player composes the component into its own windows: a
331
+ * new instance of the component is made whenever the main window is rebuilt
332
+ * or the sidebar moves to or from its floating window, while the global is
333
+ * one stable address.
334
+ *
335
+ * A plugin mounts at most one panel per slot (SDK 1.6.15, player 0.7.6;
336
+ * before, one panel in all): a playback plugin can have its control bar in
337
+ * `"bottom"` and its controls in `"adjust"`. Each {@link Panel} has its own
338
+ * bridge, state, `toggle()` and `setInteraction()`; disposing one leaves
339
+ * the others, and stopping the plugin unmounts them all. The bottom bar and
340
+ * the backdrop hold one panel for all plugins; the sidebar and the adjust
341
+ * column one tab per plugin. {@link Panels.bottom}, {@link Panels.sidebar}
342
+ * and {@link Panels.adjust} describe the positions, whoever mounted there.
343
+ *
344
+ * @capability ui.mount
345
+ *
346
+ * @example Mount a list in the sidebar (examples/panel-menu)
347
+ * The sidebar gets an "Example list" tab showing three rows. `mount`
348
+ * returns at once; the SDK sends the mount with the values bound so far,
349
+ * and the player rebuilds its main window with the panel. The Slint file
350
+ * exports the component and the bridge global whose properties `bind`
351
+ * writes.
352
+ *
353
+ * {@includeCode ../../../examples/panel-menu/main.ts#mount}
354
+ *
355
+ * `ui/panel.slint`:
356
+ *
357
+ * {@includeCode ../../../examples/panel-menu/ui/panel.slint}
358
+ *
359
+ * @see {@link Panel}, {@link PanelSlot}, [Windows, panels, settings pages, dialogs and the OSD](../../../docs/explanation/ui.md)
360
+ * @since 1.0.0
361
+ * @category UI
362
+ */
363
+ export interface Panels {
364
+ /**
365
+ * Mount a Slint component in the bottom bar, the sidebar or the backdrop.
366
+ *
367
+ * @remarks
368
+ * Returns at once; the panel is on screen when {@link Panel.ready}
369
+ * resolves. Handlers and bindings made right after `mount()` (in the same
370
+ * synchronous code) are part of the first values.
371
+ *
372
+ * - `"bottom"`: under the video, as wide as the video column, as tall as the
373
+ * component's preferred height. It may draw above its slot into the video
374
+ * area (negative `y`); the player does not clip it. In fullscreen it
375
+ * floats over the video and shows only while the pointer is in its band
376
+ * at the bottom of the screen (hidden 500 ms after the pointer leaves;
377
+ * {@link Panel.setInteraction} locks keep it).
378
+ * - `"sidebar"`: right of the video, the window's full height, as wide as the
379
+ * user drags it (at least 317). The user can detach it into a floating
380
+ * window titled `title`. Several plugins may mount here (player 0.4.x
381
+ * after 0.4.0): each panel is a tab, labelled `title` (else the plugin's
382
+ * name), and the player draws a 31px tab strip above the current one
383
+ * while there are two or more (with one panel, nothing changes).
384
+ * Showing, hiding and detaching apply to the whole sidebar. If the
385
+ * bridge global declares `in property <bool> tabbed`, the player sets
386
+ * it to `true` while it draws the strip, so a panel with a tab strip of
387
+ * its own can hide it. Panel coordinates (drops) start below the strip.
388
+ * - `"backdrop"`: the whole video area, under the OSD, while there is no
389
+ * video picture (see {@link Panels.backdrop}). One plugin at a time (as
390
+ * for the bottom bar, another one's mount rejects with `conflict`); it
391
+ * takes no pointer or keyboard input. While it is mounted, the player does
392
+ * not show the cover art of audio files itself (from the next file
393
+ * opened on), so the plugin can draw it.
394
+ * - `"adjust"` (player 0.7.6, SDK 1.6.11): **controls that change what is
395
+ * playing**: the picture, the sound, the subtitles, the speed (the
396
+ * player's own Picture, Audio, Subtitles and Playback panels, a colour
397
+ * grading tool). Several plugins may mount here, one tab each, labelled
398
+ * `title` (else the plugin's name). Declare `minPlayerVersion: "0.7.6"`:
399
+ * older players refuse the slot (`invalid`, "unknown mount slot"), and a
400
+ * mount refused during `activate` fails the activation.
401
+ *
402
+ * **Choosing between `"sidebar"` and `"adjust"`.** The slot says what the
403
+ * panel is for; the player decides how it looks and may change that at any
404
+ * time. Ask: after the user closes the panel, do they still look at what it
405
+ * showed? If yes (a list, chapters, search results, another video), it is
406
+ * content: `"sidebar"`. If it only changes what is playing, it is
407
+ * `"adjust"`.
408
+ *
409
+ * **What the player shows today (may change; do not depend on it).** The
410
+ * adjust column is a second column between the video and the sidebar
411
+ * (`[video][adjust][sidebar]`; both can be open, the sidebar always
412
+ * rightmost), 317 wide by default, 280 to half the window, with text tabs
413
+ * and the key that opens each tab under its title (the key of the command
414
+ * your other commands name as their {@link CommandOptions.home | home}). It
415
+ * has no close or detach button: the bottom bar's Adjust button, your
416
+ * panel's own command ({@link Panel.toggle}) and the menus open and close
417
+ * it. It starts closed. In a window too narrow to dock it beside a video at
418
+ * least 480 wide, it floats over the right of the video, 300 wide; in
419
+ * fullscreen it slides out from the right edge, left of the sidebar. Its
420
+ * width, open state, current tab and tab order are remembered across
421
+ * launches. Its strip is always drawn, so panel coordinates (drops) start
422
+ * below it, and the bridge global's `tabbed` property, if declared, is
423
+ * `true`. As in the sidebar, only the current tab's plugin is kept
424
+ * running while the column is open, and the player compiles a panel the
425
+ * first time it is shown, not at start-up.
426
+ *
427
+ * @capability ui.mount
428
+ *
429
+ * @param slot - Where to mount the panel.
430
+ * @param file - Path relative to the package directory, for example
431
+ * `"ui/playlist.slint"`.
432
+ * @param options - `component` and `global`: the names to mount, needed
433
+ * only if the file exports more than one of either. `title`: the floating
434
+ * sidebar window's title (at most 128 bytes; default "Vestra Player");
435
+ * not used for the other slots.
436
+ * @returns A {@link Panel} owned by this scope; await {@link Panel.ready}
437
+ * for the result.
438
+ *
439
+ * @throws `Error` without a code (throws) This plugin already has a panel
440
+ * in this slot (a panel in another slot is fine from player 0.7.6;
441
+ * players before 0.7.6 refuse a second panel with `conflict`, so a
442
+ * plugin that mounts two declares `minPlayerVersion` 0.7.6), or the file
443
+ * exports no component or global, or several and `options`
444
+ * does not name one. A file that cannot be read throws Node's file system
445
+ * error (`code` `ENOENT` and so on).
446
+ * @throws The errors of {@link Panel.ready} (rejects `ready`) The player
447
+ * refused the mount.
448
+ *
449
+ * @example Mount a bottom bar with a seek slider
450
+ * The plugin's own control bar appears under the video, its slider
451
+ * following the playback position and seeking when dragged. Bindings and
452
+ * handlers made right after `mount` are part of the first values;
453
+ * `ready` resolves once the main window shows the bar, and rejects with
454
+ * `conflict` when another plugin's panel holds the bottom bar.
455
+ * ```ts
456
+ * const bar = plugin.panels.mount("bottom", "ui/bar.slint");
457
+ * // Sent again whenever the position changes.
458
+ * bar.bind(() => ({ position: plugin.player.state.position ?? 0 }));
459
+ * bar.on("seek", (seconds: number) => plugin.player.seek(seconds));
460
+ * await bar.ready;
461
+ * ```
462
+ *
463
+ * @since 1.0.0
464
+ */
465
+ mount(slot: "bottom" | "sidebar" | "adjust" | "backdrop", file: string, options?: {
466
+ /** The exported component to mount, if the file exports several. */
467
+ component?: string;
468
+ /** The exported global to use as the bridge, if the file exports several. */
469
+ global?: string;
470
+ /** The tab label and the floating sidebar window's title (at most 128 bytes). */
471
+ title?: string;
472
+ }): Panel;
473
+ /**
474
+ * The backdrop position: whether a backdrop is mounted (by any plugin) and
475
+ * shown now.
476
+ */
477
+ readonly backdrop: BackdropSlot;
478
+ /** The bottom bar position, whoever mounted it; any plugin may read and toggle it. */
479
+ readonly bottom: PanelSlot;
480
+ /** The sidebar position, including its floating state; any plugin may read and toggle it. */
481
+ readonly sidebar: SidebarSlot;
482
+ /**
483
+ * The adjust column (player 0.7.6, SDK 1.6.11), whoever mounted there;
484
+ * any plugin may read and toggle it. The same shape as
485
+ * {@link Panels.sidebar} without floating: the adjust column never
486
+ * detaches.
487
+ *
488
+ * @remarks
489
+ * `state` is `null` while no plugin has a panel there. Players before
490
+ * 0.7.6 build the `plugin` object with their own SDK, which has no
491
+ * `adjust`: there `plugin.panels.adjust` is `undefined` and reading its
492
+ * `state` throws a `TypeError`, so declare `"minPlayerVersion": "0.7.6"`
493
+ * (or test `plugin.panels.adjust` first). The column starts hidden (`preferred: false`, `reason:
494
+ * "userHidden"`) until the user opens it. To open the column at your own
495
+ * panel, call {@link Panel.show} (or {@link Panel.toggle}, which closes it
496
+ * again when your tab is already the current one, the behaviour of the
497
+ * player's own `Alt+1…4`).
498
+ *
499
+ * @example Open the adjust column at this plugin's tab with a key
500
+ * One command opens the column at the plugin's tab, and pressing it again
501
+ * while that tab is shown closes the column. The panel's other commands
502
+ * name it as their `home`, so the player shows its key under the tab and
503
+ * the command palette knows where they live.
504
+ * ```ts
505
+ * const panel = plugin.panels.mount("adjust", "ui/wheels.slint", { title: "Wheels" });
506
+ * plugin.commands.add({
507
+ * id: "wheels",
508
+ * title: "Colour Wheels",
509
+ * bindings: ["Alt+5"],
510
+ * // Opens the column at this tab; closes it when this tab is shown.
511
+ * run: () => panel.toggle(),
512
+ * });
513
+ * plugin.commands.add({
514
+ * id: "wheels-reset",
515
+ * title: "Reset Colour Wheels",
516
+ * // Lives in the panel `wheels` opens: its key shows under the tab.
517
+ * home: "wheels",
518
+ * run: () => panel.set({ lift: 0 }),
519
+ * });
520
+ * ```
521
+ *
522
+ * @player 0.7.6 (declare `"minPlayerVersion": "0.7.6"`; older players
523
+ * have no `adjust`: reading its `state` throws a `TypeError`).
524
+ * @since 1.6.11
525
+ */
526
+ readonly adjust: PanelSlot;
527
+ }
528
+ /**
529
+ * Options of {@link Dialogs.confirm}. Lengths count Unicode characters (one
530
+ * Chinese character is one character).
531
+ *
532
+ * @since 1.0.0
533
+ * @category UI
534
+ */
535
+ export interface ConfirmOptions {
536
+ /** The question, shown in bold; 1–200 characters. */
537
+ message: TextValue;
538
+ /** More text under the message; at most 2000 characters. */
539
+ detail?: TextValue;
540
+ /** The confirm button's text (the default button: Enter picks it); 1–40 characters. */
541
+ confirm: TextValue;
542
+ /**
543
+ * The cancel button's text (Escape picks it); 1–40 characters.
544
+ *
545
+ * @defaultValue "Cancel", in the player's language
546
+ */
547
+ cancel?: TextValue;
548
+ /**
549
+ * Mark the confirm button as destructive: red text on macOS, a warning
550
+ * icon on Windows.
551
+ *
552
+ * @defaultValue `false`
553
+ */
554
+ destructive?: boolean;
555
+ /** A checkbox under the text, such as "Don't ask again"; 1–40 characters. */
556
+ checkbox?: TextValue;
557
+ /**
558
+ * Values for the placeholders of `message` and `detail` (player 0.4.3).
559
+ * Any of the texts may instead be a {@link Text} (SDK 1.5.11), which
560
+ * carries its own arguments; `args` only fills the string ones.
561
+ * Every text of the dialog is English source text that the player shows
562
+ * translated from the plugin's catalog; `message` and `detail` are
563
+ * templates like {@link Osd.show}'s. The length limits apply to the shown
564
+ * text.
565
+ *
566
+ * @since 1.5.9
567
+ */
568
+ args?: TemplateArgs;
569
+ }
570
+ /**
571
+ * The system's own dialogs: a confirmation alert and the open and save file
572
+ * dialogs. `plugin.dialogs`.
573
+ *
574
+ * @remarks
575
+ * The plugin passes text and gets the answer; the system draws the dialog,
576
+ * so it looks and behaves like every other dialog on the system. Each call
577
+ * resolves when the user answers; there is no time limit and no way to close
578
+ * a dialog from code. Only one dialog (of any kind, from any plugin) is open
579
+ * at a time: another call meanwhile rejects with `busy`. Playback continues
580
+ * while a dialog is open; command key bindings pause.
581
+ *
582
+ * **Platforms:** {@link Dialogs.confirm} needs macOS or Windows (other
583
+ * systems reject it with `unsupported`); the file dialogs work on every
584
+ * system.
585
+ *
586
+ * For anything more than a question or a path, use a {@link Windows | tool
587
+ * window}.
588
+ *
589
+ * @capability ui.dialog
590
+ *
591
+ * @example Ask before deleting, remembering "Don't ask again"
592
+ * Deleting asks for confirmation in a system alert with a "Don't ask
593
+ * again" box; once the user ticks it, later deletes go ahead without
594
+ * asking. `confirm` resolves with the button and the checkbox when the
595
+ * user answers; the texts are templates the player translates, so the
596
+ * count goes in `args`. Remembering the box is up to the plugin.
597
+ * ```ts
598
+ * const store = plugin.storage.json("confirm", { defaults: { askBeforeDelete: true } });
599
+ * async function deleteAll(count: number) {
600
+ * if (store.value.askBeforeDelete) {
601
+ * const { confirmed, checked } = await plugin.dialogs.confirm({
602
+ * message: "Delete {} bookmarks?",
603
+ * args: [count],
604
+ * detail: "This cannot be undone.",
605
+ * confirm: "Delete",
606
+ * destructive: true,
607
+ * checkbox: "Don't ask again",
608
+ * });
609
+ * if (!confirmed) return;
610
+ * if (checked) store.save({ askBeforeDelete: false });
611
+ * }
612
+ * // … delete …
613
+ * }
614
+ * ```
615
+ *
616
+ * @see [Windows, panels, settings pages, dialogs and the OSD](../../../docs/explanation/ui.md)
617
+ * @since 1.0.0
618
+ * @category UI
619
+ */
620
+ export interface Dialogs {
621
+ /**
622
+ * Ask the user to confirm something, in a system alert.
623
+ *
624
+ * @remarks
625
+ * **macOS:** an `NSAlert` sheet on the active player window (usually the
626
+ * tool window the user just clicked in), else on the main window.
627
+ *
628
+ * **Windows:** a task dialog owned by the active player window, titled
629
+ * "Vestra Player"; `detail` follows `message` after a blank line. A
630
+ * `checkbox` is asked as a second yes/no dialog after the user confirms
631
+ * (on cancel it is not asked and `checked` is `false`).
632
+ *
633
+ * Remembering "Don't ask again" is up to the plugin (see
634
+ * {@link Scope.storage}).
635
+ *
636
+ * @capability ui.dialog
637
+ *
638
+ * @param options - The text and buttons; see {@link ConfirmOptions}.
639
+ * @returns The answer: `confirmed` is `true` when the user picked the
640
+ * confirm button (Escape, the cancel button or closing the dialog give
641
+ * `false`); `checked` is the checkbox's state (`false` without one).
642
+ *
643
+ * @throws `invalid` (rejects) A text is empty or too long, or `destructive`
644
+ * is not a boolean.
645
+ * @throws `busy` (rejects) Another dialog is open.
646
+ * @throws `unavailable` (rejects) The player runs without a user interface.
647
+ * @throws `unsupported` (rejects) A system other than macOS and Windows.
648
+ * @throws `capability` (rejects) The manifest does not declare `ui.dialog`.
649
+ *
650
+ * @example Confirm before replacing the playlist
651
+ * The user sees "Replace the current playlist?" with a Replace button and
652
+ * the playlist is replaced only after a yes. The system draws the alert
653
+ * and the promise resolves when the user answers; only one dialog is
654
+ * open at a time, so a second one meanwhile rejects with `busy`.
655
+ * ```ts
656
+ * try {
657
+ * const { confirmed } = await plugin.dialogs.confirm({
658
+ * message: "Replace the current playlist?",
659
+ * confirm: "Replace",
660
+ * });
661
+ * if (confirmed) await plugin.osd.show("Playlist replaced");
662
+ * } catch (error) {
663
+ * if ((error as PluginError).code !== "busy") throw error;
664
+ * // Another dialog is already open: let the user finish that one.
665
+ * }
666
+ * ```
667
+ *
668
+ * @since 1.0.0
669
+ */
670
+ confirm(options: ConfirmOptions): Promise<{
671
+ /** The user picked the confirm button. */
672
+ confirmed: boolean;
673
+ /** The checkbox's state (`false` without one; reported on cancel too). */
674
+ checked: boolean;
675
+ }>;
676
+ /**
677
+ * Ask the user for one file to open.
678
+ *
679
+ * @capability ui.dialog
680
+ *
681
+ * @param options - `title`: the dialog's title, at most 256 bytes.
682
+ * @returns The absolute path, or `null` when the user cancelled.
683
+ *
684
+ * @throws `busy` (rejects) Another dialog is open.
685
+ * @throws `unavailable` (rejects) The player runs without a user interface.
686
+ * @throws `invalid` (rejects) `title` is longer than 256 bytes.
687
+ * @throws `capability` (rejects) The manifest does not declare `ui.dialog`.
688
+ *
689
+ * @example Let the user pick a subtitle file
690
+ * The system's Open dialog appears titled "Choose a subtitle file" and
691
+ * the chosen path is shown on the OSD. The promise resolves when the
692
+ * user answers: with the absolute path, or `null` when they cancelled.
693
+ * ```ts
694
+ * const path = await plugin.dialogs.openFile({ title: "Choose a subtitle file" });
695
+ * if (path !== null) await plugin.osd.show("Chosen: {}", [path]); // a path is data
696
+ * ```
697
+ *
698
+ * @since 1.0.0
699
+ */
700
+ openFile(options?: {
701
+ /** The dialog's title (English source text or a {@link Text}), at most 256 bytes. */
702
+ title?: TextValue;
703
+ }): Promise<string | null>;
704
+ /**
705
+ * Ask the user for one or more files to open.
706
+ *
707
+ * @capability ui.dialog
708
+ *
709
+ * @param options - `title`: the dialog's title, at most 256 bytes.
710
+ * @returns The absolute paths, or `[]` when the user cancelled.
711
+ *
712
+ * @throws `busy` (rejects) Another dialog is open.
713
+ * @throws `unavailable` (rejects) The player runs without a user interface.
714
+ * @throws `invalid` (rejects) `title` is longer than 256 bytes.
715
+ * @throws `capability` (rejects) The manifest does not declare `ui.dialog`.
716
+ *
717
+ * @example Let the user pick several files at once
718
+ * The Open dialog allows selecting several files; the OSD says how many
719
+ * were added. The promise resolves with the absolute paths, or with an
720
+ * empty array when the user cancelled.
721
+ * ```ts
722
+ * const paths = await plugin.dialogs.openFiles({ title: "Add to the playlist" });
723
+ * if (paths.length) await plugin.osd.show("{} files added", [paths.length]);
724
+ * ```
725
+ *
726
+ * @since 1.0.0
727
+ */
728
+ openFiles(options?: {
729
+ /** The dialog's title (English source text or a {@link Text}), at most 256 bytes. */
730
+ title?: TextValue;
731
+ }): Promise<string[]>;
732
+ /**
733
+ * Ask the user for a folder.
734
+ *
735
+ * @capability ui.dialog
736
+ *
737
+ * @param options - `title`: the dialog's title, at most 256 bytes.
738
+ * @returns The absolute path, or `null` when the user cancelled.
739
+ *
740
+ * @throws `busy` (rejects) Another dialog is open.
741
+ * @throws `unavailable` (rejects) The player runs without a user interface.
742
+ * @throws `invalid` (rejects) `title` is longer than 256 bytes.
743
+ * @throws `capability` (rejects) The manifest does not declare `ui.dialog`.
744
+ *
745
+ * @example Let the user choose a folder for snapshots
746
+ * The system's folder dialog appears titled "Save snapshots in". It
747
+ * resolves with the folder's absolute path, or `null` when the user
748
+ * cancelled, in which case the plugin stops there.
749
+ * ```ts
750
+ * const folder = await plugin.dialogs.openDirectory({ title: "Save snapshots in" });
751
+ * if (folder === null) return; // cancelled
752
+ * ```
753
+ *
754
+ * @since 1.0.0
755
+ */
756
+ openDirectory(options?: {
757
+ /** The dialog's title (English source text or a {@link Text}), at most 256 bytes. */
758
+ title?: TextValue;
759
+ }): Promise<string | null>;
760
+ /**
761
+ * Ask the user where to save a file.
762
+ *
763
+ * @remarks
764
+ * The dialog only returns a path; writing the file is up to the plugin.
765
+ *
766
+ * @capability ui.dialog
767
+ *
768
+ * @param options - `title`: the dialog's title, at most 256 bytes.
769
+ * `fileName`: the proposed file name (a plain name without `/` or `\`,
770
+ * at most 256 bytes).
771
+ * @returns The absolute path, or `null` when the user cancelled.
772
+ *
773
+ * @throws `busy` (rejects) Another dialog is open.
774
+ * @throws `unavailable` (rejects) The player runs without a user interface.
775
+ * @throws `invalid` (rejects) `title` is too long, or `fileName` is too long
776
+ * or contains `/` or `\`.
777
+ * @throws `capability` (rejects) The manifest does not declare `ui.dialog`.
778
+ *
779
+ * @example Ask where to save a snapshot
780
+ * The system's Save dialog proposes "frame.png" and returns where the
781
+ * user wants it. The dialog only returns the path (or `null` when
782
+ * cancelled); writing the file is up to the plugin afterwards.
783
+ * ```ts
784
+ * const path = await plugin.dialogs.saveFile({ title: "Save snapshot", fileName: "frame.png" });
785
+ * if (path === null) return; // cancelled
786
+ * ```
787
+ *
788
+ * @since 1.0.0
789
+ */
790
+ saveFile(options?: {
791
+ /** The dialog's title (English source text or a {@link Text}), at most 256 bytes. */
792
+ title?: TextValue;
793
+ /**
794
+ * The proposed file name: a plain name, at most 256 bytes. A string is
795
+ * data (not translated); a {@link Text} (SDK 1.5.11) is shown
796
+ * translated, `text("Playlist.m3u8")` (a `/` or `\\` in a translation
797
+ * becomes `-`).
798
+ */
799
+ fileName?: TextValue;
800
+ }): Promise<string | null>;
801
+ }
802
+ /**
803
+ * This plugin's information block on the OSD: multi-line text over the
804
+ * video that stays until the plugin changes or removes it. Made by
805
+ * {@link Osd.panel}.
806
+ *
807
+ * @remarks
808
+ * The block sits under the OSD message line, on a translucent dark plate
809
+ * (see {@link Osd} for sizes), and takes no input. When
810
+ * several plugins have one, they are stacked from top to bottom. `dispose()`,
811
+ * disposing the scope or stopping the plugin removes it.
812
+ *
813
+ * @capability ui.osd
814
+ *
815
+ * @example Show live playback numbers over the video
816
+ * A block over the video shows the position and the duration, updated
817
+ * as playback moves. `player.onChange` runs after the SDK updated the
818
+ * state (with `events`); `set` never throws and sends only the newest
819
+ * text while one is in flight, so calling it on every change is fine.
820
+ * ```ts
821
+ * const info = plugin.osd.panel();
822
+ * plugin.player.onChange((state) =>
823
+ * // A template with data arguments; the player translates "{} / {} s".
824
+ * info.set("{} / {} s", [state.position?.toFixed(1) ?? "–", state.duration?.toFixed(1) ?? "–"]),
825
+ * );
826
+ * ```
827
+ *
828
+ * @since 1.0.0
829
+ * @category UI
830
+ */
831
+ export interface OsdPanel extends Disposable {
832
+ /**
833
+ * Show the block with this text, change it, or hide it.
834
+ *
835
+ * @remarks
836
+ * Latest value wins: calling it on every state change is fine, the same
837
+ * text is not sent twice and only the newest text is sent while a write is
838
+ * in flight. Never throws; a failed write goes to {@link Scope.onError}
839
+ * (`invalid` for too much text, `unavailable` without a user interface,
840
+ * `capability` without `ui.osd`).
841
+ *
842
+ * @capability ui.osd
843
+ *
844
+ * @param text - The text, with `\n` between lines: at most 32 lines and
845
+ * 4096 bytes once translated and formatted. `null` hides the block. A
846
+ * template, like {@link Osd.show}'s.
847
+ * @param args - Values for its placeholders (player 0.4.3); `null` or
848
+ * omitted for none.
849
+ * @param options - `maxColumns`: cut long lines (SDK 1.5.11).
850
+ *
851
+ * @example Show two loop points, then hide the block
852
+ * The block shows "A: 12.0 s" and "B: 18.5 s" on two lines, then
853
+ * disappears. The text is a template the player translates and fills
854
+ * in; `\n` separates lines, and `null` hides the block.
855
+ * ```ts
856
+ * const info = plugin.osd.panel();
857
+ * info.set("A: {} s\nB: {} s", ["12.0", "18.5"]);
858
+ * info.set(null); // hide it
859
+ * ```
860
+ *
861
+ * @since 1.0.0
862
+ */
863
+ set(text: TextValue | null, args?: TemplateArgs | null, options?: OsdPanelOptions): void;
864
+ }
865
+ /**
866
+ * Options of {@link OsdPanel.set}.
867
+ *
868
+ * @since 1.5.11
869
+ * @category UI
870
+ */
871
+ export interface OsdPanelOptions {
872
+ /**
873
+ * Cut every line longer than this many columns, after translation and
874
+ * formatting, ending it with `…`: a wide character (Chinese, Japanese,
875
+ * Korean, full-width forms) is two columns, a combining mark none, any
876
+ * other one. An integer from 8 to 1000 (player 0.4.3; older players show
877
+ * whole lines). Measure the video area to choose it.
878
+ */
879
+ maxColumns?: number;
880
+ }
881
+ /**
882
+ * Text the player draws over the video: short messages and an information
883
+ * block. `plugin.osd`.
884
+ *
885
+ * @remarks
886
+ * The on-screen display (OSD) is the lightest way to tell the user something:
887
+ * no Slint file, no window, visible in fullscreen. A message
888
+ * ({@link Osd.show}) is one line at the top left of the video that
889
+ * disappears after 2 seconds; a newer message, from any plugin, replaces it.
890
+ * The information block ({@link Osd.panel}) stays until the plugin changes
891
+ * or removes it.
892
+ *
893
+ * How the player draws them (a player before 0.4.0 drew bold white text
894
+ * with a black outline instead):
895
+ *
896
+ * - **Message**: white text on a translucent dark plate with rounded
897
+ * corners and a gradient line along its bottom edge, 10px from the
898
+ * video area's left and top edges.
899
+ * - **Font size** follows the video area: 3 % of its height, rounded and
900
+ * clamped to 12–48px (about 18px in the default window, 32px in
901
+ * fullscreen at 1080 pixels high). The plate's padding and corners scale
902
+ * with it.
903
+ * - **Information block**: 4px below the message plate, on the same kind of
904
+ * plate; its font scales in proportion (11px when the message is 16px),
905
+ * clamped to 9–28px.
906
+ *
907
+ * How long a text may be is in
908
+ * [Limits: on-screen display](../../../docs/reference/limits.md#on-screen-display)
909
+ * ({@link "@vestra-player/sdk/testing"!OSD_LIMITS | OSD_LIMITS}).
910
+ *
911
+ * @capability ui.osd
912
+ *
913
+ * @example Show on-screen messages the user can turn off
914
+ * "Blur on" appears over the video unless the user turned messages off in
915
+ * the plugin's settings. `osd.show` asks the player to draw the text for a
916
+ * moment; the plugin checks its own stored preference before each call.
917
+ * ```ts
918
+ * const store = plugin.storage.json("prefs", { defaults: { messages: true } });
919
+ * const say = (text: string) => {
920
+ * if (store.value.messages) void plugin.osd.show(text);
921
+ * };
922
+ * say("Blur on");
923
+ * ```
924
+ *
925
+ * @see {@link OsdPanel}, [Windows, panels, settings pages, dialogs and the OSD](../../../docs/explanation/ui.md)
926
+ * @since 1.0.0
927
+ * @category UI
928
+ */
929
+ export interface Osd {
930
+ /**
931
+ * Show a one-line message at the top left of the video for 2 seconds.
932
+ *
933
+ * @remarks
934
+ * Replaces the message on screen, whichever plugin showed it. A message
935
+ * that is on screen when the plugin stops still disappears on time.
936
+ *
937
+ * The text is a template in English: the player shows its translation
938
+ * from the plugin's catalog, with the placeholders (`{}`, `{0}`, `{name}`;
939
+ * `{{` and `}}` for braces) filled from `args`. Without `args` the text
940
+ * shows as it is (braces included). Untranslated, the English template is
941
+ * formatted. Never compose the sentence in TypeScript
942
+ * (`` `Speed ${rate}×` ``): translators can only translate whole templates.
943
+ * An argument that is itself words is a {@link Text} (SDK 1.5.11), and a
944
+ * message made of a varying number of parts is a {@link TextList} of
945
+ * texts; `text` may also be a `Text` (then without `args`).
946
+ *
947
+ * @capability ui.osd
948
+ *
949
+ * @param text - The template, 1–200 characters once translated and
950
+ * formatted; line breaks become spaces.
951
+ * With `options.actions` (player 0.7.6) the message ends in up to two
952
+ * buttons, each running one of the plugin's own commands
953
+ * ({@link OsdShowOptions}). Older players show the message without them.
954
+ *
955
+ * @param args - Values for its placeholders (player 0.4.3; older players
956
+ * show the template as it is). Pass `null` with a `Text` and options.
957
+ * @param options - Action buttons after the text (SDK 1.6.9).
958
+ * @returns Resolves once the message is on screen.
959
+ *
960
+ * @throws `invalid` (rejects) The shown text is empty, only white space,
961
+ * or longer than 200 characters, or `args` is not a {@link TemplateArgs};
962
+ * or there are more than 2 actions, a title is empty or longer than 40
963
+ * characters once translated, or a command is not one of the plugin's.
964
+ * @throws `unavailable` (rejects) The player runs without a user interface.
965
+ * @throws `capability` (rejects) The manifest does not declare `ui.osd`.
966
+ *
967
+ * @example Confirm an action and show a value
968
+ * The OSD shows "Bookmark added", then "Speed 1.5×" in the user's
969
+ * language. The text is English source the player translates with the
970
+ * plugin's catalog; `{}` is filled in with the argument, which stays as
971
+ * it is because it is data.
972
+ * ```ts
973
+ * await plugin.osd.show("Bookmark added");
974
+ * await plugin.osd.show("Speed {}×", [plugin.player.state.rate]);
975
+ * ```
976
+ *
977
+ * @example Offer "Show in Folder" after saving a file
978
+ * The OSD reads "Saved clip.mp4 [Show in Folder]" for about 4 seconds,
979
+ * longer while the pointer is on it. A click runs the plugin's own
980
+ * `reveal` command, which knows the last saved file; the message goes.
981
+ * ```ts
982
+ * declare const path: string;
983
+ * // ---cut---
984
+ * let saved = path; // the command acts on the last saved file
985
+ * plugin.commands.add({
986
+ * id: "reveal",
987
+ * title: "Show Last Saved File in Folder",
988
+ * enabled: () => saved !== "",
989
+ * run: () => plugin.system.reveal(saved),
990
+ * });
991
+ * await plugin.osd.show("Saved {}", [saved.split(/[\\/]/).pop() ?? saved], {
992
+ * actions: [{ title: "Show in Folder", command: "reveal" }], // one button
993
+ * });
994
+ * ```
995
+ *
996
+ * @since 1.0.0
997
+ */
998
+ show(text: TextValue, args?: TemplateArgs | null, options?: OsdShowOptions): Promise<void>;
999
+ /**
1000
+ * Create this plugin's information block.
1001
+ *
1002
+ * @remarks
1003
+ * Nothing is shown until {@link OsdPanel.set}. A plugin has one block;
1004
+ * dispose it before creating another.
1005
+ *
1006
+ * @capability ui.osd
1007
+ *
1008
+ * @returns An {@link OsdPanel} owned by this scope.
1009
+ *
1010
+ * @throws `Error` without a code (throws) This plugin already has a block.
1011
+ *
1012
+ * @example Show a status block over the video
1013
+ * A small block over the video says "Loop: off" until the plugin changes
1014
+ * or hides it. Each plugin has one block, stacked with other plugins'
1015
+ * blocks; a second `panel()` call throws.
1016
+ * ```ts
1017
+ * const info = plugin.osd.panel();
1018
+ * info.set("Loop: off");
1019
+ * ```
1020
+ *
1021
+ * @since 1.0.0
1022
+ */
1023
+ panel(): OsdPanel;
1024
+ }
1025
+ /**
1026
+ * One button at the end of an OSD message ({@link Osd.show}, player 0.7.6).
1027
+ *
1028
+ * @since 1.6.9
1029
+ * @category UI
1030
+ */
1031
+ export interface OsdAction {
1032
+ /**
1033
+ * The button's label: English source text the player translates with the
1034
+ * plugin's catalog, or a {@link Text}; 1–40 characters once translated
1035
+ * (`OSD_LIMITS.actionChars`). A verb, as on a menu item: "Show in
1036
+ * Folder", "Copy", "Undo".
1037
+ */
1038
+ title: TextValue;
1039
+ /**
1040
+ * The local id of one of this plugin's own commands
1041
+ * ({@link CommandOptions.id}), declared when the message is shown. A
1042
+ * click runs it as if the user picked it from a menu: a disabled command
1043
+ * does nothing. The command takes no arguments, so it acts on what the
1044
+ * plugin remembers (the file it just saved).
1045
+ */
1046
+ command: string;
1047
+ }
1048
+ /**
1049
+ * Options of {@link Osd.show} (SDK 1.6.9).
1050
+ *
1051
+ * @remarks
1052
+ * A message with actions stays about 4 seconds instead of 2, and does not
1053
+ * fade while the pointer is on it and moving: it goes 2 seconds after the
1054
+ * pointer leaves or rests (the player's idle time), and at the latest 30
1055
+ * seconds after it showed, hovered or not. A click on a button runs its
1056
+ * command and removes the message.
1057
+ * It is still one line: the buttons follow the text. Buttons take no
1058
+ * keyboard focus; screen readers can press them. A newer message, from any
1059
+ * plugin or the player, replaces the message with its buttons, and the
1060
+ * buttons go when the plugin stops. While its buttons show, the plugin is
1061
+ * not stopped for being idle.
1062
+ *
1063
+ * Players before 0.7.6 ignore `actions` and show the text alone for 2
1064
+ * seconds, so do not make an action the only way to reach something.
1065
+ *
1066
+ * @since 1.6.9
1067
+ * @category UI
1068
+ */
1069
+ export interface OsdShowOptions {
1070
+ /** At most 2 buttons (`OSD_LIMITS.actions`), in order after the text. */
1071
+ actions?: readonly OsdAction[];
1072
+ }