@vestra-player/sdk 1.8.0 → 1.10.0
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 +64 -2
- package/README.md +2 -2
- package/bin/vestra-plugin.mjs +98 -106
- package/capability-scan.json +21 -1
- package/dist/api-requests.d.ts +15 -39
- package/dist/api-requests.js +28 -50
- package/dist/capability-scan.d.ts +1 -1
- package/dist/capability-scan.js +8 -9
- package/dist/condition-table.d.ts +1889 -0
- package/dist/condition-table.js +562 -0
- package/dist/docs-tree.json.gz +0 -0
- package/dist/docs.d.ts +1 -1
- package/dist/docs.js +1 -1
- package/dist/i18n-tools.d.ts +7 -0
- package/dist/i18n-tools.js +66 -3
- package/dist/index.d.ts +4 -5
- package/dist/manifest.d.ts +5 -0
- package/dist/manifest.js +9 -24
- package/dist/member-uses.d.ts +61 -0
- package/dist/member-uses.js +160 -0
- package/dist/player-runtime.d.ts +4 -2
- package/dist/player-runtime.js +4 -2
- package/dist/plugin/appearance.d.ts +1 -1
- package/dist/plugin/appearance.js +2 -2
- package/dist/plugin/bindings.d.ts +1 -1
- package/dist/plugin/bindings.js +2 -2
- package/dist/plugin/commands.js +1 -12
- package/dist/plugin/connection.d.ts +38 -8
- package/dist/plugin/connection.js +126 -37
- package/dist/plugin/drops.js +1 -1
- package/dist/plugin/index.d.ts +7 -0
- package/dist/plugin/index.js +22 -15
- package/dist/plugin/media.js +0 -12
- package/dist/plugin/mpv.js +39 -12
- package/dist/plugin/packages.js +1 -2
- package/dist/plugin/player/events.d.ts +17 -7
- package/dist/plugin/player/events.js +26 -9
- package/dist/plugin/player.d.ts +37 -13
- package/dist/plugin/player.js +133 -22
- package/dist/plugin/scope.d.ts +4 -1
- package/dist/plugin/scope.js +8 -0
- package/dist/plugin/services.d.ts +4 -4
- package/dist/plugin/services.js +7 -29
- package/dist/plugin/settings.js +1 -1
- package/dist/plugin/shaders.js +0 -2
- package/dist/plugin/stream.d.ts +2 -1
- package/dist/plugin/stream.js +2 -2
- package/dist/plugin/testing/commands.d.ts +3 -10
- package/dist/plugin/testing/commands.js +24 -37
- package/dist/plugin/testing/index.d.ts +133 -116
- package/dist/plugin/testing/index.js +198 -125
- package/dist/plugin/testing/media.d.ts +6 -0
- package/dist/plugin/testing/media.js +15 -2
- package/dist/plugin/testing/processing.js +1 -1
- package/dist/plugin/testing/services.js +0 -1
- package/dist/plugin/testing/source-events.d.ts +28 -0
- package/dist/plugin/testing/source-events.js +66 -0
- package/dist/plugin/testing/transport.js +5 -0
- package/dist/plugin/testing/triggers.d.ts +82 -0
- package/dist/plugin/testing/triggers.js +448 -0
- package/dist/plugin/timeline.d.ts +5 -6
- package/dist/plugin/timeline.js +7 -11
- package/dist/plugin/triggers.d.ts +55 -0
- package/dist/plugin/triggers.js +233 -0
- package/dist/plugin/types/base.d.ts +77 -87
- package/dist/plugin/types/commands.d.ts +384 -68
- package/dist/plugin/types/packages.d.ts +17 -55
- package/dist/plugin/types/playback.d.ts +382 -152
- package/dist/plugin/types/plugin-wire.d.ts +6 -36
- package/dist/plugin/types/processing.d.ts +10 -49
- package/dist/plugin/types/services.d.ts +11 -70
- package/dist/plugin/types/snapshots.d.ts +7 -60
- package/dist/plugin/types/sources.d.ts +2 -11
- package/dist/plugin/types/subtitles.d.ts +5 -26
- package/dist/plugin/types/ui-content.d.ts +1 -16
- package/dist/plugin/types/ui-layout.d.ts +53 -79
- package/dist/plugin/types/ui-locale.d.ts +5 -23
- package/dist/plugin/types/ui-shell.d.ts +13 -59
- package/dist/plugin/view/layout.js +1 -1
- package/dist/plugin/view.js +0 -2
- package/dist/plugin/when.d.ts +78 -4
- package/dist/plugin/when.js +182 -14
- package/dist/plugin/window.d.ts +1 -1
- package/dist/plugin/window.js +1 -1
- package/dist/plugin/wire-facade.js +1 -2
- package/dist/processing.d.ts +2 -3
- package/dist/protocol.d.ts +14 -0
- package/dist/protocol.js +14 -0
- package/dist/request-queue.js +1 -1
- package/dist/slint-version.d.ts +7 -0
- package/dist/slint-version.js +7 -0
- package/dist/subtitles.d.ts +1 -1
- package/dist/ts-plugin.d.ts +8 -15
- package/dist/ts-plugin.js +3 -141
- package/dist/wire.d.ts +22 -12
- package/dist/wire.js +17 -8
- package/llms.txt +6 -6
- package/package.json +1 -2
- package/dist/capabilities.d.ts +0 -107
- package/dist/capabilities.js +0 -69
- package/dist/capability-check.d.ts +0 -176
- package/dist/capability-check.js +0 -461
- package/dist/capability-rules.d.ts +0 -125
- package/dist/capability-rules.js +0 -192
- package/dist/host-capabilities.d.ts +0 -10
- package/dist/host-capabilities.js +0 -492
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Scope } from "./base.ts";
|
|
2
|
-
import type { Player } from "./playback.ts";
|
|
2
|
+
import type { AudioTrack, Player, TimelineLayer } from "./playback.ts";
|
|
3
3
|
import type { Ui, View } from "./ui-content.ts";
|
|
4
4
|
import type { Disposable } from "./base.ts";
|
|
5
5
|
import type { PlayerState } from "./playback.ts";
|
|
@@ -69,8 +69,6 @@ export type Bindable<T> = T | (() => T);
|
|
|
69
69
|
* keeps working; one that reads `plugin.player.state` or another service's
|
|
70
70
|
* state keeps the plugin running so the SDK can evaluate it.
|
|
71
71
|
*
|
|
72
|
-
* @capability commands
|
|
73
|
-
*
|
|
74
72
|
* @example Enable an item while a frame can be saved
|
|
75
73
|
* "Save Snapshot" is greyed out with its reason unless a media file is
|
|
76
74
|
* open at a frame the player can capture. The condition is sent with the
|
|
@@ -105,7 +103,6 @@ export interface Condition {
|
|
|
105
103
|
* const playingFullscreen = when.playing.and(when.fullscreen);
|
|
106
104
|
* ```
|
|
107
105
|
*
|
|
108
|
-
* @capability None (the command it is given to needs `commands`).
|
|
109
106
|
* @since 1.5.40
|
|
110
107
|
*/
|
|
111
108
|
and(...others: Condition[]): Condition;
|
|
@@ -120,7 +117,6 @@ export interface Condition {
|
|
|
120
117
|
* const active = when.playing.or(when.paused);
|
|
121
118
|
* ```
|
|
122
119
|
*
|
|
123
|
-
* @capability None (the command it is given to needs `commands`).
|
|
124
120
|
* @since 1.5.40
|
|
125
121
|
*/
|
|
126
122
|
or(...others: Condition[]): Condition;
|
|
@@ -136,7 +132,6 @@ export interface Condition {
|
|
|
136
132
|
* const windowed = when.fullscreen.not();
|
|
137
133
|
* ```
|
|
138
134
|
*
|
|
139
|
-
* @capability None (the command it is given to needs `commands`).
|
|
140
135
|
* @since 1.5.40
|
|
141
136
|
*/
|
|
142
137
|
not(): Condition;
|
|
@@ -159,8 +154,6 @@ export interface Condition {
|
|
|
159
154
|
* window, a track list) stays a function or a value set with
|
|
160
155
|
* {@link Command.set}.
|
|
161
156
|
*
|
|
162
|
-
* @capability commands
|
|
163
|
-
*
|
|
164
157
|
* @example Check a palette item and follow the palette
|
|
165
158
|
* The Appearance submenu has one radio item per palette; the player
|
|
166
159
|
* checks the one in use, also after another plugin or the user changed
|
|
@@ -207,7 +200,6 @@ export interface When {
|
|
|
207
200
|
* const hasFrame = when.phase("ready", "ended");
|
|
208
201
|
* ```
|
|
209
202
|
*
|
|
210
|
-
* @capability None (the command it is given to needs `commands`).
|
|
211
203
|
* @since 1.5.40
|
|
212
204
|
*/
|
|
213
205
|
phase(...phases: PlayerState["phase"][]): Condition;
|
|
@@ -224,7 +216,6 @@ export interface When {
|
|
|
224
216
|
* const seekable = when.can("seek");
|
|
225
217
|
* ```
|
|
226
218
|
*
|
|
227
|
-
* @capability None (the command it is given to needs `commands`).
|
|
228
219
|
* @since 1.5.40
|
|
229
220
|
*/
|
|
230
221
|
can(control: keyof PlayerState["can"]): Condition;
|
|
@@ -241,7 +232,6 @@ export interface When {
|
|
|
241
232
|
* const light = when.theme("vestra-light");
|
|
242
233
|
* ```
|
|
243
234
|
*
|
|
244
|
-
* @capability None (the command it is given to needs `commands`).
|
|
245
235
|
* @since 1.5.40
|
|
246
236
|
*/
|
|
247
237
|
theme(theme: ThemeId): Condition;
|
|
@@ -259,10 +249,382 @@ export interface When {
|
|
|
259
249
|
* const followSystem = when.language("system");
|
|
260
250
|
* ```
|
|
261
251
|
*
|
|
262
|
-
* @capability None (the command it is given to needs `commands`).
|
|
263
252
|
* @since 1.5.40
|
|
264
253
|
*/
|
|
265
254
|
language(language: LanguagePreference): Condition;
|
|
255
|
+
/**
|
|
256
|
+
* The source is muted (`PlayerState.muted`).
|
|
257
|
+
*
|
|
258
|
+
* @since 1.10.0
|
|
259
|
+
*/
|
|
260
|
+
readonly muted: Condition;
|
|
261
|
+
/**
|
|
262
|
+
* The main window is maximized (`MainWindowState.maximized`).
|
|
263
|
+
*
|
|
264
|
+
* @since 1.10.0
|
|
265
|
+
*/
|
|
266
|
+
readonly maximized: Condition;
|
|
267
|
+
/**
|
|
268
|
+
* The video shows in the picture-in-picture window.
|
|
269
|
+
*
|
|
270
|
+
* @since 1.10.0
|
|
271
|
+
*/
|
|
272
|
+
readonly pip: Condition;
|
|
273
|
+
/**
|
|
274
|
+
* An A-B loop is set (`PlayerState.loop` is not `null`).
|
|
275
|
+
*
|
|
276
|
+
* @since 1.10.0
|
|
277
|
+
*/
|
|
278
|
+
readonly looping: Condition;
|
|
279
|
+
/**
|
|
280
|
+
* The source's duration in seconds is within `min ≤ duration < max`
|
|
281
|
+
* (at least one bound); false while it is unknown.
|
|
282
|
+
*
|
|
283
|
+
* @throws `TypeError` (throws) No bound, a bound that is not a finite
|
|
284
|
+
* number, or `min ≥ max`.
|
|
285
|
+
*
|
|
286
|
+
* @example Only for files longer than ten minutes
|
|
287
|
+
* The condition holds once the player knows the file lasts 600 seconds
|
|
288
|
+
* or more; with no `max` the range is open upwards.
|
|
289
|
+
* ```ts
|
|
290
|
+
* const { when } = plugin;
|
|
291
|
+
* const long = when.duration({ min: 600 });
|
|
292
|
+
* ```
|
|
293
|
+
*
|
|
294
|
+
* @since 1.10.0
|
|
295
|
+
*/
|
|
296
|
+
duration(bounds: {
|
|
297
|
+
min?: number;
|
|
298
|
+
max?: number;
|
|
299
|
+
}): Condition;
|
|
300
|
+
/**
|
|
301
|
+
* The volume (0–200) is within `min ≤ volume < max`.
|
|
302
|
+
*
|
|
303
|
+
* @throws `TypeError` (throws) As {@link When.duration}.
|
|
304
|
+
*
|
|
305
|
+
* @example Check a Boost item above full volume
|
|
306
|
+
* The item carries a check mark while the volume is above 100, whoever
|
|
307
|
+
* raised it; the player compares its own volume, so the plugin need
|
|
308
|
+
* not follow the state.
|
|
309
|
+
* ```ts
|
|
310
|
+
* const { when } = plugin;
|
|
311
|
+
* const boosted = when.volume({ min: 101 });
|
|
312
|
+
* ```
|
|
313
|
+
*
|
|
314
|
+
* @since 1.10.0
|
|
315
|
+
*/
|
|
316
|
+
volume(bounds: {
|
|
317
|
+
min?: number;
|
|
318
|
+
max?: number;
|
|
319
|
+
}): Condition;
|
|
320
|
+
/**
|
|
321
|
+
* The playback rate is within `min ≤ rate < max`.
|
|
322
|
+
*
|
|
323
|
+
* @throws `TypeError` (throws) As {@link When.duration}.
|
|
324
|
+
*
|
|
325
|
+
* @example Enable Normal Speed only when sped up
|
|
326
|
+
* The item is greyed out at normal speed or slower: the condition holds
|
|
327
|
+
* from a rate of just over 1 upwards.
|
|
328
|
+
* ```ts
|
|
329
|
+
* const { when } = plugin;
|
|
330
|
+
* const fast = when.rate({ min: 1.01 });
|
|
331
|
+
* ```
|
|
332
|
+
*
|
|
333
|
+
* @since 1.10.0
|
|
334
|
+
*/
|
|
335
|
+
rate(bounds: {
|
|
336
|
+
min?: number;
|
|
337
|
+
max?: number;
|
|
338
|
+
}): Condition;
|
|
339
|
+
/**
|
|
340
|
+
* The wall clock (Unix milliseconds, as `Date.now()`) is within
|
|
341
|
+
* `min ≤ now < max`. For a trigger only (`plugin.trigger().firesOn`): a
|
|
342
|
+
* command's state refuses it.
|
|
343
|
+
*
|
|
344
|
+
* @throws `TypeError` (throws) As {@link When.duration}.
|
|
345
|
+
*
|
|
346
|
+
* @example The clock is at or past 45 minutes from now
|
|
347
|
+
* The bound is computed once, when the condition is made, so the
|
|
348
|
+
* condition turns true 45 minutes later and stays true.
|
|
349
|
+
* ```ts
|
|
350
|
+
* const { when } = plugin;
|
|
351
|
+
* const due = when.time({ min: Date.now() + 45 * 60_000 });
|
|
352
|
+
* ```
|
|
353
|
+
*
|
|
354
|
+
* @since 1.10.0
|
|
355
|
+
*/
|
|
356
|
+
time(bounds: {
|
|
357
|
+
min?: number;
|
|
358
|
+
max?: number;
|
|
359
|
+
}): Condition;
|
|
360
|
+
/**
|
|
361
|
+
* The selected audio track is `id` ({@link AudioTrack.id}).
|
|
362
|
+
*
|
|
363
|
+
* @throws `TypeError` (throws) `id` is not an integer.
|
|
364
|
+
*
|
|
365
|
+
* @example Check the item of each audio track
|
|
366
|
+
* One menu item per track of the file carries a check mark while that
|
|
367
|
+
* track plays, also when the user picks it in the player's own menu.
|
|
368
|
+
* ```ts
|
|
369
|
+
* const { when, player } = plugin;
|
|
370
|
+
* for (const track of player.state.audioTracks ?? [])
|
|
371
|
+
* plugin.commands.add({
|
|
372
|
+
* id: `audio-${track.id}`,
|
|
373
|
+
* path: ["@audio", "Track", track.title ?? `Track ${track.id}`],
|
|
374
|
+
* radio: true,
|
|
375
|
+
* checked: when.audioTrack(track.id), // the player keeps the mark current
|
|
376
|
+
* run: () => player.selectAudioTrack(track.id),
|
|
377
|
+
* });
|
|
378
|
+
* ```
|
|
379
|
+
*
|
|
380
|
+
* @since 1.10.0
|
|
381
|
+
*/
|
|
382
|
+
audioTrack(id: number): Condition;
|
|
383
|
+
/**
|
|
384
|
+
* The primary subtitle track is `id` (`SubtitleTrack.id`).
|
|
385
|
+
*
|
|
386
|
+
* @throws `TypeError` (throws) `id` is not a string of 1–256 characters.
|
|
387
|
+
*
|
|
388
|
+
* @example Check the item of a subtitle track
|
|
389
|
+
* The item carries a check mark while the track with this id is the
|
|
390
|
+
* primary subtitle, whoever selected it.
|
|
391
|
+
* ```ts
|
|
392
|
+
* declare const trackId: string;
|
|
393
|
+
* // ---cut---
|
|
394
|
+
* const { when } = plugin;
|
|
395
|
+
* const shown = when.subtitleTrack(trackId);
|
|
396
|
+
* ```
|
|
397
|
+
*
|
|
398
|
+
* @since 1.10.0
|
|
399
|
+
*/
|
|
400
|
+
subtitleTrack(id: string): Condition;
|
|
401
|
+
/**
|
|
402
|
+
* The active audio output device is `id` (`PlayerState.audioOutput.active`).
|
|
403
|
+
*
|
|
404
|
+
* @throws `TypeError` (throws) `id` is not a string of 1–256 characters.
|
|
405
|
+
*
|
|
406
|
+
* @example Check the item of the active output device
|
|
407
|
+
* One menu item per output device carries a check mark while the
|
|
408
|
+
* player plays through it; the player compares its own active device.
|
|
409
|
+
* ```ts
|
|
410
|
+
* const { when, player } = plugin;
|
|
411
|
+
* for (const device of await player.audioDevices())
|
|
412
|
+
* plugin.commands.add({
|
|
413
|
+
* id: `out-${device.id}`,
|
|
414
|
+
* path: ["@audio", "Output", device.name],
|
|
415
|
+
* radio: true,
|
|
416
|
+
* checked: when.audioDevice(device.id), // no state read in the plugin
|
|
417
|
+
* run: () => player.setAudioDevice(device.id),
|
|
418
|
+
* });
|
|
419
|
+
* ```
|
|
420
|
+
*
|
|
421
|
+
* @since 1.10.0
|
|
422
|
+
*/
|
|
423
|
+
audioDevice(id: string): Condition;
|
|
424
|
+
/**
|
|
425
|
+
* The playback position. For a trigger only: a command's state refuses
|
|
426
|
+
* it.
|
|
427
|
+
*
|
|
428
|
+
* @since 1.10.0
|
|
429
|
+
*/
|
|
430
|
+
readonly position: {
|
|
431
|
+
/**
|
|
432
|
+
* The position is inside one of `ranges` (`start ≤ position < end`; no
|
|
433
|
+
* `end`: open), or less than `lead` media seconds before a range's
|
|
434
|
+
* start. The player binds the list to the source that is current when
|
|
435
|
+
* it receives it: for any other source this is false. When several
|
|
436
|
+
* ranges hold, the one with the earliest start is the one a trigger's
|
|
437
|
+
* `enter` gets as `range`. At most one position list per condition;
|
|
438
|
+
* it counts as one part however long it is.
|
|
439
|
+
*
|
|
440
|
+
* @param ranges - Objects with `start` and optionally `end` (media
|
|
441
|
+
* seconds); other fields are ignored, so the list given to
|
|
442
|
+
* {@link TimelineLayer.setRanges} fits as it is. At most 1000
|
|
443
|
+
* (`TIMELINE_LIMITS.ranges`).
|
|
444
|
+
* @param options - `lead`: media seconds each range starts earlier,
|
|
445
|
+
* to make up for the time a plugin in standby takes to start.
|
|
446
|
+
* @throws `TypeError` (throws) A start that is not a finite number of
|
|
447
|
+
* 0 or more, an end not after its start, a negative lead.
|
|
448
|
+
* @throws `limit` (throws) More than 1000 ranges.
|
|
449
|
+
*
|
|
450
|
+
* @example Be told 2 s before each silence
|
|
451
|
+
* ```ts
|
|
452
|
+
* declare const spans: { start: number; end: number }[];
|
|
453
|
+
* // ---cut---
|
|
454
|
+
* const { when } = plugin;
|
|
455
|
+
* const near = when.playing.and(when.position.in(spans, { lead: 2 }));
|
|
456
|
+
* ```
|
|
457
|
+
*
|
|
458
|
+
* @since 1.10.0
|
|
459
|
+
*/
|
|
460
|
+
in(ranges: Iterable<PositionRange>, options?: {
|
|
461
|
+
lead?: number;
|
|
462
|
+
}): Condition;
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* A range of media time for {@link When.position}: any object with `start`
|
|
467
|
+
* and, optionally, `end`, in seconds.
|
|
468
|
+
*
|
|
469
|
+
* @since 1.10.0
|
|
470
|
+
* @category Commands
|
|
471
|
+
*/
|
|
472
|
+
export interface PositionRange {
|
|
473
|
+
/** Where the range starts, in media seconds (0 or more). */
|
|
474
|
+
readonly start: number;
|
|
475
|
+
/** Where it ends, in media seconds, after `start`; absent or `null`: open. */
|
|
476
|
+
readonly end?: number | null;
|
|
477
|
+
}
|
|
478
|
+
/**
|
|
479
|
+
* What a trigger's `enter` and `leave` get.
|
|
480
|
+
*
|
|
481
|
+
* @since 1.10.0
|
|
482
|
+
* @category Commands
|
|
483
|
+
*/
|
|
484
|
+
export interface TriggerEvent {
|
|
485
|
+
/** The player's state at the moment the player saw the condition flip. */
|
|
486
|
+
readonly state: PlayerState;
|
|
487
|
+
/**
|
|
488
|
+
* For a condition with {@link When.position}`.in`, when the position is
|
|
489
|
+
* in one of its ranges: that range as given, and its place in the list
|
|
490
|
+
* the player evaluated. `start` and `end` name the range; `index` is its
|
|
491
|
+
* place in that list: an `enter` that was on its way while the plugin
|
|
492
|
+
* gave a new list holding the same range (the trigger stays entered)
|
|
493
|
+
* carries the place in the old list, and the later `leave` the place in
|
|
494
|
+
* the new one.
|
|
495
|
+
*/
|
|
496
|
+
readonly range?: {
|
|
497
|
+
/** The range's start, in media seconds. */
|
|
498
|
+
readonly start: number;
|
|
499
|
+
/** The range's end, in media seconds (`null`: open). */
|
|
500
|
+
readonly end: number | null;
|
|
501
|
+
/** Its place in the list given to `when.position.in`, from 0. */
|
|
502
|
+
readonly index: number;
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
/**
|
|
506
|
+
* A trigger (`plugin.trigger()`): a place for one condition the player
|
|
507
|
+
* keeps and evaluates, also while the plugin is in standby, and the
|
|
508
|
+
* functions to call when it becomes true (`enter`) and false (`leave`).
|
|
509
|
+
*
|
|
510
|
+
* @remarks
|
|
511
|
+
* When it flips while the plugin has no process, the player starts the
|
|
512
|
+
* plugin; `activate()` declares the same triggers again and the waiting
|
|
513
|
+
* notification reaches the same trigger. Every method returns the
|
|
514
|
+
* trigger, so the calls chain.
|
|
515
|
+
*
|
|
516
|
+
* @example On top while playing in fullscreen
|
|
517
|
+
* The window stays on top while a file plays in fullscreen and goes back
|
|
518
|
+
* when either ends. The player evaluates the condition itself, so the
|
|
519
|
+
* plugin may be in standby in between.
|
|
520
|
+
* ```ts
|
|
521
|
+
* const { when, window } = plugin;
|
|
522
|
+
* plugin
|
|
523
|
+
* .trigger()
|
|
524
|
+
* // The player keeps this condition and calls back when it flips.
|
|
525
|
+
* .firesOn(when.playing.and(when.fullscreen))
|
|
526
|
+
* .enter(() => window.setAlwaysOnTop(true))
|
|
527
|
+
* .leave(() => window.setAlwaysOnTop(false));
|
|
528
|
+
* ```
|
|
529
|
+
*
|
|
530
|
+
* @since 1.10.0
|
|
531
|
+
* @category Commands
|
|
532
|
+
*/
|
|
533
|
+
export interface Trigger {
|
|
534
|
+
/**
|
|
535
|
+
* Hands the player this condition, replacing the one it has (without a
|
|
536
|
+
* `leave` for the old one). A condition already true is entered at once,
|
|
537
|
+
* except a range list given again for the same source while the
|
|
538
|
+
* position is still in the range it was entered with (the same start,
|
|
539
|
+
* end and lead; a list that grew as a scan went on): that range stays
|
|
540
|
+
* entered, with no second `enter`, and an `enter` of it still on its way
|
|
541
|
+
* (a plugin woken for it) reaches `enter` all the same. The same
|
|
542
|
+
* condition again changes nothing. A refusal (`invalid`,
|
|
543
|
+
* `limit`) reaches the plugin's error handlers.
|
|
544
|
+
*
|
|
545
|
+
* @throws `TypeError` (throws) Not a condition from `plugin.when`, or
|
|
546
|
+
* one with two position lists.
|
|
547
|
+
*
|
|
548
|
+
* @example Pause ten seconds before the end
|
|
549
|
+
* A command arms the trigger for the file open now: its condition holds
|
|
550
|
+
* from ten seconds before the end, and `enter` pauses. Pressing it again
|
|
551
|
+
* replaces the condition, without a `leave` for the old one.
|
|
552
|
+
* ```ts
|
|
553
|
+
* const { when, player } = plugin;
|
|
554
|
+
* const nearEnd = plugin.trigger("near-end").enter(() => player.setPaused(true));
|
|
555
|
+
* plugin.commands.add({
|
|
556
|
+
* id: "pause-near-end",
|
|
557
|
+
* path: ["Tools", "Pause Near the End"],
|
|
558
|
+
* run: () => {
|
|
559
|
+
* const duration = player.state.duration;
|
|
560
|
+
* // Bound to the current file: another file never matches it.
|
|
561
|
+
* if (duration !== null)
|
|
562
|
+
* nearEnd.firesOn(when.position.in([{ start: Math.max(0, duration - 10) }]));
|
|
563
|
+
* },
|
|
564
|
+
* });
|
|
565
|
+
* ```
|
|
566
|
+
*
|
|
567
|
+
* @since 1.10.0
|
|
568
|
+
*/
|
|
569
|
+
firesOn(condition: Condition): Trigger;
|
|
570
|
+
/**
|
|
571
|
+
* `fn` runs each time the condition turns from false to true. One
|
|
572
|
+
* trigger's functions run one after another: the next waits for the
|
|
573
|
+
* promise of the one before. A second call replaces the function.
|
|
574
|
+
*
|
|
575
|
+
* @throws `TypeError` (throws) `fn` is not a function.
|
|
576
|
+
*
|
|
577
|
+
* @example Show a note as each marked range starts
|
|
578
|
+
* The OSD names the part of the file as playback reaches it. `range`
|
|
579
|
+
* says which of the ranges was entered: `index` is its place in the
|
|
580
|
+
* list the condition was given.
|
|
581
|
+
* ```ts
|
|
582
|
+
* declare const parts: { start: number; end: number; name: string }[];
|
|
583
|
+
* // ---cut---
|
|
584
|
+
* const { when, osd } = plugin;
|
|
585
|
+
* plugin
|
|
586
|
+
* .trigger()
|
|
587
|
+
* .firesOn(when.position.in(parts))
|
|
588
|
+
* // `range` is set because the condition has a position list.
|
|
589
|
+
* .enter(async ({ range }) => {
|
|
590
|
+
* if (range) await osd.show("Now: {}", [parts[range.index].name]);
|
|
591
|
+
* });
|
|
592
|
+
* ```
|
|
593
|
+
*
|
|
594
|
+
* @since 1.10.0
|
|
595
|
+
*/
|
|
596
|
+
enter(fn: (event: TriggerEvent) => unknown): Trigger;
|
|
597
|
+
/**
|
|
598
|
+
* Optional: `fn` runs each time the condition turns from true to false.
|
|
599
|
+
* A second call replaces the function.
|
|
600
|
+
*
|
|
601
|
+
* @throws `TypeError` (throws) `fn` is not a function.
|
|
602
|
+
*
|
|
603
|
+
* @example See Trigger
|
|
604
|
+
* {@link Trigger}
|
|
605
|
+
*
|
|
606
|
+
* @since 1.10.0
|
|
607
|
+
*/
|
|
608
|
+
leave(fn: (event: TriggerEvent) => unknown): Trigger;
|
|
609
|
+
/**
|
|
610
|
+
* Removes the condition, without a `leave`. The trigger stays declared
|
|
611
|
+
* and can be given a new condition.
|
|
612
|
+
*
|
|
613
|
+
* @example Cancel a sleep timer
|
|
614
|
+
* A second command disarms the timer the first one set: the player
|
|
615
|
+
* forgets the condition, so the plugin is not started for it.
|
|
616
|
+
* ```ts
|
|
617
|
+
* const sleep = plugin.trigger("sleep").enter(() => plugin.player.setPaused(true));
|
|
618
|
+
* plugin.commands.add({
|
|
619
|
+
* id: "sleep-cancel",
|
|
620
|
+
* path: ["Tools", "Cancel Sleep Timer"],
|
|
621
|
+
* run: () => sleep.off(), // the trigger stays; only its condition goes
|
|
622
|
+
* });
|
|
623
|
+
* ```
|
|
624
|
+
*
|
|
625
|
+
* @since 1.10.0
|
|
626
|
+
*/
|
|
627
|
+
off(): Trigger;
|
|
266
628
|
}
|
|
267
629
|
/**
|
|
268
630
|
* A built-in top-level menu of the player, named in a command path as `@<id>`
|
|
@@ -621,8 +983,6 @@ export interface CommandOptions {
|
|
|
621
983
|
* again. Disposing it, its scope or stopping the plugin removes the menu
|
|
622
984
|
* item, its keys and its bar button.
|
|
623
985
|
*
|
|
624
|
-
* @capability commands
|
|
625
|
-
*
|
|
626
986
|
* @example Enable an item only while a file is open
|
|
627
987
|
* Video ▸ Export… is greyed out until a file is open. `set` replaces the
|
|
628
988
|
* `enabled` field with a function; the SDK evaluates it again after every
|
|
@@ -681,7 +1041,6 @@ export interface Command extends Disposable {
|
|
|
681
1041
|
* });
|
|
682
1042
|
* ```
|
|
683
1043
|
*
|
|
684
|
-
* @capability commands
|
|
685
1044
|
* @since 1.0.0
|
|
686
1045
|
*/
|
|
687
1046
|
set(state: Partial<{
|
|
@@ -701,7 +1060,7 @@ export interface Command extends Disposable {
|
|
|
701
1060
|
* activation completes, so a listener added anywhere in `activate` hears it.
|
|
702
1061
|
* `startPlugin` stays strict: there a refusal during activation fails it, so
|
|
703
1062
|
* tests show the bad declaration. Any other failure during activation
|
|
704
|
-
* (
|
|
1063
|
+
* (no answer, for example) fails activation.
|
|
705
1064
|
*
|
|
706
1065
|
* Only the player's answer is skipped. What {@link Commands.add} checks
|
|
707
1066
|
* itself still throws from `add` (an unknown `@` menu id, more than 8
|
|
@@ -711,7 +1070,6 @@ export interface Command extends Disposable {
|
|
|
711
1070
|
*
|
|
712
1071
|
* @throws `conflict` (rejects) Another command already has this menu path,
|
|
713
1072
|
* or the path would be both a menu item and a submenu.
|
|
714
|
-
* @throws `capability` (rejects) The manifest does not declare `commands`.
|
|
715
1073
|
* @throws `invalid` (rejects) The player refused the declaration.
|
|
716
1074
|
* @throws `limit` (rejects) More than 160 commands in this plugin, or 1024 in
|
|
717
1075
|
* the player.
|
|
@@ -733,8 +1091,6 @@ export interface Command extends Disposable {
|
|
|
733
1091
|
* command; `startPlugin` fails on it). What `add` checks itself throws from
|
|
734
1092
|
* `add`.
|
|
735
1093
|
*
|
|
736
|
-
* @capability commands
|
|
737
|
-
*
|
|
738
1094
|
* @example Add a menu item with a default key
|
|
739
1095
|
* Tools ▸ Say hello, or Ctrl+H, shows a greeting. `add` declares the item;
|
|
740
1096
|
* the player calls `run` when the user picks it or presses its key, and the
|
|
@@ -789,7 +1145,6 @@ export interface Commands {
|
|
|
789
1145
|
* });
|
|
790
1146
|
* ```
|
|
791
1147
|
*
|
|
792
|
-
* @capability commands
|
|
793
1148
|
* @since 1.0.0
|
|
794
1149
|
*/
|
|
795
1150
|
add(options: CommandOptions): Command;
|
|
@@ -822,9 +1177,7 @@ export interface Commands {
|
|
|
822
1177
|
* {@link "@vestra-player/sdk/testing"!BUILTIN_COMMANDS | BUILTIN_COMMANDS}
|
|
823
1178
|
* rows owned by `host`), for a panel that shows the player's keys beside its
|
|
824
1179
|
* own controls; an id the plugin has not added (or another plugin's) reads
|
|
825
|
-
* `[]`.
|
|
826
|
-
* binding table, every plugin's, is {@link Bindings.list}). Without the
|
|
827
|
-
* `commands` capability every command reads `[]`.
|
|
1180
|
+
* `[]`. The whole binding table, every plugin's, is {@link Bindings.list}.
|
|
828
1181
|
*
|
|
829
1182
|
* @example Show a slider's keys beside it
|
|
830
1183
|
* The Brightness row shows its two keys, W and E by default, as key caps
|
|
@@ -842,7 +1195,6 @@ export interface Commands {
|
|
|
842
1195
|
* }));
|
|
843
1196
|
* ```
|
|
844
1197
|
*
|
|
845
|
-
* @capability commands
|
|
846
1198
|
* @player 0.7.6
|
|
847
1199
|
* @since 1.6.6
|
|
848
1200
|
*/
|
|
@@ -868,14 +1220,12 @@ export interface Commands {
|
|
|
868
1220
|
* const row = commands.find((each) => each.id === "vestra.subtitles/tuning");
|
|
869
1221
|
* if (row?.keys[0]) await plugin.osd.show("Press {}", [row.keys[0]]);
|
|
870
1222
|
* } catch (error) {
|
|
871
|
-
* // `capability`: not a built-in plugin
|
|
1223
|
+
* // `capability`: not a built-in plugin.
|
|
872
1224
|
* if ((error as PluginError).code !== "capability") throw error;
|
|
873
1225
|
* }
|
|
874
1226
|
* ```
|
|
875
1227
|
*
|
|
876
|
-
* @capability
|
|
877
|
-
* @throws `capability` (rejects) The manifest does not declare
|
|
878
|
-
* `commands.run`, or the plugin is not built into the player.
|
|
1228
|
+
* @throws `capability` (rejects) The plugin is not built into the player.
|
|
879
1229
|
* @player 0.7.6
|
|
880
1230
|
* @since 1.7.9
|
|
881
1231
|
*/
|
|
@@ -947,9 +1297,7 @@ export interface Commands {
|
|
|
947
1297
|
* });
|
|
948
1298
|
* ```
|
|
949
1299
|
*
|
|
950
|
-
* @capability
|
|
951
|
-
* @throws `capability` (rejects) The manifest does not declare
|
|
952
|
-
* `commands.run`, or the plugin is not built into the player.
|
|
1300
|
+
* @throws `capability` (rejects) The plugin is not built into the player.
|
|
953
1301
|
* @throws `ticket` (rejects) No ticket, or it ended or expired.
|
|
954
1302
|
* @throws `missing` (rejects) No listed command has this id, or one of
|
|
955
1303
|
* the ids of `then`.
|
|
@@ -1109,8 +1457,6 @@ export interface CommandInfo {
|
|
|
1109
1457
|
* an assistant that runs commands for a sentence. There is one lead in the
|
|
1110
1458
|
* player, and only a built-in plugin can hold it.
|
|
1111
1459
|
*
|
|
1112
|
-
* @capability palette.lead (built-in plugins only)
|
|
1113
|
-
*
|
|
1114
1460
|
* @example Answer typed time stamps from the palette
|
|
1115
1461
|
* The palette's first row reads "Go to: 12:30"; Enter seeks there. `lead`
|
|
1116
1462
|
* puts the row up; the player sends the typed text with Enter, and the
|
|
@@ -1140,9 +1486,7 @@ export interface Palette {
|
|
|
1140
1486
|
* @example See Palette
|
|
1141
1487
|
* {@link Palette}
|
|
1142
1488
|
*
|
|
1143
|
-
* @capability
|
|
1144
|
-
* @throws `capability` (through `ready`) The manifest does not declare
|
|
1145
|
-
* `palette.lead`, or the plugin is not built into the player.
|
|
1489
|
+
* @throws `capability` (through `ready`) The plugin is not built into the player.
|
|
1146
1490
|
* @throws `conflict` (through `ready`) Another plugin holds the lead.
|
|
1147
1491
|
* @throws `invalid` (through `ready`) A text over its length.
|
|
1148
1492
|
* @player 0.7.6
|
|
@@ -1260,8 +1604,6 @@ export interface PaletteLeadRun {
|
|
|
1260
1604
|
* status while a request runs, a note while it cannot run); `onRun` hears
|
|
1261
1605
|
* each activation; `done` ends the ticket of a finished request.
|
|
1262
1606
|
*
|
|
1263
|
-
* @capability palette.lead (built-in plugins only)
|
|
1264
|
-
*
|
|
1265
1607
|
* @example Show a status while a request runs
|
|
1266
1608
|
* While the plugin works on a request the row shows "Working… (Enter to
|
|
1267
1609
|
* stop)"; Enter on it stops the work. The status row replaces the lead
|
|
@@ -1290,7 +1632,7 @@ export interface PaletteLead extends Disposable {
|
|
|
1290
1632
|
/**
|
|
1291
1633
|
* Settles when the player has the row.
|
|
1292
1634
|
*
|
|
1293
|
-
* @throws `capability` (rejects)
|
|
1635
|
+
* @throws `capability` (rejects) The plugin is not built into the player.
|
|
1294
1636
|
* @throws `conflict` (rejects) Another plugin holds the lead.
|
|
1295
1637
|
* @throws `invalid` (rejects) A text over its length.
|
|
1296
1638
|
*/
|
|
@@ -1301,7 +1643,6 @@ export interface PaletteLead extends Disposable {
|
|
|
1301
1643
|
* @example See PaletteLead
|
|
1302
1644
|
* {@link PaletteLead}
|
|
1303
1645
|
*
|
|
1304
|
-
* @capability palette.lead (built-in plugins only)
|
|
1305
1646
|
* @throws `invalid` (rejects) A text over its length.
|
|
1306
1647
|
* @throws `capability` (rejects) The row was refused (see `ready`).
|
|
1307
1648
|
* @since 1.7.9
|
|
@@ -1326,7 +1667,6 @@ export interface PaletteLead extends Disposable {
|
|
|
1326
1667
|
* });
|
|
1327
1668
|
* ```
|
|
1328
1669
|
*
|
|
1329
|
-
* @capability palette.lead (built-in plugins only)
|
|
1330
1670
|
* @since 1.7.9
|
|
1331
1671
|
*/
|
|
1332
1672
|
onRun(listener: (run: PaletteLeadRun) => void): Disposable;
|
|
@@ -1351,8 +1691,7 @@ export interface PaletteLead extends Disposable {
|
|
|
1351
1691
|
* });
|
|
1352
1692
|
* ```
|
|
1353
1693
|
*
|
|
1354
|
-
* @capability
|
|
1355
|
-
* @throws `capability` (rejects) The manifest does not declare `palette.lead`.
|
|
1694
|
+
* @throws `capability` (rejects) The plugin is not built into the player.
|
|
1356
1695
|
* @since 1.7.9
|
|
1357
1696
|
*/
|
|
1358
1697
|
done(ticket: string): Promise<void>;
|
|
@@ -1393,8 +1732,6 @@ export type HostAction = "play-pause" | "stop" | "previous" | "next" | "frame-ba
|
|
|
1393
1732
|
* accumulation of repeated presses and the same on-screen text, instead of
|
|
1394
1733
|
* reimplementing them with {@link Player} calls.
|
|
1395
1734
|
*
|
|
1396
|
-
* @capability commands
|
|
1397
|
-
*
|
|
1398
1735
|
* @example Give a custom bar the player's own Stop and Mute
|
|
1399
1736
|
* The plugin's bar buttons stop playback and mute exactly as the player's
|
|
1400
1737
|
* own keys do, with the same on-screen text. Each callback runs a core
|
|
@@ -1442,11 +1779,9 @@ export interface Host {
|
|
|
1442
1779
|
* });
|
|
1443
1780
|
* ```
|
|
1444
1781
|
*
|
|
1445
|
-
* @capability commands
|
|
1446
1782
|
* @throws `unavailable` (rejects) The action is disabled right now (nothing
|
|
1447
1783
|
* open, no window for `fullscreen`).
|
|
1448
1784
|
* @throws `invalid` (rejects) An unknown action, or `seconds` out of range.
|
|
1449
|
-
* @throws `capability` (rejects) The manifest does not declare `commands`.
|
|
1450
1785
|
*
|
|
1451
1786
|
* @since 1.0.0
|
|
1452
1787
|
*/
|
|
@@ -1478,11 +1813,9 @@ export interface Host {
|
|
|
1478
1813
|
* bar.on("forward30", () => plugin.host.run("seek-forward", { seconds: 30 }));
|
|
1479
1814
|
* ```
|
|
1480
1815
|
*
|
|
1481
|
-
* @capability commands
|
|
1482
1816
|
* @throws `unavailable` (rejects) The action is disabled right now (nothing
|
|
1483
1817
|
* open, no window for `fullscreen`).
|
|
1484
1818
|
* @throws `invalid` (rejects) An unknown action, or `seconds` out of range.
|
|
1485
|
-
* @throws `capability` (rejects) The manifest does not declare `commands`.
|
|
1486
1819
|
*/
|
|
1487
1820
|
run(action: "seek-backward" | "seek-forward", options: {
|
|
1488
1821
|
seconds: number;
|
|
@@ -1550,7 +1883,7 @@ export interface BindingInfo extends BindingRef {
|
|
|
1550
1883
|
}
|
|
1551
1884
|
/**
|
|
1552
1885
|
* `plugin.bindings`: list and override every command's bindings, including
|
|
1553
|
-
* the player's.
|
|
1886
|
+
* the player's.
|
|
1554
1887
|
*
|
|
1555
1888
|
* @example Unbind the player's Mute key, then restore it
|
|
1556
1889
|
* The player's Mute command loses its default key, and later gets it
|
|
@@ -1570,7 +1903,6 @@ export interface BindingInfo extends BindingRef {
|
|
|
1570
1903
|
* plugin lists the table, writes overrides and resets them; the player
|
|
1571
1904
|
* applies the change at once to every running plugin.
|
|
1572
1905
|
*
|
|
1573
|
-
* @capability bindings.manage
|
|
1574
1906
|
* @see [Commands, menus and bindings](../../../docs/reference/commands.md)
|
|
1575
1907
|
* @since 1.0.0
|
|
1576
1908
|
* @category Commands
|
|
@@ -1579,15 +1911,6 @@ export interface Bindings {
|
|
|
1579
1911
|
/**
|
|
1580
1912
|
* Every declared command, and overrides whose command is gone.
|
|
1581
1913
|
*
|
|
1582
|
-
* A `focus: "panel"` command of a plugin whose manifest does not declare
|
|
1583
|
-
* `ui.mount` is left out (player 0.8.0): it has no panel, so no key can
|
|
1584
|
-
* reach it. It is still declared: its stored binding is not an orphan,
|
|
1585
|
-
* and `set` accepts it.
|
|
1586
|
-
*
|
|
1587
|
-
* @capability bindings.manage
|
|
1588
|
-
* @throws `capability` (rejects) The manifest does not declare
|
|
1589
|
-
* `bindings.manage`.
|
|
1590
|
-
*
|
|
1591
1914
|
* @example Find the commands that use a key
|
|
1592
1915
|
* A key-settings window shows which commands Ctrl+K is bound to now. `list`
|
|
1593
1916
|
* resolves with every declared command and its current bindings (the
|
|
@@ -1599,6 +1922,7 @@ export interface Bindings {
|
|
|
1599
1922
|
* console.log(users.map((command) => `${command.plugin}/${command.command}`)); // "host" for the player
|
|
1600
1923
|
* ```
|
|
1601
1924
|
*
|
|
1925
|
+
* @throws `disabled` (rejects) The plugin is stopping.
|
|
1602
1926
|
* @since 1.0.0
|
|
1603
1927
|
*/
|
|
1604
1928
|
list(): Promise<{
|
|
@@ -1618,12 +1942,9 @@ export interface Bindings {
|
|
|
1618
1942
|
* no override either.
|
|
1619
1943
|
* At most 16 inputs, syntax as {@link CommandOptions.bindings}.
|
|
1620
1944
|
*
|
|
1621
|
-
* @capability bindings.manage
|
|
1622
1945
|
* @throws `invalid` (rejects) A malformed binding, or more than 16.
|
|
1623
1946
|
* @throws `missing` (rejects) An unknown command that has no override
|
|
1624
1947
|
* either.
|
|
1625
|
-
* @throws `capability` (rejects) The manifest does not declare
|
|
1626
|
-
* `bindings.manage`.
|
|
1627
1948
|
*
|
|
1628
1949
|
* @example Give the player's Mute command a second key
|
|
1629
1950
|
* Mute now answers to M and to Ctrl+M. `set` replaces the command's
|
|
@@ -1639,11 +1960,8 @@ export interface Bindings {
|
|
|
1639
1960
|
/**
|
|
1640
1961
|
* Back to the defaults: one command, or every override when omitted.
|
|
1641
1962
|
*
|
|
1642
|
-
* @capability bindings.manage
|
|
1643
1963
|
* @throws `missing` (rejects) A command that has no override and is not
|
|
1644
1964
|
* declared.
|
|
1645
|
-
* @throws `capability` (rejects) The manifest does not declare
|
|
1646
|
-
* `bindings.manage`.
|
|
1647
1965
|
*
|
|
1648
1966
|
* @example Restore every default key
|
|
1649
1967
|
* A "Restore defaults" button removes all of the user's overrides, so
|
|
@@ -1661,8 +1979,6 @@ export interface Bindings {
|
|
|
1661
1979
|
* override. At most every 200 ms, and only when the list itself changed,
|
|
1662
1980
|
* not when a plugin starts again with the same commands.
|
|
1663
1981
|
*
|
|
1664
|
-
* @capability bindings.manage
|
|
1665
|
-
*
|
|
1666
1982
|
* @example Refresh a key list when bindings change
|
|
1667
1983
|
* The plugin's key list stays current when the user changes a key in the
|
|
1668
1984
|
* player or a plugin with other commands is installed. The listener
|