@vestra-player/sdk 1.10.0 → 1.11.0-rc.1

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 (65) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/bin/vestra-plugin.mjs +1 -131
  3. package/dist/api-requests.d.ts +1 -1
  4. package/dist/api-requests.js +10 -2
  5. package/dist/commands.js +1 -0
  6. package/dist/docs-tree.json.gz +0 -0
  7. package/dist/manifest.d.ts +0 -5
  8. package/dist/manifest.js +1 -8
  9. package/dist/mpv.js +1 -1
  10. package/dist/plugin/appearance.d.ts +2 -2
  11. package/dist/plugin/appearance.js +3 -3
  12. package/dist/plugin/connection.d.ts +39 -29
  13. package/dist/plugin/connection.js +110 -101
  14. package/dist/plugin/index.js +8 -6
  15. package/dist/plugin/passes.js +1 -1
  16. package/dist/plugin/player/events.d.ts +18 -9
  17. package/dist/plugin/player/events.js +36 -11
  18. package/dist/plugin/player.d.ts +31 -28
  19. package/dist/plugin/player.js +42 -68
  20. package/dist/plugin/scope.d.ts +2 -9
  21. package/dist/plugin/scope.js +21 -27
  22. package/dist/plugin/subtitles.d.ts +6 -1
  23. package/dist/plugin/subtitles.js +18 -2
  24. package/dist/plugin/testing/commands.d.ts +5 -0
  25. package/dist/plugin/testing/commands.js +6 -3
  26. package/dist/plugin/testing/facts.d.ts +46 -0
  27. package/dist/plugin/testing/facts.js +106 -0
  28. package/dist/plugin/testing/index.d.ts +38 -13
  29. package/dist/plugin/testing/index.js +63 -17
  30. package/dist/plugin/testing/media.js +6 -0
  31. package/dist/plugin/testing/revoke.d.ts +15 -0
  32. package/dist/plugin/testing/revoke.js +13 -0
  33. package/dist/plugin/testing/services.js +50 -1
  34. package/dist/plugin/testing/transport.js +8 -0
  35. package/dist/plugin/timeline.d.ts +2 -2
  36. package/dist/plugin/timeline.js +3 -3
  37. package/dist/plugin/types/base.d.ts +91 -13
  38. package/dist/plugin/types/commands.d.ts +8 -8
  39. package/dist/plugin/types/packages.d.ts +10 -1
  40. package/dist/plugin/types/playback.d.ts +240 -116
  41. package/dist/plugin/types/plugin-wire.d.ts +2 -2
  42. package/dist/plugin/types/processing.d.ts +2 -3
  43. package/dist/plugin/types/services.d.ts +10 -4
  44. package/dist/plugin/types/subtitles.d.ts +9 -8
  45. package/dist/plugin/types/ui-layout.d.ts +32 -17
  46. package/dist/plugin/types/ui-locale.d.ts +9 -9
  47. package/dist/plugin/types/ui-shell.d.ts +7 -6
  48. package/dist/plugin/view/layout.d.ts +33 -1
  49. package/dist/plugin/view/layout.js +63 -34
  50. package/dist/plugin/window.d.ts +9 -1
  51. package/dist/plugin/window.js +14 -2
  52. package/dist/processing.d.ts +2 -2
  53. package/dist/request-queue.d.ts +7 -3
  54. package/dist/request-queue.js +19 -5
  55. package/dist/ts-plugin.d.ts +3 -4
  56. package/dist/ts-plugin.js +1 -1
  57. package/dist/wire.d.ts +4 -1
  58. package/dist/wire.js +2 -1
  59. package/llms.txt +3 -3
  60. package/package.json +3 -5
  61. package/capability-scan.json +0 -387
  62. package/dist/capability-scan.d.ts +0 -95
  63. package/dist/capability-scan.js +0 -249
  64. package/dist/member-uses.d.ts +0 -61
  65. package/dist/member-uses.js +0 -160
@@ -48,8 +48,8 @@ import type { Wire } from "./plugin-wire.ts";
48
48
  * disposing it removes just that listener, before the scope that owns it
49
49
  * ends.
50
50
  * ```ts
51
- * const subscription = plugin.player.onChange((state) => {
52
- * if (state.phase === "ready") void subscription.dispose();
51
+ * const subscription = plugin.player.on("source.ready", () => {
52
+ * void subscription.dispose(); // heard once
53
53
  * });
54
54
  * ```
55
55
  *
