@vestra-player/sdk 1.11.0-rc.3 → 1.11.0-rc.5
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 -3
- package/README.md +3 -2
- package/dist/docs-tree.json.gz +0 -0
- package/dist/plugin/connection.d.ts +19 -6
- package/dist/plugin/connection.js +28 -12
- package/dist/plugin/filters.js +1 -1
- package/dist/plugin/player.d.ts +11 -3
- package/dist/plugin/player.js +21 -3
- package/dist/plugin/shaders.js +1 -1
- package/dist/plugin/testing/index.d.ts +12 -11
- package/dist/plugin/testing/index.js +12 -11
- package/dist/plugin/types/commands.d.ts +23 -18
- package/dist/plugin/types/playback.d.ts +6 -5
- package/dist/plugin/types/ui-content.d.ts +7 -2
- package/dist/plugin/types/ui-shell.d.ts +14 -6
- package/dist/plugin/view.js +1 -1
- package/llms.txt +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,15 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
## 1.11.0
|
|
4
4
|
|
|
5
|
-
**The second batch of events, no capability disclosure, and the built-in-only refusal renamed** (user rulings 2026-11-16 and 2026-11-21). Plugins have no capabilities, neither as declarations (gone since 1.9.0) nor as a disclosure: the name-based scan and its table are removed, and the plugin store no longer shows what a plugin's code uses. The player's real API boundaries stay (request validation and the built-in-only requests); their refusal now has the code `builtin-only`. Breaking, released as a minor without an alias, since every plugin is the project's own (ruling 2026-11-21). Who must change: a tool that runs `vestra-plugin scan` or reads `@vestra-player/sdk/capability-scan.json`, and a plugin that compares `error.code` for a built-in-only call (below).
|
|
5
|
+
**The second batch of events, no capability disclosure, and the built-in-only refusal renamed** (user rulings 2026-11-16 and 2026-11-21). Plugins have no capabilities, neither as declarations (gone since 1.9.0) nor as a disclosure: the name-based scan and its table are removed, and the plugin store no longer shows what a plugin's code uses. The player's real API boundaries stay (request validation and the built-in-only requests); their refusal now has the code `builtin-only`. Breaking, released as a minor without an alias, since every plugin is the project's own (ruling 2026-11-21). Who must change: a plugin that calls `player.subscribe()` or `player.onChange()`, a tool that runs `vestra-plugin scan` or reads `@vestra-player/sdk/capability-scan.json`, and a plugin that compares `error.code` for a built-in-only call (below).
|
|
6
6
|
|
|
7
7
|
**The second batch of events** (needs the player version that sends them, 0.11):
|
|
8
8
|
|
|
9
9
|
- **Fact events** (new, `FactEvent` and `FactEventPayloads`, a third overload of `player.on`): `video.reconfigured` (`{ sourceId, width, height, displayWidth, displayHeight, fps, rotation, hdr }`), `audio.reconfigured` (`{ sourceId, sampleRate, channels, format }`), `audio.tracks.changed` (`{ sourceId, audioTracks }`, as `AudioTrack`s), `subtitles.changed` (`{ state }`, a `SubtitlesState`, taken into `plugin.subtitles.state` first), `window.changed` (a `WindowState`, taken into `plugin.window.state` first; a resize once it has settled for 300 ms), `layout.changed` (`{ slots }`, each position with its panels, `LayoutPosition`), `audio.devices.changed` (`{ devices, requested, active }`) and `app.started` (`{ version, previous }`). Each is sent once per change; a listener of one does not keep the plugin running, and the player wakes a plugin in standby for it.
|
|
10
|
-
- **The copies take a fact first
|
|
10
|
+
- **The copies take a fact first**: `subtitles.changed` into `plugin.subtitles.state`, `window.changed` into `plugin.window.state`, `layout.changed` into the panel layout, `audio.tracks.changed` into `plugin.player.state.audioTracks` (when it is the copy's source) and `audio.devices.changed` into `plugin.player.state.audioOutput`, so the copy holds it when the listener runs and a binding that reads it runs again.
|
|
11
11
|
- Removed `Player.subscribe()` and `Player.onChange()`.
|
|
12
12
|
- **An event reaches a plugin from its first listener.** `source.state`, `playback.backend`, `window.state`, `timeline.changed`, `appearance.changed` and `resolvers.fileTypes` are subscribed while a listener, a watcher (`MainWindow.onChange`, a panel slot's `onChange`, `Subtitles.onChange`, a media handle's `ready` and `onEnd`, a scrub) or a stream holds them; the SDK's own copy and a binding's read never subscribe them on their own, so a bound value or a command state that reads `plugin.player.state` shows the newest snapshot the plugin has. `Media.ready` no longer polls the state every 100 ms.
|
|
13
|
-
- **
|
|
13
|
+
- **Following the source is not listening**: `plugin.video.view()`, a shader channel (`plugin.video.shaders(id)`) and a processing node (`plugin.video.filter`, `plugin.audio.filter`) send their values again when the source changes, so they follow `source.state`, but they do not count as a listener of it: the player is told the SDK's copy (`mirror`), and a plugin is never classified as "listening to source.state" because of such a handle. What the handle holds keeps the plugin running, with its own reason: the display layer from the moment it is made, a filter chain once it has nodes, a shader channel once it has shaders. `Media.ready`, `Media.onEnd` and a scrub count as listeners: they serve the plugin's own wait, callback or gesture. A binding or a command's function field that reads a state never makes the plugin a listener, not even while such a handle keeps the event subscribed; its reason joins what the player is told only while a real listener or stream listens. (The `theme-widgets` example's trace: its view's bind of `plugin.commands.keys` subscribes as the SDK's copy.)
|
|
14
|
+
- **No request after `runtime.stop`**: once the player sent `runtime.stop`, every request of the plugin is refused with `disabled` and not sent, the plugin's own cleanup included (the player's runner refused them already). In `TestHost` the cleanup requests at a plugin's stop (and at `park()` and `upgrade()`) are therefore no longer sent, and the test host revokes what the run held itself, as the player does at each kind of stop: at every stop its windows, panels, commands, settings pages, resolvers, sequence provider, streams, filter chains, display layer, render options and shaders; its timeline layer, always-on-top and cursor settings stay through `park()` (an idle stop) and go at every other stop (disable, a fault, uninstall, reload, `upgrade()`, quit, or `stop()` without a reason).
|
|
14
15
|
- **`TestHost`** sends the fact events by the player's rules: `audio.tracks.changed` after a source change, `window.changed` and `layout.changed` after a `window.state`, `subtitles.changed` and `audio.devices.changed` after a request or an event changed them, and `video.reconfigured` and `audio.reconfigured` from `host.stats` when a source becomes ready. `app.started` is sent with `host.emit`.
|
|
15
16
|
|
|
16
17
|
**No capability disclosure:**
|
|
@@ -22,6 +23,13 @@
|
|
|
22
23
|
- The message table reads hyphenated `@throws` codes too: `builtin-only`, `source-missing` and `source-changed` now show in its Errors column (`scripts/doc-tables/messages.mjs`).
|
|
23
24
|
- `doc-lint` drops its check that no `@capability` tag is left in `src/`; the issue template for API proposals no longer asks for one; the deprecated `ts-plugin` stub's log line and `check --json`'s refusal no longer mention capabilities.
|
|
24
25
|
|
|
26
|
+
**Docs and examples** (no code change):
|
|
27
|
+
|
|
28
|
+
- **New guide, [Learn what happens in the player without staying up](docs/guides/events-and-triggers.md)**: the four ways to learn the state (a read, an event, a trigger, a stream) and when each fits, with four examples (on top while playing fullscreen; a named sleep timer; acting at position ranges; a window that shows the time left), the patterns for state that has no event, and tests with `keepsRunning`, `park`, `advance` and `upgrade`.
|
|
29
|
+
- **[Command state](docs/guides/command-state.md) covers the whole `when` language**: a function field is evaluated in the plugin with the plugin's own copy of the state, a condition by the player, also in standby. How a plugin works, Control playback, Troubleshooting (an old playback state in a menu, a plugin that never parks, a trigger declared after an `await`), the tutorial, Filters, Sliders, Subtitles, Design rules, the README and the `@example`s of `Commands.add`, `Command.set`, `Bindable`, `Player.read`, `Player.previous`, `Player.audioDevices`, `View.bind`, `Panels.mount` and `OsdPanel` follow the same rules: commands follow the player with `when`, handlers read the state with `refresh()`, a stream is open only while something shows the state, and a filter is made when it is first needed (a filter follows the source from the moment it is made, which keeps the plugin running).
|
|
30
|
+
- **Examples**: `adjust-panel` follows the speed with a stream only while its tab is on screen (`layout.changed`) and enables Normal Speed with `when.can("rate")`; `bookmark` streams only while its window is open and keeps its mark in session storage; `menus` checks the speeds with `when.rate` and enables them with `when.can("rate")`; `three-ways` follows the speed only while the bar shows and learns a new source from `source.opening`/`ready`/`ended` in every style; `blur` makes its filter on first use; `panel-menu` keeps its list in session storage. Every example's test checks with `keepsRunning` that nothing keeps it running while idle. `minPlayerVersion`: `adjust-panel` 0.11.0, `menus` 0.10.0. The golden traces of `adjust-panel`, `blur`, `bookmark`, `menus` and `panel-menu` are recorded again (fewer subscriptions and passes; the session storage reads), and `docs-tree.test.ts` looks for style B's new listener line in the tutorial.
|
|
31
|
+
- `TestHost.listening`, `listeningWhy` and `keepsRunning` say what they list now: listeners and streams, not bindings.
|
|
32
|
+
|
|
25
33
|
## 1.10.1
|
|
26
34
|
|
|
27
35
|
**Temporary windows: a product-data sync and the members that go with them.** Who must change: nobody. Additions and docs only; every existing behaviour of the SDK and of `TestHost` is as in 1.10.0 (a `TestHost` behaves differently only when a test sets the new `app.temporary`). Needs player 0.10.3 for the additions; an older player sends no `temporary` and refuses `app.openWindow`.
|
package/README.md
CHANGED
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
## Features
|
|
20
20
|
|
|
21
21
|
- **One typed API** (`vestra/1`) for commands and menus, windows, panels, settings pages, on-screen messages, playback state and control, video and audio filters, and generated streams.
|
|
22
|
+
- **Plugins that cost nothing while idle**: a plugin learns what happens in the player from events and triggers the player keeps for it (a file opened, playing in fullscreen, a time, a position range), and its menu items follow playback through `plugin.when` conditions the player evaluates; the player stops it while nothing uses it and starts it again for the moment it is needed.
|
|
22
23
|
- **Native user interfaces** written in [Slint](https://slint.dev), with the player's own theme and widgets.
|
|
23
24
|
- **Tests without the player**: `@vestra-player/sdk/testing` runs your plugin against an in-memory host with `node --test`.
|
|
24
25
|
- **One command line tool**, `vestra-plugin`, to check, test, build and pack a `.vxp` package.
|
|
@@ -68,7 +69,7 @@ Complete, tested plugins in [`examples/`](https://github.com/vestrasys/vestra-pl
|
|
|
68
69
|
| [hello](https://github.com/vestrasys/vestra-player-sdk/tree/main/examples/hello) | The smallest plugin: a manifest, one menu command, an on-screen message. | [Step by step](https://vestrasys.github.io/vestra-player-sdk/documents/Hello.html) |
|
|
69
70
|
| [blur](https://github.com/vestrasys/vestra-player-sdk/tree/main/examples/blur) | A video filter driven by one slider in a tool window. | [Step by step](https://vestrasys.github.io/vestra-player-sdk/documents/Example__Blur.html) |
|
|
70
71
|
| [signal-generator](https://github.com/vestrasys/vestra-player-sdk/tree/main/examples/signal-generator) | Generating video and audio frames yourself: colour bars and a sine tone. | [Step by step](https://vestrasys.github.io/vestra-player-sdk/documents/Example__Signal_generator.html) |
|
|
71
|
-
| [bookmark](https://github.com/vestrasys/vestra-player-sdk/tree/main/examples/bookmark) | A tool window
|
|
72
|
+
| [bookmark](https://github.com/vestrasys/vestra-player-sdk/tree/main/examples/bookmark) | A tool window that follows playback while it is open: Mark and Jump. | [Step by step](https://vestrasys.github.io/vestra-player-sdk/documents/Example__Bookmark.html) |
|
|
72
73
|
| [panel-menu](https://github.com/vestrasys/vestra-player-sdk/tree/main/examples/panel-menu) | A sidebar panel with its own right-click menu. | [Step by step](https://vestrasys.github.io/vestra-player-sdk/documents/Example__Panel_menu.html) |
|
|
73
74
|
| [menus](https://github.com/vestrasys/vestra-player-sdk/tree/main/examples/menus) | Radio items, separator groups and a menu item whose title changes. | [Step by step](https://vestrasys.github.io/vestra-player-sdk/documents/Example__Menus.html) |
|
|
74
75
|
| [theme-widgets](https://github.com/vestrasys/vestra-player-sdk/tree/main/examples/theme-widgets) | A tool window drawn with the player's theme and widgets. | [Step by step](https://vestrasys.github.io/vestra-player-sdk/documents/Example__Theme_widgets.html) |
|
|
@@ -80,7 +81,7 @@ Complete, tested plugins in [`examples/`](https://github.com/vestrasys/vestra-pl
|
|
|
80
81
|
The [documentation site](https://vestrasys.github.io/vestra-player-sdk/) is the one place for everything a plugin author needs:
|
|
81
82
|
|
|
82
83
|
- **[Tutorial](https://vestrasys.github.io/vestra-player-sdk/documents/Tutorial.html)**: one page: what a plugin is (a process that talks to the player), the three ways to write one with an example each, where things live, and running, testing and publishing.
|
|
83
|
-
- **[Guides](https://vestrasys.github.io/vestra-player-sdk/documents/Guides.html)**: one task each (goal, steps, often a complete example): windows, settings and translations, playback, storage, window state, sliders, subtitles, video filters, the GPU switch, menu state that needs no running plugin (`plugin.when`), testing, publishing, your own store, documentation for coding agents; the design rules every plugin follows; and troubleshooting.
|
|
84
|
+
- **[Guides](https://vestrasys.github.io/vestra-player-sdk/documents/Guides.html)**: one task each (goal, steps, often a complete example): windows, settings and translations, playback, storage, window state, sliders, subtitles, video filters, the GPU switch, events and triggers that wake a stopped plugin, menu state that needs no running plugin (`plugin.when`), testing, publishing, your own store, documentation for coding agents; the design rules every plugin follows; and troubleshooting.
|
|
84
85
|
- **[Reference](https://vestrasys.github.io/vestra-player-sdk/documents/Reference.html)**: manifest fields, limits, menus and bindings, platforms, theme, error codes, events, messages, translations, the test host, and the [command line](https://vestrasys.github.io/vestra-player-sdk/documents/Command_line.html) (`vestra-plugin check`, `test`, `build`, `pack`, `i18n extract`, `i18n check`).
|
|
85
86
|
- **[Examples](https://vestrasys.github.io/vestra-player-sdk/documents/Examples.html)**: the walkthroughs above.
|
|
86
87
|
- **[API](https://vestrasys.github.io/vestra-player-sdk/modules/_vestra-player_sdk.html)**: every type and member of `@vestra-player/sdk` and `@vestra-player/sdk/testing`.
|
package/dist/docs-tree.json.gz
CHANGED
|
Binary file
|
|
@@ -171,6 +171,16 @@ export declare class Connection {
|
|
|
171
171
|
* not start).
|
|
172
172
|
*/
|
|
173
173
|
hold(event: string, why?: Why, always?: boolean): Disposable;
|
|
174
|
+
/**
|
|
175
|
+
* The SDK's own follower of `event`: a handle that sends
|
|
176
|
+
* its values again when the source changes (`plugin.video.view()`, a
|
|
177
|
+
* shader channel, a processing node). It subscribes a held-only group
|
|
178
|
+
* while it lives, as {@link Connection.hold} does, but counts as the SDK's
|
|
179
|
+
* copy, not as a listener: the player is told `mirror` unless a plugin
|
|
180
|
+
* listener holds the group too. What the handle holds keeps the plugin
|
|
181
|
+
* running with its own reason; following the source is not one.
|
|
182
|
+
*/
|
|
183
|
+
track(event: string, always?: boolean): Disposable;
|
|
174
184
|
/**
|
|
175
185
|
* {@link Connection.hold} for `plugin.player.stream` (SDK 1.10.0): the
|
|
176
186
|
* stream reads the state itself when it opens, so the copy is not read
|
|
@@ -178,12 +188,15 @@ export declare class Connection {
|
|
|
178
188
|
*/
|
|
179
189
|
follow(event: string, why?: Why): Disposable;
|
|
180
190
|
/**
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
191
|
+
* A binding (or a command's function field) reads `event`'s state: its
|
|
192
|
+
* reason joins what the player is told while a plugin listener, hold or
|
|
193
|
+
* stream listens to the group, but the read never makes the plugin a
|
|
194
|
+
* listener on its own, whether or not the group is subscribed (by a
|
|
195
|
+
* handle that follows the source, {@link Connection.track}). It never
|
|
196
|
+
* subscribes a held-only group either: a bound value that reads
|
|
197
|
+
* `plugin.player.state` shows the newest snapshot the plugin has; a stream
|
|
198
|
+
* or an event makes it follow the player. Nothing when nothing started
|
|
199
|
+
* the group.
|
|
187
200
|
*/
|
|
188
201
|
bindingReads(event: string, why: Why): Disposable;
|
|
189
202
|
/**
|
|
@@ -425,6 +425,18 @@ export class Connection {
|
|
|
425
425
|
hold(event, why, always = false) {
|
|
426
426
|
return this.#hold(event, why, always ? "always" : "read");
|
|
427
427
|
}
|
|
428
|
+
/**
|
|
429
|
+
* The SDK's own follower of `event`: a handle that sends
|
|
430
|
+
* its values again when the source changes (`plugin.video.view()`, a
|
|
431
|
+
* shader channel, a processing node). It subscribes a held-only group
|
|
432
|
+
* while it lives, as {@link Connection.hold} does, but counts as the SDK's
|
|
433
|
+
* copy, not as a listener: the player is told `mirror` unless a plugin
|
|
434
|
+
* listener holds the group too. What the handle holds keeps the plugin
|
|
435
|
+
* running with its own reason; following the source is not one.
|
|
436
|
+
*/
|
|
437
|
+
track(event, always = false) {
|
|
438
|
+
return this.#hold(event, undefined, always ? "always" : "read", false);
|
|
439
|
+
}
|
|
428
440
|
/**
|
|
429
441
|
* {@link Connection.hold} for `plugin.player.stream` (SDK 1.10.0): the
|
|
430
442
|
* stream reads the state itself when it opens, so the copy is not read
|
|
@@ -433,14 +445,16 @@ export class Connection {
|
|
|
433
445
|
follow(event, why) {
|
|
434
446
|
return this.#hold(event, why, "never");
|
|
435
447
|
}
|
|
436
|
-
#hold(event, why, catchUp) {
|
|
448
|
+
#hold(event, why, catchUp, listens = true) {
|
|
437
449
|
const group = this.#events.get(event);
|
|
438
450
|
if (!group)
|
|
439
451
|
return { dispose: async () => { } };
|
|
440
|
-
|
|
452
|
+
if (listens)
|
|
453
|
+
group.active++;
|
|
441
454
|
group.holders++;
|
|
442
455
|
const token = {};
|
|
443
|
-
|
|
456
|
+
if (listens)
|
|
457
|
+
group.whys.set(token, why ?? listenerWhy(this.callSite()));
|
|
444
458
|
this.#heldBy(event, group, catchUp);
|
|
445
459
|
let held = true;
|
|
446
460
|
return {
|
|
@@ -448,7 +462,8 @@ export class Connection {
|
|
|
448
462
|
if (!held)
|
|
449
463
|
return;
|
|
450
464
|
held = false;
|
|
451
|
-
|
|
465
|
+
if (listens)
|
|
466
|
+
group.active--;
|
|
452
467
|
group.holders--;
|
|
453
468
|
group.whys.delete(token);
|
|
454
469
|
if (this.#events.get(event) === group)
|
|
@@ -457,18 +472,20 @@ export class Connection {
|
|
|
457
472
|
};
|
|
458
473
|
}
|
|
459
474
|
/**
|
|
460
|
-
*
|
|
461
|
-
*
|
|
462
|
-
*
|
|
463
|
-
*
|
|
464
|
-
*
|
|
465
|
-
*
|
|
475
|
+
* A binding (or a command's function field) reads `event`'s state: its
|
|
476
|
+
* reason joins what the player is told while a plugin listener, hold or
|
|
477
|
+
* stream listens to the group, but the read never makes the plugin a
|
|
478
|
+
* listener on its own, whether or not the group is subscribed (by a
|
|
479
|
+
* handle that follows the source, {@link Connection.track}). It never
|
|
480
|
+
* subscribes a held-only group either: a bound value that reads
|
|
481
|
+
* `plugin.player.state` shows the newest snapshot the plugin has; a stream
|
|
482
|
+
* or an event makes it follow the player. Nothing when nothing started
|
|
483
|
+
* the group.
|
|
466
484
|
*/
|
|
467
485
|
bindingReads(event, why) {
|
|
468
486
|
const group = this.#events.get(event);
|
|
469
487
|
if (!group)
|
|
470
488
|
return { dispose: async () => { } };
|
|
471
|
-
group.active++;
|
|
472
489
|
const token = {};
|
|
473
490
|
group.whys.set(token, why);
|
|
474
491
|
this.#tell(event, group);
|
|
@@ -478,7 +495,6 @@ export class Connection {
|
|
|
478
495
|
if (!reading)
|
|
479
496
|
return;
|
|
480
497
|
reading = false;
|
|
481
|
-
group.active--;
|
|
482
498
|
group.whys.delete(token);
|
|
483
499
|
if (this.#events.get(event) === group)
|
|
484
500
|
this.#tell(event, group);
|
package/dist/plugin/filters.js
CHANGED
|
@@ -27,7 +27,7 @@ class FilterHandle {
|
|
|
27
27
|
this.#stage = stage;
|
|
28
28
|
this.#id = id;
|
|
29
29
|
// Only phase/source changes matter, not the 10 Hz position updates.
|
|
30
|
-
this.#watch = player.
|
|
30
|
+
this.#watch = player.track((raw) => {
|
|
31
31
|
const source = `${raw.stamp.generation}:${raw.phase}:${raw.kind}`;
|
|
32
32
|
if (source === this.#source)
|
|
33
33
|
return;
|
package/dist/plugin/player.d.ts
CHANGED
|
@@ -72,13 +72,21 @@ export declare class PlayerService implements StreamSource {
|
|
|
72
72
|
* more when the subscription starts, also without `read()`.
|
|
73
73
|
*/
|
|
74
74
|
/**
|
|
75
|
-
* A fact event's fields of the state
|
|
75
|
+
* A fact event's fields of the state: taken into the copy
|
|
76
76
|
* when `belongs` holds for it, as `accept` takes a state (a precise
|
|
77
77
|
* pass for the fields that changed); its event sequence is kept, so the
|
|
78
78
|
* next `source.state` is accepted as before.
|
|
79
79
|
*/
|
|
80
80
|
patch(belongs: (raw: SourceState) => boolean, fields: Partial<SourceState>): void;
|
|
81
81
|
watch(watcher: (raw: SourceState) => void, always?: boolean): Disposable;
|
|
82
|
+
/**
|
|
83
|
+
* `watch` for the SDK's own handles that send their values again when the
|
|
84
|
+
* source changes (the video view, a shader channel, a processing node):
|
|
85
|
+
* the copy hears `source.state` while the handle lives, but the plugin is
|
|
86
|
+
* not counted as listening to it (`Connection.track`). The handle's own
|
|
87
|
+
* resource is what keeps the plugin running.
|
|
88
|
+
*/
|
|
89
|
+
track(watcher: (raw: SourceState) => void): Disposable;
|
|
82
90
|
/**
|
|
83
91
|
* `watch`, for `plugin.player.stream`: the copy hears `source.state` while
|
|
84
92
|
* the watcher is open, and the plugin counts as listening to it
|
|
@@ -112,14 +120,14 @@ export declare class PlayerService implements StreamSource {
|
|
|
112
120
|
/**
|
|
113
121
|
* `audio.tracks.changed`'s data as the listener gets it (`ScopeImpl.fact`,
|
|
114
122
|
* SDK 1.11.0): the tracks as {@link PlayerState.audioTracks} lists them.
|
|
115
|
-
* The copy takes them first
|
|
123
|
+
* The copy takes them first, when they are of its source.
|
|
116
124
|
*/
|
|
117
125
|
export declare function audioTracksChanged(runtime: Runtime, data: unknown): {
|
|
118
126
|
sourceId: number;
|
|
119
127
|
audioTracks: AudioTrack[];
|
|
120
128
|
};
|
|
121
129
|
/**
|
|
122
|
-
* `audio.devices.changed`'s data as the listener gets it
|
|
130
|
+
* `audio.devices.changed`'s data as the listener gets it:
|
|
123
131
|
* as the player sent it; the copy takes `requested` and `active` into
|
|
124
132
|
* {@link PlayerState.audioOutput} first.
|
|
125
133
|
*/
|
package/dist/plugin/player.js
CHANGED
|
@@ -271,7 +271,7 @@ export class PlayerService {
|
|
|
271
271
|
* more when the subscription starts, also without `read()`.
|
|
272
272
|
*/
|
|
273
273
|
/**
|
|
274
|
-
* A fact event's fields of the state
|
|
274
|
+
* A fact event's fields of the state: taken into the copy
|
|
275
275
|
* when `belongs` holds for it, as `accept` takes a state (a precise
|
|
276
276
|
* pass for the fields that changed); its event sequence is kept, so the
|
|
277
277
|
* next `source.state` is accepted as before.
|
|
@@ -302,6 +302,24 @@ export class PlayerService {
|
|
|
302
302
|
},
|
|
303
303
|
};
|
|
304
304
|
}
|
|
305
|
+
/**
|
|
306
|
+
* `watch` for the SDK's own handles that send their values again when the
|
|
307
|
+
* source changes (the video view, a shader channel, a processing node):
|
|
308
|
+
* the copy hears `source.state` while the handle lives, but the plugin is
|
|
309
|
+
* not counted as listening to it (`Connection.track`). The handle's own
|
|
310
|
+
* resource is what keeps the plugin running.
|
|
311
|
+
*/
|
|
312
|
+
track(watcher) {
|
|
313
|
+
void this.start();
|
|
314
|
+
this.#watchers.add(watcher);
|
|
315
|
+
const tracked = this.runtime.track("source.state");
|
|
316
|
+
return {
|
|
317
|
+
dispose: async () => {
|
|
318
|
+
this.#watchers.delete(watcher);
|
|
319
|
+
await tracked.dispose();
|
|
320
|
+
},
|
|
321
|
+
};
|
|
322
|
+
}
|
|
305
323
|
/**
|
|
306
324
|
* `watch`, for `plugin.player.stream`: the copy hears `source.state` while
|
|
307
325
|
* the watcher is open, and the plugin counts as listening to it
|
|
@@ -618,7 +636,7 @@ function provideSequence(scope, provider) {
|
|
|
618
636
|
/**
|
|
619
637
|
* `audio.tracks.changed`'s data as the listener gets it (`ScopeImpl.fact`,
|
|
620
638
|
* SDK 1.11.0): the tracks as {@link PlayerState.audioTracks} lists them.
|
|
621
|
-
* The copy takes them first
|
|
639
|
+
* The copy takes them first, when they are of its source.
|
|
622
640
|
*/
|
|
623
641
|
export function audioTracksChanged(runtime, data) {
|
|
624
642
|
const { sourceId, audioTracks } = data;
|
|
@@ -628,7 +646,7 @@ export function audioTracksChanged(runtime, data) {
|
|
|
628
646
|
return { sourceId, audioTracks: audioTracks.map(audioTrack) };
|
|
629
647
|
}
|
|
630
648
|
/**
|
|
631
|
-
* `audio.devices.changed`'s data as the listener gets it
|
|
649
|
+
* `audio.devices.changed`'s data as the listener gets it:
|
|
632
650
|
* as the player sent it; the copy takes `requested` and `active` into
|
|
633
651
|
* {@link PlayerState.audioOutput} first.
|
|
634
652
|
*/
|
package/dist/plugin/shaders.js
CHANGED
|
@@ -56,7 +56,7 @@ class ShaderHandle {
|
|
|
56
56
|
this.#report({ state });
|
|
57
57
|
});
|
|
58
58
|
// `waiting` becomes `applied` when media becomes ready: ask again.
|
|
59
|
-
this.#watch = playerOf(scope.runtime).
|
|
59
|
+
this.#watch = playerOf(scope.runtime).track((raw) => {
|
|
60
60
|
const source = `${raw.stamp.generation}:${raw.phase}`;
|
|
61
61
|
if (source === this.#source)
|
|
62
62
|
return;
|
|
@@ -587,9 +587,10 @@ export declare class TestHost implements Transport {
|
|
|
587
587
|
/** The host events the plugin subscribed to. */
|
|
588
588
|
readonly subscriptions: Set<string>;
|
|
589
589
|
/**
|
|
590
|
-
* The subscribed events the plugin really listens to:
|
|
591
|
-
* the like
|
|
592
|
-
* the state
|
|
590
|
+
* The subscribed events the plugin really listens to: a listener
|
|
591
|
+
* (`player.on`, an `onChange` and the like) or a stream. The SDK's own
|
|
592
|
+
* copies of the state are left out, and a binding that reads a state
|
|
593
|
+
* subscribes nothing.
|
|
593
594
|
* Empty means the player may stop the plugin while nothing uses it
|
|
594
595
|
* (unless it holds something else: a window, a panel, a filter…).
|
|
595
596
|
*
|
|
@@ -598,10 +599,9 @@ export declare class TestHost implements Transport {
|
|
|
598
599
|
readonly listening: Set<string>;
|
|
599
600
|
/**
|
|
600
601
|
* Why the plugin listens to each event of {@link TestHost.listening}:
|
|
601
|
-
* every listener and
|
|
602
|
-
*
|
|
603
|
-
*
|
|
604
|
-
* (main.ts:40) — use plugin.when`), in the order they came.
|
|
602
|
+
* every listener and stream, as the player's log says them (`a listener
|
|
603
|
+
* added at main.ts:12`, `a stream opened at main.ts:20`), in the order
|
|
604
|
+
* they came.
|
|
605
605
|
*
|
|
606
606
|
* @since 1.5.40
|
|
607
607
|
*/
|
|
@@ -3214,15 +3214,16 @@ export declare class TestHost implements Transport {
|
|
|
3214
3214
|
* keeps the plugin running only while the tab is shown, and a sidebar panel
|
|
3215
3215
|
* in a background tab is no reason at all (the plugin may go to standby;
|
|
3216
3216
|
* showing the tab starts it again). Empty: the player may stop it while idle
|
|
3217
|
-
* and start it again on its next use.
|
|
3218
|
-
*
|
|
3217
|
+
* and start it again on its next use. A state stream (`player.stream`)
|
|
3218
|
+
* shows as a listener of `source.state`; filter chains, producer streams,
|
|
3219
|
+
* jobs and the like (which also keep a plugin running) are not listed.
|
|
3219
3220
|
*
|
|
3220
3221
|
* @since 1.5.40
|
|
3221
3222
|
*
|
|
3222
3223
|
* @example Check that a plugin can be stopped while idle
|
|
3223
3224
|
* The test fails if the plugin keeps running for no reason after it
|
|
3224
|
-
* starts, and names the reason (a
|
|
3225
|
-
*
|
|
3225
|
+
* starts, and names the reason (a stream opened in `activate`, say:
|
|
3226
|
+
* open it only while something shows the state). The
|
|
3226
3227
|
* player stops such a plugin while nothing uses it and starts it again
|
|
3227
3228
|
* on its next use, so it costs no process meanwhile.
|
|
3228
3229
|
* ```ts
|
|
@@ -265,9 +265,10 @@ export class TestHost {
|
|
|
265
265
|
/** The host events the plugin subscribed to. */
|
|
266
266
|
subscriptions = new Set();
|
|
267
267
|
/**
|
|
268
|
-
* The subscribed events the plugin really listens to:
|
|
269
|
-
* the like
|
|
270
|
-
* the state
|
|
268
|
+
* The subscribed events the plugin really listens to: a listener
|
|
269
|
+
* (`player.on`, an `onChange` and the like) or a stream. The SDK's own
|
|
270
|
+
* copies of the state are left out, and a binding that reads a state
|
|
271
|
+
* subscribes nothing.
|
|
271
272
|
* Empty means the player may stop the plugin while nothing uses it
|
|
272
273
|
* (unless it holds something else: a window, a panel, a filter…).
|
|
273
274
|
*
|
|
@@ -276,10 +277,9 @@ export class TestHost {
|
|
|
276
277
|
listening = new Set();
|
|
277
278
|
/**
|
|
278
279
|
* Why the plugin listens to each event of {@link TestHost.listening}:
|
|
279
|
-
* every listener and
|
|
280
|
-
*
|
|
281
|
-
*
|
|
282
|
-
* (main.ts:40) — use plugin.when`), in the order they came.
|
|
280
|
+
* every listener and stream, as the player's log says them (`a listener
|
|
281
|
+
* added at main.ts:12`, `a stream opened at main.ts:20`), in the order
|
|
282
|
+
* they came.
|
|
283
283
|
*
|
|
284
284
|
* @since 1.5.40
|
|
285
285
|
*/
|
|
@@ -2790,15 +2790,16 @@ export class TestHost {
|
|
|
2790
2790
|
* keeps the plugin running only while the tab is shown, and a sidebar panel
|
|
2791
2791
|
* in a background tab is no reason at all (the plugin may go to standby;
|
|
2792
2792
|
* showing the tab starts it again). Empty: the player may stop it while idle
|
|
2793
|
-
* and start it again on its next use.
|
|
2794
|
-
*
|
|
2793
|
+
* and start it again on its next use. A state stream (`player.stream`)
|
|
2794
|
+
* shows as a listener of `source.state`; filter chains, producer streams,
|
|
2795
|
+
* jobs and the like (which also keep a plugin running) are not listed.
|
|
2795
2796
|
*
|
|
2796
2797
|
* @since 1.5.40
|
|
2797
2798
|
*
|
|
2798
2799
|
* @example Check that a plugin can be stopped while idle
|
|
2799
2800
|
* The test fails if the plugin keeps running for no reason after it
|
|
2800
|
-
* starts, and names the reason (a
|
|
2801
|
-
*
|
|
2801
|
+
* starts, and names the reason (a stream opened in `activate`, say:
|
|
2802
|
+
* open it only while something shows the state). The
|
|
2802
2803
|
* player stops such a plugin while nothing uses it and starts it again
|
|
2803
2804
|
* on its next use, so it costs no process meanwhile.
|
|
2804
2805
|
* ```ts
|
|
@@ -37,17 +37,19 @@ export interface CommandState {
|
|
|
37
37
|
* registered once and evaluated again only when {@link Command.set} changes it.
|
|
38
38
|
*
|
|
39
39
|
* @example Mix a computed state with a fixed one
|
|
40
|
-
* The
|
|
41
|
-
* enabled. A function is evaluated again in every full
|
|
42
|
-
*
|
|
43
|
-
*
|
|
40
|
+
* The Shuffle item carries a check mark while the plugin's own `shuffle`
|
|
41
|
+
* is on and is always enabled. A function is evaluated again in every full
|
|
42
|
+
* update pass (after each handler); only changes are sent, and a plain
|
|
43
|
+
* value never changes. A state of the player is a `plugin.when`
|
|
44
|
+
* condition instead, which the player evaluates itself.
|
|
44
45
|
* ```ts
|
|
46
|
+
* let shuffle = false;
|
|
45
47
|
* plugin.commands.add({
|
|
46
|
-
* id: "
|
|
47
|
-
* path: ["Playback", "
|
|
48
|
-
* checked: () =>
|
|
48
|
+
* id: "shuffle",
|
|
49
|
+
* path: ["Playback", "Shuffle"],
|
|
50
|
+
* checked: () => shuffle, // re-evaluated after the handler
|
|
49
51
|
* enabled: true, // a fixed value
|
|
50
|
-
* run: () =>
|
|
52
|
+
* run: () => void (shuffle = !shuffle),
|
|
51
53
|
* });
|
|
52
54
|
* ```
|
|
53
55
|
*
|
|
@@ -985,9 +987,9 @@ export interface CommandOptions {
|
|
|
985
987
|
*
|
|
986
988
|
* @example Enable an item only while a file is open
|
|
987
989
|
* Video ▸ Export… is greyed out until a file is open. `set` replaces the
|
|
988
|
-
* `enabled` field with a
|
|
989
|
-
*
|
|
990
|
-
*
|
|
990
|
+
* `enabled` field with a condition, which the player evaluates itself at
|
|
991
|
+
* every change, so the item follows the player without further code, also
|
|
992
|
+
* while the plugin is stopped.
|
|
991
993
|
* ```ts
|
|
992
994
|
* declare function runExport(): Promise<void>;
|
|
993
995
|
* // ---cut---
|
|
@@ -996,8 +998,7 @@ export interface CommandOptions {
|
|
|
996
998
|
* path: ["@video", "Export…"],
|
|
997
999
|
* run: runExport,
|
|
998
1000
|
* });
|
|
999
|
-
*
|
|
1000
|
-
* exportCommand.set({ enabled: () => plugin.player.state.phase === "ready" });
|
|
1001
|
+
* exportCommand.set({ enabled: plugin.when.ready }); // evaluated by the player
|
|
1001
1002
|
* ```
|
|
1002
1003
|
*
|
|
1003
1004
|
* @see {@link Commands.add}, [Commands, menus and bindings](../../../docs/reference/commands.md)
|
|
@@ -1131,17 +1132,21 @@ export interface Commands {
|
|
|
1131
1132
|
* Playback ▸ Pause (and Ctrl+P) pauses and resumes, shows a check mark
|
|
1132
1133
|
* while paused and is greyed out when nothing can be paused. The player
|
|
1133
1134
|
* calls `run` when the user picks the item or presses its key; `enabled`
|
|
1134
|
-
* and `checked` are
|
|
1135
|
-
*
|
|
1135
|
+
* and `checked` are `plugin.when` conditions the player evaluates
|
|
1136
|
+
* itself at every change, also while the plugin is stopped.
|
|
1136
1137
|
* ```ts
|
|
1138
|
+
* const { when } = plugin;
|
|
1137
1139
|
* const toggle = plugin.commands.add({
|
|
1138
1140
|
* id: "toggle-pause",
|
|
1139
1141
|
* path: ["Playback", "Pause"],
|
|
1140
1142
|
* order: 210, // position among the Playback menu's items
|
|
1141
1143
|
* bindings: ["Ctrl+P"],
|
|
1142
|
-
* enabled:
|
|
1143
|
-
* checked:
|
|
1144
|
-
* run: () =>
|
|
1144
|
+
* enabled: when.can("pause"),
|
|
1145
|
+
* checked: when.paused,
|
|
1146
|
+
* run: async () => {
|
|
1147
|
+
* const now = await plugin.player.refresh(); // the state now
|
|
1148
|
+
* await plugin.player.setPaused(!now.paused);
|
|
1149
|
+
* },
|
|
1145
1150
|
* });
|
|
1146
1151
|
* ```
|
|
1147
1152
|
*
|
|
@@ -1214,7 +1214,7 @@ export interface Player {
|
|
|
1214
1214
|
* plugin.commands.add({
|
|
1215
1215
|
* id: "left",
|
|
1216
1216
|
* path: ["Tools", "Time Left"],
|
|
1217
|
-
* enabled:
|
|
1217
|
+
* enabled: plugin.when.ready, // evaluated by the player
|
|
1218
1218
|
* run: async () => {
|
|
1219
1219
|
* // No events: ask the player for the position now.
|
|
1220
1220
|
* const { duration, position } = await plugin.player.refresh();
|
|
@@ -1580,8 +1580,8 @@ export interface Player {
|
|
|
1580
1580
|
* plugin.commands.add({
|
|
1581
1581
|
* id: "previous",
|
|
1582
1582
|
* title: "Previous item",
|
|
1583
|
-
* // The provider's `canPrevious`, as the player
|
|
1584
|
-
* enabled:
|
|
1583
|
+
* // The provider's `canPrevious`, as the player evaluates it.
|
|
1584
|
+
* enabled: plugin.when.can("previous"),
|
|
1585
1585
|
* run: () => plugin.player.previous(),
|
|
1586
1586
|
* });
|
|
1587
1587
|
* ```
|
|
@@ -1783,7 +1783,8 @@ export interface Player {
|
|
|
1783
1783
|
* @example Offer the audio output devices in a menu
|
|
1784
1784
|
* A submenu lists the output devices present now, with a radio mark on the
|
|
1785
1785
|
* one in use. `audioDevices` asks the player when called (devices come and
|
|
1786
|
-
* go), and `
|
|
1786
|
+
* go; `audio.devices.changed` says when), and `when.audioDevice` checks
|
|
1787
|
+
* the one in use, evaluated by the player.
|
|
1787
1788
|
* ```ts
|
|
1788
1789
|
* // The devices present now; build the menu again when they change.
|
|
1789
1790
|
* for (const device of await plugin.player.audioDevices())
|
|
@@ -1791,7 +1792,7 @@ export interface Player {
|
|
|
1791
1792
|
* id: `device.${device.id}`,
|
|
1792
1793
|
* path: ["@audio", "Output", device.name],
|
|
1793
1794
|
* radio: true,
|
|
1794
|
-
* checked:
|
|
1795
|
+
* checked: plugin.when.audioDevice(device.id),
|
|
1795
1796
|
* run: () => plugin.player.setAudioDevice(device.id),
|
|
1796
1797
|
* });
|
|
1797
1798
|
* ```
|
|
@@ -674,14 +674,19 @@ export interface View {
|
|
|
674
674
|
* The status window always shows the current file and enables its seek
|
|
675
675
|
* controls only for seekable sources. The SDK calls the function right
|
|
676
676
|
* away, again in every full update pass (after each handler) and after
|
|
677
|
-
* each change of `source` or `can
|
|
678
|
-
*
|
|
677
|
+
* each change of `source` or `can` while a stream keeps
|
|
678
|
+
* `plugin.player.state` following the player, and sends only the values
|
|
679
|
+
* that changed. The stream is opened with the window and stopped when it
|
|
680
|
+
* closes.
|
|
679
681
|
* ```ts
|
|
680
682
|
* const status = plugin.windows.create("ui/status.slint");
|
|
681
683
|
* status.bind(() => ({
|
|
682
684
|
* title: plugin.player.state.source ?? "Nothing playing",
|
|
683
685
|
* canSeek: plugin.player.state.can.seek,
|
|
684
686
|
* }));
|
|
687
|
+
* await status.show();
|
|
688
|
+
* const feed = plugin.player.stream(() => {}); // while it is open
|
|
689
|
+
* status.onClose(() => feed.stop());
|
|
685
690
|
* ```
|
|
686
691
|
*
|
|
687
692
|
* @see [Keep a slider responsive while dragging](../../../docs/guides/slider.md)
|
|
@@ -432,10 +432,13 @@ export interface Panels {
|
|
|
432
432
|
* `conflict` when another plugin's panel holds the bottom bar.
|
|
433
433
|
* ```ts
|
|
434
434
|
* const bar = plugin.panels.mount("bottom", "ui/bar.slint");
|
|
435
|
-
* // Sent again whenever the position changes.
|
|
435
|
+
* // Sent again whenever the position changes, while a stream is open.
|
|
436
436
|
* bar.bind(() => ({ position: plugin.player.state.position ?? 0 }));
|
|
437
437
|
* bar.on("seek", (seconds: number) => plugin.player.seek(seconds));
|
|
438
438
|
* await bar.ready;
|
|
439
|
+
* // The bar shows the position (and keeps the plugin running anyway):
|
|
440
|
+
* // a stream makes `plugin.player.state` follow the player.
|
|
441
|
+
* plugin.player.stream(() => {});
|
|
439
442
|
* ```
|
|
440
443
|
*
|
|
441
444
|
* @since 1.0.0
|
|
@@ -790,15 +793,20 @@ export interface Dialogs {
|
|
|
790
793
|
*
|
|
791
794
|
* @example Show live playback numbers over the video
|
|
792
795
|
* A block over the video shows the position and the duration, updated
|
|
793
|
-
* as playback moves
|
|
794
|
-
* state; `set` never throws and
|
|
795
|
-
* in flight, so calling it on
|
|
796
|
+
* as playback moves, while the user has it switched on. A stream's
|
|
797
|
+
* listener runs after the SDK updated the state; `set` never throws and
|
|
798
|
+
* sends only the newest text while one is in flight, so calling it on
|
|
799
|
+
* every change is fine. The stream lives only while the block shows, so
|
|
800
|
+
* the plugin can be stopped while it is off.
|
|
796
801
|
* ```ts
|
|
797
|
-
* const
|
|
798
|
-
*
|
|
802
|
+
* const shown = plugin.scope(); // the block and its stream, together
|
|
803
|
+
* const info = shown.osd.panel();
|
|
804
|
+
* shown.player.stream((state) =>
|
|
799
805
|
* // A template with data arguments; the player translates "{} / {} s".
|
|
800
806
|
* info.set("{} / {} s", [state.position?.toFixed(1) ?? "–", state.duration?.toFixed(1) ?? "–"]),
|
|
801
807
|
* );
|
|
808
|
+
* // Switched off: removes the block and stops the stream.
|
|
809
|
+
* await shown.dispose();
|
|
802
810
|
* ```
|
|
803
811
|
*
|
|
804
812
|
* @since 1.0.0
|
package/dist/plugin/view.js
CHANGED
|
@@ -130,7 +130,7 @@ class OwnedSettings {
|
|
|
130
130
|
// `status`, and the next `set` tries again.
|
|
131
131
|
this.#send();
|
|
132
132
|
// Only a new source or phase matters: "waiting" becomes "applied".
|
|
133
|
-
this.#watch = playerOf(scope.runtime).
|
|
133
|
+
this.#watch = playerOf(scope.runtime).track((raw) => {
|
|
134
134
|
const source = `${raw.stamp.generation}:${raw.phase}`;
|
|
135
135
|
if (source === this.#source)
|
|
136
136
|
return;
|
package/llms.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Vestra Player SDK
|
|
2
2
|
|
|
3
|
-
> @vestra-player/sdk 1.11.0-rc.
|
|
3
|
+
> @vestra-player/sdk 1.11.0-rc.5: write plugins for Vestra Player in TypeScript (plugin API `vestra/1`). A plugin is a folder with `manifest.json` and an entry module whose default export `activate(plugin)` the player calls. The documentation is a tree of short pages read by path, like `go doc`: the same pages and API as https://vestrasys.github.io/vestra-player-sdk/.
|
|
4
4
|
|
|
5
5
|
## Read the documentation
|
|
6
6
|
|