@vestra-player/sdk 1.7.4 → 1.7.6

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 (38) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/api-requests.js +0 -4
  3. package/dist/commands.js +1 -0
  4. package/dist/docs-tree.json.gz +0 -0
  5. package/dist/plugin/appearance.d.ts +19 -1
  6. package/dist/plugin/appearance.js +6 -74
  7. package/dist/plugin/commands.d.ts +16 -0
  8. package/dist/plugin/commands.js +3 -27
  9. package/dist/plugin/connection.d.ts +6 -0
  10. package/dist/plugin/connection.js +30 -2
  11. package/dist/plugin/index.js +2 -0
  12. package/dist/plugin/passes.js +0 -4
  13. package/dist/plugin/player/events.d.ts +2 -0
  14. package/dist/plugin/player/events.js +6 -2
  15. package/dist/plugin/player.js +8 -2
  16. package/dist/plugin/resolvers.js +0 -97
  17. package/dist/plugin/scope.d.ts +6 -0
  18. package/dist/plugin/scope.js +22 -3
  19. package/dist/plugin/testing/core-actions.d.ts +7 -0
  20. package/dist/plugin/testing/core-actions.js +66 -8
  21. package/dist/plugin/testing/index.d.ts +32 -12
  22. package/dist/plugin/testing/index.js +32 -12
  23. package/dist/plugin/testing/internals.d.ts +10 -0
  24. package/dist/plugin/testing/internals.js +10 -0
  25. package/dist/plugin/testing/media.d.ts +7 -1
  26. package/dist/plugin/testing/media.js +46 -3
  27. package/dist/plugin/testing/transport.js +3 -2
  28. package/dist/plugin/timeline.d.ts +2 -4
  29. package/dist/plugin/timeline.js +4 -27
  30. package/dist/plugin/types/commands.d.ts +8 -28
  31. package/dist/plugin/types/playback.d.ts +18 -24
  32. package/dist/plugin/types/sources.d.ts +0 -50
  33. package/dist/plugin/types/ui-locale.d.ts +4 -36
  34. package/dist/plugin/window.d.ts +0 -2
  35. package/dist/plugin/window.js +0 -4
  36. package/dist/wire.d.ts +1 -1
  37. package/llms.txt +1 -1
  38. package/package.json +1 -1