@@ -94,12 +94,12 @@ export interface Disposable {
94
94
  * | code | meaning |
95
95
  * | --- | --- |
96
96
  * | `stale` | A condition no longer held (the source or the subtitle selection changed); nothing was done. See {@link Conditional}. |
97
- * | `capability` | The call is for the player's built-in plugins only (`commands.list`, `commands.run`, `palette.lead`) and this plugin is not one. |
97
+ * | `builtin-only` | The call is for the player's built-in plugins only (`commands.list`, `commands.run`, `palette.lead`, `app.openWindow`) and this plugin is not one. |
98
98
  * | `invalid` | A bad argument (out of range, malformed, unknown id). |
99
99
  * | `missing` | The target does not exist (an empty panel position, a missing file, an unknown command). |
100
100
  * | `busy` | The player is still doing a previous call of the same kind (a dialog is open, a step is in flight). |
101
101
  * | `conflict` | Another plugin owns the resource (the sequence provider, the display layer, the backdrop, a menu path, the command palette's lead row), or this plugin already uses the id (a window or command id). |
102
- * | `unavailable` | Not possible right now (no ready media, no user interface, fullscreen, a disabled core action). |
102
+ * | `unavailable` | Not possible right now (no ready media, no user interface, fullscreen, a disabled core action), or not in a temporary window (saving a secret, changing the plugin library; {@link AppInfo.temporary}). |
103
103
  * | `unsupported` | Not possible on this system, build or source (a platform gap, software rendering, a source that cannot seek, a filter on a generated stream, an export the player cannot make as asked: a stream copy, a source bitrate it cannot tell). |
104
104
  * | `backend` | Loading or resolving failed, or mpv failed a command or a property of {@link Mpv}; `message` is the backend's reason. |
105
105
  * | `refused` | {@link Mpv}: a command or a property the pass-through does not carry (it would start a program, load code, write files, end the player, or change what the player manages); `message` names it and why. |
@@ -230,9 +230,8 @@ export interface Scope extends Disposable {
230
230
  /**
231
231
  * Video processing: this plugin's filter chain, the display layer, the
232
232
  * GPU render options, this plugin's shaders, the GPU's video upscaler and
233
- * motion smoothing. The filter chain follows the player: call
234
- * `plugin.player.subscribe()` and `plugin.player.read()` first (without `subscribe()` the SDK never sees
235
- * the media become ready and the chain stays `waiting`).
233
+ * motion smoothing. The filter chain follows the player by itself while
234
+ * it exists (it applies when a video becomes ready).
236
235
  */
237
236
  readonly video: {
238
237
  /**
@@ -574,7 +573,7 @@ export interface Scope extends Disposable {
574
573
  * // ---cut---
575
574
  * const st = plugin.state({ video: null as boolean | null });
576
575
  * bar.bind(() => ({ keyframes: st.video === true })); // reads st.video
577
- * plugin.player.onChange((state) => {
576
+ * plugin.player.on("source.ready", ({ state }) => {
578
577
  * if (state.source === null) return;
579
578
  * void hasVideo(state.source).then((video) => (st.video = video)); // re-runs the bind above
580
579
  * });
@@ -819,9 +818,9 @@ export interface WindowState {
819
818
  /**
820
819
  * The player's main window: read it, change it.
821
820
  *
822
- * After `plugin.player.subscribe()`, `state` follows the window from the first read or
823
- * `onChange`; without it, it updates only at start and after this plugin's
824
- * `setVideoArea`.
821
+ * `state` is read at start; it follows the window while an `onChange`
822
+ * listener exists, and takes each `window.changed` a `player.on` listener
823
+ * hears; otherwise it updates only after this plugin's `setVideoArea`.
825
824
  *
826
825
  * @example Resize the window to the video's own size
827
826
  * Screen ▸ Original size makes the video area as many logical points as
@@ -856,12 +855,13 @@ export interface MainWindow {
856
855
  /** Latest state; zero video area without a native window. */
857
856
  readonly state: WindowState;
858
857
  /**
859
- * The window state changed (outside changes after `plugin.player.subscribe()`).
858
+ * The window state changed, here or elsewhere (the listener keeps the
859
+ * plugin running; `window.changed` with {@link Player.on} does not).
860
860
  *
861
861
  * @example Fit a panel to fullscreen
862
862
  * The plugin's panel uses larger text while the player is fullscreen. The
863
863
  * listener runs after the SDK updated `state` from the player's events
864
- * (after `plugin.player.subscribe()`; without it only after this plugin's own changes).
864
+ * while it listens.
865
865
  * ```ts
866
866
  * declare const bar: Panel;
867
867
  * // ---cut---
@@ -1011,6 +1011,40 @@ export interface AppInfo {
1011
1011
  /** The linked Slint version, e.g. `"1.18.1"`. */
1012
1012
  readonly slint: string;
1013
1013
  };
1014
+ /**
1015
+ * `true` when this player is a temporary window (a guest, like a
1016
+ * browser's guest window): a second player the main one started with
1017
+ * {@link App.openWindow} (the playlist's Play in New Window), or one the
1018
+ * user started with `--guest`. Absent in the main player and in a player
1019
+ * before 0.10.3.
1020
+ *
1021
+ * @remarks
1022
+ * A temporary window runs with a temporary profile that is deleted when
1023
+ * it closes. Only the player's own settings (look, language, keys,
1024
+ * rendering, window layout) are copied from the main window. A plugin's
1025
+ * data directory (its options, history and lists included) and its
1026
+ * session storage start empty and are discarded when the window closes;
1027
+ * nothing a plugin writes reaches the main window. The plugin library and the keychain are
1028
+ * the main window's, read-only: {@link Secrets.get} reads the main
1029
+ * window's values, while {@link Secrets.set}, {@link Secrets.delete},
1030
+ * {@link PackageCandidate.install}, {@link Packages.uninstall} and
1031
+ * {@link Packages.setEnabled} reject with `unavailable`. A plugin that
1032
+ * does background work for the user's profile (an automatic update
1033
+ * check, a sync) skips it here; work the user starts still runs.
1034
+ *
1035
+ * @example Skip the automatic update check in a temporary window
1036
+ * The main window checks for updates once a day; a temporary window
1037
+ * leaves it to the main one. A check the user asks for still runs.
1038
+ * ```ts
1039
+ * declare function checkForUpdates(): Promise<void>;
1040
+ * // ---cut---
1041
+ * if (!plugin.app.temporary) void checkForUpdates();
1042
+ * ```
1043
+ *
1044
+ * @player 0.10.3
1045
+ * @since 1.10.1
1046
+ */
1047
+ readonly temporary?: boolean;
1014
1048
  }
1015
1049
  /**
1016
1050
  * `plugin.app`: the fixed facts plus the system, read on request.
@@ -1057,6 +1091,50 @@ export interface App extends AppInfo {
1057
1091
  * @since 1.0.0
1058
1092
  */
1059
1093
  system(): Promise<SystemInfo>;
1094
+ /**
1095
+ * Open the files in a new temporary window: a second player with a
1096
+ * temporary profile ({@link AppInfo.temporary}) that plays the first file
1097
+ * and lists them all. Resolves once its process started, with its
1098
+ * process id. **Built-in plugins only.**
1099
+ *
1100
+ * @remarks
1101
+ * The playlist's Play in New Window. The new window is a separate player
1102
+ * process and keeps running after this one quits; it shares nothing with
1103
+ * the calling plugin.
1104
+ *
1105
+ * @param paths 1 to 64 absolute paths of existing files, in play order.
1106
+ *
1107
+ * @throws `builtin-only` (rejects) The plugin is not built into the player.
1108
+ * @throws `invalid` (rejects) No path, more than 64, or a path that is not
1109
+ * an absolute path.
1110
+ * @throws `missing` (rejects) A path that is not an existing file.
1111
+ * @throws `unsupported` (rejects) On macOS (not yet), or a player without
1112
+ * windows.
1113
+ * @throws `failed` (rejects) The new player did not start.
1114
+ *
1115
+ * @example Play the selected files in a new window
1116
+ * The playlist's row menu opens the selected local files in a temporary
1117
+ * window, which plays them without changing the main window's list or
1118
+ * settings.
1119
+ * ```ts
1120
+ * declare const selected: string[];
1121
+ * // ---cut---
1122
+ * try {
1123
+ * const { pid } = await plugin.app.openWindow(selected.slice(0, 64));
1124
+ * console.log("temporary window", pid);
1125
+ * } catch (error) {
1126
+ * // `builtin-only`: not a built-in plugin; `unsupported`: macOS.
1127
+ * if ((error as PluginError).code !== "builtin-only") throw error;
1128
+ * }
1129
+ * ```
1130
+ *
1131
+ * @player 0.10.3
1132
+ * @since 1.10.1
1133
+ */
1134
+ openWindow(paths: readonly string[]): Promise<{
1135
+ /** The new player's process id. */
1136
+ readonly pid: number;
1137
+ }>;
1060
1138
  }
1061
1139
  /**
1062
1140
  * What {@link App.system} reports.
@@ -1220,12 +1220,12 @@ export interface Commands {
1220
1220
  * const row = commands.find((each) => each.id === "vestra.subtitles/tuning");
1221
1221
  * if (row?.keys[0]) await plugin.osd.show("Press {}", [row.keys[0]]);
1222
1222
  * } catch (error) {
1223
- * // `capability`: not a built-in plugin.
1224
- * if ((error as PluginError).code !== "capability") throw error;
1223
+ * // `builtin-only`: not a built-in plugin.
1224
+ * if ((error as PluginError).code !== "builtin-only") throw error;
1225
1225
  * }
1226
1226
  * ```
1227
1227
  *
1228
- * @throws `capability` (rejects) The plugin is not built into the player.
1228
+ * @throws `builtin-only` (rejects) The plugin is not built into the player.
1229
1229
  * @player 0.7.6
1230
1230
  * @since 1.7.9
1231
1231
  */
@@ -1297,7 +1297,7 @@ export interface Commands {
1297
1297
  * });
