@vestra-player/sdk 1.6.21 → 1.7.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.
- package/CHANGELOG.md +55 -0
- package/bin/vestra-plugin.mjs +34 -12
- package/dist/api-requests.d.ts +22 -0
- package/dist/api-requests.js +38 -0
- package/dist/capability-check.d.ts +48 -0
- package/dist/capability-check.js +219 -51
- package/dist/capability-rules.d.ts +21 -0
- package/dist/capability-rules.js +32 -1
- package/dist/commands.d.ts +9 -1
- package/dist/commands.js +8 -8
- package/dist/docs-tree.json.gz +0 -0
- package/dist/plugin/commands.js +43 -13
- package/dist/plugin/connection.d.ts +37 -0
- package/dist/plugin/connection.js +34 -0
- package/dist/plugin/index.js +12 -2
- package/dist/plugin/media.js +3 -1
- package/dist/plugin/packages.js +3 -1
- package/dist/plugin/passes.d.ts +38 -1
- package/dist/plugin/passes.js +89 -5
- package/dist/plugin/player/events.d.ts +9 -0
- package/dist/plugin/player/events.js +43 -0
- package/dist/plugin/player/rules.d.ts +7 -0
- package/dist/plugin/player/rules.js +11 -0
- package/dist/plugin/player.d.ts +37 -4
- package/dist/plugin/player.js +85 -12
- package/dist/plugin/resolvers.js +2 -3
- package/dist/plugin/runtime.d.ts +2 -3
- package/dist/plugin/runtime.js +8 -2
- package/dist/plugin/scope.d.ts +9 -0
- package/dist/plugin/scope.js +24 -0
- package/dist/plugin/services.js +4 -5
- package/dist/plugin/state.d.ts +3 -0
- package/dist/plugin/state.js +81 -0
- package/dist/plugin/stream.d.ts +27 -3
- package/dist/plugin/testing/commands.js +3 -3
- package/dist/plugin/testing/core-actions.js +1 -1
- package/dist/plugin/testing/services.js +1 -1
- package/dist/plugin/types/base.d.ts +78 -2
- package/dist/plugin/types/commands.d.ts +17 -1
- package/dist/plugin/types/playback.d.ts +156 -1
- package/dist/plugin/types/plugin-wire.d.ts +589 -0
- package/dist/plugin/types/plugin-wire.js +1 -0
- package/dist/plugin/types/ui-content.d.ts +23 -4
- package/dist/plugin/types/ui-layout.d.ts +1 -1
- package/dist/plugin/types/ui-shell.d.ts +4 -3
- package/dist/plugin/types.d.ts +4 -2
- package/dist/plugin/view/base.d.ts +10 -3
- package/dist/plugin/view/base.js +30 -6
- package/dist/plugin/view/binder.js +8 -1
- package/dist/plugin/view/writer.d.ts +49 -4
- package/dist/plugin/view/writer.js +383 -17
- package/dist/plugin/wire-facade.d.ts +4 -0
- package/dist/plugin/wire-facade.js +190 -0
- package/dist/ts-plugin.d.ts +3 -0
- package/dist/ts-plugin.js +18 -6
- package/dist/wire.d.ts +233 -20
- package/llms.txt +3 -3
- package/package.json +1 -1
- package/slint/vestra/focus.slint +33 -0
|
@@ -3,9 +3,13 @@ import type { PluginInfo } from "./packages.ts";
|
|
|
3
3
|
import type { MediaCapture } from "./snapshots.ts";
|
|
4
4
|
import type { FileResolverOptions, Resolver } from "./sources.ts";
|
|
5
5
|
import type { View } from "./ui-content.ts";
|
|
6
|
+
import type { Scope, WindowState } from "./base.ts";
|
|
6
7
|
import type { Disposable, PluginError } from "./base.ts";
|
|
7
8
|
import type { Bindable } from "./commands.ts";
|
|
8
9
|
import type { Text } from "./ui-locale.ts";
|
|
10
|
+
import type { CommandKeys } from "../../commands.ts";
|
|
11
|
+
import type { SourceState } from "../../source.ts";
|
|
12
|
+
import type { PackageInfo, WindowFacts, WireTimeline, WireUpscalingState } from "../../wire.ts";
|
|
9
13
|
/**
|
|
10
14
|
* What a timeline mark stands for; readers choose colours by it.
|
|
11
15
|
*
|
|
@@ -951,7 +955,13 @@ export interface PlaybackStats {
|
|
|
951
955
|
* @category Playback
|
|
952
956
|
*/
|
|
953
957
|
export interface Player {
|
|
954
|
-
/**
|
|
958
|
+
/**
|
|
959
|
+
* Latest state; always newer than anything delivered before.
|
|
960
|
+
*
|
|
961
|
+
* With `events` the SDK follows the player's events for this copy from
|
|
962
|
+
* the plugin's start; without it the copy moves only with the start-up
|
|
963
|
+
* read and the plugin's own calls (`playback.read`).
|
|
964
|
+
*/
|
|
955
965
|
readonly state: PlayerState;
|
|
956
966
|
/**
|
|
957
967
|
* The state changed (needs `events` for outside changes).
|
|
@@ -974,6 +984,63 @@ export interface Player {
|
|
|
974
984
|
* @since 1.0.0
|
|
975
985
|
*/
|
|
976
986
|
onChange(listener: (state: PlayerState) => void): Disposable;
|
|
987
|
+
/**
|
|
988
|
+
* Listen to one event of the player, with its data as the player sent
|
|
989
|
+
* it: no state copy, no comparison.
|
|
990
|
+
*
|
|
991
|
+
* @remarks
|
|
992
|
+
* `event` is one of the {@link HostEvent} names (`"source.state"`,
|
|
993
|
+
* `"window.state"`, `"timeline.changed"`…), whatever part of the plugin
|
|
994
|
+
* API it concerns; `listener` gets a copy of that event's data, typed
|
|
995
|
+
* {@link EventPayload} (`source.state`: the player's source state, with
|
|
996
|
+
* `rate`, `paused`, `position`, `stamp`…). Each subscription counts as a
|
|
997
|
+
* listener of the plugin: the player keeps the plugin running while one
|
|
998
|
+
* exists (unless the event is one the player wakes a stopped plugin for),
|
|
999
|
+
* and its log names where the plugin added it
|
|
1000
|
+
* (`a listener added at main.ts:12`). Every name, its payload and its
|
|
1001
|
+
* capability: [Events](../../../docs/reference/events.md).
|
|
1002
|
+
*
|
|
1003
|
+
* Unlike {@link Player.onChange} it does not start the SDK's copy of the
|
|
1004
|
+
* state: `plugin.player.state` is not kept current by it, and the
|
|
1005
|
+
* listener runs for every event, changed or not. It suits pushing
|
|
1006
|
+
* values yourself (`view.set` from the listener) or reading a field the
|
|
1007
|
+
* SDK does not expose. Errors go to {@link Scope.onError}, as for every
|
|
1008
|
+
* handler; unlike the others, no full update pass follows it, so bound
|
|
1009
|
+
* values do not re-evaluate on every event: a write to a
|
|
1010
|
+
* {@link Scope.state} field re-runs only its readers, and
|
|
1011
|
+
* {@link Scope.update} re-runs everything.
|
|
1012
|
+
*
|
|
1013
|
+
* Each event needs a capability: `events` for most, `bindings.manage`
|
|
1014
|
+
* for `bindings.changed`, `commands` for `commands.keys`,
|
|
1015
|
+
* `video.upscaling` for `video.upscaling.changed`, none for
|
|
1016
|
+
* `packages.changed`. Without it the listener never runs (for `events`,
|
|
1017
|
+
* a warning in the log says so). An event an older player does not know
|
|
1018
|
+
* yet (`commands.keys`, `video.upscaling.changed`) is refused with
|
|
1019
|
+
* `unsupported`; added during `activate`, that fails the activation.
|
|
1020
|
+
*
|
|
1021
|
+
* @param event - The event's name.
|
|
1022
|
+
* @param listener - Receives each event's data.
|
|
1023
|
+
* @returns A handle that stops listening; it is disposed with the scope.
|
|
1024
|
+
*
|
|
1025
|
+
* @throws `invalid` (throws) `event` is not a {@link HostEvent} name, or
|
|
1026
|
+
* `listener` is not a function.
|
|
1027
|
+
*
|
|
1028
|
+
* @capability That of the event: `events`, or `bindings.manage`,
|
|
1029
|
+
* `commands`, `video.upscaling` for the events named above.
|
|
1030
|
+
*
|
|
1031
|
+
* @example Push the speed to a panel as it changes
|
|
1032
|
+
* A bottom panel shows the playback speed. The listener gets each
|
|
1033
|
+
* `source.state` event's data and writes the text with `set`; no update
|
|
1034
|
+
* pass runs and the SDK keeps no copy of the state for this.
|
|
1035
|
+
* ```ts
|
|
1036
|
+
* const bar = plugin.panels.mount("bottom", "ui/bar.slint");
|
|
1037
|
+
* plugin.player.on("source.state", (s) => bar.set({ rate: `${s.rate.toFixed(2)}×` }));
|
|
1038
|
+
* ```
|
|
1039
|
+
*
|
|
1040
|
+
* @see [Three ways to write a plugin](../../../docs/explanation/three-ways.md)
|
|
1041
|
+
* @since 1.7.0
|
|
1042
|
+
*/
|
|
1043
|
+
on<E extends HostEvent>(event: E, listener: (data: EventPayload<E>) => void): Disposable;
|
|
977
1044
|
/**
|
|
978
1045
|
* Read the state from the player now (`playback.read`).
|
|
979
1046
|
*
|
|
@@ -1652,3 +1719,91 @@ export interface Player {
|
|
|
1652
1719
|
*/
|
|
1653
1720
|
setAudioDevice(id: string | null): Promise<void>;
|
|
1654
1721
|
}
|
|
1722
|
+
/**
|
|
1723
|
+
* The events a plugin can listen to with {@link Player.on}, by the name
|
|
1724
|
+
* the player gives them.
|
|
1725
|
+
*
|
|
1726
|
+
* @remarks
|
|
1727
|
+
* The same names the SDK subscribes to for its own copies of the player's
|
|
1728
|
+
* state (`plugin.player.state`, `plugin.window.state`,
|
|
1729
|
+
* `plugin.timeline.marks`…). {@link EventPayloads} says what each one
|
|
1730
|
+
* carries. A name outside this list is refused with `invalid`.
|
|
1731
|
+
*
|
|
1732
|
+
* @example Name the event a listener follows
|
|
1733
|
+
* A plugin logs each change of its own key labels. The name completes in
|
|
1734
|
+
* the editor, and the listener's parameter takes the type of that event's
|
|
1735
|
+
* data.
|
|
1736
|
+
* ```ts
|
|
1737
|
+
* const event: HostEvent = "commands.keys";
|
|
1738
|
+
* plugin.player.on(event, (data) => console.log("keys changed", data));
|
|
1739
|
+
* ```
|
|
1740
|
+
*
|
|
1741
|
+
* @since 1.7.0
|
|
1742
|
+
* @category Playback
|
|
1743
|
+
*/
|
|
1744
|
+
export type HostEvent = "source.state" | "playback.backend" | "window.state" | "packages.changed" | "bindings.changed" | "commands.keys" | "timeline.changed" | "appearance.changed" | "resolvers.fileTypes" | "video.upscaling.changed";
|
|
1745
|
+
/**
|
|
1746
|
+
* The data each {@link HostEvent} carries, as the player sends it: the
|
|
1747
|
+
* listener of {@link Player.on} gets a copy.
|
|
1748
|
+
*
|
|
1749
|
+
* @remarks
|
|
1750
|
+
* These are the player's wire shapes, not the SDK's views of them: field
|
|
1751
|
+
* names and units are the player's (`source.state` names the source
|
|
1752
|
+
* generation `stamp.generation`, where {@link PlayerState} says
|
|
1753
|
+
* `sourceId`). They follow the player's protocol and can gain fields with
|
|
1754
|
+
* a player version.
|
|
1755
|
+
*
|
|
1756
|
+
* @since 1.7.0
|
|
1757
|
+
* @category Playback
|
|
1758
|
+
*/
|
|
1759
|
+
export interface EventPayloads {
|
|
1760
|
+
/** The player's source: phase, position, rate, volume, its stamp (what {@link PlayerState} is made from). */
|
|
1761
|
+
"source.state": SourceState;
|
|
1762
|
+
/** A playback backend event: the backend's name for it (`event`) and the source generation it belongs to. */
|
|
1763
|
+
"playback.backend": {
|
|
1764
|
+
/** The source generation it belongs to. */
|
|
1765
|
+
currentSession: number;
|
|
1766
|
+
/** The backend's name for the event. */
|
|
1767
|
+
event: string;
|
|
1768
|
+
};
|
|
1769
|
+
/** The main window: fullscreen, maximized, video area, picture-in-picture (what {@link WindowState} is made from). */
|
|
1770
|
+
"window.state": WindowFacts;
|
|
1771
|
+
/** Every installed plugin, after an install, an uninstall or a change of one (needs no capability). */
|
|
1772
|
+
"packages.changed": PackageInfo[];
|
|
1773
|
+
/** A key binding changed somewhere; read them again with `plugin.bindings.list()`. */
|
|
1774
|
+
"bindings.changed": null;
|
|
1775
|
+
/** The key labels of this plugin's own commands, with the binding table's revision. */
|
|
1776
|
+
"commands.keys": CommandKeys;
|
|
1777
|
+
/** Every timeline mark and range, after any plugin or the player changed one. */
|
|
1778
|
+
"timeline.changed": WireTimeline;
|
|
1779
|
+
/** The palette changed (`theme`), or the interface language the user saved (`language`; the oldest players send no language). */
|
|
1780
|
+
"appearance.changed": {
|
|
1781
|
+
/** The palette now (`ThemeId`; a newer player may name one this SDK does not list). */
|
|
1782
|
+
theme: string;
|
|
1783
|
+
/** The interface language the user saved, `"system"` or a locale (absent from the oldest players). */
|
|
1784
|
+
language?: string;
|
|
1785
|
+
};
|
|
1786
|
+
/** The file extensions the plugins' file resolvers claim now. */
|
|
1787
|
+
"resolvers.fileTypes": {
|
|
1788
|
+
/** The extensions, lower case without the dot. */
|
|
1789
|
+
fileTypes: string[];
|
|
1790
|
+
};
|
|
1791
|
+
/** The AI upscaling state, without this plugin's own `enabled`. */
|
|
1792
|
+
"video.upscaling.changed": Omit<WireUpscalingState, "enabled">;
|
|
1793
|
+
}
|
|
1794
|
+
/**
|
|
1795
|
+
* The data of event `E`, as the listener of {@link Player.on} gets it.
|
|
1796
|
+
*
|
|
1797
|
+
* @example Type a listener kept apart from the call
|
|
1798
|
+
* A function that handles the player's source state is written on its
|
|
1799
|
+
* own and passed to `on` later. `EventPayload` gives its parameter the
|
|
1800
|
+
* type of that event's data.
|
|
1801
|
+
* ```ts
|
|
1802
|
+
* const showRate = (s: EventPayload<"source.state">) => void plugin.osd.show("{}×", [s.rate]);
|
|
1803
|
+
* plugin.player.on("source.state", showRate);
|
|
1804
|
+
* ```
|
|
1805
|
+
*
|
|
1806
|
+
* @since 1.7.0
|
|
1807
|
+
* @category Playback
|
|
1808
|
+
*/
|
|
1809
|
+
export type EventPayload<E extends HostEvent> = EventPayloads[E];
|