@vestra-player/sdk 1.8.0 → 1.9.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.
Files changed (86) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/README.md +2 -2
  3. package/bin/vestra-plugin.mjs +11 -100
  4. package/capability-scan.json +3 -1
  5. package/dist/api-requests.d.ts +11 -36
  6. package/dist/api-requests.js +18 -47
  7. package/dist/capability-scan.d.ts +1 -1
  8. package/dist/capability-scan.js +8 -9
  9. package/dist/docs-tree.json.gz +0 -0
  10. package/dist/docs.d.ts +1 -1
  11. package/dist/docs.js +1 -1
  12. package/dist/index.d.ts +4 -5
  13. package/dist/manifest.d.ts +5 -0
  14. package/dist/manifest.js +9 -24
  15. package/dist/member-uses.d.ts +61 -0
  16. package/dist/member-uses.js +160 -0
  17. package/dist/player-runtime.d.ts +1 -2
  18. package/dist/player-runtime.js +1 -2
  19. package/dist/plugin/appearance.d.ts +1 -1
  20. package/dist/plugin/appearance.js +2 -2
  21. package/dist/plugin/bindings.d.ts +1 -1
  22. package/dist/plugin/bindings.js +2 -2
  23. package/dist/plugin/commands.js +1 -12
  24. package/dist/plugin/connection.d.ts +26 -7
  25. package/dist/plugin/connection.js +68 -36
  26. package/dist/plugin/drops.js +1 -1
  27. package/dist/plugin/index.js +9 -15
  28. package/dist/plugin/media.js +0 -12
  29. package/dist/plugin/mpv.js +0 -7
  30. package/dist/plugin/packages.js +1 -2
  31. package/dist/plugin/player/events.d.ts +4 -3
  32. package/dist/plugin/player/events.js +7 -6
  33. package/dist/plugin/player.d.ts +21 -13
  34. package/dist/plugin/player.js +56 -21
  35. package/dist/plugin/services.d.ts +4 -4
  36. package/dist/plugin/services.js +7 -29
  37. package/dist/plugin/settings.js +1 -1
  38. package/dist/plugin/shaders.js +0 -2
  39. package/dist/plugin/stream.d.ts +2 -1
  40. package/dist/plugin/stream.js +2 -2
  41. package/dist/plugin/testing/commands.d.ts +3 -10
  42. package/dist/plugin/testing/commands.js +6 -15
  43. package/dist/plugin/testing/index.d.ts +26 -116
  44. package/dist/plugin/testing/index.js +30 -104
  45. package/dist/plugin/testing/processing.js +1 -1
  46. package/dist/plugin/testing/services.js +0 -1
  47. package/dist/plugin/timeline.d.ts +2 -3
  48. package/dist/plugin/timeline.js +4 -8
  49. package/dist/plugin/types/base.d.ts +40 -86
  50. package/dist/plugin/types/commands.d.ts +10 -67
  51. package/dist/plugin/types/packages.d.ts +17 -55
  52. package/dist/plugin/types/playback.d.ts +126 -144
  53. package/dist/plugin/types/plugin-wire.d.ts +6 -36
  54. package/dist/plugin/types/processing.d.ts +10 -49
  55. package/dist/plugin/types/services.d.ts +11 -70
  56. package/dist/plugin/types/snapshots.d.ts +7 -60
  57. package/dist/plugin/types/sources.d.ts +2 -11
  58. package/dist/plugin/types/subtitles.d.ts +5 -26
  59. package/dist/plugin/types/ui-content.d.ts +1 -16
  60. package/dist/plugin/types/ui-layout.d.ts +53 -79
  61. package/dist/plugin/types/ui-locale.d.ts +5 -23
  62. package/dist/plugin/types/ui-shell.d.ts +13 -59
  63. package/dist/plugin/view/layout.js +1 -1
  64. package/dist/plugin/view.js +0 -2
  65. package/dist/plugin/window.d.ts +1 -1
  66. package/dist/plugin/window.js +1 -1
  67. package/dist/plugin/wire-facade.js +1 -2
  68. package/dist/processing.d.ts +2 -3
  69. package/dist/protocol.d.ts +14 -0
  70. package/dist/protocol.js +14 -0
  71. package/dist/request-queue.js +1 -1
  72. package/dist/subtitles.d.ts +1 -1
  73. package/dist/ts-plugin.d.ts +8 -15
  74. package/dist/ts-plugin.js +3 -141
  75. package/dist/wire.d.ts +7 -12
  76. package/dist/wire.js +6 -8
  77. package/llms.txt +4 -4
  78. package/package.json +1 -2
  79. package/dist/capabilities.d.ts +0 -107
  80. package/dist/capabilities.js +0 -69
  81. package/dist/capability-check.d.ts +0 -176
  82. package/dist/capability-check.js +0 -461
  83. package/dist/capability-rules.d.ts +0 -125
  84. package/dist/capability-rules.js +0 -192
  85. package/dist/host-capabilities.d.ts +0 -10
  86. package/dist/host-capabilities.js +0 -492
