@vestra-player/sdk 1.9.0 → 1.10.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 (53) hide show
  1. package/CHANGELOG.md +44 -7
  2. package/bin/vestra-plugin.mjs +89 -8
  3. package/capability-scan.json +20 -0
  4. package/dist/api-requests.d.ts +4 -3
  5. package/dist/api-requests.js +11 -3
  6. package/dist/commands.js +1 -0
  7. package/dist/condition-table.d.ts +1889 -0
  8. package/dist/condition-table.js +562 -0
  9. package/dist/docs-tree.json.gz +0 -0
  10. package/dist/i18n-tools.d.ts +7 -0
  11. package/dist/i18n-tools.js +66 -3
  12. package/dist/player-runtime.d.ts +3 -0
  13. package/dist/player-runtime.js +3 -0
  14. package/dist/plugin/connection.d.ts +13 -2
  15. package/dist/plugin/connection.js +67 -4
  16. package/dist/plugin/index.d.ts +7 -0
  17. package/dist/plugin/index.js +13 -0
  18. package/dist/plugin/mpv.js +39 -5
  19. package/dist/plugin/player/events.d.ts +14 -5
  20. package/dist/plugin/player/events.js +19 -3
  21. package/dist/plugin/player.d.ts +16 -0
  22. package/dist/plugin/player.js +77 -1
  23. package/dist/plugin/scope.d.ts +4 -1
  24. package/dist/plugin/scope.js +8 -0
  25. package/dist/plugin/testing/commands.d.ts +5 -0
  26. package/dist/plugin/testing/commands.js +23 -24
  27. package/dist/plugin/testing/index.d.ts +134 -0
  28. package/dist/plugin/testing/index.js +180 -21
  29. package/dist/plugin/testing/media.d.ts +6 -0
  30. package/dist/plugin/testing/media.js +15 -2
  31. package/dist/plugin/testing/services.js +50 -1
  32. package/dist/plugin/testing/source-events.d.ts +28 -0
  33. package/dist/plugin/testing/source-events.js +66 -0
  34. package/dist/plugin/testing/transport.js +5 -0
  35. package/dist/plugin/testing/triggers.d.ts +82 -0
  36. package/dist/plugin/testing/triggers.js +448 -0
  37. package/dist/plugin/timeline.d.ts +3 -3
  38. package/dist/plugin/timeline.js +3 -3
  39. package/dist/plugin/triggers.d.ts +55 -0
  40. package/dist/plugin/triggers.js +233 -0
  41. package/dist/plugin/types/base.d.ts +117 -3
  42. package/dist/plugin/types/commands.d.ts +374 -1
  43. package/dist/plugin/types/packages.d.ts +10 -1
  44. package/dist/plugin/types/playback.d.ts +257 -9
  45. package/dist/plugin/types/services.d.ts +10 -4
  46. package/dist/plugin/when.d.ts +78 -4
  47. package/dist/plugin/when.js +182 -14
  48. package/dist/slint-version.d.ts +7 -0
  49. package/dist/slint-version.js +7 -0
  50. package/dist/wire.d.ts +18 -0
  51. package/dist/wire.js +12 -0
  52. package/llms.txt +4 -4
  53. package/package.json +2 -2
@@ -1,5 +1,7 @@
1
1
  import { LOCALES } from "../i18n.js";
2
2
  import { THEMES } from "./appearance.js";
