@vestra-player/sdk 1.7.20 → 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 (96) hide show
  1. package/CHANGELOG.md +72 -0
  2. package/README.md +2 -2
  3. package/bin/vestra-plugin.mjs +139 -100
  4. package/capability-scan.json +369 -0
  5. package/dist/api-requests.d.ts +11 -36
  6. package/dist/api-requests.js +22 -47
  7. package/dist/capability-scan.d.ts +95 -0
  8. package/dist/capability-scan.js +249 -0
  9. package/dist/commands.d.ts +35 -0
  10. package/dist/commands.js +42 -1
  11. package/dist/docs-tree.json.gz +0 -0
  12. package/dist/docs.d.ts +1 -1
  13. package/dist/docs.js +1 -1
  14. package/dist/index.d.ts +4 -5
  15. package/dist/manifest.d.ts +5 -0
  16. package/dist/manifest.js +9 -24
  17. package/dist/member-uses.d.ts +61 -0
  18. package/dist/member-uses.js +160 -0
  19. package/dist/mpv.d.ts +139 -0
  20. package/dist/mpv.js +496 -0
  21. package/dist/player-runtime.d.ts +3 -3
  22. package/dist/player-runtime.js +3 -3
  23. package/dist/plugin/appearance.d.ts +1 -1
  24. package/dist/plugin/appearance.js +2 -2
  25. package/dist/plugin/bindings.d.ts +1 -1
  26. package/dist/plugin/bindings.js +2 -2
  27. package/dist/plugin/commands.js +6 -14
  28. package/dist/plugin/connection.d.ts +26 -7
  29. package/dist/plugin/connection.js +68 -36
  30. package/dist/plugin/drops.js +1 -1
  31. package/dist/plugin/index.js +9 -15
  32. package/dist/plugin/media.js +0 -12
  33. package/dist/plugin/mpv.d.ts +3 -0
  34. package/dist/plugin/mpv.js +91 -0
  35. package/dist/plugin/packages.js +1 -2
  36. package/dist/plugin/player/events.d.ts +4 -3
  37. package/dist/plugin/player/events.js +7 -6
  38. package/dist/plugin/player.d.ts +21 -13
  39. package/dist/plugin/player.js +56 -21
  40. package/dist/plugin/scope.d.ts +1 -0
  41. package/dist/plugin/scope.js +2 -0
  42. package/dist/plugin/services.d.ts +4 -4
  43. package/dist/plugin/services.js +7 -29
  44. package/dist/plugin/settings.js +1 -1
  45. package/dist/plugin/shaders.js +0 -2
  46. package/dist/plugin/stream.d.ts +2 -1
  47. package/dist/plugin/stream.js +2 -2
  48. package/dist/plugin/testing/commands.d.ts +3 -10
  49. package/dist/plugin/testing/commands.js +43 -24
  50. package/dist/plugin/testing/index.d.ts +75 -114
  51. package/dist/plugin/testing/index.js +83 -102
  52. package/dist/plugin/testing/mpv.d.ts +7 -0
  53. package/dist/plugin/testing/mpv.js +90 -0
  54. package/dist/plugin/testing/processing.js +1 -1
  55. package/dist/plugin/testing/services.js +0 -1
  56. package/dist/plugin/timeline.d.ts +2 -3
  57. package/dist/plugin/timeline.js +4 -8
  58. package/dist/plugin/types/base.d.ts +49 -88
  59. package/dist/plugin/types/commands.d.ts +44 -77
  60. package/dist/plugin/types/packages.d.ts +17 -55
  61. package/dist/plugin/types/playback.d.ts +302 -135
  62. package/dist/plugin/types/plugin-wire.d.ts +6 -36
  63. package/dist/plugin/types/processing.d.ts +10 -49
  64. package/dist/plugin/types/services.d.ts +11 -70
  65. package/dist/plugin/types/snapshots.d.ts +7 -60
  66. package/dist/plugin/types/sources.d.ts +2 -11
  67. package/dist/plugin/types/subtitles.d.ts +5 -26
  68. package/dist/plugin/types/ui-content.d.ts +1 -16
  69. package/dist/plugin/types/ui-layout.d.ts +53 -79
  70. package/dist/plugin/types/ui-locale.d.ts +5 -23
  71. package/dist/plugin/types/ui-shell.d.ts +13 -59
  72. package/dist/plugin/view/layout.js +1 -1
  73. package/dist/plugin/view.js +0 -2
  74. package/dist/plugin/window.d.ts +1 -1
  75. package/dist/plugin/window.js +1 -1
  76. package/dist/plugin/wire-facade.js +1 -2
  77. package/dist/processing.d.ts +2 -3
  78. package/dist/protocol.d.ts +14 -0
  79. package/dist/protocol.js +14 -0
  80. package/dist/request-queue.js +1 -1
  81. package/dist/subtitles.d.ts +1 -1
  82. package/dist/ts-plugin.d.ts +8 -15
  83. package/dist/ts-plugin.js +3 -141
  84. package/dist/wire.d.ts +22 -12
  85. package/dist/wire.js +17 -8
  86. package/llms.txt +5 -5
  87. package/package.json +4 -3
  88. package/slint/vestra/widgets.slint +12 -4
  89. package/dist/capabilities.d.ts +0 -107
  90. package/dist/capabilities.js +0 -69
  91. package/dist/capability-check.d.ts +0 -133
  92. package/dist/capability-check.js +0 -371
  93. package/dist/capability-rules.d.ts +0 -125
  94. package/dist/capability-rules.js +0 -192
  95. package/dist/host-capabilities.d.ts +0 -10
  96. package/dist/host-capabilities.js +0 -477