1298
1298
  * ```
1299
1299
  *
1300
- * @throws `capability` (rejects) The plugin is not built into the player.
1300
+ * @throws `builtin-only` (rejects) The plugin is not built into the player.
1301
1301
  * @throws `ticket` (rejects) No ticket, or it ended or expired.
1302
1302
  * @throws `missing` (rejects) No listed command has this id, or one of
1303
1303
  * the ids of `then`.
@@ -1486,7 +1486,7 @@ export interface Palette {
1486
1486
  * @example See Palette
1487
1487
  * {@link Palette}
1488
1488
  *
1489
- * @throws `capability` (through `ready`) The plugin is not built into the player.
1489
+ * @throws `builtin-only` (through `ready`) The plugin is not built into the player.
1490
1490
  * @throws `conflict` (through `ready`) Another plugin holds the lead.
1491
1491
  * @throws `invalid` (through `ready`) A text over its length.
1492
1492
  * @player 0.7.6
@@ -1632,7 +1632,7 @@ export interface PaletteLead extends Disposable {
1632
1632
  /**
1633
1633
  * Settles when the player has the row.
1634
1634
  *
1635
- * @throws `capability` (rejects) The plugin is not built into the player.
1635
+ * @throws `builtin-only` (rejects) The plugin is not built into the player.
1636
1636
  * @throws `conflict` (rejects) Another plugin holds the lead.
1637
1637
  * @throws `invalid` (rejects) A text over its length.
1638
1638
  */
@@ -1644,7 +1644,7 @@ export interface PaletteLead extends Disposable {
1644
1644
  * {@link PaletteLead}
1645
1645
  *
1646
1646
  * @throws `invalid` (rejects) A text over its length.
1647
- * @throws `capability` (rejects) The row was refused (see `ready`).
1647
+ * @throws `builtin-only` (rejects) The row was refused (see `ready`).
1648
1648
  * @since 1.7.9
1649
1649
  */
1650
1650
  update(options: PaletteLeadOptions): Promise<void>;
@@ -1691,7 +1691,7 @@ export interface PaletteLead extends Disposable {
1691
1691
  * });
1692
1692
  * ```
1693
1693
  *
1694
- * @throws `capability` (rejects) The plugin is not built into the player.
1694
+ * @throws `builtin-only` (rejects) The plugin is not built into the player.
1695
1695
  * @since 1.7.9
1696
1696
  */
1697
1697
  done(ticket: string): Promise<void>;
@@ -1,4 +1,4 @@
1
- import type { Plugin } from "./base.ts";
1
+ import type { AppInfo, Plugin } from "./base.ts";
2
2
  import type { Disposable } from "./base.ts";
3
3
  /**
4
4
  * The manifest of a package, as validated. The display fields and
@@ -160,6 +160,9 @@ export interface PackageCandidate {
160
160
  * needed).
161
161
  * @throws `stale` (rejects) The candidate is older than the 32 the player
162
162
  * keeps.
163
+ * @throws `unavailable` (rejects) The player is a temporary window
164
+ * ({@link AppInfo.temporary}, player 0.10.3): it runs the main window's
165
+ * plugins as they are and installs or updates none.
163
166
  *
164
167
  * @example Replace a plugin installed from another source
165
168
  * The new package replaces the installed plugin even though it came from
@@ -531,6 +534,9 @@ export interface Packages {
531
534
  * @throws `missing` (rejects) An unknown id.
532
535
  * @throws `busy` (rejects) The plugin is being installed or reloaded.
533
536
  * @throws `unsupported` (rejects) A built-in plugin.
537
+ * @throws `unavailable` (rejects) The player is a temporary window
538
+ * ({@link AppInfo.temporary}, player 0.10.3): it runs the main window's
539
+ * plugins as they are and enables or disables none.
534
540
  *
535
541
  * @example Turn a third-party plugin off
536
542
  * The plugin stops another plugin and keeps it disabled across launches
@@ -590,6 +596,9 @@ export interface Packages {
590
596
  * plugin is being installed or reloaded.
591
597
  * @throws `revisionConflict` (rejects) The installed revision of that
592
598
  * plugin changed meanwhile; call `uninstall` again.
599
+ * @throws `unavailable` (rejects) The player is a temporary window
600
+ * ({@link AppInfo.temporary}, player 0.10.3): it runs the main window's
601
+ * plugins as they are and removes none.
593
602
  *
594
603
  * @example Uninstall a plugin together with its data
595
604
  * The other plugin is removed and its data directory deleted, so a later