3
+ import { failure } from "./errors.js";
4
+ import { TIMELINE_LIMITS } from "./timeline.js";
3
5
  const PHASES = [
4
6
  "empty",
5
7
  "loading",
@@ -51,7 +53,83 @@ export function conditionJson(condition) {
51
53
  throw new TypeError("a condition comes from plugin.when");
52
54
  return ConditionImpl.json(condition);
53
55
  }
56
+ /** Whether a wire condition reads the position or the clock (a trigger's only). */
57
+ export function readsPositionOrTime(json) {
58
+ if ("position" in json || "time" in json)
59
+ return true;
60
+ if ("all" in json)
61
+ return json.all.some(readsPositionOrTime);
62
+ if ("any" in json)
63
+ return json.any.some(readsPositionOrTime);
64
+ if ("not" in json)
65
+ return readsPositionOrTime(json.not);
66
+ return false;
67
+ }
68
+ /** How many position lists a wire condition has (at most one is allowed). */
69
+ export function positionLists(json) {
70
+ if ("position" in json)
71
+ return 1;
72
+ if ("all" in json)
73
+ return json.all.reduce((n, c) => n + positionLists(c), 0);
74
+ if ("any" in json)
75
+ return json.any.reduce((n, c) => n + positionLists(c), 0);
76
+ if ("not" in json)
77
+ return positionLists(json.not);
78
+ return 0;
79
+ }
54
80
  const make = (json) => new ConditionImpl(json);
81
+ const finite = (value) => typeof value === "number" && Number.isFinite(value);
82
+ /** A numeric atom's `{ min?, max? }`, checked. */
83
+ function interval(name, bounds) {
84
+ const shape = `${name} takes { min?, max? }: finite numbers, at least one, min < max`;
85
+ if (!bounds || typeof bounds !== "object")
86
+ throw new TypeError(shape);
87
+ const { min, max, ...rest } = bounds;
88
+ if (Object.keys(rest).length)
89
+ throw new TypeError(shape);
90
+ if (min === undefined && max === undefined)
91
+ throw new TypeError(shape);
92
+ if ((min !== undefined && !finite(min)) ||
93
+ (max !== undefined && !finite(max)))
94
+ throw new TypeError(shape);
95
+ if (finite(min) && finite(max) && min >= max)
96
+ throw new TypeError(shape);
97
+ const json = {};
98
+ if (min !== undefined)
99
+ json.min = min;
100
+ if (max !== undefined)
101
+ json.max = max;
102
+ return json;
103
+ }
104
+ function identity(name, id) {
105
+ if (typeof id !== "string" || id.length === 0 || id.length > 256)
106
+ throw new TypeError(`${name} takes an id (a string of 1–256 characters)`);
107
+ return id;
108
+ }
109
+ /** `when.position.in`'s ranges and lead in the wire form. */
110
+ function positionList(ranges, options = {}) {
111
+ const list = [...(ranges ?? [])];
112
+ if (list.length > TIMELINE_LIMITS.ranges)
113
+ throw failure("limit", `a position list holds at most ${TIMELINE_LIMITS.ranges} ranges`);
114
+ const pairs = list.map((range) => {
115
+ const { start, end } = (range ?? {});
116
+ if (!finite(start) || start < 0)
117
+ throw new TypeError("a range starts at a finite number of seconds, 0 or more");
118
+ if (end === undefined || end === null)
119
+ return [start];
120
+ if (!finite(end) || end <= start)
121
+ throw new TypeError("a range ends after its start");
122
+ return [start, end];
123
+ });
124
+ const json = { ranges: pairs };
125
+ const lead = options?.lead;
126
+ if (lead !== undefined) {
127
+ if (!finite(lead) || lead < 0)
128
+ throw new TypeError("lead is a number of seconds, 0 or more");
129
+ json.lead = lead;
130
+ }
131
+ return json;
132
+ }
55
133
  /** The one `plugin.when` (conditions hold no plugin state). */
56
134
  export const WHEN = Object.freeze({
57
135
  open: make({ not: { phase: ["empty"] } }),
@@ -60,6 +138,10 @@ export const WHEN = Object.freeze({
60
138
  paused: make({ all: [{ phase: ["ready"] }, { paused: true }] }),
61
139
  stream: make({ kind: "stream" }),
62
140
  fullscreen: make({ fullscreen: true }),
141
+ muted: make({ muted: true }),
142
+ maximized: make({ maximized: true }),
143
+ pip: make({ pip: true }),
144
+ looping: make({ looping: true }),
63
145
  phase(...phases) {
64
146
  if (!phases.length || phases.some((phase) => !PHASES.includes(phase)))
65
147
  throw new TypeError(`phase is one or more of ${PHASES.join(", ")}`);
@@ -81,26 +163,112 @@ export const WHEN = Object.freeze({
81
163
  throw new TypeError(`language is "system" or one of ${LOCALES.map((l) => `"${l}"`).join(", ")}`);
82
164
  return make({ language });
83
165
  },
166
+ duration: (bounds) => make({ duration: interval("duration", bounds) }),
167
+ volume: (bounds) => make({ volume: interval("volume", bounds) }),
168
+ rate: (bounds) => make({ rate: interval("rate", bounds) }),
169
+ time: (bounds) => make({ time: interval("time", bounds) }),
170
+ audioTrack(id) {
171
+ if (!Number.isInteger(id))
172
+ throw new TypeError("audioTrack takes a track id (an integer)");
173
+ return make({ audioTrack: id });
174
+ },
175
+ subtitleTrack: (id) => make({ subtitleTrack: identity("subtitleTrack", id) }),
176
+ audioDevice: (id) => make({ audioDevice: identity("audioDevice", id) }),
177
+ position: Object.freeze({
178
+ in: (ranges, options) => make({ position: positionList(ranges, options) }),
179
+ }),
84
180
  });
85
- /** Evaluate a wire condition as the player does (for the test host). */
86
- export function evaluate(json, facts) {
181
+ /**
182
+ * The range of `list` the position `at` is in (`start − lead ≤ at < end`):
183
+ * the earliest start when several are, as the player does.
184
+ */
185
+ export function matchedRange(list, at) {
186
+ const lead = list.lead ?? 0;
187
+ let found = null;
188
+ let earliest = Infinity;
189
+ list.ranges.forEach(([start, end], index) => {
190
+ const from = start - lead;
191
+ if (from <= at && at < (end ?? Infinity) && from < earliest) {
192
+ earliest = from;
193
+ found = index;
194
+ }
195
+ });
196
+ return found;
197
+ }
198
+ /** Evaluate a wire condition as the player does, with its range (the test host). */
199
+ export function evaluateTruth(json, facts) {
200
+ const plain = (holds) => ({ holds, range: null });
201
+ const inside = (bounds, value) => typeof value === "number" &&
202
+ (bounds.min === undefined || bounds.min <= value) &&
203
+ (bounds.max === undefined || value < bounds.max);
87
204
  if ("phase" in json)
88
- return json.phase.includes(facts.phase);
205
+ return plain(json.phase.includes(facts.phase));
89
206
  if ("paused" in json)
90
- return facts.paused === json.paused;
207
+ return plain(facts.paused === json.paused);
91
208
  if ("kind" in json)
92
- return facts.kind === json.kind;
209
+ return plain(facts.kind === json.kind);
93
210
  if ("can" in json)
94
- return facts.can[json.can] === true;
211
+ return plain(facts.can[json.can] === true);
95
212
  if ("fullscreen" in json)
96
- return facts.fullscreen === json.fullscreen;
213
+ return plain(facts.fullscreen === json.fullscreen);
97
214
  if ("theme" in json)
98
- return facts.theme === json.theme;
215
+ return plain(facts.theme === json.theme);
99
216
  if ("language" in json)
100
- return facts.language === json.language;
101
- if ("all" in json)
102
- return json.all.every((each) => evaluate(each, facts));
103
- if ("any" in json)
104
- return json.any.some((each) => evaluate(each, facts));
105
- return !evaluate(json.not, facts);
217
+ return plain(facts.language === json.language);
218
+ if ("duration" in json)
219
+ return plain(inside(json.duration, facts.duration));
220
+ if ("volume" in json)
221
+ return plain(inside(json.volume, facts.volume ?? 100));
222
+ if ("rate" in json)
223
+ return plain(inside(json.rate, facts.rate ?? 1));
224
+ if ("time" in json)
225
+ return plain(inside(json.time, facts.time));
226
+ if ("audioTrack" in json)
227
+ return plain((facts.audioTrack ?? null) === json.audioTrack);
228
+ if ("subtitleTrack" in json)
229
+ return plain((facts.subtitleTrack ?? null) === json.subtitleTrack);
230
+ if ("audioDevice" in json)
231
+ return plain((facts.audioDevice ?? null) === json.audioDevice);
232
+ if ("muted" in json)
233
+ return plain((facts.muted ?? false) === json.muted);
234
+ if ("maximized" in json)
235
+ return plain((facts.maximized ?? false) === json.maximized);
236
+ if ("pip" in json)
237
+ return plain((facts.pip ?? false) === json.pip);
238
+ if ("looping" in json)
239
+ return plain((facts.looping ?? false) === json.looping);
240
+ if ("position" in json) {
241
+ const position = facts.position;
242
+ const range = typeof position === "number" &&
243
+ facts.bound !== null &&
244
+ facts.bound !== undefined &&
245
+ facts.bound === facts.sourceId
246
+ ? matchedRange(json.position, position)
247
+ : null;
248
+ return { holds: range !== null, range };
249
+ }
250
+ if ("all" in json) {
251
+ let range = null;
252
+ for (const each of json.all) {
253
+ const truth = evaluateTruth(each, facts);
254
+ if (!truth.holds)
255
+ return plain(false);
256
+ range ??= truth.range;
257
+ }
258
+ return { holds: true, range };
259
+ }
260
+ if ("any" in json) {
261
+ const truth = plain(false);
262
+ for (const each of json.any) {
263
+ const one = evaluateTruth(each, facts);
264
+ truth.holds ||= one.holds;
265
+ truth.range ??= one.range;
266
+ }
267
+ return truth;
268
+ }
269
+ return plain(!evaluateTruth(json.not, facts).holds);
270
+ }
271
+ /** Evaluate a wire condition as the player does (for the test host). */
272
+ export function evaluate(json, facts) {
273
+ return evaluateTruth(json, facts).holds;
106
274
  }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The Slint version the player links (its `Cargo.toml` pins `=1.18.1`): the
3
+ * compiler that `vestra-plugin check` asks of an installed `slint-ui` package,
4
+ * and `TestHost`'s `app.components.slint`. Changes with a player that
5
+ * upgrades Slint.
6
+ */
7
+ export declare const PLAYER_SLINT = "1.18.1";
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The Slint version the player links (its `Cargo.toml` pins `=1.18.1`): the
3
+ * compiler that `vestra-plugin check` asks of an installed `slint-ui` package,
4
+ * and `TestHost`'s `app.components.slint`. Changes with a player that
5
+ * upgrades Slint.
6
+ */
7
+ export const PLAYER_SLINT = "1.18.1";
package/dist/wire.d.ts CHANGED
@@ -931,6 +931,21 @@ export declare function createWire(transport: Transport): {
931
931
  observeProperty: (name: string) => Promise<void>;
932
932
  unobserveProperty: (name: string) => Promise<void>;
933
933
  };
934
+ /**
935
+ * Trigger conditions (1.10.0, `plugin.trigger`): `set` hands one over
936
+ * (or replaces it), `off` removes it, `declare` names what `activate()`
937
+ * declared. Each `set` and `off` answers the condition's sequence
938
+ * number; the flips arrive as `triggers.fired` events.
939
+ */
940
+ triggers: {
941
+ set: (trigger: number | string, when: Json) => Promise<{
942
+ seq: number;
943
+ }>;
944
+ off: (trigger: number | string, unhandled?: boolean) => Promise<{
945
+ seq: number;
946
+ }>;
947
+ declare: (names: string[], unnamed: number) => Promise<null>;
948
+ };
934
949
  /** The system's secret store, per plugin (`secrets`). */
935
950
  secrets: {
936
951
  get: (name: string) => Promise<string | null>;
@@ -951,6 +966,9 @@ export declare function createWire(transport: Transport): {
951
966
  };
952
967
  app: {
953
968
  system: () => Promise<WireSystemInfo>;
969
+ openWindow: (paths: string[]) => Promise<{
970
+ pid: number;
971
+ }>;
954
972
  };
955
973
  /**
956
974
  * The rendering choice: `state`, `setPreference` and `restart`.
package/dist/wire.js CHANGED
@@ -232,6 +232,17 @@ export function createWire(transport) {
232
232
  observeProperty: (name) => transport.request("mpv.observe", { name }),
233
233
  unobserveProperty: (name) => transport.request("mpv.unobserve", { name }),
234
234
  },
235
+ /**
236
+ * Trigger conditions (1.10.0, `plugin.trigger`): `set` hands one over
237
+ * (or replaces it), `off` removes it, `declare` names what `activate()`
238
+ * declared. Each `set` and `off` answers the condition's sequence
239
+ * number; the flips arrive as `triggers.fired` events.
240
+ */
241
+ triggers: {
242
+ set: (trigger, when) => transport.request("triggers.set", { trigger, when }),
243
+ off: (trigger, unhandled = false) => transport.request("triggers.off", unhandled ? { trigger, unhandled } : { trigger }),
244
+ declare: (names, unnamed) => transport.request("triggers.declare", { names, unnamed }),
245
+ },
235
246
  /** The system's secret store, per plugin (`secrets`). */
236
247
  secrets: {
237
248
  get: (name) => transport.request("secrets.get", { name }),
@@ -250,6 +261,7 @@ export function createWire(transport) {
250
261
  },
251
262
  app: {
252
263
  system: () => transport.request("app.system"),
264
+ openWindow: (paths) => transport.request("app.openWindow", { paths }),
253
265
  },
254
266
  /**
255
267
  * The rendering choice: `state`, `setPreference` and `restart`.
package/llms.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  # Vestra Player SDK
2
2
 
3
- > @vestra-player/sdk 1.9.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/.
3
+ > @vestra-player/sdk 1.10.1: 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
 
@@ -25,15 +25,15 @@
25
25
 
26
26
  ## API
27
27
 
28
- - `/API/Commands`: 23 entries: CommandState, Bindable, Condition, When, MenuId, BarButtonIcon, CommandButton, CommandOptions, Command, Commands, CommandRunOptions, CommandRunResult, CommandList, CommandInfo, Palette,…
28
+ - `/API/Commands`: 26 entries: CommandState, Bindable, Condition, When, PositionRange, TriggerEvent, Trigger, MenuId, BarButtonIcon, CommandButton, CommandOptions, Command, Commands, CommandRunOptions,…
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`: 36 entries: CommandKeys, MarkKind, TimelineMark, RangeStyle, TimelineRange, TimelineLayer, Timeline, AudioTrack, PlayerState, AudioDevice, Chapter, Conditional, Media, Scrub, StreamFrame,…
31
+ - `/API/Playback`: 39 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,…
35
35
  - `/API/Sources`: 7 entries: ResolverOptions, WebResolverOptions, FileResolverOptions, ResolvedStream, Resolver, Resolvers, ResolvedMedia
36
36
  - `/API/Subtitles`: 5 entries: SubtitleTrack, SubtitlesState, SubtitleConditional, Subtitles, SubtitleStyle
37
37
  - `/API/UI`: 44 entries: ImageRef, ImageOptions, MarkdownRef, MarkdownOptions, PropValue, PropData, Props, Ui, View, Window, Windows, SlotState, SlotPanel, PanelState, PanelSlot, SidebarSlot, Panel,…
38
- - `/API/Testing`: 32 entries: COMMAND_LIMITS, MENU_IDS, BAR_BUTTON_ICONS, BAR_BUTTON_LIMITS, BuiltinSubmenu, BUILTIN_SUBMENUS, BuiltinCommand, BUILTIN_COMMANDS, LOCALES, LIST_SEPARATORS, TEXT_LIMITS, THEME_PALETTES,…
38
+ - `/API/Testing`: 34 entries: COMMAND_LIMITS, MENU_IDS, BAR_BUTTON_ICONS, BAR_BUTTON_LIMITS, BuiltinSubmenu, BUILTIN_SUBMENUS, BuiltinCommand, BUILTIN_COMMANDS, LOCALES, LIST_SEPARATORS, TEXT_LIMITS, THEME_PALETTES,…
39
39
  - `/API/Docs`: 4 entries: DOCS_PAGE_BYTES, DocsOptions, docs, searchDocs
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vestra-player/sdk",
3
- "version": "1.9.0",
3
+ "version": "1.10.1",
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": {
@@ -75,7 +75,7 @@
75
75
  },
76
76
  "devDependencies": {
77
77
  "@arethetypeswrong/cli": "0.18.5",
78
- "oxlint": "1.89.0",
78
+ "oxlint": "1.93.0",
79
79
  "prettier": "^3.9.10",
80
80
  "publint": "0.3.25",
81
81
  "typedoc": "0.28.20",