@vestra-player/sdk 1.8.0 → 1.9.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.
Files changed (86) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/README.md +2 -2
  3. package/bin/vestra-plugin.mjs +11 -100
  4. package/capability-scan.json +3 -1
  5. package/dist/api-requests.d.ts +11 -36
  6. package/dist/api-requests.js +18 -47
  7. package/dist/capability-scan.d.ts +1 -1
  8. package/dist/capability-scan.js +8 -9
  9. package/dist/docs-tree.json.gz +0 -0
  10. package/dist/docs.d.ts +1 -1
  11. package/dist/docs.js +1 -1
  12. package/dist/index.d.ts +4 -5
  13. package/dist/manifest.d.ts +5 -0
  14. package/dist/manifest.js +9 -24
  15. package/dist/member-uses.d.ts +61 -0
  16. package/dist/member-uses.js +160 -0
  17. package/dist/player-runtime.d.ts +1 -2
  18. package/dist/player-runtime.js +1 -2
  19. package/dist/plugin/appearance.d.ts +1 -1
  20. package/dist/plugin/appearance.js +2 -2
  21. package/dist/plugin/bindings.d.ts +1 -1
  22. package/dist/plugin/bindings.js +2 -2
  23. package/dist/plugin/commands.js +1 -12
  24. package/dist/plugin/connection.d.ts +26 -7
  25. package/dist/plugin/connection.js +68 -36
  26. package/dist/plugin/drops.js +1 -1
  27. package/dist/plugin/index.js +9 -15
  28. package/dist/plugin/media.js +0 -12
  29. package/dist/plugin/mpv.js +0 -7
  30. package/dist/plugin/packages.js +1 -2
  31. package/dist/plugin/player/events.d.ts +4 -3
  32. package/dist/plugin/player/events.js +7 -6
  33. package/dist/plugin/player.d.ts +21 -13
  34. package/dist/plugin/player.js +56 -21
  35. package/dist/plugin/services.d.ts +4 -4
  36. package/dist/plugin/services.js +7 -29
  37. package/dist/plugin/settings.js +1 -1
  38. package/dist/plugin/shaders.js +0 -2
  39. package/dist/plugin/stream.d.ts +2 -1
  40. package/dist/plugin/stream.js +2 -2
  41. package/dist/plugin/testing/commands.d.ts +3 -10
  42. package/dist/plugin/testing/commands.js +6 -15
  43. package/dist/plugin/testing/index.d.ts +26 -116
  44. package/dist/plugin/testing/index.js +30 -104
  45. package/dist/plugin/testing/processing.js +1 -1
  46. package/dist/plugin/testing/services.js +0 -1
  47. package/dist/plugin/timeline.d.ts +2 -3
  48. package/dist/plugin/timeline.js +4 -8
  49. package/dist/plugin/types/base.d.ts +40 -86
  50. package/dist/plugin/types/commands.d.ts +10 -67
  51. package/dist/plugin/types/packages.d.ts +17 -55
  52. package/dist/plugin/types/playback.d.ts +126 -144
  53. package/dist/plugin/types/plugin-wire.d.ts +6 -36
  54. package/dist/plugin/types/processing.d.ts +10 -49
  55. package/dist/plugin/types/services.d.ts +11 -70
  56. package/dist/plugin/types/snapshots.d.ts +7 -60
  57. package/dist/plugin/types/sources.d.ts +2 -11
  58. package/dist/plugin/types/subtitles.d.ts +5 -26
  59. package/dist/plugin/types/ui-content.d.ts +1 -16
  60. package/dist/plugin/types/ui-layout.d.ts +53 -79
  61. package/dist/plugin/types/ui-locale.d.ts +5 -23
  62. package/dist/plugin/types/ui-shell.d.ts +13 -59
  63. package/dist/plugin/view/layout.js +1 -1
  64. package/dist/plugin/view.js +0 -2
  65. package/dist/plugin/window.d.ts +1 -1
  66. package/dist/plugin/window.js +1 -1
  67. package/dist/plugin/wire-facade.js +1 -2
  68. package/dist/processing.d.ts +2 -3
  69. package/dist/protocol.d.ts +14 -0
  70. package/dist/protocol.js +14 -0
  71. package/dist/request-queue.js +1 -1
  72. package/dist/subtitles.d.ts +1 -1
  73. package/dist/ts-plugin.d.ts +8 -15
  74. package/dist/ts-plugin.js +3 -141
  75. package/dist/wire.d.ts +7 -12
  76. package/dist/wire.js +6 -8
  77. package/llms.txt +4 -4
  78. package/package.json +1 -2
  79. package/dist/capabilities.d.ts +0 -107
  80. package/dist/capabilities.js +0 -69
  81. package/dist/capability-check.d.ts +0 -176
  82. package/dist/capability-check.js +0 -461
  83. package/dist/capability-rules.d.ts +0 -125
  84. package/dist/capability-rules.js +0 -192
  85. package/dist/host-capabilities.d.ts +0 -10
  86. package/dist/host-capabilities.js +0 -492