@@ -174,7 +174,9 @@ export interface TimelineLayer extends Disposable {
174
174
  * plugin publishes one layer with {@link Timeline.layer}; the player merges
175
175
  * the layers by time and shows them. A new source clears every layer, so a
176
176
  * plugin publishes again for each file. `marks` is the merged list, which
177
- * any plugin can read.
177
+ * any plugin can read. To run code when they change, listen with
178
+ * `plugin.player.on("timeline.changed", …)` (needs `events`): `marks` and
179
+ * `ranges` already hold the event's lists when the listener runs.
178
180
  *
179
181
  * @capability `timeline.marks` to publish; `playback.read` to read;
180
182
  * `events` to follow changes.
@@ -197,8 +199,7 @@ export interface Timeline {
197
199
  /**
198
200
  * Every layer's ranges merged, by start (`playback.read`). Empty on a new
199
201
  * source. Kept current like `marks` (with `events`): read it in a
200
- * {@link View.bind} function and the view follows it. `onChange` runs only
201
- * when the marks change.
202
+ * {@link View.bind} function and the view follows it.
202
203
  *
203
204
  * @example Draw the published ranges in a seek bar of your own
204
205
  * A bottom bar draws a band for every range on the seek bar, whoever
@@ -225,24 +226,6 @@ export interface Timeline {
225
226
  * @since 1.6.9
226
227
  */
227
228
  readonly ranges: readonly TimelineRange[];
228
- /**
229
- * The merged list changed (needs `events`; at most every 100 ms).
230
- *
231
- * @capability events and playback.read
232
- *
233
- * @example Follow the marks as they change
234
- * A panel lists the seek bar's marks and updates when any plugin publishes
235
- * or a new file clears them. The listener gets the merged list, at most
236
- * every 100 ms.
237
- * ```ts
238
- * plugin.timeline.onChange((marks) => {
239
- * console.log(marks.map((mark) => `${mark.time}s ${mark.title ?? mark.kind}`));
240
- * });
241
- * ```
242
- *
243
- * @since 1.0.0
244
- */
245
- onChange(listener: (marks: readonly TimelineMark[]) => void): Disposable;
246
229
  /**
247
230
  * This plugin's layer (`timeline.marks`); a second call throws.
248
231
  *
@@ -994,7 +977,16 @@ export interface Player {
994
977
  *
995
978
  * Unlike {@link Player.onChange} it does not start the SDK's copy of the
996
979
  * state: `plugin.player.state` is not kept current by it, and the
997
- * listener runs for every event, changed or not. It suits pushing
980
+ * listener runs for every event, changed or not. Three events are the
981
+ * exception: `commands.keys`, `timeline.changed` and `appearance.changed`
982
+ * start the copy they keep current (`plugin.commands.keys`,
983
+ * `plugin.timeline.marks` and `ranges`, `plugin.appearance.theme` and
984
+ * `language`), which stays for the plugin's life as a copy (not a
985
+ * listener: it keeps no plugin running), and the copy takes each event
986
+ * before the listener runs, so the listener reads the new values there.
987
+ * The listener hears only the player's events, never the copy's own first
988
+ * read: take the starting value once after activation, or read the copy
989
+ * in a {@link View.bind} function, which follows both. It suits pushing
998
990
  * values yourself (`view.set` from the listener) or reading a field the
999
991
  * SDK does not expose. Errors go to {@link Scope.onError}, as for every
1000
992
  * handler; unlike the others, no full update pass follows it, so bound
@@ -1192,7 +1184,9 @@ export interface Player {
1192
1184
  */
1193
1185
  setPaused(paused: boolean, options?: Conditional): Promise<void>;
1194
1186
  /**
1195
- * Jump to `seconds`.
1187
+ * Jump to `seconds`. After the end (`phase: "ended"`) the player leaves
1188
+ * the end there and plays on, unless the end was reached while paused or
1189
+ * by a frame step; a seek at or past the end leaves it ended and paused.
1196
1190
  *
1197
1191
  * @capability playback.control
1198
1192
  * @throws `stale` (rejects) The source changed since the state the call is
@@ -1562,7 +1556,7 @@ export interface Player {
1562
1556
  * at or after position + step, backward on the last at or before position −
1563
1557
  * step, and they always move. Presses during a seek add up and continue from
1564
1558
  * where it landed; the on-screen text shows the landed time. Sources without
1565
- * moving video seek exactly. {@link Player.seek}, chapters, loops and
1559
+ * moving video seek exactly, and so does a step seek after the end. {@link Player.seek}, chapters, loops and
1566
1560
  * {@link Player.step} are unaffected, and so is a scrub unless it asks for
1567
1561
  * keyframes itself ({@link Scrub.seek} with `keyframes: true`). Omitted or
1568
1562
  * `false`: exact seeks, as before. `seconds` and `keyframes` are written as a
@@ -247,54 +247,4 @@ export interface Resolvers {
247
247
  * @since 1.0.0
248
248
  */
249
249
  add(options: ResolverOptions): Resolver;
250
- /**
251
- * The extensions some plugin's file resolver handles: lower case, without the
252
- * dot, sorted, each once; not who registered them. Reading needs no
253
- * capability. Without `events` it is the list from when the plugin first read
254
- * it. Use it to accept such files beside the player's own media types, for
255
- * example in a playlist's drop or folder scan.
256
- *
257
- * @example Accept files that a resolver plugin can play
258
- * A plugin's own file filter also accepts types other plugins turn into
259
- * streams. `fileTypes` lists the extensions every running file resolver
260
- * claims (lower case, no dot); the SDK keeps it current with `events`.
261
- * ```ts
262
- * const MEDIA = ["mp4", "mkv", "mp3"];
263
- * // Extensions compare in lower case, without the dot.
264
- * const accepted = (path: string) => {
265
- * const extension = path.split(".").pop()?.toLowerCase() ?? "";
266
- * return MEDIA.includes(extension) || plugin.resolvers.fileTypes.includes(extension);
267
- * };
268
- * ```
269
- *
270
- * @capability None.
271
- * @player 0.4.2
272
- * @since 1.5.8
273
- */
274
- readonly fileTypes: readonly string[];
275
- /**
276
- * {@link Resolvers.fileTypes} changed: a file resolver was added, or its
277
- * plugin stopped. Needs `events`; without it the listener never fires. When
278
- * the player starts a stopped plugin for this change,
279
- * {@link Resolvers.fileTypes} already has the new list at start and the
280
- * listener still hears the change.
281
- *
282
- * @param listener - Receives the new list.
283
- * @returns A handle that removes the listener.
284
- *
285
- * @example Say which file types became playable
286
- * When a plugin with a file resolver starts or stops, the OSD lists the
287
- * extra file types now accepted. The listener (which needs `events`)
288
- * receives the new list each time it changes.
289
- * ```ts
290
- * plugin.resolvers.onFileTypesChange((types) => {
291
- * void plugin.osd.show("Also accepted: {}", [plugin.i18n.list(types)]);
292
- * });
293
- * ```
294
- *
295
- * @capability `events`
296
- * @player 0.4.2
297
- * @since 1.5.8
298
- */
299
- onFileTypesChange(listener: (types: string[]) => void): Disposable;
300
250
  }
@@ -1,7 +1,6 @@
1
1
  import type { Scope } from "./base.ts";
2
2
  import type { FileResolverOptions, WebResolverOptions } from "./sources.ts";
3
3
  import type { ConfirmOptions, Dialogs, Osd, OsdPanel } from "./ui-shell.ts";
4
- import type { Disposable } from "./base.ts";
5
4
  /**
6
5
  * The player's palettes: `vestra`, the dark default, and `vestra-light`, a
7
6
  * light palette whose video area stays dark. Both draw on the logo's colours.
@@ -32,6 +31,10 @@ export type ThemeId = "vestra" | "vestra-light";
32
31
  * Tell the user about a change yourself (for example with
33
32
  * {@link Osd.show}).
34
33
  *
34
+ * To run code when the palette or the language changes, listen with
35
+ * `plugin.player.on("appearance.changed", …)` (needs `events`): `theme` and
36
+ * `language` already hold the event's values when the listener runs.
37
+ *
35
38
  * @capability None to read `theme`; `events` to follow changes; `ui.theme`
36
39
  * to change it.
37
40
  *
@@ -61,41 +64,6 @@ export interface Appearance {
61
64
  * plugin's own.
62
65
  */
63
66
  readonly theme: ThemeId;
64
- /**
65
- * Run code when the palette changes.
66
- *
67
- * @remarks
68
- * Needs `events`: without it the listener never runs for other plugins'
69
- * changes. Views need no help to follow the palette; use this for things the
70
- * plugin draws itself (a rendered image, colours it computes). Errors go to
71
- * {@link Scope.onError}. When the player starts a stopped plugin for a
72
- * palette change, {@link Appearance.theme} already has the new palette at
73
- * start and the listener still hears the change. A
74
- * language change does not call it, except in one case: a plugin started for
75
- * a language change alone may hear the unchanged palette once, since the
76
- * player's event does not say which of the two changed.
77
- *
78
- * @capability events
79
- *
80
- * @param listener - Receives the new palette.
81
- * @returns A handle that removes the listener.
82
- *
83
- * @example Redraw a picture the plugin renders when the palette changes
84
- * The plugin renders a chart image in the palette's colours and draws it
85
- * again when the user or another plugin switches palettes. Views that use
86
- * `Theme` follow on their own; this listener (which needs `events`) is
87
- * for what the plugin draws itself.
88
- * ```ts
89
- * declare function renderChart(dark: boolean): Promise<void>;
90
- * // ---cut---
91
- * plugin.appearance.onChange((theme) => {
92
- * void renderChart(theme === "vestra"); // the dark default
93
- * });
94
- * ```
95
- *
96
- * @since 1.0.0
97
- */
98
- onChange(listener: (theme: ThemeId) => void): Disposable;
99
67
  /**
100
68
  * Switch the palette of every view.
101
69
  *
@@ -19,8 +19,6 @@ export declare class WindowService {
19
19
  start(): void;
20
20
  /** The palette, as the `window.state` reply carried it (`plugin.appearance`). */
21
21
  appearance: string | undefined;
22
- /** The file resolvers' extensions, as the reply carried them (`plugin.resolvers.fileTypes`). */
23
- fileTypes: string[] | undefined;
24
22
  /** The saved interface language, as the reply carried it (`plugin.appearance.language`). */
25
23
  language: string | undefined;
26
24
  accept(facts: WindowFacts): void;
@@ -55,8 +55,6 @@ export class WindowService {
55
55
  }
56
56
  /** The palette, as the `window.state` reply carried it (`plugin.appearance`). */
57
57
  appearance;
58
- /** The file resolvers' extensions, as the reply carried them (`plugin.resolvers.fileTypes`). */
59
- fileTypes;
60
58
  /** The saved interface language, as the reply carried it (`plugin.appearance.language`). */
61
59
  language;
62
60
  accept(facts) {
@@ -64,8 +62,6 @@ export class WindowService {
64
62
  this.appearance = facts.appearance;
65
63
  if (facts.language)
66
64
  this.language = facts.language;
67
- if (Array.isArray(facts.fileTypes))
68
- this.fileTypes = [...facts.fileTypes];
69
65
  const next = view(facts);
70
66
  if (JSON.stringify(next) === JSON.stringify(this.state))
71
67
  return;
package/dist/wire.d.ts CHANGED
@@ -368,7 +368,7 @@ export interface WindowFacts {
368
368
  };
369
369
  /** The palette (`plugin.appearance`), with the `window.state` reply; a newer player may name a palette this SDK does not list. */
370
370
  appearance?: string;
371
- /** The file resolvers' extensions (`plugin.resolvers.fileTypes`). */
371
+ /** The file resolvers' extensions (as `resolvers.fileTypes` carries them). */
372
372
  fileTypes?: string[];
373
373
  /** The saved interface language, `"system"` or a locale. */
374
374
  language?: string;
package/llms.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  # Vestra Player SDK
2
2
 
3
- > @vestra-player/sdk 1.7.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/.
3
+ > @vestra-player/sdk 1.7.6: 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.7.4",
3
+ "version": "1.7.6",
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": {