@@ -12,9 +12,14 @@ export type Why = () => string;
12
12
  * the palette, a resolver), not playback.
13
13
  */
14
14
  export declare const WAKE_EVENTS: readonly string[];
15
+ /**
16
+ * What the runtime reads of the plugin's manifest: its id. Nothing in the
17
+ * manifest switches behaviour (1.9.0): event delivery and the start-up
18
+ * reads are the plugin's explicit calls (`plugin.player.subscribe()`,
19
+ * `plugin.player.read()`).
20
+ */
15
21
  export interface PluginManifest {
16
22
  id: string;
17
- capabilities: string[];
18
23
  }
19
24
  /** How the plugin is run: the player's runner, or `TestHost`. */
20
25
  export interface RuntimeOptions {
@@ -63,6 +68,11 @@ export declare class Connection {
63
68
  * `REQUEST_LIMITS` in flight, the rest wait in order (`request-queue.ts`).
64
69
  */
65
70
  readonly requests: RequestQueue;
71
+ /**
72
+ * The player's state is read again after the plugin's own actions:
73
+ * `plugin.player.read()` was called.
74
+ */
75
+ reads: boolean;
66
76
  readonly views: Map<string, (callback: string, args: Json[]) => void>;
67
77
  readonly commands: Map<string, () => void>;
68
78
  /**
@@ -104,7 +114,14 @@ export declare class Connection {
104
114
  */
105
115
  readonly features: ReadonlySet<string>;
106
116
  constructor(transport: Transport, manifest: PluginManifest, directory: string, dataDirectory?: string, app?: unknown, options?: RuntimeOptions);
107
- can(capability: string): boolean;
117
+ /** Event delivery is on (`plugin.player.subscribe()` was called). */
118
+ get delivering(): boolean;
119
+ /**
120
+ * Turn event delivery on (`plugin.player.subscribe()`): every later
121
+ * listener is subscribed, and so is what was added before and heard
122
+ * nothing. Idempotent.
123
+ */
124
+ deliver(): void;
108
125
  /** Read the state copy kept by `event` again, if one exists; never rejects. */
109
126
  reread(event: string): Promise<void>;
110
127
  /** Lazily created singletons shared by every scope of this plugin. */
@@ -133,17 +150,19 @@ export declare class Connection {
133
150
  callSite(): () => string | undefined;
134
151
  /**
135
152
  * Host events with one `events.subscribe` per name, however many listeners.
136
- * Without the `events` capability the listener simply never fires.
153
+ * An event that needs delivery (`"events"`) is subscribed only once
154
+ * `plugin.player.subscribe()` was called; until then its listener simply
155
+ * never fires.
137
156
  * `mirror`: the SDK's own copy of the state (`plugin.player.state` and
138
157
  * the like), not a listener of the plugin's (see {@link EventGroup}).
139
158
  */
140
159
  on(event: string, listener: Listener,
141
- /** The capability the event needs; `null`: none. */
142
- needs?: string | null, mirror?: boolean): Disposable;
160
+ /** `"events"`: it arrives after `plugin.player.subscribe()`; `null`: always. */
161
+ needs?: "events" | null, mirror?: boolean): Disposable;
143
162
  /**
144
163
  * Count `event` as listened to while held: a watcher of a service's
145
164
  * state, a binding that reads it. Nothing when nothing subscribed to it
146
- * (no capability, or the service did not start).
165
+ * (no `plugin.player.subscribe()`, or the service did not start).
147
166
  */
148
167
  hold(event: string, why?: Why): Disposable;
149
168
  /**
@@ -154,7 +173,7 @@ export declare class Connection {
154
173
  listening(): Map<string, string[]>;
155
174
  /**
156
175
  * One request by its method name, as given (`plugin.wire.request`): nothing
157
- * added, nothing checked here, the player checks the capability. Every other
176
+ * added, nothing checked here; the player checks the request. Every other
158
177
  * part of the SDK uses the typed clients (`host`); `scripts/check-layers.mjs`
159
178
  * keeps it so. It waits in the request queue like every other.
160
179
  */
@@ -88,8 +88,18 @@ export class Connection {
88
88
  */
89
89
  requests;
90
90
  #events = new Map();
91
- /** The missing `events` warning was given (once per plugin). */
91
+ /** The missing `subscribe()` warning was given (once per plugin). */
92
92
  #warnedEvents = false;
93
+ /**
94
+ * Event delivery is on: `plugin.player.subscribe()` was called
95
+ * ({@link Connection.deliver}).
96
+ */
97
+ #delivering = false;
98
+ /**
99
+ * The player's state is read again after the plugin's own actions:
100
+ * `plugin.player.read()` was called.
101
+ */
102
+ reads = false;
93
103
  views = new Map();
94
104
  commands = new Map();
95
105
  /**
@@ -169,8 +179,24 @@ export class Connection {
169
179
  this.commands.get(data.id)?.();
170
180
  });
171
181
  }
172
- can(capability) {
173
- return this.manifest.capabilities.includes(capability);
182
+ /** Event delivery is on (`plugin.player.subscribe()` was called). */
183
+ get delivering() {
184
+ return this.#delivering;
185
+ }
186
+ /**
187
+ * Turn event delivery on (`plugin.player.subscribe()`): every later
188
+ * listener is subscribed, and so is what was added before and heard
189
+ * nothing. Idempotent.
190
+ */
191
+ deliver() {
192
+ if (this.#delivering)
193
+ return;
194
+ this.#delivering = true;
195
+ for (const [event, group] of this.#events)
196
+ if (group.unheard) {
197
+ group.unheard = false;
198
+ this.#open(event, group);
199
+ }
174
200
  }
175
201
  /** Read the state copy kept by `event` again, if one exists; never rejects. */
176
202
  async reread(event) {
@@ -275,12 +301,14 @@ export class Connection {
275
301
  }
276
302
  /**
277
303
  * Host events with one `events.subscribe` per name, however many listeners.
278
- * Without the `events` capability the listener simply never fires.
304
+ * An event that needs delivery (`"events"`) is subscribed only once
305
+ * `plugin.player.subscribe()` was called; until then its listener simply
306
+ * never fires.
279
307
  * `mirror`: the SDK's own copy of the state (`plugin.player.state` and
280
308
  * the like), not a listener of the plugin's (see {@link EventGroup}).
281
309
  */
282
310
  on(event, listener,
283
- /** The capability the event needs; `null`: none. */
311
+ /** `"events"`: it arrives after `plugin.player.subscribe()`; `null`: always. */
284
312
  needs = "events", mirror = false) {
285
313
  let entry = this.#events.get(event);
286
314
  const created = !entry;
@@ -302,34 +330,12 @@ export class Connection {
302
330
  group.active++;
303
331
  group.whys.set(token, listenerWhy(this.callSite()));
304
332
  }
305
- if (created && needs === "events" && !this.can(needs))
333
+ if (created && needs === "events" && !this.#delivering)
306
334
  group.unheard = true;
307
335
  if (!mirror && group.unheard)
308
336
  this.#warnUnheard(event);
309
- if (created && (needs === null || this.can(needs))) {
310
- group.told = group.active > 0;
311
- const whys = group.told ? allWhys(group) : undefined;
312
- group.toldWhy = whys?.join("\n");
313
- group.off = this.host.events.subscribe(event, (data) => {
314
- // Split once: the state copies first, each on its own (one that
315
- // throws stops neither the others nor the plugin's listeners),
316
- // then the plugin's listeners in order.
317
- const mirrors = [];
318
- const others = [];
319
- for (const each of group.listeners)
320
- (group.mirrors.has(each) ? mirrors : others).push(each);
321
- for (const each of mirrors)
322
- try {
323
- each(data);
324
- }
325
- catch (error) {
326
- this.reportMirror(error);
327
- }
328
- for (const each of others)
329
- each(data);
330
- }, !group.told, whys);
331
- this.starting(group.off, (error) => console.error(`[${this.manifest.id}] subscribe ${event}:`, error));
332
- }
337
+ if (created && !group.unheard)
338
+ this.#open(event, group);
333
339
  else
334
340
  this.#tell(event, group);
335
341
  let listening = true;
@@ -353,10 +359,35 @@ export class Connection {
353
359
  },
354
360
  };
355
361
  }
362
+ /** Subscribe `group` to `event` at the player, as it stands now. */
363
+ #open(event, group) {
364
+ group.told = group.active > 0;
365
+ const whys = group.told ? allWhys(group) : undefined;
366
+ group.toldWhy = whys?.join("\n");
367
+ group.off = this.host.events.subscribe(event, (data) => {
368
+ // Split once: the state copies first, each on its own (one that
369
+ // throws stops neither the others nor the plugin's listeners),
370
+ // then the plugin's listeners in order.
371
+ const mirrors = [];
372
+ const others = [];
373
+ for (const each of group.listeners)
374
+ (group.mirrors.has(each) ? mirrors : others).push(each);
375
+ for (const each of mirrors)
376
+ try {
377
+ each(data);
378
+ }
379
+ catch (error) {
380
+ this.reportMirror(error);
381
+ }
382
+ for (const each of others)
383
+ each(data);
384
+ }, !group.told, whys);
385
+ this.starting(group.off, (error) => console.error(`[${this.manifest.id}] subscribe ${event}:`, error));
386
+ }
356
387
  /**
357
388
  * Count `event` as listened to while held: a watcher of a service's
358
389
  * state, a binding that reads it. Nothing when nothing subscribed to it
359
- * (no capability, or the service did not start).
390
+ * (no `plugin.player.subscribe()`, or the service did not start).
360
391
  */
361
392
  hold(event, why) {
362
393
  const group = this.#events.get(event);
@@ -383,15 +414,16 @@ export class Connection {
383
414
  }
384
415
  /**
385
416
  * A development warning, once per plugin, no behaviour change: the plugin
386
- * follows `event` (an `onChange`, a `bind` that reads the state) without the
387
- * `events` capability, so changes made elsewhere (the user, the player,
388
- * another plugin) never reach it; the state moves only after its own calls.
417
+ * follows `event` (a listener, an `onChange`, a `bind` that reads the
418
+ * state) before `plugin.player.subscribe()`, so changes made elsewhere
419
+ * (the user, the player, another plugin) never reach it; the state moves
420
+ * only after its own calls.
389
421
  */
390
422
  #warnUnheard(event) {
391
423
  if (this.#warnedEvents)
392
424
  return;
393
425
  this.#warnedEvents = true;
394
- console.warn(`[${this.manifest.id}] follows ${event} (onChange, or a bind() that reads the state) without the "events" capability: changes made elsewhere will not reach it, only its own calls refresh the state. Declare "events" in manifest.json.`);
426
+ console.warn(`[${this.manifest.id}] follows ${event} (a listener, onChange, or a bind() that reads the state) before plugin.player.subscribe(): changes made elsewhere will not reach it, only its own calls refresh the state. Call plugin.player.subscribe() first in activate().`);
395
427
  }
396
428
  /**
397
429
  * Tell the player when `group` changes between mirror and listener, and
@@ -430,7 +462,7 @@ export class Connection {
430
462
  }
431
463
  /**
432
464
  * One request by its method name, as given (`plugin.wire.request`): nothing
433
- * added, nothing checked here, the player checks the capability. Every other
465
+ * added, nothing checked here; the player checks the request. Every other
434
466
  * part of the SDK uses the typed clients (`host`); `scripts/check-layers.mjs`
435
467
  * keeps it so. It waits in the request queue like every other.
436
468
  */
@@ -1,4 +1,4 @@
1
- /** File drops (`plugin.drops`, `Panel.onDrop`; capability `ui.drop`). */
1
+ /** File drops (`plugin.drops`, `Panel.onDrop`). */
2
2
  import { failure } from "./errors.js";
3
3
  const modifiers = (raw) => Object.freeze({
4
4
  alt: raw?.alt === true,
@@ -2,7 +2,6 @@ import { Runtime } from "./runtime.js";
2
2
  import { stopReason } from "./connection.js";
3
3
  import { failure } from "./errors.js";
4
4
  import { ScopeImpl } from "./scope.js";
5
- import { playerOf } from "./player.js";
6
5
  import { windowOf } from "./window.js";
7
6
  import { timelineOf } from "./timeline.js";
8
7
  export async function createPlugin(transport, manifest, directory, dataDirectory,
@@ -11,20 +10,15 @@ app,
11
10
  /** `TestHost` sets `strictDeclarations`; the player's runner does not. */
12
11
  options) {
13
12
  const runtime = new Runtime(transport, manifest, directory, dataDirectory, app, options);
14
- // Player, window and timeline state are synchronous for plugins: read them
15
- // first. With `events` the copy of the player's state follows the events
16
- // from the start, subscribed before the read, as before 1.7.0: a read in
17
- // any later handler is current. Without `events` nothing can be
18
- // subscribed, and the copy starts on its first use. Window and timeline
19
- // subscribe on their first use.
20
- const player = playerOf(runtime);
21
- if (runtime.can("events"))
22
- void player.start(false);
23
- await Promise.all([
24
- player.init(),
25
- windowOf(runtime).init(),
26
- timelineOf(runtime).init(),
27
- ]);
13
+ // The window state is synchronous for plugins: read it first. The
14
+ // player's state and the timeline are the plugin's explicit calls, first
15
+ // in `activate`: `plugin.player.subscribe()` (event delivery, the copy
16
+ // of the player's state follows from then on) and
17
+ // `await plugin.player.read()` (state and timeline read once). Window and
18
+ // timeline subscribe on their first use. The timeline's copy exists from
19
+ // the start: it tells the connection how `read()` reads the lists.
20
+ timelineOf(runtime);
21
+ await windowOf(runtime).init();
28
22
  const root = new ScopeImpl(runtime);
29
23
  // A runaway of the update passes goes to the plugin's error handlers.
30
24
  runtime.passes.report = (error) => root.report(error);
@@ -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");
@@ -0,0 +1,3 @@
1
+ import type { ScopeImpl } from "./scope.ts";
2
+ import type { Mpv } from "./types.ts";
3
+ export declare const mpv: (scope: ScopeImpl) => Mpv;
@@ -0,0 +1,91 @@
1
+ /**
2
+ * `plugin.mpv`: the mpv pass-through (L1). The checks here are the
3
+ * player's own, made early with the same table (`src/mpv.ts`); what only
4
+ * the player can tell (another plugin's label, mpv's answer) is its.
5
+ */
6
+ import { mpvCommandProblem, mpvCommandRefusal, mpvNameProblem, mpvPropertyRefusal, } from "../mpv.js";
7
+ import { failure } from "./errors.js";
8
+ /** One per plugin: the properties observed and their listeners. */
9
+ class Observers {
10
+ #runtime;
11
+ #names = new Map();
12
+ #started = false;
13
+ constructor(runtime) {
14
+ this.#runtime = runtime;
15
+ }
16
+ /** One `mpv.observe` per name, however many listeners. */
17
+ add(name, listener, report) {
18
+ if (!this.#started) {
19
+ this.#started = true;
20
+ // Sent to the plugin that observes: no subscription of its own.
21
+ this.#runtime.raw("mpv.property", (data) => {
22
+ const event = data;
23
+ for (const each of [...(this.#names.get(event.name) ?? [])])
24
+ each(event.value);
25
+ });
26
+ }
27
+ let listeners = this.#names.get(name);
28
+ if (!listeners) {
29
+ listeners = new Set();
30
+ this.#names.set(name, listeners);
31
+ this.#runtime.starting(this.#runtime.host.mpv.observeProperty(name), report);
32
+ }
33
+ listeners.add(listener);
34
+ }
35
+ async remove(name, listener) {
36
+ const listeners = this.#names.get(name);
37
+ if (!listeners?.delete(listener) || listeners.size)
38
+ return;
39
+ this.#names.delete(name);
40
+ await this.#runtime.host.mpv.unobserveProperty(name).catch(() => { });
41
+ }
42
+ }
43
+ export const mpv = (scope) => {
44
+ const named = (name, write) => {
45
+ const problem = mpvNameProblem(name);
46
+ if (problem)
47
+ throw failure("invalid", problem);
48
+ const refused = mpvPropertyRefusal(name, write);
49
+ if (refused)
50
+ throw failure("refused", refused);
51
+ return name;
52
+ };
53
+ const observers = () => scope.runtime.service("mpv.observers", () => new Observers(scope.runtime));
54
+ return {
55
+ async command(args) {
56
+ const problem = mpvCommandProblem(args);
57
+ if (problem)
58
+ throw failure("invalid", problem);
59
+ const refused = mpvCommandRefusal(args);
60
+ if (refused)
61
+ throw failure("refused", refused);
62
+ const answer = await scope.runtime.host.mpv.command([...args]);
63
+ return (answer?.result ?? null);
64
+ },
65
+ async get(name) {
66
+ const answer = await scope.runtime.host.mpv.get(named(name, false));
67
+ return (answer?.value ?? null);
68
+ },
69
+ async set(name, value) {
70
+ const property = named(name, true);
71
+ if (value === undefined)
72
+ throw failure("invalid", "set takes a value");
73
+ await scope.runtime.host.mpv.set(property, value);
74
+ },
75
+ observe(name, listener) {
76
+ const property = named(name, false);
77
+ if (typeof listener !== "function")
78
+ throw failure("invalid", "observe takes a property name and a listener");
79
+ // Like `player.on`: no full update pass after it.
80
+ const deliver = (value) => scope.runQuiet(listener, value);
81
+ observers().add(property, deliver, (error) => scope.report(error));
82
+ const handle = {
83
+ dispose: async () => {
84
+ scope.forget(handle);
85
+ await observers().remove(property, deliver);
86
+ },
87
+ };
88
+ return scope.add(handle);
89
+ },
90
+ };
91
+ };
@@ -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. */