@vestra-player/sdk 1.6.20 → 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.
- package/CHANGELOG.md +11 -0
- package/dist/docs-tree.json.gz +0 -0
- package/dist/i18n-tools.js +7 -2
- package/dist/plugin/types/base.d.ts +1097 -0
- package/dist/plugin/types/base.js +1 -0
- package/dist/plugin/types/commands.d.ts +1189 -0
- package/dist/plugin/types/commands.js +1 -0
- package/dist/plugin/types/packages.d.ts +661 -0
- package/dist/plugin/types/packages.js +1 -0
- package/dist/plugin/types/playback.d.ts +1654 -0
- package/dist/plugin/types/playback.js +1 -0
- package/dist/plugin/types/processing.d.ts +974 -0
- package/dist/plugin/types/processing.js +1 -0
- package/dist/plugin/types/services.d.ts +1132 -0
- package/dist/plugin/types/services.js +1 -0
- package/dist/plugin/types/snapshots.d.ts +491 -0
- package/dist/plugin/types/snapshots.js +1 -0
- package/dist/plugin/types/sources.d.ts +302 -0
- package/dist/plugin/types/sources.js +1 -0
- package/dist/plugin/types/subtitles.d.ts +327 -0
- package/dist/plugin/types/subtitles.js +1 -0
- package/dist/plugin/types/ui-content.d.ts +692 -0
- package/dist/plugin/types/ui-content.js +1 -0
- package/dist/plugin/types/ui-layout.d.ts +1079 -0
- package/dist/plugin/types/ui-layout.js +1 -0
- package/dist/plugin/types/ui-locale.d.ts +490 -0
- package/dist/plugin/types/ui-locale.js +1 -0
- package/dist/plugin/types/ui-shell.d.ts +1072 -0
- package/dist/plugin/types/ui-shell.js +1 -0
- package/dist/plugin/types.d.ts +18 -11072
- package/llms.txt +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,1097 @@
|
|
|
1
|
+
import type { Command } from "./commands.ts";
|
|
2
|
+
import type { PackageCandidate, PluginInfo } from "./packages.ts";
|
|
3
|
+
import type { Conditional, Media, Stream } from "./playback.ts";
|
|
4
|
+
import type {
|
|
5
|
+
JsonStore,
|
|
6
|
+
RenderingReasonCode,
|
|
7
|
+
RenderingState,
|
|
8
|
+
} from "./services.ts";
|
|
9
|
+
import type { ExportJob, Snapshot } from "./snapshots.ts";
|
|
10
|
+
import type { Resolver } from "./sources.ts";
|
|
11
|
+
import type { PropValue } from "./ui-content.ts";
|
|
12
|
+
import type { Panel, Window } from "./ui-layout.ts";
|
|
13
|
+
import type { Bindings, Commands, Host, When } from "./commands.ts";
|
|
14
|
+
import type { Packages } from "./packages.ts";
|
|
15
|
+
import type { Player, Timeline } from "./playback.ts";
|
|
16
|
+
import type { AudioFilter, RenderOptions, VideoFilter, VideoShaders, VideoUpscaling, VideoView } from "./processing.ts";
|
|
17
|
+
import type { Clipboard, Power, Rendering, RenderingReason, Secrets, Storage, System, Tools } from "./services.ts";
|
|
18
|
+
import type { MediaCapture } from "./snapshots.ts";
|
|
19
|
+
import type { Resolvers } from "./sources.ts";
|
|
20
|
+
import type { Subtitles } from "./subtitles.ts";
|
|
21
|
+
import type { Ui } from "./ui-content.ts";
|
|
22
|
+
import type { Drops, Windows } from "./ui-layout.ts";
|
|
23
|
+
import type { Appearance, I18n } from "./ui-locale.ts";
|
|
24
|
+
import type { Dialogs, Osd, Panels, Settings } from "./ui-shell.ts";
|
|
25
|
+
/**
|
|
26
|
+
* Anything that owns player-side or local resources: every handle the API
|
|
27
|
+
* returns (commands, windows, panels, filters, snapshots, listeners…).
|
|
28
|
+
*
|
|
29
|
+
* A handle belongs to the {@link Scope} that created it and is disposed with
|
|
30
|
+
* that scope, so most plugins never call `dispose()` themselves. Call it to
|
|
31
|
+
* release one resource early. Disposing twice is harmless, and `dispose()`
|
|
32
|
+
* never rejects: failures are only written to the plugin log.
|
|
33
|
+
*
|
|
34
|
+
* What disposal does depends on the handle: a {@link Command} leaves the menu
|
|
35
|
+
* and the binding table, a {@link Window} closes, a {@link Panel} is
|
|
36
|
+
* unmounted, a {@link VideoFilter} / {@link AudioFilter} withdraws this
|
|
37
|
+
* plugin's chain, a {@link Snapshot} is released, an unfinished
|
|
38
|
+
* {@link ExportJob} is cancelled, a {@link Stream} stops, a {@link Resolver}
|
|
39
|
+
* is unregistered (aborting resolutions in flight), a {@link JsonStore}
|
|
40
|
+
* flushes, a running `tools.run` process is killed and a listener is
|
|
41
|
+
* unsubscribed. A {@link Media} is the exception: disposing its scope does
|
|
42
|
+
* **not** close the media; call {@link Media.close} for that.
|
|
43
|
+
*
|
|
44
|
+
* @example Stop listening once the file is ready
|
|
45
|
+
* The listener reacts to the first time the source becomes ready and then
|
|
46
|
+
* stops being called. Every registration returns a `Disposable`;
|
|
47
|
+
* disposing it removes just that listener, before the scope that owns it
|
|
48
|
+
* ends.
|
|
49
|
+
* ```ts
|
|
50
|
+
* const subscription = plugin.player.onChange((state) => {
|
|
51
|
+
* if (state.phase === "ready") void subscription.dispose();
|
|
52
|
+
* });
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* @remarks
|
|
56
|
+
* Every handle a plugin creates is a `Disposable` owned by the scope that
|
|
57
|
+
* created it; disposing the scope (or stopping the plugin) disposes them in
|
|
58
|
+
* reverse creation order, so a plugin rarely calls `dispose` itself.
|
|
59
|
+
*
|
|
60
|
+
* @capability None of its own: that of the handle.
|
|
61
|
+
* @since 1.0.0
|
|
62
|
+
* @category Plugin
|
|
63
|
+
*/
|
|
64
|
+
export interface Disposable {
|
|
65
|
+
/**
|
|
66
|
+
* Release the resource. Resolves once the player confirmed the release
|
|
67
|
+
* (or immediately for purely local resources). Never rejects.
|
|
68
|
+
*
|
|
69
|
+
* @capability None of its own: that of the handle.
|
|
70
|
+
* @throws Never.
|
|
71
|
+
*
|
|
72
|
+
* @example Remove a command when its feature is turned off
|
|
73
|
+
* A "Turn feature off" item removes the feature's own menu item at once,
|
|
74
|
+
* before the plugin stops. `dispose` takes the command out of the menu and
|
|
75
|
+
* the binding table and resolves once the player confirmed it; the id can
|
|
76
|
+
* be added again later.
|
|
77
|
+
* ```ts
|
|
78
|
+
* const extra = plugin.commands.add({ id: "extra", path: ["Tools", "Extra"], run() {} });
|
|
79
|
+
* plugin.commands.add({
|
|
80
|
+
* id: "extra-off",
|
|
81
|
+
* path: ["Tools", "Turn extra off"],
|
|
82
|
+
* run: () => extra.dispose(), // never rejects
|
|
83
|
+
* });
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
86
|
+
* @since 1.0.0
|
|
87
|
+
*/
|
|
88
|
+
dispose(): Promise<void>;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Every API failure is an ordinary `Error` with a stable string `code`.
|
|
92
|
+
* Branch on `code`, never on `message` (the message is for logs and may
|
|
93
|
+
* change).
|
|
94
|
+
*
|
|
95
|
+
* | code | meaning |
|
|
96
|
+
* | --- | --- |
|
|
97
|
+
* | `stale` | A condition no longer held (the source or the subtitle selection changed); nothing was done. See {@link Conditional}. |
|
|
98
|
+
* | `capability` | The manifest does not declare the capability the call needs. |
|
|
99
|
+
* | `invalid` | A bad argument (out of range, malformed, unknown id). |
|
|
100
|
+
* | `missing` | The target does not exist (an empty panel position, a missing file, an unknown command). |
|
|
101
|
+
* | `busy` | The player is still doing a previous call of the same kind (a dialog is open, a step is in flight). |
|
|
102
|
+
* | `conflict` | Another plugin owns the resource (the sequence provider, the display layer, the backdrop, a menu path), or this plugin already uses the id (a window or command id). |
|
|
103
|
+
* | `unavailable` | Not possible right now (no ready media, no user interface, fullscreen, a disabled core action). |
|
|
104
|
+
* | `unsupported` | Not possible on this system, build or source (a platform gap, software rendering, a source that cannot seek, a filter on a generated stream, an export the player cannot make as asked: a stream copy, a source bitrate it cannot tell). |
|
|
105
|
+
* | `backend` | Loading or resolving failed; `message` is the backend's reason. |
|
|
106
|
+
* | `failed` | The operation ran and failed (`media.ready()` load error, a non-zero `tools.run` exit, the system refused). |
|
|
107
|
+
* | `replaced` | Accepted, but another source replaced it before it finished. |
|
|
108
|
+
* | `ended` | {@link Media.ready}: the media already played to the end. |
|
|
109
|
+
* | `noSource` | {@link MediaCapture.capture}: nothing is playing to capture. |
|
|
110
|
+
* | `released`, `disposed` | A {@link Snapshot} used after `release()`; an {@link ExportJob} handle disposed while something still waited for it. |
|
|
111
|
+
* | `aborted` | An `AbortSignal` fired (`error.name === "AbortError"`). |
|
|
112
|
+
* | `timeout` | A time limit ran out (`openStream` start-up, `tools.run`, `system.*` after 10 s). |
|
|
113
|
+
* | `stream`, `device` | `openStream`: the producer failed / the audio device is not ready. |
|
|
114
|
+
* | `backend-uncertain` | The player's backend blocked a filter stage; call `retry()`. |
|
|
115
|
+
* | `limit` | A player-wide limit was reached (for example the number of commands), a property value is over the limits of {@link PropValue}, or a request is longer than the player's 1 MiB message. |
|
|
116
|
+
* | `reserved` | {@link Packages.validate}, {@link PackageCandidate.install}: the id is `vestra` or starts with `vestra.` (any case), which only the player's built-in plugins use (player 0.4.1). |
|
|
117
|
+
* | `versionMismatch` | The package needs a newer player (`minPlayerVersion`). |
|
|
118
|
+
* | `ui-prepare` | The player could not prepare a mounted panel or a settings page (its Slint file does not compile, a bound property is not declared, or another plugin's panel holds the slot); `message` has the diagnostics. |
|
|
119
|
+
* | `ui` | The player could not apply a property to a tool window or a settings page, or could not build the Options window (a property the Slint file does not declare, a value of the wrong type); `message` has Slint's reason. Also reported to {@link Scope.onError} without a request: a callback whose arguments the player could not convert, a property it could not show again when it rebuilt a view (an image file removed since). |
|
|
120
|
+
* | `host` | Any other failure inside the player; `message` is the player's reason. |
|
|
121
|
+
* | `disabled` | The plugin is being stopped; pending requests fail with it. |
|
|
122
|
+
* | `unknown`, `rejected`, `expired` | After a transport problem the SDK could not confirm the outcome (does not happen in normal operation). |
|
|
123
|
+
* | `activation` | The plugin opened a tool window while its activation was still pending and the player could not track it. |
|
|
124
|
+
* | `command` | The player could not run or update a command it no longer knows for this plugin (removed meanwhile, or another plugin's). |
|
|
125
|
+
* | `export-failed` | An export job ({@link ExportJob}) failed: the code of its `outcome.error`, not a rejection; `message` has the worker's or FFmpeg's reason. |
|
|
126
|
+
* | `input-overflow` | `openStream` input: the player's queue of physical key transitions was full; the input was revoked and its keys released. |
|
|
127
|
+
* | `internal` | An internal step of the player failed (keeping an operation's result, a subtitle or media job); `message` has the reason. |
|
|
128
|
+
* | `javascript`, `slint` | {@link Packages.validate}: the package's entry module does not pass `node --check` / one of its Slint files does not compile; `message` has the diagnostics. |
|
|
129
|
+
* | `owner` | A resolver answered a request that belongs to another plugin's resolver. |
|
|
130
|
+
* | `pending` | An operation with the same token is still running in the player. The SDK waits and asks again, so it rarely reaches a plugin. |
|
|
131
|
+
* | `producer` | `openStream`: the player refused or lost the generated stream; `message` has the reason. |
|
|
132
|
+
* | `resolution` | A file or web resolver's result could not be opened; `message` has the reason. |
|
|
133
|
+
* | `revisionConflict` | {@link Packages}: the installed revision changed since it was read (another install or uninstall ran). Read again and retry; the SDK passes the revision it read, so this reaches plugins that act on old data. |
|
|
134
|
+
* | `source-geometry`, `source-geometry-unsupported` | The source's picture size or rotation could not be applied: invalid decoder dimensions / a rotation that is not a multiple of 90°. |
|
|
135
|
+
* | `previous-crash` | {@link VideoShaders}, {@link RenderOptions} `shaders` (player 0.6.3): plugin shaders are off because the player ended abnormally while they were drawing; clearing still works. Do not retry while refused (the player shows its own OSD line). |
|
|
136
|
+
* | `source-unavailable` | The source is not ready (still loading, or its time or native binding is not available yet). |
|
|
137
|
+
* | `unknown-expired` | The player no longer knows the operation or snapshot (it expired or was released). The SDK maps it to `unknownExpired` results where it can; do not resubmit the operation blindly. |
|
|
138
|
+
*
|
|
139
|
+
* Errors thrown by handlers the SDK invokes go to {@link Scope.onError}. A
|
|
140
|
+
* rejected promise you forgot to `await` is only logged; it never crashes
|
|
141
|
+
* the plugin process. Requests have no client-side timeout: the player
|
|
142
|
+
* answers every request or stops the plugin.
|
|
143
|
+
*
|
|
144
|
+
* @example Ignore a seek that lost a race, rethrow anything else
|
|
145
|
+
* The plugin seeks to 0:30 and stays quiet when another file was opened in
|
|
146
|
+
* between. Every failure is an `Error` with a stable `code`; `stale` means
|
|
147
|
+
* the source changed since the state the call was based on and nothing
|
|
148
|
+
* was done, so it is safe to drop. Other codes are real failures.
|
|
149
|
+
* ```ts
|
|
150
|
+
* try {
|
|
151
|
+
* await plugin.player.seek(30);
|
|
152
|
+
* } catch (error) {
|
|
153
|
+
* if ((error as PluginError).code === "stale") return; // someone else changed the source
|
|
154
|
+
* throw error;
|
|
155
|
+
* }
|
|
156
|
+
* ```
|
|
157
|
+
*
|
|
158
|
+
* @since 1.0.0
|
|
159
|
+
* @category Plugin
|
|
160
|
+
*/
|
|
161
|
+
export type PluginError = Error & {
|
|
162
|
+
/** The stable failure code (see the table above). */
|
|
163
|
+
code: string;
|
|
164
|
+
};
|
|
165
|
+
/**
|
|
166
|
+
* A group of handles released together.
|
|
167
|
+
*
|
|
168
|
+
* {@link Plugin} is the root scope. Create a child with {@link Scope.scope}
|
|
169
|
+
* for a feature that can be torn down on its own (a dynamic submenu, a
|
|
170
|
+
* temporary window and its listeners). Both have exactly the same modules;
|
|
171
|
+
* a handle created through a child belongs only to that child, and
|
|
172
|
+
* `child.dispose()` releases its handles and deeper children in reverse
|
|
173
|
+
* creation order.
|
|
174
|
+
*
|
|
175
|
+
* Capabilities: each module documents the manifest capability it needs.
|
|
176
|
+
* Reading {@link Scope.window}, {@link Scope.app}, {@link Scope.appearance}
|
|
177
|
+
* `.theme`, {@link Scope.ui}, {@link Scope.tools}, {@link Scope.storage} and
|
|
178
|
+
* {@link Scope.system} needs none.
|
|
179
|
+
*
|
|
180
|
+
* @example Rebuild a dynamic submenu with a child scope
|
|
181
|
+
* Subtitles ▸ Track lists the current file's subtitle tracks and is
|
|
182
|
+
* rebuilt whenever they change. Commands added through a child scope
|
|
183
|
+
* belong to it; disposing the scope removes all of them at once, and a
|
|
184
|
+
* new child scope collects the next set.
|
|
185
|
+
* ```ts
|
|
186
|
+
* let tracks = plugin.scope();
|
|
187
|
+
* plugin.subtitles.onChange(async (state) => {
|
|
188
|
+
* await tracks.dispose(); // removes the previous menu items
|
|
189
|
+
* tracks = plugin.scope();
|
|
190
|
+
* state.tracks.forEach((track, i) =>
|
|
191
|
+
* tracks.commands.add({
|
|
192
|
+
* id: `track.${i}`,
|
|
193
|
+
* path: ["Subtitles", "Track", track.title],
|
|
194
|
+
* order: 300 + i,
|
|
195
|
+
* radio: true,
|
|
196
|
+
* checked: () => plugin.subtitles.state?.selected?.id === track.id,
|
|
197
|
+
* run: () => plugin.subtitles.select(track),
|
|
198
|
+
* }),
|
|
199
|
+
* );
|
|
200
|
+
* });
|
|
201
|
+
* ```
|
|
202
|
+
*
|
|
203
|
+
* @remarks
|
|
204
|
+
* Every module of the API (`commands`, `windows`, `player`…) is reachable
|
|
205
|
+
* from a scope, and every handle made through it belongs to it. A child
|
|
206
|
+
* scope from {@link Scope.scope} is the unit for features that come and
|
|
207
|
+
* go: dispose the child and everything it created is released, while the
|
|
208
|
+
* rest of the plugin keeps running.
|
|
209
|
+
*
|
|
210
|
+
* @capability That of each module (see the modules).
|
|
211
|
+
* @since 1.0.0
|
|
212
|
+
* @category Plugin
|
|
213
|
+
*/
|
|
214
|
+
export interface Scope extends Disposable {
|
|
215
|
+
/** Menu commands and their default bindings (`commands`). */
|
|
216
|
+
readonly commands: Commands;
|
|
217
|
+
/**
|
|
218
|
+
* Conditions on the player's own state for a command's `enabled` and
|
|
219
|
+
* `checked` (SDK 1.5.40, player 0.5.21): the player evaluates them, so
|
|
220
|
+
* the menu follows playback even while the plugin is stopped. See
|
|
221
|
+
* {@link When}.
|
|
222
|
+
*/
|
|
223
|
+
readonly when: When;
|
|
224
|
+
/** Tool windows from `.slint` files (`ui.window`). */
|
|
225
|
+
readonly windows: Windows;
|
|
226
|
+
/** Docked panels: bottom bar, sidebar and backdrop (`ui.mount`). */
|
|
227
|
+
readonly panels: Panels;
|
|
228
|
+
/** Native file dialogs and confirmation alerts (`ui.dialog`). */
|
|
229
|
+
readonly dialogs: Dialogs;
|
|
230
|
+
/** Playback state and controls (`playback.read`, `events`, `playback.control`). */
|
|
231
|
+
readonly player: Player;
|
|
232
|
+
/**
|
|
233
|
+
* Video processing: this plugin's filter chain, the display layer, the
|
|
234
|
+
* GPU render options, this plugin's shaders and the GPU's video
|
|
235
|
+
* upscaler. The first four need `processing.video` and `playback.read`;
|
|
236
|
+
* the filter chain also needs `events` (without it the SDK never sees
|
|
237
|
+
* the media become ready and the chain stays `waiting`). The upscaler
|
|
238
|
+
* needs `video.upscaling` only.
|
|
239
|
+
*/
|
|
240
|
+
readonly video: {
|
|
241
|
+
/**
|
|
242
|
+
* This plugin's video filter chain named `id` (unique within the
|
|
243
|
+
* plugin). Nothing is sent until the first `set()`.
|
|
244
|
+
*
|
|
245
|
+
* @param id - Local name of the chain.
|
|
246
|
+
* @returns A {@link VideoFilter} owned by this scope.
|
|
247
|
+
*/
|
|
248
|
+
filter(id: string): VideoFilter;
|
|
249
|
+
/**
|
|
250
|
+
* The display layer (needs `processing.video`). The first plugin to call
|
|
251
|
+
* it owns the layer; another plugin's view fails with `conflict` until the
|
|
252
|
+
* owner disposes or stops.
|
|
253
|
+
*
|
|
254
|
+
* @throws `capability` (throws) The manifest does not declare
|
|
255
|
+
* `processing.video`.
|
|
256
|
+
* @throws `Error` without a code (throws) A second call in the same plugin
|
|
257
|
+
* while the first view is not disposed.
|
|
258
|
+
*/
|
|
259
|
+
view(): VideoView;
|
|
260
|
+
/**
|
|
261
|
+
* The GPU renderer's options (needs `processing.video`), owned like the
|
|
262
|
+
* display layer. Under software rendering the handle is `failed` with
|
|
263
|
+
* `unsupported` after the player's first answer, and `onError` hears it.
|
|
264
|
+
*
|
|
265
|
+
* @throws `capability` (throws) The manifest does not declare
|
|
266
|
+
* `processing.video`.
|
|
267
|
+
* @throws `Error` without a code (throws) A second call in the same plugin
|
|
268
|
+
* while the first handle is not disposed.
|
|
269
|
+
*/
|
|
270
|
+
render(): RenderOptions;
|
|
271
|
+
/**
|
|
272
|
+
* This plugin's own GPU shaders named `id` (default `"shaders"`;
|
|
273
|
+
* needs `processing.video`; SDK 1.5.39, player 0.5.20). Unlike
|
|
274
|
+
* {@link Scope.video | render()}, every plugin may hold shader
|
|
275
|
+
* handles at the same time; the player joins their lists. Nothing is
|
|
276
|
+
* sent until the first `set()`.
|
|
277
|
+
*
|
|
278
|
+
* @param id - Local name of the handle, 1–128 bytes, unique within
|
|
279
|
+
* the plugin.
|
|
280
|
+
* @returns A {@link VideoShaders} owned by this scope.
|
|
281
|
+
* @throws `capability` (throws) The manifest does not declare
|
|
282
|
+
* `processing.video`.
|
|
283
|
+
* @throws `invalid` (throws) `id` is empty, longer than 128 bytes or
|
|
284
|
+
* has control characters.
|
|
285
|
+
* @throws `Error` without a code (throws) A second handle with the
|
|
286
|
+
* same `id` while the first is not disposed.
|
|
287
|
+
*/
|
|
288
|
+
shaders(id?: string): VideoShaders;
|
|
289
|
+
/**
|
|
290
|
+
* The GPU's video upscaler (NVIDIA RTX Video Super Resolution on
|
|
291
|
+
* Windows; needs `video.upscaling`, player 0.5.16): whether it works
|
|
292
|
+
* here and why not, and turning it on or off for this plugin.
|
|
293
|
+
*/
|
|
294
|
+
readonly upscaling: VideoUpscaling;
|
|
295
|
+
};
|
|
296
|
+
/**
|
|
297
|
+
* Audio processing: this plugin's filter chain and delay
|
|
298
|
+
* (`processing.audio`, `playback.read` and `events`, as for
|
|
299
|
+
* {@link VideoFilter}).
|
|
300
|
+
*/
|
|
301
|
+
readonly audio: {
|
|
302
|
+
/**
|
|
303
|
+
* This plugin's audio filter chain named `id` (unique within the
|
|
304
|
+
* plugin). Nothing is sent until the first `set()`.
|
|
305
|
+
*
|
|
306
|
+
* @param id - Local name of the chain.
|
|
307
|
+
* @returns An {@link AudioFilter} owned by this scope.
|
|
308
|
+
*/
|
|
309
|
+
filter(id: string): AudioFilter;
|
|
310
|
+
};
|
|
311
|
+
/** Subtitle tracks, uploads and style (`subtitles.read`, `subtitles.control`). */
|
|
312
|
+
readonly subtitles: Subtitles;
|
|
313
|
+
/** Frozen snapshots and offline exports (`media.read`, `media.control`). */
|
|
314
|
+
readonly media: MediaCapture;
|
|
315
|
+
/** Page-URL to stream-URL resolvers (`source.resolve`). */
|
|
316
|
+
readonly resolvers: Resolvers;
|
|
317
|
+
/** The installed plugins; validation, installs (`plugins.manage` for changes). */
|
|
318
|
+
readonly packages: Packages;
|
|
319
|
+
/** On-screen messages over the video (`ui.osd`). */
|
|
320
|
+
readonly osd: Osd;
|
|
321
|
+
/** The player's own core playback actions (`commands`). */
|
|
322
|
+
readonly host: Host;
|
|
323
|
+
/** The system clipboard (`clipboard`). */
|
|
324
|
+
readonly clipboard: Clipboard;
|
|
325
|
+
/** Keeping the computer awake while playing (`playback.control`). */
|
|
326
|
+
readonly power: Power;
|
|
327
|
+
/** ffmpeg / ffprobe, run by this plugin's process. */
|
|
328
|
+
readonly tools: Tools;
|
|
329
|
+
/** JSON settings files in `dataDirectory`. */
|
|
330
|
+
readonly storage: Storage;
|
|
331
|
+
/** Show files in the file manager, open files and links. */
|
|
332
|
+
readonly system: System;
|
|
333
|
+
/** Small secrets in the system's secret store (`secrets`). */
|
|
334
|
+
readonly secrets: Secrets;
|
|
335
|
+
/** The main window: fullscreen, video area, size, level, pointer hiding. */
|
|
336
|
+
readonly window: MainWindow;
|
|
337
|
+
/** The player's version and components, and the system it runs on. */
|
|
338
|
+
readonly app: App;
|
|
339
|
+
/** GPU or software rendering: read the choice, change it (`rendering.manage`). */
|
|
340
|
+
readonly rendering: Rendering;
|
|
341
|
+
/** Every command's bindings and the user's overrides (`bindings.manage`). */
|
|
342
|
+
readonly bindings: Bindings;
|
|
343
|
+
/** Runtime images for Slint `image` properties. */
|
|
344
|
+
readonly ui: Ui;
|
|
345
|
+
/** Marks on the seek bar, merged from every plugin's layer. */
|
|
346
|
+
readonly timeline: Timeline;
|
|
347
|
+
/** Files dropped on the video area, by extension (`ui.drop`). */
|
|
348
|
+
readonly drops: Drops;
|
|
349
|
+
/** The player's palette and the saved interface language. */
|
|
350
|
+
readonly appearance: Appearance;
|
|
351
|
+
/** The interface language of this run (read-only). */
|
|
352
|
+
readonly i18n: I18n;
|
|
353
|
+
/** Pages in the player's options window (`ui.settings`). */
|
|
354
|
+
readonly settings: Settings;
|
|
355
|
+
/**
|
|
356
|
+
* A child scope; disposing it releases only what was created through it.
|
|
357
|
+
* The child is itself owned by this scope.
|
|
358
|
+
*
|
|
359
|
+
* @capability None.
|
|
360
|
+
*
|
|
361
|
+
* @example Tie a temporary window and its timer to one feature
|
|
362
|
+
* A "Live stats" feature opens a window and starts a timer; turning it off
|
|
363
|
+
* releases both together. Everything made through the child scope, and
|
|
364
|
+
* cleanups registered on it, go when the child is disposed; the parent
|
|
365
|
+
* scope is untouched.
|
|
366
|
+
* ```ts
|
|
367
|
+
* let live: Scope | null = null;
|
|
368
|
+
* plugin.commands.add({
|
|
369
|
+
* id: "live-stats",
|
|
370
|
+
* path: ["Tools", "Live stats"],
|
|
371
|
+
* checked: () => live !== null,
|
|
372
|
+
* run: async () => {
|
|
373
|
+
* if (live) {
|
|
374
|
+
* await live.dispose(); // closes the window, stops the timer
|
|
375
|
+
* live = null;
|
|
376
|
+
* return;
|
|
377
|
+
* }
|
|
378
|
+
* live = plugin.scope();
|
|
379
|
+
* const statsWindow = live.windows.create("ui/stats.slint");
|
|
380
|
+
* const timer = setInterval(() => live?.update(), 1000);
|
|
381
|
+
* live.onDispose(() => clearInterval(timer));
|
|
382
|
+
* await statsWindow.show();
|
|
383
|
+
* },
|
|
384
|
+
* });
|
|
385
|
+
* ```
|
|
386
|
+
*
|
|
387
|
+
* @since 1.0.0
|
|
388
|
+
*/
|
|
389
|
+
scope(): Scope;
|
|
390
|
+
/**
|
|
391
|
+
* Adopt an existing handle: it is disposed together with this scope.
|
|
392
|
+
*
|
|
393
|
+
* @param item - Any {@link Disposable}, for example a handle created
|
|
394
|
+
* through another scope.
|
|
395
|
+
* @returns `item` itself, for chaining.
|
|
396
|
+
*
|
|
397
|
+
* @capability None.
|
|
398
|
+
*
|
|
399
|
+
* @example Dispose a handle from another scope together with this one
|
|
400
|
+
* A filter made through the root scope is withdrawn when a child feature
|
|
401
|
+
* ends. `add` hands an existing disposable to this scope, which then
|
|
402
|
+
* disposes it with its own handles; it returns the same handle for
|
|
403
|
+
* chaining.
|
|
404
|
+
* ```ts
|
|
405
|
+
* const feature = plugin.scope();
|
|
406
|
+
* const blur = feature.add(plugin.video.filter("blur")); // now ends with `feature`
|
|
407
|
+
* blur.set([{ kind: "gblur", sigma: 4, steps: 3 }]);
|
|
408
|
+
* ```
|
|
409
|
+
*
|
|
410
|
+
* @since 1.0.0
|
|
411
|
+
*/
|
|
412
|
+
add<T extends Disposable>(item: T): T;
|
|
413
|
+
/**
|
|
414
|
+
* Run `cleanup` when this scope is disposed (for example `clearInterval`
|
|
415
|
+
* or closing a socket). It may be async; errors are logged.
|
|
416
|
+
*
|
|
417
|
+
* @returns A handle that cancels the registration early (without
|
|
418
|
+
* running `cleanup`).
|
|
419
|
+
*
|
|
420
|
+
* @example Stop a timer when the plugin stops
|
|
421
|
+
* A once-a-second refresh runs as long as the plugin does. `onDispose`
|
|
422
|
+
* runs the cleanup when the scope is disposed, which for `plugin` is
|
|
423
|
+
* when the player stops the plugin, so the timer never outlives it.
|
|
424
|
+
* ```ts
|
|
425
|
+
* const timer = setInterval(() => plugin.update(), 1000); // re-evaluate bindings
|
|
426
|
+
* plugin.onDispose(() => clearInterval(timer));
|
|
427
|
+
* ```
|
|
428
|
+
*
|
|
429
|
+
* @example Save a cache at once when the player is lost
|
|
430
|
+
* The plugin writes its cache file at once when the player crashed or
|
|
431
|
+
* was killed, instead of waiting for the next periodic save. The cleanup
|
|
432
|
+
* may get a {@link DisposeInfo}: `stopping` says the plugin itself stops
|
|
433
|
+
* (not a child scope), `reason` why (player 0.6.4). Players
|
|
434
|
+
* whose SDK is older than 1.5.54 call the cleanup without an argument,
|
|
435
|
+
* so read it with `?.`.
|
|
436
|
+
* ```ts
|
|
437
|
+
* declare function saveCacheNow(): void;
|
|
438
|
+
* // ---cut---
|
|
439
|
+
* plugin.onDispose((info) => {
|
|
440
|
+
* // The player is gone: ask it nothing, keep what is local.
|
|
441
|
+
* if (info?.reason === "host-lost") saveCacheNow();
|
|
442
|
+
* });
|
|
443
|
+
* ```
|
|
444
|
+
*
|
|
445
|
+
* @remarks
|
|
446
|
+
* From SDK 1.5.54 in the player (and in `TestHost`) the cleanup is called
|
|
447
|
+
* with one argument, a {@link DisposeInfo}: whether the plugin stops, and
|
|
448
|
+
* why. A player whose own SDK is older calls it without one (`info` is
|
|
449
|
+
* `undefined`). A cleanup that takes no argument works as before; a
|
|
450
|
+
* function with optional parameters of its own that is passed directly
|
|
451
|
+
* (`onDispose(controller.abort.bind(controller))`) now receives the
|
|
452
|
+
* `DisposeInfo` as its first argument: wrap it (`() => controller.abort()`)
|
|
453
|
+
* when that matters.
|
|
454
|
+
*
|
|
455
|
+
* @capability None.
|
|
456
|
+
* @since 1.0.0
|
|
457
|
+
*/
|
|
458
|
+
onDispose(cleanup: ((info?: DisposeInfo) => void | Promise<void>) | (() => void | Promise<void>)): Disposable;
|
|
459
|
+
/**
|
|
460
|
+
* Errors thrown by handlers that the SDK invoked (command `run`, window and
|
|
461
|
+
* panel callbacks, `onChange` listeners) in this scope. Without a listener
|
|
462
|
+
* they go to the parent scope, and finally to the plugin log.
|
|
463
|
+
*
|
|
464
|
+
* Rejections of async handlers count too, and so do failures of
|
|
465
|
+
* registrations made after activation (a command whose `ready` rejects,
|
|
466
|
+
* a property write the player refused).
|
|
467
|
+
*
|
|
468
|
+
* @example Show errors from handlers on the OSD
|
|
469
|
+
* When a menu command, a window callback or a listener of the plugin
|
|
470
|
+
* fails, the user sees why. The SDK catches what those handlers throw
|
|
471
|
+
* (and their rejected promises) and passes it here instead of only
|
|
472
|
+
* logging it; the message is data in a translated template.
|
|
473
|
+
* ```ts
|
|
474
|
+
* plugin.onError((error) => {
|
|
475
|
+
* void plugin.osd.show("Bookmarks: {}", [error.message]);
|
|
476
|
+
* });
|
|
477
|
+
* ```
|
|
478
|
+
*
|
|
479
|
+
* @capability None.
|
|
480
|
+
* @since 1.0.0
|
|
481
|
+
*/
|
|
482
|
+
onError(listener: (error: PluginError) => void): Disposable;
|
|
483
|
+
/**
|
|
484
|
+
* Re-evaluate every bound value (`bind()` functions and command state
|
|
485
|
+
* functions) and send what changed. The SDK already does this after each
|
|
486
|
+
* handler it invokes and when that handler's promise settles; call it after
|
|
487
|
+
* changing state from your own timers or between awaits of a long task.
|
|
488
|
+
*
|
|
489
|
+
* Several calls within one microtask are merged into one pass.
|
|
490
|
+
*
|
|
491
|
+
* @capability None.
|
|
492
|
+
*
|
|
493
|
+
* @example Show progress from a long task between awaits
|
|
494
|
+
* A progress label moves while a long download runs, not only when it
|
|
495
|
+
* ends. The SDK re-evaluates bound values after each handler and when its
|
|
496
|
+
* promise settles; state changed between the awaits of a long handler
|
|
497
|
+
* shows only after an explicit `update()`.
|
|
498
|
+
* ```ts
|
|
499
|
+
* declare const downloadWindow: Window;
|
|
500
|
+
* declare function downloadPart(part: number): Promise<void>;
|
|
501
|
+
* // ---cut---
|
|
502
|
+
* let done = 0;
|
|
503
|
+
* downloadWindow.bind(() => ({ progress: done }));
|
|
504
|
+
* downloadWindow.on("start", async () => {
|
|
505
|
+
* for (let part = 0; part < 10; part++) {
|
|
506
|
+
* await downloadPart(part);
|
|
507
|
+
* done = part + 1;
|
|
508
|
+
* plugin.update(); // send `progress` now, not when the handler ends
|
|
509
|
+
* }
|
|
510
|
+
* });
|
|
511
|
+
* ```
|
|
512
|
+
*
|
|
513
|
+
* @since 1.0.0
|
|
514
|
+
*/
|
|
515
|
+
update(): void;
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* The object the player passes to a plugin's `activate`: the root
|
|
519
|
+
* {@link Scope}, plus the plugin's identity and data directory.
|
|
520
|
+
*
|
|
521
|
+
* Activation: the player starts one Node process per plugin, reads the
|
|
522
|
+
* initial player, window and timeline state, then calls `activate(plugin)`.
|
|
523
|
+
* Registrations started during activation (commands, panels, resolvers,
|
|
524
|
+
* subscriptions) do not need to be awaited: the plugin is reported ready
|
|
525
|
+
* once they all succeed, and activation fails if `activate` throws or any
|
|
526
|
+
* of them fails. A command declaration the player refuses is the exception
|
|
527
|
+
* (SDK 1.5.49): the SDK logs and skips it, its `ready` rejects and
|
|
528
|
+
* {@link Scope.onError} hears it, the rest of the plugin activates
|
|
529
|
+
* (`startPlugin` still fails on it). The entry module must
|
|
530
|
+
* **default-export** `activate`.
|
|
531
|
+
*
|
|
532
|
+
* Stopping: the player first revokes everything the plugin owns on its side
|
|
533
|
+
* (menus, windows, panels, filters, subtitle layers, snapshots, jobs,
|
|
534
|
+
* resolvers, streams); pending requests then fail with `disabled` and the
|
|
535
|
+
* root scope is disposed for local cleanup (timers, signals, sockets). A
|
|
536
|
+
* process that has not exited after its grace is killed: 5 s from player
|
|
537
|
+
* 0.7.1 (before it 300 ms; 300 ms after a fault); at quit all plugins
|
|
538
|
+
* together get 1 s. Media the
|
|
539
|
+
* plugin opened with {@link Player.open} keeps playing.
|
|
540
|
+
*
|
|
541
|
+
* @example Write a minimal plugin with one menu item
|
|
542
|
+
* Tools ▸ Say hello, or Ctrl+H, shows "Hello from" and the plugin's id.
|
|
543
|
+
* The player imports `main.ts`, calls its default export with the
|
|
544
|
+
* `Plugin` object, and keeps the registrations made during activation;
|
|
545
|
+
* the manifest declares the capabilities `commands` and `ui.osd`.
|
|
546
|
+
* ```ts
|
|
547
|
+
* import type { Plugin } from "@vestra-player/sdk";
|
|
548
|
+
*
|
|
549
|
+
* export default async function activate(plugin: Plugin) {
|
|
550
|
+
* plugin.commands.add({
|
|
551
|
+
* id: "hello",
|
|
552
|
+
* path: ["Tools", "Say hello"],
|
|
553
|
+
* bindings: ["Ctrl+H"], // a default the user can change
|
|
554
|
+
* run: () => plugin.osd.show("Hello from {}", [plugin.id]),
|
|
555
|
+
* });
|
|
556
|
+
* }
|
|
557
|
+
* ```
|
|
558
|
+
*
|
|
559
|
+
* @remarks
|
|
560
|
+
* The root scope: disposing it is what stopping the plugin does. Besides
|
|
561
|
+
* the modules of {@link Scope}, it carries the plugin's `id` and its
|
|
562
|
+
* `dataDirectory`.
|
|
563
|
+
*
|
|
564
|
+
* @capability That of each module (see the modules).
|
|
565
|
+
* @see [How a plugin runs](../../../docs/explanation/plugins.md)
|
|
566
|
+
* @since 1.0.0
|
|
567
|
+
* @category Plugin
|
|
568
|
+
*/
|
|
569
|
+
export interface Plugin extends Scope {
|
|
570
|
+
/** The manifest id, e.g. `"community.bookmark"`. */
|
|
571
|
+
readonly id: string;
|
|
572
|
+
/**
|
|
573
|
+
* A writable directory for this plugin's own files (settings, caches,
|
|
574
|
+
* remembered folders), created by the player before it starts the plugin.
|
|
575
|
+
* Each installation has its own directory (player 0.2.0): it is kept across
|
|
576
|
+
* restarts, disabling and upgrades, and a reinstall of the same
|
|
577
|
+
* id from a different source gets a new, empty one. It is deleted only by
|
|
578
|
+
* `packages.uninstall(id, { removeData: true })`. No capability.
|
|
579
|
+
*
|
|
580
|
+
* The path's format is not part of the API: do not derive another
|
|
581
|
+
* plugin's directory from it (a plugin manager reads
|
|
582
|
+
* {@link PluginInfo.dataDirectory}). Write files atomically (to a
|
|
583
|
+
* temporary name, then rename); for JSON settings prefer
|
|
584
|
+
* {@link Scope.storage}. Throws `unavailable` when the player provided
|
|
585
|
+
* none. See [How a plugin runs](../../../docs/explanation/plugins.md#the-data-directory).
|
|
586
|
+
*/
|
|
587
|
+
readonly dataDirectory: string;
|
|
588
|
+
/**
|
|
589
|
+
* Why the player stops this plugin (SDK 1.5.54, player 0.6.4): set when
|
|
590
|
+
* the stop begins, before any
|
|
591
|
+
* {@link Scope.onDispose} cleanup runs. `undefined` while the plugin
|
|
592
|
+
* runs, and for every stop by an older player (one whose own SDK is older
|
|
593
|
+
* than 1.5.54 does not have the property at all). See {@link StopReason}.
|
|
594
|
+
*/
|
|
595
|
+
readonly stopReason: StopReason | undefined;
|
|
596
|
+
}
|
|
597
|
+
/**
|
|
598
|
+
* Why the player stopped the plugin ({@link DisposeInfo.reason},
|
|
599
|
+
* {@link Plugin.stopReason}).
|
|
600
|
+
*
|
|
601
|
+
* - `quit`: the player quits (or restarts after a lost GPU device). Every
|
|
602
|
+
* plugin is stopped at the same time, with 1 s in all (300 ms after a
|
|
603
|
+
* lost device; player 0.7.1).
|
|
604
|
+
* - `disable`: the user, or a plugin with `plugins.manage`, switched the
|
|
605
|
+
* plugin off. Its session storage is cleared.
|
|
606
|
+
* - `uninstall`: the user uninstalls it.
|
|
607
|
+
* - `reload`: it is reloaded (from the plugin manager, or a development
|
|
608
|
+
* load with `--plugin`).
|
|
609
|
+
* - `upgrade`: an install or update replaces the running version; also a
|
|
610
|
+
* new version stopped because its install was cancelled (the previous
|
|
611
|
+
* version comes back).
|
|
612
|
+
* - `idle`: the plugin goes to standby and its next use starts it again;
|
|
613
|
+
* its menu items, keys, settings pages, resolvers and drop targets stay,
|
|
614
|
+
* and so does its session storage
|
|
615
|
+
* ([Idle plugins](../../../docs/explanation/plugins.md#idle-plugins-are-stopped)).
|
|
616
|
+
* Only with on-demand start (lazy activation): on for everyone from
|
|
617
|
+
* player 0.7.1, off by default before it (`VESTRA_LAZY=1` turns it on).
|
|
618
|
+
* It comes after the idle time without use (30 s; 60 s before 0.7.1),
|
|
619
|
+
* right after a first run that holds nothing live, and, from player
|
|
620
|
+
* 0.7.1, when the player's limit on third-party processes or low system
|
|
621
|
+
* memory puts an idle plugin in standby early. A busy plugin never gets
|
|
622
|
+
* it; a resident one (it held something live when it became ready) never
|
|
623
|
+
* from player 0.7.1 (before it, after the idle time).
|
|
624
|
+
* - `failed`: the player stops it for a fault it can still tell the plugin
|
|
625
|
+
* about: a malformed request, an unreadable or oversized line, a start
|
|
626
|
+
* that is not ready within the start timeout (60 s from player 0.7.1;
|
|
627
|
+
* the stop may come while `activate` still runs), an uncaught exception
|
|
628
|
+
* the shared process attributes to this plugin, and, from player 0.7.1,
|
|
629
|
+
* a request from the player (a resolution) it leaves unanswered for 5
|
|
630
|
+
* minutes. From player 0.7.1 the player may start it again afterwards (a
|
|
631
|
+
* built-in or resident plugin by itself, a plugin that has run before on
|
|
632
|
+
* its next use), until the fifth fault within 10 minutes.
|
|
633
|
+
* - `host-lost`: the plugin's runner saw its pipe to the player close
|
|
634
|
+
* without a stop: the player crashed or was killed. Requests are refused
|
|
635
|
+
* with `disabled`; clean up locally only. Player 0.6.4 sends `quit` on a
|
|
636
|
+
* normal exit; read `host-lost` as "the player is gone", not as proof of
|
|
637
|
+
* a crash.
|
|
638
|
+
*
|
|
639
|
+
* Some ends are no stop at all: the plugin gets no reason and its
|
|
640
|
+
* {@link Scope.onDispose} cleanups do not run. That is the case when its
|
|
641
|
+
* own process is killed because its input queue is full or a write to it
|
|
642
|
+
* failed, when its own process fails to activate (the runner exits without
|
|
643
|
+
* cleaning up), when the process ended by itself (it crashed, or its
|
|
644
|
+
* JavaScript heap passed the 512 MB cap of player 0.7.1 and V8 ended it:
|
|
645
|
+
* "ran out of memory"), and when the shared runner is restarted as a whole
|
|
646
|
+
* (a hang, a fault it cannot attribute, an unreadable line of its own, a
|
|
647
|
+
* member's full input queue, the runner exiting): every member is killed
|
|
648
|
+
* with it. Keep state that must survive such an end in storage as it
|
|
649
|
+
* changes, not only in a cleanup. Timings and restarts are in
|
|
650
|
+
* [How the player runs and talks to plugins](../../../docs/explanation/host-and-node.md#crashes-and-restarts).
|
|
651
|
+
*
|
|
652
|
+
* Player 0.6.4 and later send the reason with `runtime.stop`, and their
|
|
653
|
+
* runner reports `host-lost`. Players up to 0.6.3 give no reason for any
|
|
654
|
+
* stop, a lost player included (`undefined`); so does a stop that does not
|
|
655
|
+
* come from the player (a `TestHost` `stop()` without a reason). A value
|
|
656
|
+
* this SDK does not know reads as `undefined`.
|
|
657
|
+
*
|
|
658
|
+
* @player 0.6.4; older players give no reason (`undefined`).
|
|
659
|
+
* @since 1.5.54
|
|
660
|
+
* @category Plugin
|
|
661
|
+
*/
|
|
662
|
+
export type StopReason = "quit" | "disable" | "uninstall" | "reload" | "upgrade" | "idle" | "failed" | "host-lost";
|
|
663
|
+
/**
|
|
664
|
+
* What a {@link Scope.onDispose} cleanup is told (SDK 1.5.54). A player
|
|
665
|
+
* whose own SDK is older passes nothing, so the cleanup's parameter is
|
|
666
|
+
* optional.
|
|
667
|
+
*
|
|
668
|
+
* @since 1.5.54
|
|
669
|
+
* @category Plugin
|
|
670
|
+
*/
|
|
671
|
+
export interface DisposeInfo {
|
|
672
|
+
/**
|
|
673
|
+
* `true` when the plugin itself stops (the player stops it), `false`
|
|
674
|
+
* when the plugin's own code disposed this scope or one of its parents.
|
|
675
|
+
*/
|
|
676
|
+
readonly stopping: boolean;
|
|
677
|
+
/**
|
|
678
|
+
* Why the player stops the plugin (player 0.6.4; the causes are listed at
|
|
679
|
+
* {@link StopReason}); `undefined` while `stopping` is false, and for
|
|
680
|
+
* every stop by an older player.
|
|
681
|
+
*/
|
|
682
|
+
readonly reason?: StopReason;
|
|
683
|
+
}
|
|
684
|
+
/**
|
|
685
|
+
* The main window as `plugin.window.state` reports it (logical points).
|
|
686
|
+
*
|
|
687
|
+
* @see {@link MainWindow.state}
|
|
688
|
+
* @since 1.0.0
|
|
689
|
+
* @category Plugin
|
|
690
|
+
*/
|
|
691
|
+
export interface WindowState {
|
|
692
|
+
/** The main window is fullscreen. */
|
|
693
|
+
readonly fullscreen: boolean;
|
|
694
|
+
/**
|
|
695
|
+
* The main window is maximized (`false` in fullscreen, also when it was
|
|
696
|
+
* maximized before and will be again after). Changes reach
|
|
697
|
+
* {@link MainWindow.onChange}. A plugin that sizes the window, such as to
|
|
698
|
+
* the video when playback starts, leaves a maximized window alone, as
|
|
699
|
+
* MPC-HC and mpv do. Always `false` with players before 0.6.3, which do
|
|
700
|
+
* not report it.
|
|
701
|
+
*
|
|
702
|
+
* @player 0.6.3; older players: always `false`.
|
|
703
|
+
* @since 1.5.52
|
|
704
|
+
*/
|
|
705
|
+
readonly maximized: boolean;
|
|
706
|
+
/** The video column, without the bottom bar, sidebar and splitter. */
|
|
707
|
+
readonly videoArea: {
|
|
708
|
+
/** Logical points. */
|
|
709
|
+
readonly width: number;
|
|
710
|
+
/** Logical points. */
|
|
711
|
+
readonly height: number;
|
|
712
|
+
};
|
|
713
|
+
/**
|
|
714
|
+
* System picture-in-picture: `supported` on this system and build (macOS
|
|
715
|
+
* 14+; `false` on Windows, Linux and without a native window), `active`
|
|
716
|
+
* while its window shows the video.
|
|
717
|
+
*/
|
|
718
|
+
readonly pictureInPicture: {
|
|
719
|
+
/** Picture-in-picture is possible here (macOS 14+ with a native window). */
|
|
720
|
+
readonly supported: boolean;
|
|
721
|
+
/** The picture-in-picture window shows the video now. */
|
|
722
|
+
readonly active: boolean;
|
|
723
|
+
};
|
|
724
|
+
}
|
|
725
|
+
/**
|
|
726
|
+
* The player's main window. Reading needs no capability; changes need `window.control`.
|
|
727
|
+
*
|
|
728
|
+
* With `events`, `state` follows the window from the first read or
|
|
729
|
+
* `onChange`; without it, it updates only at start and after this plugin's
|
|
730
|
+
* `setVideoArea`.
|
|
731
|
+
*
|
|
732
|
+
* @example Resize the window to the video's own size
|
|
733
|
+
* Screen ▸ Original size makes the video area as many logical points as
|
|
734
|
+
* the video has pixels (one pixel per pixel at a display scale of 100 %).
|
|
735
|
+
* `stats()` reports the video's size;
|
|
736
|
+
* `setVideoArea` resizes the window around the video column (bars and a
|
|
737
|
+
* docked sidebar added), scales it down if it would not fit the screen,
|
|
738
|
+
* and is refused in fullscreen, hence the `enabled` check.
|
|
739
|
+
* ```ts
|
|
740
|
+
* plugin.commands.add({
|
|
741
|
+
* id: "size-1x",
|
|
742
|
+
* path: ["Screen", "Original size"],
|
|
743
|
+
* enabled: () => !plugin.window.state.fullscreen,
|
|
744
|
+
* run: async () => {
|
|
745
|
+
* const stats = await plugin.player.stats();
|
|
746
|
+
* // No video stream (an audio file): nothing to size to.
|
|
747
|
+
* if (stats.video?.width && stats.video.height)
|
|
748
|
+
* await plugin.window.setVideoArea({ width: stats.video.width, height: stats.video.height });
|
|
749
|
+
* },
|
|
750
|
+
* });
|
|
751
|
+
* ```
|
|
752
|
+
*
|
|
753
|
+
* @remarks
|
|
754
|
+
* `plugin.window` is the player's main window: its size, whether it is
|
|
755
|
+
* maximized or fullscreen, picture-in-picture and the video area. Reading it needs no capability;
|
|
756
|
+
* changing it needs `window.control`. Changes that last only while the
|
|
757
|
+
* plugin runs (always on top, pointer auto-hide) revert when it stops.
|
|
758
|
+
*
|
|
759
|
+
* @capability None to read; window.control to change; events to follow
|
|
760
|
+
* outside changes.
|
|
761
|
+
* @since 1.0.0
|
|
762
|
+
* @category Plugin
|
|
763
|
+
*/
|
|
764
|
+
export interface MainWindow {
|
|
765
|
+
/** Latest state; zero video area without a native window. */
|
|
766
|
+
readonly state: WindowState;
|
|
767
|
+
/**
|
|
768
|
+
* The window state changed (needs `events` for outside changes).
|
|
769
|
+
*
|
|
770
|
+
* @capability events (for outside changes)
|
|
771
|
+
*
|
|
772
|
+
* @example Fit a panel to fullscreen
|
|
773
|
+
* The plugin's panel uses larger text while the player is fullscreen. The
|
|
774
|
+
* listener runs after the SDK updated `state` from the player's events
|
|
775
|
+
* (with `events`; without it only after this plugin's own changes).
|
|
776
|
+
* ```ts
|
|
777
|
+
* declare const bar: Panel;
|
|
778
|
+
* // ---cut---
|
|
779
|
+
* plugin.window.onChange((state) => bar.set({ large: state.fullscreen }));
|
|
780
|
+
* ```
|
|
781
|
+
*
|
|
782
|
+
* @since 1.0.0
|
|
783
|
+
*/
|
|
784
|
+
onChange(listener: (state: WindowState) => void): Disposable;
|
|
785
|
+
/**
|
|
786
|
+
* Resize the window so the video column is `width`×`height` (the bottom bar
|
|
787
|
+
* and a docked sidebar are added), keeping the top-left corner, moved back
|
|
788
|
+
* inside the screen's visible area. Too large: scaled down keeping the
|
|
789
|
+
* aspect; too small: raised to the minimum; `clamped` then. Resolves with
|
|
790
|
+
* the video area applied. `unavailable` in fullscreen.
|
|
791
|
+
*
|
|
792
|
+
* Sizes are 1–16384 logical points; the minimum video area is 318×120.
|
|
793
|
+
* The visible area excludes the menu bar and Dock on macOS; on Windows it
|
|
794
|
+
* is the whole display. `unavailable` without a user interface too.
|
|
795
|
+
*
|
|
796
|
+
* @capability window.control
|
|
797
|
+
* @throws `unavailable` (rejects) Fullscreen, or no user interface.
|
|
798
|
+
* @throws `invalid` (rejects) A size outside 1–16384 logical points.
|
|
799
|
+
* @throws `capability` (rejects) The manifest does not declare
|
|
800
|
+
* `window.control`.
|
|
801
|
+
*
|
|
802
|
+
* @example Make the video area 1280×720 points
|
|
803
|
+
* The window resizes so that the video column is 1280×720 logical points,
|
|
804
|
+
* the bars and a docked sidebar added around it. A request that does not
|
|
805
|
+
* fit the screen is scaled down keeping the aspect, and `clamped` says so.
|
|
806
|
+
* ```ts
|
|
807
|
+
* const applied = await plugin.window.setVideoArea({ width: 1280, height: 720 });
|
|
808
|
+
* if (applied.clamped) await plugin.osd.show("{}×{}", [applied.width, applied.height]);
|
|
809
|
+
* ```
|
|
810
|
+
*
|
|
811
|
+
* @since 1.0.0
|
|
812
|
+
*/
|
|
813
|
+
setVideoArea(size: {
|
|
814
|
+
width: number;
|
|
815
|
+
height: number;
|
|
816
|
+
}): Promise<{
|
|
817
|
+
/** The applied video area width, logical points. */
|
|
818
|
+
width: number;
|
|
819
|
+
/** The applied video area height, logical points. */
|
|
820
|
+
height: number;
|
|
821
|
+
/** The request was scaled down or raised to fit. */
|
|
822
|
+
clamped: boolean;
|
|
823
|
+
}>;
|
|
824
|
+
/**
|
|
825
|
+
* Float the player's windows above other applications. Newest call wins; reverts when this plugin stops.
|
|
826
|
+
* `unavailable` without a user interface.
|
|
827
|
+
*
|
|
828
|
+
* @capability window.control
|
|
829
|
+
* @throws `unavailable` (rejects) No user interface.
|
|
830
|
+
* @throws `invalid` (rejects) `onTop` is not a boolean.
|
|
831
|
+
* @throws `capability` (rejects) The manifest does not declare
|
|
832
|
+
* `window.control`.
|
|
833
|
+
*
|
|
834
|
+
* @example Keep the player above other windows
|
|
835
|
+
* The player's windows (tool windows too) float above other applications
|
|
836
|
+
* while the plugin's "Always on top" item is checked. The newest call of
|
|
837
|
+
* any plugin wins, and the setting reverts when this plugin stops.
|
|
838
|
+
* ```ts
|
|
839
|
+
* let onTop = false;
|
|
840
|
+
* plugin.commands.add({
|
|
841
|
+
* id: "on-top",
|
|
842
|
+
* path: ["@screen", "Always on top"],
|
|
843
|
+
* checked: () => onTop,
|
|
844
|
+
* run: async () => {
|
|
845
|
+
* onTop = !onTop;
|
|
846
|
+
* await plugin.window.setAlwaysOnTop(onTop); // reverts when this plugin stops
|
|
847
|
+
* },
|
|
848
|
+
* });
|
|
849
|
+
* ```
|
|
850
|
+
*
|
|
851
|
+
* @since 1.0.0
|
|
852
|
+
*/
|
|
853
|
+
setAlwaysOnTop(onTop: boolean): Promise<void>;
|
|
854
|
+
/**
|
|
855
|
+
* `"playing"`: hide the pointer over the video after 3 idle seconds while
|
|
856
|
+
* playing, in a window too (not only fullscreen). Newest call wins;
|
|
857
|
+
* reverts to `"fullscreen"` when this plugin stops.
|
|
858
|
+
*
|
|
859
|
+
* @capability window.control
|
|
860
|
+
* @throws `invalid` (rejects) A mode other than `"fullscreen"` or
|
|
861
|
+
* `"playing"`.
|
|
862
|
+
* @throws `capability` (rejects) The manifest does not declare
|
|
863
|
+
* `window.control`.
|
|
864
|
+
*
|
|
865
|
+
* @example Hide the pointer over playing video in a window too
|
|
866
|
+
* The pointer disappears after 3 idle seconds over playing video, not only
|
|
867
|
+
* in fullscreen. The newest call wins; when this plugin stops the player
|
|
868
|
+
* goes back to hiding it in fullscreen only.
|
|
869
|
+
* ```ts
|
|
870
|
+
* await plugin.window.setCursorAutoHide("playing");
|
|
871
|
+
* ```
|
|
872
|
+
*
|
|
873
|
+
* @since 1.0.0
|
|
874
|
+
*/
|
|
875
|
+
setCursorAutoHide(mode: "fullscreen" | "playing"): Promise<void>;
|
|
876
|
+
/**
|
|
877
|
+
* Play the video in the system picture-in-picture window (`true`) or back
|
|
878
|
+
* in the main window. Resolves once the window has opened or closed and
|
|
879
|
+
* `state.pictureInPicture` shows it. From fullscreen the player leaves
|
|
880
|
+
* fullscreen first. `unsupported` where `supported` is false; `unavailable`
|
|
881
|
+
* without video; `busy` while the previous call is still switching;
|
|
882
|
+
* `failed` when the system refuses. The window's play/pause and skip
|
|
883
|
+
* buttons drive playback; its close button also pauses. It closes when
|
|
884
|
+
* this plugin stops or the video goes away.
|
|
885
|
+
*
|
|
886
|
+
* Where it is unsupported (Windows, Linux), `setVideoArea` plus
|
|
887
|
+
* `setAlwaysOnTop` make a reasonable "mini player" fallback.
|
|
888
|
+
*
|
|
889
|
+
* @example Toggle picture-in-picture where the system has it
|
|
890
|
+
* The video moves into a floating picture-in-picture window, or back.
|
|
891
|
+
* `state.pictureInPicture` says whether the system supports it and
|
|
892
|
+
* whether it is on; the plugin only calls `setPictureInPicture` where it
|
|
893
|
+
* is supported.
|
|
894
|
+
* ```ts
|
|
895
|
+
* if (plugin.window.state.pictureInPicture.supported)
|
|
896
|
+
* await plugin.window.setPictureInPicture(!plugin.window.state.pictureInPicture.active);
|
|
897
|
+
* ```
|
|
898
|
+
*
|
|
899
|
+
* @capability window.control
|
|
900
|
+
* @throws `unsupported` (rejects) The system has no picture-in-picture
|
|
901
|
+
* (`supported` is false).
|
|
902
|
+
* @throws `unavailable` (rejects) No video, or no user interface.
|
|
903
|
+
* @throws `invalid` (rejects) `on` is not a boolean.
|
|
904
|
+
* @throws `busy` (rejects) The previous call is still switching.
|
|
905
|
+
* @throws `failed` (rejects) The system refused.
|
|
906
|
+
* @throws `capability` (rejects) The manifest does not declare
|
|
907
|
+
* `window.control`.
|
|
908
|
+
* @since 1.0.0
|
|
909
|
+
*/
|
|
910
|
+
setPictureInPicture(on: boolean): Promise<void>;
|
|
911
|
+
}
|
|
912
|
+
/**
|
|
913
|
+
* `plugin.app`: fixed for the life of the plugin process.
|
|
914
|
+
*
|
|
915
|
+
* @since 1.0.0
|
|
916
|
+
* @category Plugin
|
|
917
|
+
*/
|
|
918
|
+
export interface AppInfo {
|
|
919
|
+
/**
|
|
920
|
+
* The player's version, e.g. `"0.7.1"`. From player 0.7.1 this is the
|
|
921
|
+
* player's release version (the version of the published release), which
|
|
922
|
+
* can differ from the version of the host binary inside it. The player
|
|
923
|
+
* compares `minPlayerVersion` with this value, and plugins compare with
|
|
924
|
+
* it too.
|
|
925
|
+
*/
|
|
926
|
+
readonly version: string;
|
|
927
|
+
/** Short git hash of the build, `null` when unknown. */
|
|
928
|
+
readonly build: string | null;
|
|
929
|
+
/** Versions of the player's main components. */
|
|
930
|
+
readonly components: {
|
|
931
|
+
/** libmpv's `mpv-version`. */
|
|
932
|
+
readonly mpv: string | null;
|
|
933
|
+
/** `{ ffmpeg: <ffmpeg-version> }` (what libmpv reports). */
|
|
934
|
+
readonly libav: Readonly<Record<string, string>>;
|
|
935
|
+
/** The linked Slint version, e.g. `"1.18.1"`. */
|
|
936
|
+
readonly slint: string;
|
|
937
|
+
};
|
|
938
|
+
}
|
|
939
|
+
/**
|
|
940
|
+
* `plugin.app`: the fixed facts plus the system, read on request. No
|
|
941
|
+
* capability.
|
|
942
|
+
*
|
|
943
|
+
* @example Describe the player and the system for a bug report
|
|
944
|
+
* The plugin builds a line such as "Vestra 0.5.10 on macOS 26.2" to copy
|
|
945
|
+
* into a bug report. `app.version` is known from the start; each
|
|
946
|
+
* `system()` call asks the player, which reads the displays at that moment.
|
|
947
|
+
* The operating system's name and version it works out once, at the first
|
|
948
|
+
* call, and reuses them.
|
|
949
|
+
* ```ts
|
|
950
|
+
* const system = await plugin.app.system();
|
|
951
|
+
* const text = `Vestra ${plugin.app.version} on ${system.name} ${system.version ?? ""}`;
|
|
952
|
+
* ```
|
|
953
|
+
*
|
|
954
|
+
* @remarks
|
|
955
|
+
* `plugin.app` holds facts fixed for the player's run (its version, build,
|
|
956
|
+
* library versions) and reads the system's on request: `system()` reads
|
|
957
|
+
* the displays at each call; the operating system's name and version are
|
|
958
|
+
* worked out once, at the first call, and reused.
|
|
959
|
+
*
|
|
960
|
+
* @capability None.
|
|
961
|
+
* @since 1.0.0
|
|
962
|
+
* @category Plugin
|
|
963
|
+
*/
|
|
964
|
+
export interface App extends AppInfo {
|
|
965
|
+
/**
|
|
966
|
+
* The operating system, the displays and the renderer, read when called
|
|
967
|
+
* (displays come and go; the renderer can fall back from GPU to software
|
|
968
|
+
* once). No capability. CPU and memory: Node's `os` module.
|
|
969
|
+
*
|
|
970
|
+
* @capability None.
|
|
971
|
+
* @throws `busy` (rejects) The player could not start the request (no
|
|
972
|
+
* thread available).
|
|
973
|
+
*
|
|
974
|
+
* @example Choose a size for the primary display
|
|
975
|
+
* The plugin sizes its picture for the primary display. `system()` asks
|
|
976
|
+
* the player; `displays` lists the displays present now, the primary one
|
|
977
|
+
* first (empty without a user interface).
|
|
978
|
+
* ```ts
|
|
979
|
+
* const { displays } = await plugin.app.system();
|
|
980
|
+
* const primary = displays[0];
|
|
981
|
+
* if (primary) console.log(primary.width, primary.height);
|
|
982
|
+
* ```
|
|
983
|
+
*
|
|
984
|
+
* @since 1.0.0
|
|
985
|
+
*/
|
|
986
|
+
system(): Promise<SystemInfo>;
|
|
987
|
+
}
|
|
988
|
+
/**
|
|
989
|
+
* What {@link App.system} reports.
|
|
990
|
+
*
|
|
991
|
+
* @see {@link App.system}
|
|
992
|
+
* @since 1.0.0
|
|
993
|
+
* @category Plugin
|
|
994
|
+
*/
|
|
995
|
+
export interface SystemInfo {
|
|
996
|
+
/** The operating system family. */
|
|
997
|
+
readonly os: "macos" | "windows" | "linux" | "other";
|
|
998
|
+
/** Product name: `macOS`, `Windows 11`, … */
|
|
999
|
+
readonly name: string;
|
|
1000
|
+
/** `26.2` (macOS), `23H2` (Windows); `null` when unknown. */
|
|
1001
|
+
readonly version: string | null;
|
|
1002
|
+
/** `25C56` (macOS), `22631.4460` (Windows); `null` when unknown. */
|
|
1003
|
+
readonly build: string | null;
|
|
1004
|
+
/** Hardware model (`Mac15,6`, the firmware's product name); `null` when unknown. */
|
|
1005
|
+
readonly model: string | null;
|
|
1006
|
+
/** CPU architecture of the player build: `aarch64`, `x86_64`, … */
|
|
1007
|
+
readonly arch: string;
|
|
1008
|
+
/** Primary display first; empty without a user interface. */
|
|
1009
|
+
readonly displays: readonly DisplayInfo[];
|
|
1010
|
+
/**
|
|
1011
|
+
* Which renderer draws the video now: `"gpu"` (the GPU renderer, so
|
|
1012
|
+
* {@link RenderOptions | render options} apply) or `"software"` (they
|
|
1013
|
+
* fail with `unsupported`). Read at each call. It changes at most once
|
|
1014
|
+
* while the player runs, from `"gpu"` to `"software"` when a window
|
|
1015
|
+
* cannot show GPU frames; the owner of the render options hears that
|
|
1016
|
+
* switch through {@link RenderOptions.onStatus}.
|
|
1017
|
+
*
|
|
1018
|
+
* Absent (`undefined`) on players before 0.5.12, which do not report it:
|
|
1019
|
+
* the renderer is then unknown, not software.
|
|
1020
|
+
*
|
|
1021
|
+
* Today the player renders on the GPU on macOS, on Windows when the
|
|
1022
|
+
* user turned on Video ▸ GPU Rendering (Experimental) (since version 0.5.14;
|
|
1023
|
+
* off by default), and in software otherwise: on Windows by default, on
|
|
1024
|
+
* Linux and without a user interface (see
|
|
1025
|
+
* [Platforms](../../../docs/reference/platforms.md)); test this field
|
|
1026
|
+
* rather than {@link SystemInfo.os}.
|
|
1027
|
+
*
|
|
1028
|
+
* @example Offer the HDR menu only where render options work
|
|
1029
|
+
* The plugin adds its HDR command only when the player renders on the
|
|
1030
|
+
* GPU, instead of creating the render options just to find out from a
|
|
1031
|
+
* failed status. `system()` asks the player, which reports the renderer
|
|
1032
|
+
* drawing at that moment; no capability is needed to ask. A player before
|
|
1033
|
+
* 0.5.12 leaves the field out, so the test is for `"gpu"` exactly (an
|
|
1034
|
+
* older player gets no HDR command).
|
|
1035
|
+
* ```ts
|
|
1036
|
+
* const { rendering } = await plugin.app.system();
|
|
1037
|
+
* if (rendering === "gpu") {
|
|
1038
|
+
* const render = plugin.video.render(); // one handle, kept
|
|
1039
|
+
* plugin.commands.add({
|
|
1040
|
+
* id: "hdr",
|
|
1041
|
+
* path: ["@video", "HDR Tone Mapping"],
|
|
1042
|
+
* run: () => render.set({ toneMapping: "bt.2390", targetPeak: 250 }),
|
|
1043
|
+
* });
|
|
1044
|
+
* }
|
|
1045
|
+
* ```
|
|
1046
|
+
*
|
|
1047
|
+
* @player 0.5.12; older players leave it out (declare
|
|
1048
|
+
* `"minPlayerVersion": "0.5.12"` when the plugin relies on it).
|
|
1049
|
+
* @since 1.5.34
|
|
1050
|
+
*/
|
|
1051
|
+
readonly rendering?: "gpu" | "software";
|
|
1052
|
+
/**
|
|
1053
|
+
* Why {@link SystemInfo.rendering} is what it is now: the same reason as
|
|
1054
|
+
* {@link RenderingState.reason} (`default`, `no-gpu-backend`,
|
|
1055
|
+
* `preference`, `denylist`, `window-fallback`…, see
|
|
1056
|
+
* {@link RenderingReasonCode}). Read at each call, like `rendering`.
|
|
1057
|
+
*
|
|
1058
|
+
* Absent (`undefined`) on players before 0.5.13.
|
|
1059
|
+
*
|
|
1060
|
+
* @example Say why the video is drawn in software
|
|
1061
|
+
* An About page explains a software renderer with the player's own words,
|
|
1062
|
+
* for example that the graphics driver is on the player's denylist.
|
|
1063
|
+
* `system()` reports the renderer and its reason together, with no
|
|
1064
|
+
* capability; the message is English text that may name the adapter and
|
|
1065
|
+
* the driver version.
|
|
1066
|
+
* ```ts
|
|
1067
|
+
* const { rendering, renderingReason } = await plugin.app.system();
|
|
1068
|
+
* if (rendering === "software" && renderingReason)
|
|
1069
|
+
* console.log(`Rendering: software (${renderingReason.message})`);
|
|
1070
|
+
* ```
|
|
1071
|
+
*
|
|
1072
|
+
* @player 0.5.13; older players leave it out (declare
|
|
1073
|
+
* `"minPlayerVersion": "0.5.13"` when the plugin relies on it).
|
|
1074
|
+
* @since 1.5.35
|
|
1075
|
+
*/
|
|
1076
|
+
readonly renderingReason?: RenderingReason;
|
|
1077
|
+
}
|
|
1078
|
+
/**
|
|
1079
|
+
* One display in {@link SystemInfo.displays}.
|
|
1080
|
+
*
|
|
1081
|
+
* @since 1.0.0
|
|
1082
|
+
* @category Plugin
|
|
1083
|
+
*/
|
|
1084
|
+
export interface DisplayInfo {
|
|
1085
|
+
/** The system's name for it, `null` when it has none. */
|
|
1086
|
+
readonly name: string | null;
|
|
1087
|
+
/** Pixels in the current mode. */
|
|
1088
|
+
readonly width: number;
|
|
1089
|
+
/** Pixels in the current mode. */
|
|
1090
|
+
readonly height: number;
|
|
1091
|
+
/** Pixels per logical point (2 on Retina, 1.5 at 150 %). */
|
|
1092
|
+
readonly scale: number;
|
|
1093
|
+
/** Hz, `null` when unknown. */
|
|
1094
|
+
readonly refreshRate: number | null;
|
|
1095
|
+
/** The primary display. */
|
|
1096
|
+
readonly primary: boolean;
|
|
1097
|
+
}
|