@vestra-player/sdk 1.7.20 → 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 (96) hide show
  1. package/CHANGELOG.md +72 -0
  2. package/README.md +2 -2
  3. package/bin/vestra-plugin.mjs +139 -100
  4. package/capability-scan.json +369 -0
  5. package/dist/api-requests.d.ts +11 -36
  6. package/dist/api-requests.js +22 -47
  7. package/dist/capability-scan.d.ts +95 -0
  8. package/dist/capability-scan.js +249 -0
  9. package/dist/commands.d.ts +35 -0
  10. package/dist/commands.js +42 -1
  11. package/dist/docs-tree.json.gz +0 -0
  12. package/dist/docs.d.ts +1 -1
  13. package/dist/docs.js +1 -1
  14. package/dist/index.d.ts +4 -5
  15. package/dist/manifest.d.ts +5 -0
  16. package/dist/manifest.js +9 -24
  17. package/dist/member-uses.d.ts +61 -0
  18. package/dist/member-uses.js +160 -0
  19. package/dist/mpv.d.ts +139 -0
  20. package/dist/mpv.js +496 -0
  21. package/dist/player-runtime.d.ts +3 -3
  22. package/dist/player-runtime.js +3 -3
  23. package/dist/plugin/appearance.d.ts +1 -1
  24. package/dist/plugin/appearance.js +2 -2
  25. package/dist/plugin/bindings.d.ts +1 -1
  26. package/dist/plugin/bindings.js +2 -2
  27. package/dist/plugin/commands.js +6 -14
  28. package/dist/plugin/connection.d.ts +26 -7
  29. package/dist/plugin/connection.js +68 -36
  30. package/dist/plugin/drops.js +1 -1
  31. package/dist/plugin/index.js +9 -15
  32. package/dist/plugin/media.js +0 -12
  33. package/dist/plugin/mpv.d.ts +3 -0
  34. package/dist/plugin/mpv.js +91 -0
  35. package/dist/plugin/packages.js +1 -2
  36. package/dist/plugin/player/events.d.ts +4 -3
  37. package/dist/plugin/player/events.js +7 -6
  38. package/dist/plugin/player.d.ts +21 -13
  39. package/dist/plugin/player.js +56 -21
  40. package/dist/plugin/scope.d.ts +1 -0
  41. package/dist/plugin/scope.js +2 -0
  42. package/dist/plugin/services.d.ts +4 -4
  43. package/dist/plugin/services.js +7 -29
  44. package/dist/plugin/settings.js +1 -1
  45. package/dist/plugin/shaders.js +0 -2
  46. package/dist/plugin/stream.d.ts +2 -1
  47. package/dist/plugin/stream.js +2 -2
  48. package/dist/plugin/testing/commands.d.ts +3 -10
  49. package/dist/plugin/testing/commands.js +43 -24
  50. package/dist/plugin/testing/index.d.ts +75 -114
  51. package/dist/plugin/testing/index.js +83 -102
  52. package/dist/plugin/testing/mpv.d.ts +7 -0
  53. package/dist/plugin/testing/mpv.js +90 -0
  54. package/dist/plugin/testing/processing.js +1 -1
  55. package/dist/plugin/testing/services.js +0 -1
  56. package/dist/plugin/timeline.d.ts +2 -3
  57. package/dist/plugin/timeline.js +4 -8
  58. package/dist/plugin/types/base.d.ts +49 -88
  59. package/dist/plugin/types/commands.d.ts +44 -77
  60. package/dist/plugin/types/packages.d.ts +17 -55
  61. package/dist/plugin/types/playback.d.ts +302 -135
  62. package/dist/plugin/types/plugin-wire.d.ts +6 -36
  63. package/dist/plugin/types/processing.d.ts +10 -49
  64. package/dist/plugin/types/services.d.ts +11 -70
  65. package/dist/plugin/types/snapshots.d.ts +7 -60
  66. package/dist/plugin/types/sources.d.ts +2 -11
  67. package/dist/plugin/types/subtitles.d.ts +5 -26
  68. package/dist/plugin/types/ui-content.d.ts +1 -16
  69. package/dist/plugin/types/ui-layout.d.ts +53 -79
  70. package/dist/plugin/types/ui-locale.d.ts +5 -23
  71. package/dist/plugin/types/ui-shell.d.ts +13 -59
  72. package/dist/plugin/view/layout.js +1 -1
  73. package/dist/plugin/view.js +0 -2
  74. package/dist/plugin/window.d.ts +1 -1
  75. package/dist/plugin/window.js +1 -1
  76. package/dist/plugin/wire-facade.js +1 -2
  77. package/dist/processing.d.ts +2 -3
  78. package/dist/protocol.d.ts +14 -0
  79. package/dist/protocol.js +14 -0
  80. package/dist/request-queue.js +1 -1
  81. package/dist/subtitles.d.ts +1 -1
  82. package/dist/ts-plugin.d.ts +8 -15
  83. package/dist/ts-plugin.js +3 -141
  84. package/dist/wire.d.ts +22 -12
  85. package/dist/wire.js +17 -8
  86. package/llms.txt +5 -5
  87. package/package.json +4 -3
  88. package/slint/vestra/widgets.slint +12 -4
  89. package/dist/capabilities.d.ts +0 -107
  90. package/dist/capabilities.js +0 -69
  91. package/dist/capability-check.d.ts +0 -133
  92. package/dist/capability-check.js +0 -371
  93. package/dist/capability-rules.d.ts +0 -125
  94. package/dist/capability-rules.js +0 -192
  95. package/dist/host-capabilities.d.ts +0 -10
  96. package/dist/host-capabilities.js +0 -477
