@vestra-player/sdk 1.11.0-rc.3 → 1.11.0-rc.4

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 CHANGED
@@ -10,6 +10,7 @@
10
10
  - **The copies take a fact first** (1.11.0-rc.2 adds the last two): `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
+ - **Following the source is not listening** (1.11.0-rc.4): `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 no longer count as a listener of it. The player is told the SDK's copy (`mirror`), so a plugin is never classified as "listening to source.state" because of such a handle, nor early through the race between that subscription and its ready; the handle's own resource keeps it running, with its own reason. `Media.ready`, `Media.onEnd` and a scrub still count: they serve the plugin's own wait, callback or gesture.
13
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 (1.11.0-rc.3 matches 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
 
@@ -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 bound to the playback state, with Mark and Jump buttons. | [Step by step](https://vestrasys.github.io/vestra-player-sdk/documents/Example__Bookmark.html) |
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`.
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` (SDK 1.11.0-rc.4): 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
@@ -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` (SDK 1.11.0-rc.4): 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
- group.active++;
452
+ if (listens)
453
+ group.active++;
441
454
  group.holders++;
442
455
  const token = {};
443
- group.whys.set(token, why ?? listenerWhy(this.callSite()));
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
- group.active--;
465
+ if (listens)
466
+ group.active--;
452
467
  group.holders--;
453
468
  group.whys.delete(token);
454
469
  if (this.#events.get(event) === group)
@@ -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.watch((raw) => {
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;
@@ -79,6 +79,14 @@ export declare class PlayerService implements StreamSource {
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
@@ -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
@@ -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).watch((raw) => {
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: an `onChange` and
591
- * the like, or a binding that reads the state. The SDK's own copies of
592
- * the state (what keeps `plugin.player.state` current) are left out.
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 every binding that reads its state, as the
602
- * player's log says them (`a listener added at main.ts:12`,
603
- * `command "Save" enabled is a function that reads plugin.player.state
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. Filter chains, streams, jobs and the
3218
- * like (which also keep a plugin running) are not listed.
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 command whose `enabled` reads
3225
- * `plugin.player.state`, say: give it a `plugin.when` condition). The
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: an `onChange` and
269
- * the like, or a binding that reads the state. The SDK's own copies of
270
- * the state (what keeps `plugin.player.state` current) are left out.
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 every binding that reads its state, as the
280
- * player's log says them (`a listener added at main.ts:12`,
281
- * `command "Save" enabled is a function that reads plugin.player.state
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. Filter chains, streams, jobs and the
2794
- * like (which also keep a plugin running) are not listed.
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 command whose `enabled` reads
2801
- * `plugin.player.state`, say: give it a `plugin.when` condition). The
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 Loop item carries a check mark while a loop is set and is always
41
- * enabled. A function is evaluated again in every full update pass (after
42
- * each handler), and after a player state change only if it read a changed
43
- * field; only changes are sent, and a plain value never changes.
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: "loop",
47
- * path: ["Playback", "Loop"],
48
- * checked: () => plugin.player.state.loop != null, // re-evaluated
48
+ * id: "shuffle",
49
+ * path: ["Playback", "Shuffle"],
50
+ * checked: () => shuffle, // re-evaluated after the handler
49
51
  * enabled: true, // a fixed value
50
- * run: () => plugin.player.setLoop(null),
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 function; the SDK evaluates it again after every
989
- * player state change and sends the new state when it changes, so the
990
- * item follows the player without further code.
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
- * // A function: re-evaluated in every full pass and when `phase` changes.
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 functions the SDK evaluates again after every
1135
- * handler and player state change, sending only what changed.
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: () => plugin.player.state.can.pause,
1143
- * checked: () => plugin.player.state.paused,
1144
- * run: () => plugin.player.setPaused(!plugin.player.state.paused),
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: () => plugin.player.state.phase === "ready",
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 reports it.
1584
- * enabled: () => plugin.player.state.can.previous,
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 `state.audioOutput` tells which one is active.
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: () => plugin.player.state.audioOutput?.active === device.id,
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`, and sends only the values that
678
- * changed.
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. A stream's listener runs after the SDK updated the
794
- * state; `set` never throws and sends only the newest text while one is
795
- * in flight, so calling it on every change is fine.
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 info = plugin.osd.panel();
798
- * plugin.player.stream((state) =>
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
@@ -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).watch((raw) => {
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: 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/.
3
+ > @vestra-player/sdk 1.11.0-rc.4: 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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vestra-player/sdk",
3
- "version": "1.11.0-rc.3",
3
+ "version": "1.11.0-rc.4",
4
4
  "description": "Plugin API types, test host and plugin CLI for Vestra Player (apiVersion vestra/1)",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {