@vestra-player/sdk 1.7.20 → 1.8.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.
@@ -1790,3 +1790,188 @@ export interface EventPayloads {
1790
1790
  * @category Playback
1791
1791
  */
1792
1792
  export type EventPayload<E extends HostEvent> = EventPayloads[E];
1793
+ /**
1794
+ * A value of mpv, as JSON: what a property holds, a command returns or an
1795
+ * argument of `set` is (mpv's "node": nothing, a flag, a number, a string,
1796
+ * a list or a map of them).
1797
+ *
1798
+ * @since 1.8.0
1799
+ * @category Playback
1800
+ */
1801
+ export type MpvValue = null | boolean | number | string | MpvValue[] | {
1802
+ [key: string]: MpvValue;
1803
+ };
1804
+ /**
1805
+ * `plugin.mpv`: mpv's own commands and properties, sent to the player's
1806
+ * mpv as they are. Needs the capability `mpv`, which the store shows the
1807
+ * user before installing.
1808
+ *
1809
+ * @example Turn mpv's debanding on and show whether it took effect
1810
+ * A plugin offers mpv's `deband` option, which the plugin API has no member
1811
+ * for. `set` writes the property and `get` reads it back; the names and
1812
+ * the values are mpv's.
1813
+ * ```ts
1814
+ * await plugin.mpv.set("deband", true);
1815
+ * const on = await plugin.mpv.get("deband");
1816
+ * await plugin.osd.show(on ? "Debanding on" : "Debanding off");
1817
+ * ```
1818
+ *
1819
+ * @remarks
1820
+ * The channel is the SDK's contract: four members, their errors, what is
1821
+ * refused and who owns what. The names, the arguments and what they do are
1822
+ * mpv's, as its manual describes them for the mpv the player ships
1823
+ * ([commands](https://mpv.io/manual/stable/#list-of-input-commands),
1824
+ * [properties](https://mpv.io/manual/stable/#properties),
1825
+ * [options](https://mpv.io/manual/stable/#options)); they can change with
1826
+ * a player version, which the SDK does not track. Prefer a typed member
1827
+ * where one exists ({@link Player}, {@link Scope.video}, {@link Scope.subtitles}):
1828
+ * it is checked, tested by {@link "@vestra-player/sdk/testing"!TestHost | TestHost} and reaches snapshots and
1829
+ * exports, which a filter added here does not.
1830
+ *
1831
+ * Refused with code `refused` (the message names the command or property
1832
+ * and why): what starts a program, loads scripts or configuration, opens a
1833
+ * control channel, makes the player write or delete files, ends the player,
1834
+ * drives its keyboard and mouse, reaches the clipboard, or changes what the
1835
+ * player manages itself (the source and the playlist, the position, the
1836
+ * tracks, the output, the window, the subtitle style, the renderer options
1837
+ * of {@link Scope.video}, its own filters). A plugin does the first four with
1838
+ * Node; the last has a typed member. Reading is not refused, except the
1839
+ * clipboard. The full table is in [mpv](../../../docs/reference/mpv.md).
1840
+ *
1841
+ * Filters: `["vf", "add", "@label:…"]` (and `af`; `add`, `pre`, `toggle`,
1842
+ * `remove`) with a label of the plugin's own, not starting with `vestra-`
1843
+ * and not `all`.
1844
+ * A labelled filter belongs to the plugin that added it: another plugin
1845
+ * cannot change it (`conflict`), and the player removes it when the plugin
1846
+ * stops. The player's own filters (the typed chains of {@link Scope.video},
1847
+ * the upscaler, motion smoothing) stay in the chain beside it.
1848
+ *
1849
+ * A property a plugin set keeps its value after the plugin stops, until
1850
+ * the player quits (what the capability `mpv` discloses); a plugin that
1851
+ * wants it back sets it back. Observers end with the plugin. A filter
1852
+ * or an observer keeps the plugin running.
1853
+ *
1854
+ * @capability mpv
1855
+ * @see [mpv](../../../docs/reference/mpv.md)
1856
+ * @since 1.8.0
1857
+ * @category Playback
1858
+ */
1859
+ export interface Mpv {
1860
+ /**
1861
+ * Run an mpv command: its name, then its arguments, as mpv's manual lists
1862
+ * them. Resolves with the command's result (`null` for most).
1863
+ *
1864
+ * @param args - The command's name and its arguments: strings, numbers
1865
+ * or booleans. The first is the command itself: mpv would take a
1866
+ * prefix word (`no-osd`, `async`, `raw`…) off the front and run what
1867
+ * follows, so the channel refuses one there (`invalid`). Arguments are
1868
+ * not expanded (`${property}` stays text).
1869
+ * @returns What the command returns.
1870
+ *
1871
+ * @example Add a filter of the plugin's own and remove it again
1872
+ * A plugin sharpens the picture with an FFmpeg filter the typed chain
1873
+ * does not offer, and takes it out when the user switches it off. The
1874
+ * label makes the filter the plugin's: the player removes it by itself
1875
+ * when the plugin stops.
1876
+ * ```ts
1877
+ * await plugin.mpv.command(["vf", "add", "@crisp:lavfi=[cas=strength=0.6]"]);
1878
+ * // later
1879
+ * await plugin.mpv.command(["vf", "remove", "@crisp"]);
1880
+ * ```
1881
+ *
1882
+ * @capability mpv
1883
+ * @throws `capability` (rejects) The manifest does not declare `mpv`.
1884
+ * @throws `invalid` (rejects) Not an array of a name and up to 31
1885
+ * arguments, or an argument that is not a string, number or boolean.
1886
+ * @throws `refused` (rejects) A command the channel does not carry; the
1887
+ * message names it and why.
1888
+ * @throws `conflict` (rejects) A filter label another plugin owns.
1889
+ * @throws `backend` (rejects) mpv failed the command; `message` is
1890
+ * mpv's error ("mpv: invalid parameter").
1891
+ * @since 1.8.0
1892
+ */
1893
+ command(args: readonly (string | number | boolean)[]): Promise<MpvValue>;
1894
+ /**
1895
+ * Read an mpv property now.
1896
+ *
1897
+ * @param name - The property, as mpv names it (`"estimated-vf-fps"`,
1898
+ * `"video-params/w"`).
1899
+ * @returns Its value.
1900
+ *
1901
+ * @example Show the decoder in use
1902
+ * A statistics panel reads which hardware decoder mpv uses now.
1903
+ * `get` resolves with mpv's value: here a string, `"no"` without one.
1904
+ * ```ts
1905
+ * const decoder = await plugin.mpv.get("hwdec-current");
1906
+ * await plugin.osd.show("Decoder: {}", [String(decoder)]);
1907
+ * ```
1908
+ *
1909
+ * @capability mpv
1910
+ * @throws `capability` (rejects) The manifest does not declare `mpv`.
1911
+ * @throws `invalid` (rejects) Not a property name.
1912
+ * @throws `refused` (rejects) The clipboard's properties.
1913
+ * @throws `backend` (rejects) mpv has no such property, or it has no
1914
+ * value now ("mpv: property not found", "mpv: property unavailable").
1915
+ * @since 1.8.0
1916
+ */
1917
+ get(name: string): Promise<MpvValue>;
1918
+ /**
1919
+ * Set an mpv property (or option). It keeps the value after the plugin
1920
+ * stops, until the player quits.
1921
+ *
1922
+ * @param name - The property, as mpv names it.
1923
+ * @param value - Its new value, in the type mpv has for it.
1924
+ *
1925
+ * @example Use a sharper scaler while a panel is open
1926
+ * A plugin switches mpv's scaler and puts the old one back when its
1927
+ * panel closes. The value is read first, since `set` does not undo
1928
+ * itself.
1929
+ * ```ts
1930
+ * const before = await plugin.mpv.get("scale");
1931
+ * await plugin.mpv.set("scale", "ewa_lanczossharp");
1932
+ * // when the panel closes
1933
+ * await plugin.mpv.set("scale", before);
1934
+ * ```
1935
+ *
1936
+ * @capability mpv
1937
+ * @throws `capability` (rejects) The manifest does not declare `mpv`.
1938
+ * @throws `invalid` (rejects) Not a property name, or no value.
1939
+ * @throws `refused` (rejects) A property the channel does not carry; the
1940
+ * message names it and why.
1941
+ * @throws `backend` (rejects) mpv refused the value or has no such
1942
+ * property; `message` is mpv's error.
1943
+ * @since 1.8.0
1944
+ */
1945
+ set(name: string, value: MpvValue): Promise<void>;
1946
+ /**
1947
+ * Hear an mpv property's value now and after each change. The player
1948
+ * sends the newest value at most every 100 ms. While a listener exists
1949
+ * the player keeps the plugin running.
1950
+ *
1951
+ * @param name - The property, as mpv names it.
1952
+ * @param listener - Receives the value: first the current one, then
1953
+ * each change.
1954
+ * @returns A handle that stops listening; it is disposed with the scope.
1955
+ *
1956
+ * @example Follow the frame rate after filters
1957
+ * A panel shows the frame rate mpv measures behind its filter chain.
1958
+ * The listener runs with the current value and again whenever it
1959
+ * changes; a failure to observe goes to `plugin.onError`.
1960
+ * ```ts
1961
+ * declare const panel: Panel;
1962
+ * // ---cut---
1963
+ * plugin.mpv.observe("estimated-vf-fps", (fps) => {
1964
+ * panel.set({ fps: typeof fps === "number" ? fps.toFixed(1) : "—" });
1965
+ * });
1966
+ * ```
1967
+ *
1968
+ * @capability mpv
1969
+ * @throws `capability` (throws) The manifest does not declare `mpv`.
1970
+ * @throws `invalid` (throws) Not a property name, or no listener.
1971
+ * @throws `refused` (throws) The clipboard's properties.
1972
+ * @throws `limit` (through `onError`) More than 64 properties observed
1973
+ * by this plugin.
1974
+ * @since 1.8.0
1975
+ */
1976
+ observe(name: string, listener: (value: MpvValue) => void): Disposable;
1977
+ }
package/dist/wire.d.ts CHANGED
@@ -920,6 +920,21 @@ export declare function createWire(transport: Transport): {
920
920
  openPath: (path: string) => Promise<void>;
921
921
  openUrl: (url: string) => Promise<void>;
922
922
  };
923
+ /**
924
+ * The mpv pass-through (`mpv`): commands and properties as mpv names
925
+ * them. The observed values arrive as `mpv.property` events.
926
+ */
927
+ mpv: {
928
+ command: (args: (string | number | boolean)[]) => Promise<{
929
+ result: Json;
930
+ }>;
931
+ get: (name: string) => Promise<{
932
+ value: Json;
933
+ }>;
934
+ set: (name: string, value: Json) => Promise<void>;
935
+ observeProperty: (name: string) => Promise<void>;
936
+ unobserveProperty: (name: string) => Promise<void>;
937
+ };
923
938
  /** The system's secret store, per plugin (`secrets`). */
924
939
  secrets: {
925
940
  get: (name: string) => Promise<string | null>;
package/dist/wire.js CHANGED
@@ -222,6 +222,17 @@ export function createWire(transport) {
222
222
  openPath: (path) => transport.request("system.openPath", { path }),
223
223
  openUrl: (url) => transport.request("system.openUrl", { url }),
224
224
  },
225
+ /**
226
+ * The mpv pass-through (`mpv`): commands and properties as mpv names
227
+ * them. The observed values arrive as `mpv.property` events.
228
+ */
229
+ mpv: {
230
+ command: (args) => transport.request("mpv.command", { args }),
231
+ get: (name) => transport.request("mpv.get", { name }),
232
+ set: (name, value) => transport.request("mpv.set", { name, value }),
233
+ observeProperty: (name) => transport.request("mpv.observe", { name }),
234
+ unobserveProperty: (name) => transport.request("mpv.unobserve", { name }),
235
+ },
225
236
  /** The system's secret store, per plugin (`secrets`). */
226
237
  secrets: {
227
238
  get: (name) => transport.request("secrets.get", { name }),
package/llms.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  # Vestra Player SDK
2
2
 
3
- > @vestra-player/sdk 1.7.20: 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.8.0: 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
 
@@ -28,7 +28,7 @@
28
28
  - `/API/Commands`: 23 entries: CommandState, Bindable, Condition, When, MenuId, BarButtonIcon, CommandButton, CommandOptions, Command, Commands, CommandRunOptions, CommandRunResult, CommandList, CommandInfo, Palette,…
29
29
  - `/API/Media`: 12 entries: CaptureOptions, Snapshot, ExportOptions, ExportEncoding, JobState, ExportJob, MediaCapture, SourceReference, MediaSources, ExportPart, PartsExportOptions, ExportCheck
30
30
  - `/API/Packages`: 10 entries: PackageManifest, PackageSource, InstallOptions, PackageCandidate, PackageChangeStatus, PackageChange, PluginInfo, PluginDisplay, PluginWarning, Packages
31
- - `/API/Playback`: 34 entries: CommandKeys, MarkKind, TimelineMark, RangeStyle, TimelineRange, TimelineLayer, Timeline, AudioTrack, PlayerState, AudioDevice, Chapter, Conditional, Media, Scrub, StreamFrame,…
31
+ - `/API/Playback`: 36 entries: CommandKeys, MarkKind, TimelineMark, RangeStyle, TimelineRange, TimelineLayer, Timeline, AudioTrack, PlayerState, AudioDevice, Chapter, Conditional, Media, Scrub, StreamFrame,…
32
32
  - `/API/Plugin`: 21 entries: Disposable, PluginError, Scope, Plugin, StopReason, DisposeInfo, WindowState, MainWindow, AppInfo, App, SystemInfo, DisplayInfo, Wire, WireView, WireCommands, WireCommandOptions,…
33
33
  - `/API/Processing`: 24 entries: FilterStatus, VideoFilter, AudioFilter, ViewSettings, VideoView, RenderSettings, RenderOptions, VideoShaders, UpscalingReasonCode, UpscalingReason, UpscalingDecodingCause,…
34
34
  - `/API/Services`: 15 entries: Clipboard, Power, ToolResult, Tools, JsonStore, Storage, SessionStorage, System, Secrets, RenderingMode, RenderingPreference, RenderingReasonCode, RenderingReason, RenderingState,…
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vestra-player/sdk",
3
- "version": "1.7.20",
3
+ "version": "1.8.0",
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": {
@@ -33,6 +33,7 @@
33
33
  "default": "./ts-plugin/index.js"
34
34
  },
35
35
  "./llms.txt": "./llms.txt",
36
+ "./capability-scan.json": "./capability-scan.json",
36
37
  "./package.json": "./package.json"
37
38
  },
38
39
  "bin": {
@@ -46,7 +47,8 @@
46
47
  "README.md",
47
48
  "CHANGELOG.md",
48
49
  "LICENSE",
49
- "llms.txt"
50
+ "llms.txt",
51
+ "capability-scan.json"
50
52
  ],
51
53
  "scripts": {
52
54
  "api-surface": "node scripts/api-surface.mjs",
@@ -149,9 +149,12 @@ export component ToolTipArea {
149
149
  // Dialog button: text (21px, or 18px when `small`), or an icon button when
150
150
  // `text` is empty and `icon` holds Path data drawn in an icon-width × icon-height
151
151
  // viewbox (filled, or 1.5px round-capped lines when `stroked`, as the
152
- // @vestra/icons.slint set). The caller sizes icon buttons.
152
+ // @vestra/icons.slint set). The caller sizes icon buttons. `key`: the key that
153
+ // presses it, in a `KeyHint` 6px after the text ([Run `Enter`]); empty (the
154
+ // default) draws nothing and takes no space.
153
155
  export component Button {
154
156
  in property <string> text;
157
+ in property <string> key;
155
158
  in property <string> icon;
156
159
  in property <length> icon-width: 14px;
157
160
  in property <length> icon-height: 12px;
@@ -170,7 +173,7 @@ export component Button {
170
173
  preferred-height: self.min-height;
171
174
  // A longer (translated) label widens the button instead of overflowing it.
172
175
  preferred-width: root.icon-only ? self.min-width
173
- : max(self.min-width, label.preferred-width + 2 * Theme.button-padding);
176
+ : max(self.min-width, row.preferred-width);
174
177
  accessible-role: button;
175
178
  accessible-label: root.text;
176
179
  accessible-enabled: root.enabled;
@@ -183,16 +186,21 @@ export component Button {
183
186
  background: !root.enabled ? Theme.button-disabled
184
187
  : touch.pressed ? Theme.button-press
185
188
  : touch.has-hover ? Theme.button-hover : Theme.button-bg;
186
- HorizontalLayout {
189
+ row := HorizontalLayout {
187
190
  padding-left: Theme.button-padding;
188
191
  padding-right: Theme.button-padding;
192
+ spacing: root.key == "" ? 0px : 6px;
189
193
  alignment: center;
190
- label := Text {
194
+ Text {
191
195
  text: root.text;
192
196
  color: root.enabled ? Theme.text-list : Theme.text-dim;
193
197
  font-size: Theme.font-body;
194
198
  vertical-alignment: center;
195
199
  }
200
+ VerticalLayout {
201
+ alignment: center;
202
+ KeyHint { text: root.key; }
203
+ }
196
204
  }
197
205
  }
198
206
  if root.icon-only: Path {