@@ -1,125 +0,0 @@
1
- import type { ApiRequest } from "./api-requests.ts";
2
- /**
3
- * What a request needs, as the player's `capabilities.json` writes it:
4
- * `null` (nothing), a capability name, a choice by a string parameter, or a
5
- * choice by whether the plugin declared a capability.
6
- *
7
- * @internal
8
- */
9
- export type Needs = null | string | {
10
- readonly param: string;
11
- readonly cases: Readonly<Record<string, string | null>>;
12
- readonly otherwise: string | null;
13
- } | {
14
- readonly ifDeclared: string;
15
- readonly then: string;
16
- readonly otherwise: string;
17
- };
18
- /** @internal One RPC method of the player's table (`prefix.*` covers a prefix). */
19
- export interface HostMethod {
20
- readonly name: string;
21
- readonly needs: Needs;
22
- }
23
- /** @internal One manifest capability of the player's table. */
24
- export interface HostCapability {
25
- readonly name: string;
26
- readonly label: string;
27
- readonly risky: boolean;
28
- /** Only built-in plugins may declare it (absent: `false`). */
29
- readonly builtinOnly?: boolean;
30
- readonly requires: readonly string[];
31
- readonly residency: string;
32
- readonly methods: readonly HostMethod[];
33
- }
34
- /** @internal The player's `src/host/capabilities.json`. */
35
- export interface HostCapabilities {
36
- readonly about: string;
37
- readonly apiVersion: string;
38
- readonly capabilities: readonly HostCapability[];
39
- readonly uncapable: readonly HostMethod[];
40
- }
41
- /** @internal Both tables; tests pass their own. */
42
- export interface CapabilityRules {
43
- readonly host: HostCapabilities;
44
- readonly apis: Readonly<Record<string, readonly ApiRequest[]>>;
45
- }
46
- /** @internal The SDK's rules: the synced player table and `API_REQUESTS`. */
47
- export declare const RULES: CapabilityRules;
48
- /**
49
- * The player's entry for a method, as the player routes it: the exact name
50
- * first, then the first `prefix.*` entry whose prefix it starts with.
51
- * `undefined`: the player does not know the method.
52
- *
53
- * @internal
54
- */
55
- export declare function hostMethod(method: string, host?: HostCapabilities): HostMethod | undefined;
56
- /**
57
- * The capability one request needs, as the player decides it
58
- * (`capabilities::Route::needs`): `null` for none, `undefined` for a method
59
- * the player does not know.
60
- *
61
- * @param method - The wire method.
62
- * @param params - Its string parameters that a `Needs::Param` rule reads.
63
- * @param declared - Whether the plugin declared a capability.
64
- *
65
- * @internal
66
- */
67
- export declare function requestNeeds(method: string, params: Readonly<Record<string, string>> | undefined, declared: (capability: string) => boolean, host?: HostCapabilities): string | null | undefined;
68
- /**
69
- * One capability a member needs: the request that needs it, and the
70
- * capability whose `requires` brought it in (absent when the request needs
71
- * it directly).
72
- *
73
- * @internal
74
- */
75
- export interface MemberNeed {
76
- readonly capability: string;
77
- readonly method: string;
78
- readonly requiredBy?: string;
79
- }
80
- /**
81
- * Every capability a member of the plugin API needs with the given manifest:
82
- * those its requests need and, through `requires`, those they need in turn.
83
- * `undefined`: the member is not in the table (it needs none).
84
- *
85
- * @param api - The member as `Interface.member` (`Player.seek`).
86
- * @param capabilities - The manifest's capabilities.
87
- *
88
- * @internal
89
- */
90
- export declare function memberNeeds(api: string, capabilities: readonly string[], rules?: CapabilityRules): MemberNeed[] | undefined;
91
- /**
92
- * The requests of a call to a member of `ARGUMENT_APIS`, given the value of its
93
- * first argument and the string fields of its second: a subscribed event's
94
- * `events.subscribe`, nothing for an event that arrives unasked, or the named
95
- * method. `undefined`: a method the player's table does not know (not checked).
96
- *
97
- * @param kind - What the argument names (`ARGUMENT_APIS`).
98
- * @param name - The event or method name.
99
- * @param params - String fields of the second argument (`method` only).
100
- *
101
- * @internal
102
- */
103
- export declare function argumentRequests(kind: "event" | "method", name: string, params?: Readonly<Record<string, string>>, rules?: CapabilityRules): ApiRequest[] | undefined;
104
- /**
105
- * Every capability a list of requests needs with the given manifest (see
106
- * {@link memberNeeds}).
107
- *
108
- * @internal
109
- */
110
- export declare function requestsNeed(requests: readonly ApiRequest[], capabilities: readonly string[], rules?: CapabilityRules): MemberNeed[];
111
- /**
112
- * `CAPABILITY_INFO` from the tables: the label, highlight and requirements
113
- * from the player's table; the members from `API_REQUESTS` (every member a
114
- * request of which needs the capability, in the table's order; requests
115
- * marked `also` are left out, as they are documented at the member).
116
- *
117
- * @internal
118
- */
119
- export declare function capabilityInfo(rules?: CapabilityRules): Record<string, {
120
- apis: string[];
121
- requires: string[];
122
- label: string;
123
- risky: boolean;
124
- builtinOnly: boolean;
125
- }>;
@@ -1,192 +0,0 @@
1
- /**
2
- * The capability rule, as data: which manifest capability a request needs
3
- * (the player's table, `HOST_CAPABILITIES`, synced from its
4
- * `src/host/capabilities.json`) and which requests each public member of the
5
- * plugin API sends (`API_REQUESTS`). `CAPABILITY_INFO`, `vestra-plugin check`
6
- * and the TypeScript language-service plugin are all built from these two
7
- * tables, so they and the player cannot disagree.
8
- *
9
- * @internal
10
- */
11
- import { API_REQUESTS, SUBSCRIBED_EVENTS } from "./api-requests.js";
12
- import { HOST_CAPABILITIES } from "./host-capabilities.js";
13
- /** @internal The SDK's rules: the synced player table and `API_REQUESTS`. */
14
- export const RULES = {
15
- host: HOST_CAPABILITIES,
16
- apis: API_REQUESTS,
17
- };
18
- /**
19
- * The player's entry for a method, as the player routes it: the exact name
20
- * first, then the first `prefix.*` entry whose prefix it starts with.
21
- * `undefined`: the player does not know the method.
22
- *
23
- * @internal
24
- */
25
- export function hostMethod(method, host = RULES.host) {
26
- const all = [
27
- ...host.capabilities.flatMap((capability) => capability.methods),
28
- ...host.uncapable,
29
- ];
30
- return (all.find((entry) => entry.name === method) ??
31
- all.find((entry) => entry.name.endsWith(".*") && method.startsWith(entry.name.slice(0, -1))));
32
- }
33
- /**
34
- * The capability one request needs, as the player decides it
35
- * (`capabilities::Route::needs`): `null` for none, `undefined` for a method
36
- * the player does not know.
37
- *
38
- * @param method - The wire method.
39
- * @param params - Its string parameters that a `Needs::Param` rule reads.
40
- * @param declared - Whether the plugin declared a capability.
41
- *
42
- * @internal
43
- */
44
- export function requestNeeds(method, params, declared, host = RULES.host) {
45
- const entry = hostMethod(method, host);
46
- if (!entry)
47
- return undefined;
48
- const needs = entry.needs;
49
- if (needs === null || typeof needs === "string")
50
- return needs;
51
- if ("param" in needs) {
52
- const value = params?.[needs.param];
53
- return value !== undefined && Object.hasOwn(needs.cases, value)
54
- ? needs.cases[value]
55
- : needs.otherwise;
56
- }
57
- return declared(needs.ifDeclared) ? needs.then : needs.otherwise;
58
- }
59
- /**
60
- * Every capability a member of the plugin API needs with the given manifest:
61
- * those its requests need and, through `requires`, those they need in turn.
62
- * `undefined`: the member is not in the table (it needs none).
63
- *
64
- * @param api - The member as `Interface.member` (`Player.seek`).
65
- * @param capabilities - The manifest's capabilities.
66
- *
67
- * @internal
68
- */
69
- export function memberNeeds(api, capabilities, rules = RULES) {
70
- const requests = rules.apis[api];
71
- if (!requests)
72
- return undefined;
73
- return requestsNeed(requests, capabilities, rules);
74
- }
75
- /**
76
- * The requests of a call to a member of `ARGUMENT_APIS`, given the value of its
77
- * first argument and the string fields of its second: a subscribed event's
78
- * `events.subscribe`, nothing for an event that arrives unasked, or the named
79
- * method. `undefined`: a method the player's table does not know (not checked).
80
- *
81
- * @param kind - What the argument names (`ARGUMENT_APIS`).
82
- * @param name - The event or method name.
83
- * @param params - String fields of the second argument (`method` only).
84
- *
85
- * @internal
86
- */
87
- export function argumentRequests(kind, name, params, rules = RULES) {
88
- if (kind === "event")
89
- return SUBSCRIBED_EVENTS.includes(name)
90
- ? [{ method: "events.subscribe", params: { event: name } }]
91
- : [];
92
- if (!hostMethod(name, rules.host))
93
- return undefined;
94
- return [params ? { method: name, params } : { method: name }];
95
- }
96
- /**
97
- * Every capability a list of requests needs with the given manifest (see
98
- * {@link memberNeeds}).
99
- *
100
- * @internal
101
- */
102
- export function requestsNeed(requests, capabilities, rules = RULES) {
103
- // An `ifDeclared` rule is decided last, as if the plugin had declared what
104
- // the member's other requests need: `Player.seek` needs `playback.control`
105
- // for `source.submit`, and with it `source.operation` needs nothing more.
106
- // What a rule answers can change what another rule reads, so the needs are
107
- // worked out again, as if the plugin had declared everything an earlier
108
- // round needed, until no round adds a capability: `media.sources.open`
109
- // asks for `playback.control` until it is declared, then for
110
- // `media.sources` (and `source.operation` follows the first). The set
111
- // only grows, so the rounds end.
112
- const conditional = (request) => {
113
- const rule = hostMethod(request.method, rules.host)?.needs;
114
- return typeof rule === "object" && rule !== null && "ifDeclared" in rule;
115
- };
116
- const ordered = [
117
- ...requests.filter((request) => !conditional(request)),
118
- ...requests.filter(conditional),
119
- ];
120
- const round = (previous) => {
121
- const needs = [];
122
- const declared = (name) => capabilities.includes(name) ||
123
- previous.has(name) ||
124
- needs.some((need) => need.capability === name);
125
- const add = (need) => {
126
- if (needs.some((each) => each.capability === need.capability))
127
- return;
128
- needs.push(need);
129
- const entry = rules.host.capabilities.find((capability) => capability.name === need.capability);
130
- for (const required of entry?.requires ?? [])
131
- add({
132
- capability: required,
133
- method: need.method,
134
- requiredBy: need.capability,
135
- });
136
- };
137
- for (const request of ordered) {
138
- const capability = requestNeeds(request.method, request.params, declared, rules.host);
139
- if (capability)
140
- add({ capability, method: request.method });
141
- }
142
- return needs;
143
- };
144
- // Every capability any round needed; the answer is the last round's needs
145
- // (read with all of them declared) and then any earlier one it left out.
146
- // Each keeps the request of the round that first needed it, the one read
147
- // closest to the manifest: `MediaSources.open` needs `playback.control` for
148
- // `media.sources.open`, not for `source.operation`, which asks for it only
149
- // once it counts as declared.
150
- const all = new Map();
151
- for (;;) {
152
- const needs = round(new Set(all.keys()));
153
- const before = all.size;
154
- for (const need of needs)
155
- if (!all.has(need.capability))
156
- all.set(need.capability, need);
157
- if (all.size === before)
158
- return [
159
- ...needs.map((need) => all.get(need.capability)),
160
- ...[...all.values()].filter((need) => !needs.some((each) => each.capability === need.capability)),
161
- ];
162
- }
163
- }
164
- /**
165
- * `CAPABILITY_INFO` from the tables: the label, highlight and requirements
166
- * from the player's table; the members from `API_REQUESTS` (every member a
167
- * request of which needs the capability, in the table's order; requests
168
- * marked `also` are left out, as they are documented at the member).
169
- *
170
- * @internal
171
- */
172
- export function capabilityInfo(rules = RULES) {
173
- const info = {};
174
- for (const capability of rules.host.capabilities)
175
- info[capability.name] = {
176
- apis: [],
177
- requires: [...capability.requires],
178
- label: capability.label,
179
- risky: capability.risky,
180
- builtinOnly: capability.builtinOnly === true,
181
- };
182
- for (const [api, requests] of Object.entries(rules.apis))
183
- for (const request of requests) {
184
- if (request.also)
185
- continue;
186
- const capability = requestNeeds(request.method, request.params, () => true, rules.host);
187
- const entry = capability ? info[capability] : undefined;
188
- if (entry && !entry.apis.includes(api))
189
- entry.apis.push(api);
190
- }
191
- return info;
192
- }
@@ -1,10 +0,0 @@
1
- /**
2
- * The player's capability table, copied from its `src/host/capabilities.json`
3
- * by `npm run capabilities:sync -- <player repository>`. Do not edit: change
4
- * the player's capability modules, regenerate its JSON and sync again.
5
- *
6
- * @internal
7
- */
8
- import type { HostCapabilities } from "./capability-rules.ts";
9
- /** @internal */
10
- export declare const HOST_CAPABILITIES: HostCapabilities;