@@ -324,7 +324,6 @@ export function mediaCapture(scope) {
324
324
  const service = serviceOf(runtime);
325
325
  if (typeof options !== "object" || options === null)
326
326
  throw failure("invalid", "export options must be an object");
327
- needSources(scope);
328
327
  const parts = checkParts(options.parts);
329
328
  let mode;
330
329
  if (options.format === "copy") {
@@ -377,7 +376,6 @@ export function mediaCapture(scope) {
377
376
  // As the player: parts carry their own ends; `end` is a snapshot's.
378
377
  if (options?.end !== undefined)
379
378
  throw failure("invalid", "end belongs to a snapshot's check; parts carry their own end");
380
- needSources(scope);
381
379
  return scope.runtime.host.jobs.check(checkParts(input), encoding);
382
380
  },
383
381
  };
@@ -431,14 +429,8 @@ function checkParts(parts) {
431
429
  throw failure("invalid", `the parts are ${total} s long; an export takes at most ${MEDIA_SOURCE_LIMITS.totalSeconds} s`);
432
430
  return checked;
433
431
  }
434
- /** The parts' tokens are media.sources': refuse at once without it, as the player does. */
435
- function needSources(scope) {
436
- if (!scope.runtime.can("media.sources"))
437
- throw failure("capability", "media.sources must be declared in manifest");
438
- }
439
432
  function mediaSources(scope) {
440
433
  const host = () => {
441
- needSources(scope);
442
434
  return scope.runtime.host.mediaSources;
443
435
  };
444
436
  const token = (value) => {
@@ -459,10 +451,6 @@ function mediaSources(scope) {
459
451
  forget: async (value) => host().forget(token(value)),
460
452
  list: async () => host().list(),
461
453
  async open(value, options = {}) {
462
- needSources(scope);
463
- // An open like Player.open's: the player asks playback.control too.
464
- if (!scope.runtime.can("playback.control"))
465
- throw failure("capability", "playback.control must be declared in manifest");
466
454
  const start = options?.start;
467
455
  if (start !== undefined && !(Number.isFinite(start) && start >= 0))
468
456
  throw failure("invalid", "start must be seconds from 0");
@@ -41,13 +41,7 @@ class Observers {
41
41
  }
42
42
  }
43
43
  export const mpv = (scope) => {
44
- /** Refuse at once without `mpv`, as the player does. */
45
- const declared = () => {
46
- if (!scope.runtime.can("mpv"))
47
- throw failure("capability", "mpv must be declared in manifest");
48
- };
49
44
  const named = (name, write) => {
50
- declared();
51
45
  const problem = mpvNameProblem(name);
52
46
  if (problem)
53
47
  throw failure("invalid", problem);
@@ -59,7 +53,6 @@ export const mpv = (scope) => {
59
53
  const observers = () => scope.runtime.service("mpv.observers", () => new Observers(scope.runtime));
60
54
  return {
61
55
  async command(args) {
62
- declared();
63
56
  const problem = mpvCommandProblem(args);
64
57
  if (problem)
65
58
  throw failure("invalid", problem);
@@ -1,4 +1,4 @@
1
- /** Package validation, install and uninstall (`plugins.manage`). */
1
+ /** Package validation, install and uninstall. */
2
2
  import { randomUUID } from "node:crypto";
3
3
  import { resolve } from "node:path";
4
4
  import { failure, sleep, uncertain } from "./errors.js";
@@ -159,7 +159,6 @@ const info = (plugin) => Object.freeze({
159
159
  origin: plugin.origin,
160
160
  state: plugin.state,
161
161
  error: plugin.error,
162
- capabilities: [...plugin.capabilities],
163
162
  directory: plugin.directory,
164
163
  builtin: plugin.builtin === true,
165
164
  source: plugin.source ? Object.freeze({ ...plugin.source }) : null,
@@ -1,10 +1,11 @@
1
1
  import type { ScopeImpl } from "../scope.ts";
2
2
  import type { Disposable, EventPayload, HostEvent } from "../types.ts";
3
3
  /**
4
- * The capability each event needs, as the player checks `events.subscribe`
5
- * (`HOST_CAPABILITIES`: by event, otherwise `events`); `null`: none.
4
+ * Which events need event delivery (`"events"`: they reach the plugin only
5
+ * after `plugin.player.subscribe()`, as they needed the `events`
6
+ * declaration before 1.9.0); `null`: they arrive from the first listener.
6
7
  */
7
- export declare const EVENT_NEEDS: Readonly<Record<HostEvent, string | null>>;
8
+ export declare const EVENT_NEEDS: Readonly<Record<HostEvent, "events" | null>>;
8
9
  /** `Player.on`'s arguments: a {@link HostEvent} name and a function. */
9
10
  export declare function checkOn(event: unknown, listener: unknown): asserts event is HostEvent;
10
11
  /** `Player.on`: `listener` hears each `event`, with a copy of its data. */
@@ -7,21 +7,22 @@
7
7
  */
8
8
  import { failure } from "../errors.js";
9
9
  /**
10
- * The capability each event needs, as the player checks `events.subscribe`
11
- * (`HOST_CAPABILITIES`: by event, otherwise `events`); `null`: none.
10
+ * Which events need event delivery (`"events"`: they reach the plugin only
11
+ * after `plugin.player.subscribe()`, as they needed the `events`
12
+ * declaration before 1.9.0); `null`: they arrive from the first listener.
12
13
  */
13
14
  export const EVENT_NEEDS = {
14
15
  "source.state": "events",
15
16
  "playback.backend": "events",
16
17
  "window.state": "events",
17
18
  "packages.changed": null,
18
- "bindings.changed": "bindings.manage",
19
- "commands.keys": "commands",
19
+ "bindings.changed": null,
20
+ "commands.keys": null,
20
21
  "timeline.changed": "events",
21
22
  "appearance.changed": "events",
22
23
  "resolvers.fileTypes": "events",
23
- "video.upscaling.changed": "video.upscaling",
24
- "video.motion.changed": "video.motion",
24
+ "video.upscaling.changed": null,
25
+ "video.motion.changed": null,
25
26
  };
26
27
  /** `Player.on`'s arguments: a {@link HostEvent} name and a function. */
27
28
  export function checkOn(event, listener) {
@@ -17,14 +17,13 @@ export declare const sameStamp: (a: SourceStamp, b: SourceStamp) => boolean;
17
17
  * One per plugin: the state store and the operation book client.
18
18
  *
19
19
  * The state copy (a mirror of `source.state`) follows the player's events
20
- * from the plugin's start when the manifest declares `events`
21
- * (`createPlugin` subscribes before the start-up read, as before 1.7.0, so
22
- * a read in any later handler is current). Without `events` no event can
23
- * arrive; `start` is then called by the first use of the state (a read of
20
+ * from `plugin.player.subscribe()` on (`subscribe`, first in `activate`
21
+ * as the plugin writes it). Before that no event can arrive; `start` is
22
+ * then called by the first use of the state (a read of
24
23
  * `plugin.player.state`, `onChange`, `isCurrent`, a media handle, a
25
24
  * scrub, a stream, a filter, a shader or view request, a capture) and
26
- * subscribes nothing. A start on demand with `events` and `playback.read`
27
- * would read the state again; `createPlugin` makes it unreachable today.
25
+ * subscribes nothing until `subscribe()`, which subscribes it and, after
26
+ * `read()`, reads the state once more (`#catchUp`).
28
27
  */
29
28
  export declare class PlayerService implements StreamSource {
30
29
  #private;
@@ -41,19 +40,28 @@ export declare class PlayerService implements StreamSource {
41
40
  muted?: boolean;
42
41
  }>;
43
42
  constructor(runtime: Runtime);
44
- init(): Promise<void>;
43
+ /**
44
+ * `plugin.player.read()`: read the source state and the timeline now, and
45
+ * from now on read the state again after the plugin's own actions
46
+ * (`Connection.reads`). Idempotent: one read, however often it is called;
47
+ * a read that failed is tried again by the next call.
48
+ */
49
+ read(): Promise<void>;
50
+ /**
51
+ * `plugin.player.subscribe()`: turn event delivery on and follow
52
+ * `source.state` now. Idempotent.
53
+ */
54
+ subscribe(): void;
45
55
  /** Whether the mirror follows the player's events yet. */
46
56
  get started(): boolean;
47
57
  /**
48
58
  * Follow `source.state` from now on: the SDK's copy of the state (a
49
59
  * mirror; a plugin listens through `watch` and the bindings that read
50
- * `state`). Then read the state once more (with `playback.read` and
51
- * `events`): a change between the start-up read and the subscription
52
- * sent no event to this plugin. Resolves when that read is in.
53
- * `reread: false`: subscribed before the start-up read
54
- * (`createPlugin`), which then is that read.
60
+ * `state`). Then read the state once more (after `read()` and
61
+ * `subscribe()`): a change between that read and the subscription sent
62
+ * no event to this plugin. Resolves when that read is in.
55
63
  */
56
- start(reread?: boolean): Promise<void>;
64
+ start(): Promise<void>;
57
65
  /** The state as the player has it now, for a call that needs a source. */
58
66
  current(): Promise<PlayerState>;
59
67
  /** Drop anything older than what was already delivered. */
@@ -156,14 +156,13 @@ function sourceFailure(error) {
156
156
  * One per plugin: the state store and the operation book client.
157
157
  *
158
158
  * The state copy (a mirror of `source.state`) follows the player's events
159
- * from the plugin's start when the manifest declares `events`
160
- * (`createPlugin` subscribes before the start-up read, as before 1.7.0, so
161
- * a read in any later handler is current). Without `events` no event can
162
- * arrive; `start` is then called by the first use of the state (a read of
159
+ * from `plugin.player.subscribe()` on (`subscribe`, first in `activate`
160
+ * as the plugin writes it). Before that no event can arrive; `start` is
161
+ * then called by the first use of the state (a read of
163
162
  * `plugin.player.state`, `onChange`, `isCurrent`, a media handle, a
164
163
  * scrub, a stream, a filter, a shader or view request, a capture) and
165
- * subscribes nothing. A start on demand with `events` and `playback.read`
166
- * would read the state again; `createPlugin` makes it unreachable today.
164
+ * subscribes nothing until `subscribe()`, which subscribes it and, after
165
+ * `read()`, reads the state once more (`#catchUp`).
167
166
  */
168
167
  export class PlayerService {
169
168
  runtime;
@@ -180,6 +179,8 @@ export class PlayerService {
180
179
  #started = false;
181
180
  /** The read that followed the subscription (resolved: none was needed). */
182
181
  #fresh = Promise.resolve();
182
+ /** `read()`'s one read, once asked for. */
183
+ #read;
183
184
  output;
184
185
  constructor(runtime) {
185
186
  this.runtime = runtime;
@@ -195,9 +196,41 @@ export class PlayerService {
195
196
  await this.refresh().catch(() => { });
196
197
  });
197
198
  }
198
- async init() {
199
- if (this.runtime.can("playback.read"))
200
- await this.refresh();
199
+ /**
200
+ * `plugin.player.read()`: read the source state and the timeline now, and
201
+ * from now on read the state again after the plugin's own actions
202
+ * (`Connection.reads`). Idempotent: one read, however often it is called;
203
+ * a read that failed is tried again by the next call.
204
+ */
205
+ read() {
206
+ return (this.#read ??= (async () => {
207
+ this.runtime.reads = true;
208
+ try {
209
+ await Promise.all([
210
+ this.refresh(),
211
+ this.runtime.reread("timeline.changed"),
212
+ ]);
213
+ }
214
+ catch (error) {
215
+ this.#read = undefined;
216
+ throw error;
217
+ }
218
+ })());
219
+ }
220
+ /**
221
+ * `plugin.player.subscribe()`: turn event delivery on and follow
222
+ * `source.state` now. Idempotent.
223
+ */
224
+ subscribe() {
225
+ if (this.runtime.delivering)
226
+ return;
227
+ this.runtime.deliver();
228
+ // A copy started on demand heard nothing so far; it is subscribed now,
229
+ // and a change before that sent no event.
230
+ if (this.#started)
231
+ this.#catchUp();
232
+ else
233
+ void this.start();
201
234
  }
202
235
  /** Whether the mirror follows the player's events yet. */
203
236
  get started() {
@@ -206,23 +239,23 @@ export class PlayerService {
206
239
  /**
207
240
  * Follow `source.state` from now on: the SDK's copy of the state (a
208
241
  * mirror; a plugin listens through `watch` and the bindings that read
209
- * `state`). Then read the state once more (with `playback.read` and
210
- * `events`): a change between the start-up read and the subscription
211
- * sent no event to this plugin. Resolves when that read is in.
212
- * `reread: false`: subscribed before the start-up read
213
- * (`createPlugin`), which then is that read.
242
+ * `state`). Then read the state once more (after `read()` and
243
+ * `subscribe()`): a change between that read and the subscription sent
244
+ * no event to this plugin. Resolves when that read is in.
214
245
  */
215
- start(reread = true) {
246
+ start() {
216
247
  if (this.#started)
217
248
  return this.#fresh;
218
249
  this.#started = true;
219
250
  this.runtime.on("source.state", (data) => this.accept(data), "events", true);
220
- if (reread &&
221
- this.runtime.can("playback.read") &&
222
- this.runtime.can("events"))
223
- this.#fresh = this.refresh().then(() => { }, () => { });
251
+ this.#catchUp();
224
252
  return this.#fresh;
225
253
  }
254
+ /** Read the state once more after a subscription, when it is read at all. */
255
+ #catchUp() {
256
+ if (this.runtime.reads && this.runtime.delivering)
257
+ this.#fresh = this.refresh().then(() => { }, () => { });
258
+ }
226
259
  /** The state as the player has it now, for a call that needs a source. */
227
260
  async current() {
228
261
  await this.start();
@@ -322,7 +355,7 @@ export class PlayerService {
322
355
  }
323
356
  /** Close only if `generation` is still the player's source. */
324
357
  async closeIfCurrent(generation) {
325
- const raw = this.runtime.can("playback.read")
358
+ const raw = this.runtime.reads
326
359
  ? (await this.refresh(), this.raw)
327
360
  : this.raw;
328
361
  if (raw.stamp.generation !== generation || raw.phase === "empty")
@@ -385,7 +418,7 @@ class MediaHandle {
385
418
  return abort();
386
419
  options.signal?.addEventListener("abort", abort, { once: true });
387
420
  // Without event delivery the state only moves when read.
388
- if (!service.runtime.can("events"))
421
+ if (!service.runtime.delivering)
389
422
  poll = setInterval(() => void service.refresh().catch(() => { }), 100);
390
423
  check();
391
424
  });
@@ -586,6 +619,8 @@ export function player(scope) {
586
619
  });
587
620
  },
588
621
  refresh: () => service().refresh(),
622
+ subscribe: () => service().subscribe(),
623
+ read: () => service().read(),
589
624
  on(event, listener) {
590
625
  // Checked first; the copy then starts before the listener subscribes
591
626
  // (it hears each event first in any case).
@@ -73,8 +73,8 @@ export declare function system(scope: ScopeImpl): System;
73
73
  * `invalid`. The store itself can still refuse (`unsupported` without a
74
74
  * system store, `unavailable` when it cannot be reached, `failed` when the
75
75
  * user denies access): only
76
- * those codes get the "could not be saved" message, anything else (a
77
- * missing `secrets` capability) is a bug and is thrown on.
76
+ * those codes get the "could not be saved" message, anything else (an
77
+ * invalid name) is a bug and is thrown on.
78
78
  * ```ts
79
79
  * import type { Plugin, PluginError } from "@vestra-player/sdk";
80
80
  * declare const plugin: Plugin;
@@ -114,12 +114,12 @@ export declare const SECRET_LIMITS: Readonly<{
114
114
  export declare const secrets: (scope: ScopeImpl) => Secrets;
115
115
  export declare const rendering: (scope: ScopeImpl) => Rendering;
116
116
  /**
117
- * `plugin.video.upscaling`: both requests need `video.upscaling`; the player
117
+ * `plugin.video.upscaling`: the player
118
118
  * answers once its GPU check ran (the first call starts it).
119
119
  */
120
120
  export declare const videoUpscaling: (scope: ScopeImpl) => VideoUpscaling;
121
121
  /**
122
- * `plugin.video.motion(engine)`: both requests need `video.motion` and
122
+ * `plugin.video.motion(engine)`: both requests
123
123
  * name the engine; the event names it too and leaves out each plugin's own
124
124
  * `mode`, which the SDK keeps from the answers per engine (only this
125
125
  * plugin's `set` changes it).
@@ -47,7 +47,7 @@ export const host = (scope) => ({
47
47
  await scope.runtime.host.host.run(action, seconds);
48
48
  // Like the player's own controls: `player.state` shows the result (the
49
49
  // player's state copy registered how to read it again).
50
- if (scope.runtime.can("playback.read"))
50
+ if (scope.runtime.reads)
51
51
  await scope.runtime.reread("source.state");
52
52
  },
53
53
  });
@@ -417,8 +417,8 @@ export function system(scope) {
417
417
  * `invalid`. The store itself can still refuse (`unsupported` without a
418
418
  * system store, `unavailable` when it cannot be reached, `failed` when the
419
419
  * user denies access): only
420
- * those codes get the "could not be saved" message, anything else (a
421
- * missing `secrets` capability) is a bug and is thrown on.
420
+ * those codes get the "could not be saved" message, anything else (an
421
+ * invalid name) is a bug and is thrown on.
422
422
  * ```ts
423
423
  * import type { Plugin, PluginError } from "@vestra-player/sdk";
424
424
  * declare const plugin: Plugin;
@@ -458,8 +458,6 @@ export const SECRET_LIMITS = Object.freeze({
458
458
  const SECRET = new RegExp(`^[a-z0-9._-]{1,${SECRET_LIMITS.nameChars}}$`);
459
459
  export const secrets = (scope) => {
460
460
  const named = (name) => {
461
- if (!scope.runtime.can("secrets"))
462
- throw failure("capability", "secrets must be declared in manifest");
463
461
  if (typeof name !== "string" || !SECRET.test(name))
464
462
  throw failure("invalid", `secret names are 1–${SECRET_LIMITS.nameChars} of a-z, 0-9, ., _ and -`);
465
463
  return name;
@@ -479,33 +477,23 @@ export const secrets = (scope) => {
479
477
  };
480
478
  const PREFERENCES = new Set(["auto", "gpu", "software"]);
481
479
  export const rendering = (scope) => {
482
- const manage = () => {
483
- if (!scope.runtime.can("rendering.manage"))
484
- throw failure("capability", "rendering.manage must be declared in manifest");
485
- };
486
480
  return {
487
481
  state: async () => (await scope.runtime.host.rendering.state()),
488
482
  async setPreference(preference) {
489
- manage();
490
483
  if (typeof preference !== "string" || !PREFERENCES.has(preference))
491
484
  throw failure("invalid", 'the rendering preference is "auto", "gpu" or "software"');
492
485
  return (await scope.runtime.host.rendering.setPreference(preference));
493
486
  },
494
487
  async restartPlayer() {
495
- manage();
496
488
  await scope.runtime.host.rendering.restart();
497
489
  },
498
490
  };
499
491
  };
500
492
  /**
501
- * `plugin.video.upscaling`: both requests need `video.upscaling`; the player
493
+ * `plugin.video.upscaling`: the player
502
494
  * answers once its GPU check ran (the first call starts it).
503
495
  */
504
496
  export const videoUpscaling = (scope) => {
505
- const declared = () => {
506
- if (!scope.runtime.can("video.upscaling"))
507
- throw failure("capability", "video.upscaling must be declared in manifest");
508
- };
509
497
  // This plugin's own request, kept from every answer for `onChange`: the
510
498
  // event leaves it out (it is each plugin's own), and only this plugin's
511
499
  // `set` changes it.
@@ -515,21 +503,18 @@ export const videoUpscaling = (scope) => {
515
503
  };
516
504
  return {
517
505
  async state() {
518
- declared();
519
506
  return noted(await scope.runtime.host.video.upscalingState());
520
507
  },
521
508
  async set(enabled) {
522
- declared();
523
509
  if (typeof enabled !== "boolean")
524
510
  throw failure("invalid", "enabled must be true or false");
525
511
  return noted(await scope.runtime.host.video.upscalingSet(enabled));
526
512
  },
527
513
  onChange(listener) {
528
- declared();
529
514
  const watch = scope.runtime.on("video.upscaling.changed", (data) => scope.run(listener, {
530
515
  ...data,
531
516
  enabled: enabledOf.get(scope.runtime) ?? false,
532
- }), "video.upscaling");
517
+ }), null);
533
518
  return scope.add({
534
519
  dispose: async () => {
535
520
  scope.forget(watch);
@@ -546,7 +531,7 @@ const MOTION_MODES = ["off", "double", "display"];
546
531
  /** The engines `plugin.video.motion(engine)` accepts. */
547
532
  const MOTION_ENGINES = ["amd", "nvidia"];
548
533
  /**
549
- * `plugin.video.motion(engine)`: both requests need `video.motion` and
534
+ * `plugin.video.motion(engine)`: both requests
550
535
  * name the engine; the event names it too and leaves out each plugin's own
551
536
  * `mode`, which the SDK keeps from the answers per engine (only this
552
537
  * plugin's `set` changes it).
@@ -554,10 +539,6 @@ const MOTION_ENGINES = ["amd", "nvidia"];
554
539
  export const videoMotion = (scope, engine) => {
555
540
  if (typeof engine !== "string" || !MOTION_ENGINES.includes(engine))
556
541
  throw failure("invalid", 'engine must be "amd" or "nvidia"');
557
- const declared = () => {
558
- if (!scope.runtime.can("video.motion"))
559
- throw failure("capability", "video.motion must be declared in manifest");
560
- };
561
542
  const modes = () => {
562
543
  let map = modeOf.get(scope.runtime);
563
544
  if (!map)
@@ -570,17 +551,14 @@ export const videoMotion = (scope, engine) => {
570
551
  };
571
552
  return {
572
553
  async state() {
573
- declared();
574
554
  return noted(await scope.runtime.host.video.motionState(engine));
575
555
  },
576
556
  async set(mode) {
577
- declared();
578
557
  if (typeof mode !== "string" || !MOTION_MODES.includes(mode))
579
558
  throw failure("invalid", 'mode must be "off", "double" or "display"');
580
559
  return noted(await scope.runtime.host.video.motionSet(engine, mode));
581
560
  },
582
561
  onChange(listener) {
583
- declared();
584
562
  const watch = scope.runtime.on("video.motion.changed", (data) => {
585
563
  const state = data;
586
564
  // Another engine's change is not this handle's.
@@ -590,7 +568,7 @@ export const videoMotion = (scope, engine) => {
590
568
  ...state,
591
569
  mode: modes().get(engine) ?? "off",
592
570
  });
593
- }, "video.motion");
571
+ }, null);
594
572
  return scope.add({
595
573
  dispose: async () => {
596
574
  scope.forget(watch);
@@ -1,4 +1,4 @@
1
- /** Pages of the player's options window (`plugin.settings`, `ui.settings`). */
1
+ /** Pages of the player's options window (`plugin.settings`). */
2
2
  import { failure, quiet } from "./errors.js";
3
3
  import { exported, ViewBase } from "./view/base.js";
4
4
  const CATEGORIES = [
@@ -137,8 +137,6 @@ class ShaderHandle {
137
137
  }
138
138
  export function videoShaders(scope, id) {
139
139
  const runtime = scope.runtime;
140
- if (!runtime.can("processing.video"))
141
- throw failure("capability", "processing.video must be declared in manifest");
142
140
  const name = id ?? DEFAULT_SHADERS_ID;
143
141
  const problem = shaderIdProblem(name);
144
142
  if (problem)
@@ -12,7 +12,8 @@ import type { ResolvedStream, Stream, StreamOptions } from "./types.ts";
12
12
  export interface StreamSource {
13
13
  readonly runtime: {
14
14
  readonly host: Wire;
15
- can(capability: string): boolean;
15
+ /** `plugin.player.read()` was called: the state is read after own actions. */
16
+ readonly reads: boolean;
16
17
  };
17
18
  /** The newest source state seen. */
18
19
  readonly raw: SourceState;
@@ -190,7 +190,7 @@ async function retirement(service, generation, error) {
190
190
  const code = error?.code;
191
191
  if (code !== "unavailable" && code !== "stale")
192
192
  return undefined;
193
- const readable = service.runtime.can("playback.read");
193
+ const readable = service.runtime.reads;
194
194
  if (readable)
195
195
  await service.refresh().catch(() => { });
196
196
  const raw = service.raw;
@@ -198,7 +198,7 @@ async function retirement(service, generation, error) {
198
198
  return null;
199
199
  if (raw.phase === "error")
200
200
  return failure("stream", service.state.error ?? "无法打开此媒体");
201
- // Without `playback.read` the state may be behind: no failure was seen.
201
+ // Without `plugin.player.read()` the state may be behind: no failure was seen.
202
202
  return readable ? undefined : null;
203
203
  }
204
204
  /** Start-up timeouts say which step ran out of time. */
@@ -24,16 +24,9 @@ export declare function splitCommandKey(_host: TestHost, _inner: Internals, key:
24
24
  command: string;
25
25
  };
26
26
  /**
27
- * The capabilities of the plugin under test's manifest, set by
28
- * `startPlugin`; a host without an entry (requests sent by hand) lists
29
- * every command in `bindings.list`.
30
- */
31
- export declare const pluginCapabilities: WeakMap<TestHost, readonly string[]>;
32
- /**
33
- * `bindings.list`, as the player's (binding_manager.rs `list`, player
34
- * 0.8.0): a `focus: "panel"` command of a plugin whose manifest declares no
35
- * `ui.mount` can never fire from a key, so it is left out; it stays declared
36
- * (its stored binding is no orphan, `bindings.set` accepts it).
27
+ * `bindings.list`, as the player's (binding_manager.rs `list`): every
28
+ * declared command, a `focus: "panel"` one included (since 1.9.0 no
29
+ * manifest says whether the plugin mounts a panel).
37
30
  */
38
31
  export declare function bindingTable(host: TestHost, inner: Internals): {
39
32
  commands: {
@@ -89,23 +89,14 @@ export function splitCommandKey(_host, _inner, key) {
89
89
  return { plugin: key.slice(0, at), command: key.slice(at + 1) };
90
90
  }
91
91
  /**
92
- * The capabilities of the plugin under test's manifest, set by
93
- * `startPlugin`; a host without an entry (requests sent by hand) lists
94
- * every command in `bindings.list`.
95
- */
96
- export const pluginCapabilities = new WeakMap();
97
- /**
98
- * `bindings.list`, as the player's (binding_manager.rs `list`, player
99
- * 0.8.0): a `focus: "panel"` command of a plugin whose manifest declares no
100
- * `ui.mount` can never fire from a key, so it is left out; it stays declared
101
- * (its stored binding is no orphan, `bindings.set` accepts it).
92
+ * `bindings.list`, as the player's (binding_manager.rs `list`): every
93
+ * declared command, a `focus: "panel"` one included (since 1.9.0 no
94
+ * manifest says whether the plugin mounts a panel).
102
95
  */
103
96
  export function bindingTable(host, inner) {
104
97
  const all = bindingRows(host, inner);
105
- const capabilities = pluginCapabilities.get(host);
106
- const hidden = capabilities !== undefined && !capabilities.includes("ui.mount");
107
98
  const declared = new Set(all.map((c) => `${c.plugin}/${c.command}`));
108
- const commands = all.filter((c) => !(hidden && c.scope === "panel" && c.plugin === host.manifestId));
99
+ const commands = all;
109
100
  const orphans = [...host.bindings.overlay]
110
101
  .filter(([key]) => !declared.has(key))
111
102
  .map(([key, inputs]) => ({
@@ -432,10 +423,10 @@ export function commandsHandlers(host, inner) {
432
423
  };
433
424
  }
434
425
  /// ---------------------------------------------------------------- built-in only: commands.run, palette.lead
435
- /** The player's refusal of a built-in-only capability to any other plugin. */
426
+ /** The player's refusal of a built-in-only request to any other plugin. */
436
427
  function builtinOnly(host) {
437
428
  if (!host.builtin)
438
- throw new HostError("capability", "this capability is for built-in plugins only");
429
+ throw new HostError("capability", "this is for built-in plugins only");
439
430
  }
440
431
  /** The palette's rows: the player's core commands and the plugin's own. */
441
432
  function rows(host) {