@@ -0,0 +1,249 @@
1
+ /**
2
+ * The capability scan: which boundary categories a plugin's code uses
3
+ * (`player`, `plugins`, `clipboard`, `credentials`, `camera`, `microphone`,
4
+ * `screen`, `notifications`), read from its source. `vestra-plugin scan`
5
+ * prints the result; the plugin repository's index and the store show it.
6
+ *
7
+ * The table is `capability-scan.json` at the package's root, maintained by
8
+ * hand: every method of the public API is in one category's list or in
9
+ * `none`'s, and every request the SDK sends has a category by name or
10
+ * prefix (test/capability-scan.test.ts). Nothing here is read at run time;
11
+ * since 1.9.0 the scan is the only disclosure (manifests declare nothing).
12
+ *
13
+ * TypeScript files are scanned by type (`findMemberUses`, member-uses.ts): a member counts
14
+ * however its object was reached. JavaScript files have no types and are
15
+ * scanned by name, best effort (`scanNamesInto`); the result says which
16
+ * way each file was read.
17
+ *
18
+ * The TypeScript module is passed in, never imported (as in
19
+ * member-uses.ts). Node only: it reads the table from disk.
20
+ *
21
+ * @internal
22
+ */
23
+ import { readFileSync } from "node:fs";
24
+ import { findMemberUses } from "./member-uses.js";
25
+ /** @internal The scan's categories, in the order results list them. */
26
+ export const SCAN_CATEGORIES = [
27
+ "player",
28
+ "plugins",
29
+ "clipboard",
30
+ "credentials",
31
+ "camera",
32
+ "microphone",
33
+ "screen",
34
+ "notifications",
35
+ ];
36
+ /** @internal The version of the result's format (`scan`). */
37
+ export const SCAN_FORMAT = 1;
38
+ let table;
39
+ /**
40
+ * `capability-scan.json`, read once from the package's root (one level
41
+ * above this module, in `src/` and in `dist/` alike).
42
+ *
43
+ * @internal
44
+ */
45
+ export function scanTable() {
46
+ table ??= JSON.parse(readFileSync(new URL("../capability-scan.json", import.meta.url), "utf8"));
47
+ return table;
48
+ }
49
+ /** The category of a member; `undefined` for `none` and for unknown names. */
50
+ function memberCategories(scan) {
51
+ const categories = new Map();
52
+ for (const category of SCAN_CATEGORIES)
53
+ for (const member of scan.categories[category].members)
54
+ categories.set(member, category);
55
+ return categories;
56
+ }
57
+ /**
58
+ * The category of a request by name, as the player routes a method: the
59
+ * exact name first, then the first `prefix.*` entry it starts with.
60
+ * `null`: in `none`; `undefined`: the table does not know the method.
61
+ *
62
+ * @internal
63
+ */
64
+ export function requestCategory(method, scan = scanTable()) {
65
+ const lists = [
66
+ ...SCAN_CATEGORIES.map((category) => [
67
+ category,
68
+ scan.categories[category].requests,
69
+ ]),
70
+ [null, scan.none.requests],
71
+ ];
72
+ for (const [category, requests] of lists)
73
+ if (requests.includes(method))
74
+ return category;
75
+ for (const [category, requests] of lists)
76
+ if (requests.some((entry) => entry.endsWith(".*") && method.startsWith(entry.slice(0, -1))))
77
+ return category;
78
+ return undefined;
79
+ }
80
+ /** Collects evidence and the requests the scan cannot place. */
81
+ class Findings {
82
+ evidence = new Map();
83
+ unchecked = [];
84
+ #scan;
85
+ #relative;
86
+ constructor(scan, relative) {
87
+ this.#scan = scan;
88
+ this.#relative = relative;
89
+ }
90
+ add(category, evidence) {
91
+ const list = this.evidence.get(category) ?? [];
92
+ this.evidence.set(category, list);
93
+ list.push({ ...evidence, file: this.#relative(evidence.file) });
94
+ }
95
+ request(method, file, line, by) {
96
+ if (method === undefined) {
97
+ this.unchecked.push({
98
+ file: this.#relative(file),
99
+ line,
100
+ message: "a request whose method name is not one literal string: the scan cannot tell what it asks for",
101
+ });
102
+ return;
103
+ }
104
+ const category = requestCategory(method, this.#scan);
105
+ if (category === undefined)
106
+ this.unchecked.push({
107
+ file: this.#relative(file),
108
+ line,
109
+ message: `a request of ${JSON.stringify(method)}, which capability-scan.json does not list`,
110
+ });
111
+ else if (category !== null)
112
+ this.add(category, { request: method, file, line, by });
113
+ }
114
+ result() {
115
+ const order = (a, b) => a.file.localeCompare(b.file, "en") ||
116
+ a.line - b.line ||
117
+ (a.member ?? a.request ?? "").localeCompare(b.member ?? b.request ?? "", "en");
118
+ const uses = SCAN_CATEGORIES.filter((category) => this.evidence.has(category));
119
+ return {
120
+ uses,
121
+ evidence: Object.fromEntries(uses.map((category) => [
122
+ category,
123
+ this.evidence.get(category).toSorted(order),
124
+ ])),
125
+ unchecked: this.unchecked.toSorted((a, b) => a.file.localeCompare(b.file, "en") || a.line - b.line),
126
+ };
127
+ }
128
+ }
129
+ /** `Clipboard` → `clipboard`: the name a module has on `plugin`. */
130
+ const lowerFirst = (name) => name[0].toLowerCase() + name.slice(1);
131
+ /**
132
+ * A file's uses, by name (best effort, no types; for JavaScript, and for
133
+ * TypeScript that imports no SDK types): a property
134
+ * access or a destructured property named as a category's member, on
135
+ * something named as the member's interface is on `plugin`
136
+ * (`plugin.clipboard.readText`, `clipboard.readText`,
137
+ * `const { readText } = plugin.clipboard`; `Clipboard.readText` is on
138
+ * `clipboard`); and a call of something named `request` with one string
139
+ * literal, as a request by name. Missed: an object reached under another
140
+ * name, a computed member name, a member whose interface is not a module
141
+ * of `plugin` (`PackageCandidate.install`). A name that only looks like
142
+ * one is counted.
143
+ */
144
+ function scanNamesInto(ts, fileName, text, scan, into) {
145
+ // The kind (JavaScript, TypeScript) is the file name's.
146
+ const source = ts.createSourceFile(fileName, text, ts.ScriptTarget.Latest, true);
147
+ // "clipboard.readText" → category and member.
148
+ const pairs = new Map();
149
+ for (const [member, category] of memberCategories(scan)) {
150
+ const parts = member.split(".");
151
+ const name = parts.at(-1);
152
+ const owner = parts.length > 2 ? parts.at(-2) : lowerFirst(parts[0]);
153
+ pairs.set(`${owner}.${name}`, { category, member });
154
+ }
155
+ const line = (node) => source.getLineAndCharacterOfPosition(node.getStart(source)).line + 1;
156
+ /** The last name of an expression: `plugin.clipboard` → `clipboard`. */
157
+ const lastName = (node) => {
158
+ if (!node)
159
+ return undefined;
160
+ if (ts.isIdentifier(node))
161
+ return node.text;
162
+ if (ts.isPropertyAccessExpression(node))
163
+ return node.name.text;
164
+ if (ts.isElementAccessExpression(node) &&
165
+ ts.isStringLiteralLike(node.argumentExpression))
166
+ return node.argumentExpression.text;
167
+ if (ts.isParenthesizedExpression(node) ||
168
+ ts.isNonNullExpression(node) ||
169
+ ts.isAwaitExpression(node))
170
+ return lastName(node.expression);
171
+ return undefined;
172
+ };
173
+ const member = (owner, name, at) => {
174
+ const found = owner === undefined ? undefined : pairs.get(`${owner}.${name}`);
175
+ if (found)
176
+ into.add(found.category, {
177
+ member: found.member,
178
+ file: fileName,
179
+ line: line(at),
180
+ by: "names",
181
+ });
182
+ };
183
+ const visit = (node) => {
184
+ if (ts.isPropertyAccessExpression(node))
185
+ member(lastName(node.expression), node.name.text, node.name);
186
+ else if (ts.isElementAccessExpression(node) &&
187
+ ts.isStringLiteralLike(node.argumentExpression))
188
+ member(lastName(node.expression), node.argumentExpression.text, node.argumentExpression);
189
+ else if (ts.isBindingElement(node) &&
190
+ ts.isObjectBindingPattern(node.parent)) {
191
+ const name = node.propertyName ?? node.name;
192
+ const declaration = node.parent.parent;
193
+ const from = ts.isVariableDeclaration(declaration) ||
194
+ ts.isParameter(declaration) ||
195
+ ts.isBindingElement(declaration)
196
+ ? ts.isBindingElement(declaration)
197
+ ? // `{ clipboard: { readText } }`: the outer property's name.
198
+ (declaration.propertyName ?? declaration.name)
199
+ : declaration.initializer
200
+ : undefined;
201
+ if (ts.isIdentifier(name) || ts.isStringLiteralLike(name))
202
+ member(lastName(from), name.text, name);
203
+ }
204
+ if (ts.isCallExpression(node) && lastName(node.expression) === "request") {
205
+ const first = node.arguments[0];
206
+ into.request(first && ts.isStringLiteralLike(first) ? first.text : undefined, fileName, line(node.expression), "names");
207
+ }
208
+ ts.forEachChild(node, visit);
209
+ };
210
+ visit(source);
211
+ }
212
+ /**
213
+ * The categories a plugin's files use.
214
+ *
215
+ * `resolved` is `false` when there are TypeScript files and the program
216
+ * resolves no import of `@vestra-player/sdk` in them (the SDK is not
217
+ * installed where the plugin looks, or nothing imports it): the caller
218
+ * then scans those files by name too, or reports it.
219
+ *
220
+ * @param program - A program that has the `typed` files; `undefined` with
221
+ * none.
222
+ *
223
+ * @internal
224
+ */
225
+ export function scan(ts, program, options) {
226
+ const table = options.table ?? scanTable();
227
+ const findings = new Findings(table, options.relative ?? ((file) => file));
228
+ let resolved = true;
229
+ if (program && options.typed.length) {
230
+ const categories = memberCategories(table);
231
+ const found = findMemberUses(ts, program, {
232
+ files: options.typed,
233
+ apis: categories.keys(),
234
+ });
235
+ resolved = found.resolved;
236
+ for (const use of found.uses)
237
+ findings.add(categories.get(use.api), {
238
+ member: use.api,
239
+ file: use.file,
240
+ line: use.line,
241
+ by: "types",
242
+ });
243
+ for (const request of found.requests)
244
+ findings.request(request.method, request.file, request.line, "types");
245
+ }
246
+ for (const { file, text } of options.named)
247
+ scanNamesInto(ts, file, text, table, findings);
248
+ return { ...findings.result(), resolved };
249
+ }
@@ -196,6 +196,41 @@ export declare const COMMAND_RUN_LIMITS: {
196
196
  /** A ticket ends this long after it was given or last ran a command (ms). */
197
197
  readonly ticketIdleMs: 120000;
198
198
  };
199
+ /**
200
+ * The player's limits on the texts of `palette.lead.set`, in characters as
201
+ * shown (translated, a text value with its arguments), each on one line;
202
+ * the same values as the player's (its agreement test checks that they
203
+ * agree). The player checks them; `TestHost` does the same.
204
+ * Internal: exported from `@vestra-player/sdk/runtime` only.
205
+ *
206
+ * @internal
207
+ */
208
+ export declare const PALETTE_LEAD_LIMITS: {
209
+ /** `title` (40). */
210
+ readonly title: 40;
211
+ /** `placeholder` (60). */
212
+ readonly placeholder: 60;
213
+ /** `empty` (80). */
214
+ readonly empty: 80;
215
+ /** `note` (40). */
216
+ readonly note: 40;
217
+ /** `status.text` of a working status: one line of the row and the strip (80). */
218
+ readonly statusText: 80;
219
+ /** `status.text` of an end state: what the strip's two lines hold (160). */
220
+ readonly statusEndText: 160;
221
+ /** `status.note` (40). */
222
+ readonly statusNote: 40;
223
+ /** `status.strip`: one line of the strip (80). */
224
+ readonly statusStrip: 80;
225
+ };
226
+ /**
227
+ * `palette.lead.set`'s `status.state` values, the first the default
228
+ * (absent or `null`); the others are end states. The same list as the
229
+ * player's. Internal: exported from `@vestra-player/sdk/runtime` only.
230
+ *
231
+ * @internal
232
+ */
233
+ export declare const PALETTE_LEAD_STATES: readonly ["working", "done", "failed", "note", "stopped"];
199
234
  /**
200
235
  * What is wrong with `commands.run`'s `then` (given, not `null`), as
201
236
  * the player words it; `null` when nothing is. The SDK and `TestHost`
package/dist/commands.js CHANGED
@@ -242,6 +242,47 @@ export const COMMAND_RUN_LIMITS = {
242
242
  /** A ticket ends this long after it was given or last ran a command (ms). */
243
243
  ticketIdleMs: 120_000,
244
244
  };
245
+ /**
246
+ * The player's limits on the texts of `palette.lead.set`, in characters as
247
+ * shown (translated, a text value with its arguments), each on one line;
248
+ * the same values as the player's (its agreement test checks that they
249
+ * agree). The player checks them; `TestHost` does the same.
250
+ * Internal: exported from `@vestra-player/sdk/runtime` only.
251
+ *
252
+ * @internal
253
+ */
254
+ export const PALETTE_LEAD_LIMITS = {
255
+ /** `title` (40). */
256
+ title: 40,
257
+ /** `placeholder` (60). */
258
+ placeholder: 60,
259
+ /** `empty` (80). */
260
+ empty: 80,
261
+ /** `note` (40). */
262
+ note: 40,
263
+ /** `status.text` of a working status: one line of the row and the strip (80). */
264
+ statusText: 80,
265
+ /** `status.text` of an end state: what the strip's two lines hold (160). */
266
+ statusEndText: 160,
267
+ /** `status.note` (40). */
268
+ statusNote: 40,
269
+ /** `status.strip`: one line of the strip (80). */
270
+ statusStrip: 80,
271
+ };
272
+ /**
273
+ * `palette.lead.set`'s `status.state` values, the first the default
274
+ * (absent or `null`); the others are end states. The same list as the
275
+ * player's. Internal: exported from `@vestra-player/sdk/runtime` only.
276
+ *
277
+ * @internal
278
+ */
279
+ export const PALETTE_LEAD_STATES = [
280
+ "working",
281
+ "done",
282
+ "failed",
283
+ "note",
284
+ "stopped",
285
+ ];
245
286
  /**
246
287
  * What is wrong with `commands.run`'s `then` (given, not `null`), as
247
288
  * the player words it; `null` when nothing is. The SDK and `TestHost`
@@ -505,7 +546,7 @@ vestra.playlist | playlist.remove | (Remove Selected) | Delete | panel
505
546
  vestra.playlist | playlist.remove-unselected | (Remove Unselected) | Ctrl+Delete | panel
506
547
  vestra.playlist | playlist.remove-invalid | (Remove Invalid Items)
507
548
  vestra.playlist | playlist.clear | (Remove All) | Alt+Delete | panel
508
- vestra.playlist | playlist.reveal | (Show in Finder) | Ctrl+F | panel
549
+ vestra.playlist | playlist.reveal | (Show in Folder) | Ctrl+F | panel
509
550
  vestra.playlist | playlist.move-top | (Move to Top)
510
551
  vestra.playlist | playlist.move-up | (Move Up) | Ctrl+ArrowUp | panel
511
552
  vestra.playlist | playlist.move-down | (Move Down) | Ctrl+ArrowDown | panel
Binary file
package/dist/docs.d.ts CHANGED
@@ -21,7 +21,7 @@ export interface DocsOptions {
21
21
  * page of the documentation site (its file name works too:
22
22
  * `/Guides/Guides/testing`); `/API/<category>/<symbol>/<member>` is a
23
23
  * declaration with its signature, parameters, return value, errors,
24
- * capability, player version and examples. Matching ignores case, spaces
24
+ * player version and examples. Matching ignores case, spaces
25
25
  * and punctuation; a leading `/` and a `.md` suffix are optional; `.`
26
26
  * works like `/` (`Snapshot.export`); a name that is not at its level is
27
27
  * looked up below it (`TestHost`, `/API/Snapshot` finds
package/dist/docs.js CHANGED
@@ -450,7 +450,7 @@ function notFound(asked, segments, page) {
450
450
  * page of the documentation site (its file name works too:
451
451
  * `/Guides/Guides/testing`); `/API/<category>/<symbol>/<member>` is a
452
452
  * declaration with its signature, parameters, return value, errors,
453
- * capability, player version and examples. Matching ignores case, spaces
453
+ * player version and examples. Matching ignores case, spaces
454
454
  * and punctuation; a leading `/` and a `.md` suffix are optional; `.`
455
455
  * works like `/` (`Snapshot.export`); a name that is not at its level is
456
456
  * looked up below it (`TestHost`, `/API/Snapshot` finds
package/dist/index.d.ts CHANGED
@@ -8,16 +8,15 @@
8
8
  * import with `import type`.
9
9
  *
10
10
  * Start with {@link Plugin} and {@link Scope}: every module
11
- * (`plugin.commands`, `plugin.player`, `plugin.windows`…) hangs off them and
12
- * documents the manifest capability it needs. Errors are described at
11
+ * (`plugin.commands`, `plugin.player`, `plugin.windows`…) hangs off them.
12
+ * Errors are described at
13
13
  * {@link PluginError}. Tests use `@vestra-player/sdk/testing`.
14
14
  *
15
15
  * @example Add a menu item that shows a message
16
16
  * The player gets a Tools ▸ Hello menu item; picking it shows "Hello" on
17
17
  * the video. The player imports the entry module and calls `activate` with
18
- * the plugin's `Plugin` object; `commands.add` registers the item (manifest
19
- * capability `commands`), and the player calls `run` when the user picks it
20
- * or presses a key bound to it. `osd.show` needs `ui.osd`.
18
+ * the plugin's `Plugin` object; `commands.add` registers the item, and the
19
+ * player calls `run` when the user picks it or presses a key bound to it.
21
20
  * ```ts
22
21
  * import type { Plugin } from "@vestra-player/sdk";
23
22
  *
@@ -15,6 +15,11 @@ export declare const MANIFEST_LIMITS: Readonly<{
15
15
  /** Every field a manifest may have; anything else is rejected by the player. */
16
16
  export declare const MANIFEST_FIELDS: readonly string[];
17
17
  export declare const validVersion: (value: unknown) => value is string;
18
+ /**
19
+ * Why a manifest with `capabilities` is refused (SDK 1.9.0, player 0.9.0):
20
+ * the field is gone, and what it switched on is two calls.
21
+ */
22
+ export declare const CAPABILITIES_REMOVED = "manifest.json has \"capabilities\", which SDK 1.9.0 (player 0.9.0) removed: delete the field. What it switched on is now a call, first in activate(): plugin.player.subscribe() for \"events\", await plugin.player.read() for \"playback.read\"; everything else needs nothing (the store shows what the code uses, from its scan)";
18
23
  /** Problems with `manifest` (empty: valid) and hints that do not fail. */
19
24
  export declare function manifestProblems(manifest: Record<string, unknown>, directory: string): {
20
25
  problems: string[];
package/dist/manifest.js CHANGED
@@ -5,7 +5,7 @@
5
5
  */
6
6
  import { existsSync, lstatSync, readFileSync, realpathSync } from "node:fs";
7
7
  import { join, sep } from "node:path";
8
- import { API_VERSION, CAPABILITIES, CAPABILITY_INFO } from "./capabilities.js";
8
+ import { API_VERSION } from "./protocol.js";
9
9
  export const MANIFEST_LIMITS = Object.freeze({
10
10
  idBytes: 128,
11
11
  name: 64,
@@ -26,7 +26,6 @@ export const MANIFEST_FIELDS = [
26
26
  "version",
27
27
  "apiVersion",
28
28
  "entry",
29
- "capabilities",
30
29
  "name",
31
30
  "author",
32
31
  "punchline",
@@ -44,6 +43,11 @@ export const validVersion = (value) => typeof value === "string" &&
44
43
  value.length <= 32 &&
45
44
  VERSION.test(value) &&
46
45
  value.split(".").every((part) => BigInt(part) <= 4294967295n);
46
+ /**
47
+ * Why a manifest with `capabilities` is refused (SDK 1.9.0, player 0.9.0):
48
+ * the field is gone, and what it switched on is two calls.
49
+ */
50
+ export const CAPABILITIES_REMOVED = 'manifest.json has "capabilities", which SDK 1.9.0 (player 0.9.0) removed: delete the field. What it switched on is now a call, first in activate(): plugin.player.subscribe() for "events", await plugin.player.read() for "playback.read"; everything else needs nothing (the store shows what the code uses, from its scan)';
47
51
  /** Problems with `manifest` (empty: valid) and hints that do not fail. */
48
52
  export function manifestProblems(manifest, directory) {
49
53
  const problems = [];
@@ -54,7 +58,9 @@ export function manifestProblems(manifest, directory) {
54
58
  Array.isArray(manifest))
55
59
  return { problems: ["manifest.json must be an object"], hints };
56
60
  for (const key of Object.keys(manifest))
57
- if (!MANIFEST_FIELDS.includes(key))
61
+ if (key === "capabilities")
62
+ problem(CAPABILITIES_REMOVED);
63
+ else if (!MANIFEST_FIELDS.includes(key))
58
64
  problem(`unknown field "${key}"`);
59
65
  const id = manifest.id;
60
66
  if (typeof id !== "string" ||
@@ -66,27 +72,6 @@ export function manifestProblems(manifest, directory) {
66
72
  hints.push(`id "${id}" has no prefix: the official repository needs <GitHub user or organization>.<plugin name>`);
67
73
  if (manifest.apiVersion !== API_VERSION)
68
74
  problem(`apiVersion is ${JSON.stringify(manifest.apiVersion)}; this SDK is ${API_VERSION}`);
69
- const capabilities = manifest.capabilities;
70
- if (!Array.isArray(capabilities))
71
- problem("capabilities must be an array");
72
- else {
73
- const unknown = capabilities.filter((c) => !CAPABILITIES.includes(c));
74
- if (unknown.length)
75
- problem(`unknown capabilities ${unknown.join(", ")}`);
76
- if (new Set(capabilities).size !== capabilities.length)
77
- problem("capabilities must be unique");
78
- // Only a built-in plugin may declare these. Built-in plugins have a
79
- // `vestra.` id, which the player refuses for any other package: any
80
- // other id is an error, a `vestra.` id a reminder.
81
- const builtinOnly = capabilities.filter((c) => CAPABILITY_INFO[c]?.builtinOnly);
82
- if (builtinOnly.length) {
83
- const text = `${builtinOnly.join(", ")}: built-in plugins only (the player refuses any other plugin that declares ${builtinOnly.length === 1 ? "it" : "them"}, and its calls fail with code capability)`;
84
- if (typeof id === "string" && /^vestra\./i.test(id))
85
- hints.push(text);
86
- else
87
- problem(text);
88
- }
89
- }
90
75
  if (typeof manifest.entry !== "string" || !relative(manifest.entry))
91
76
  problem("entry must be a relative path inside the package");
92
77
  if (manifest.version !== undefined && !validVersion(manifest.version))
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Where a plugin's TypeScript uses SDK members: the type-aware resolution
3
+ * the capability scan (`capability-scan.ts`) reads a plugin's code with. A
4
+ * use is a property access, an element access with a literal name or a
5
+ * destructured property whose symbol is the SDK's declaration of a member
6
+ * asked for, however the object was reached (`plugin.player.seek`,
7
+ * `const { player } = plugin; player.seek`, a parameter typed `Player`, a
8
+ * `Panel` from `panels.mount`). Not detected: access with a computed name
9
+ * (`player[name]`), values typed `any` or `unknown`, plain JavaScript
10
+ * without types.
11
+ *
12
+ * Requests sent by name (`plugin.wire.request`) are found too, with the
13
+ * method when its type fixes it to one string.
14
+ *
15
+ * The TypeScript module is passed in, never imported: the CLI uses the
16
+ * SDK's own compiler.
17
+ *
18
+ * @internal
19
+ */
20
+ import type TS from "typescript";
21
+ /** @internal The module plugins import the API types from. */
22
+ export declare const SDK_MODULE = "@vestra-player/sdk";
23
+ /** @internal One use of an SDK member, where {@link findMemberUses} found it. */
24
+ export interface MemberUse {
25
+ readonly file: string;
26
+ /** 1-based line and column of the member's name. */
27
+ readonly line: number;
28
+ readonly column: number;
29
+ /** The member, as it was asked for (`Clipboard.readText`). */
30
+ readonly api: string;
31
+ }
32
+ /**
33
+ * @internal A request sent by name (`plugin.wire.request("clipboard.readText")`):
34
+ * the method when the types fix it to one string, else `undefined` (a
35
+ * computed name, a union of several, the member taken as a value).
36
+ */
37
+ export interface RequestUse {
38
+ readonly file: string;
39
+ readonly line: number;
40
+ readonly column: number;
41
+ readonly method: string | undefined;
42
+ }
43
+ /**
44
+ * Every use, in `files`, of the SDK members named by `apis`
45
+ * (`Interface.member`), and every request sent by name (`Wire.request`),
46
+ * in file and position order. It reads no manifest (the capability scan,
47
+ * `capability-scan.ts`, gives it its lists).
48
+ *
49
+ * `resolved` is `false` when the program has no import of
50
+ * `@vestra-player/sdk` that resolves: nothing can be found by type then.
51
+ *
52
+ * @internal
53
+ */
54
+ export declare function findMemberUses(ts: typeof TS, program: TS.Program, options: {
55
+ readonly files: readonly string[];
56
+ readonly apis: Iterable<string>;
57
+ }): {
58
+ resolved: boolean;
59
+ uses: MemberUse[];
60
+ requests: RequestUse[];
61
+ };