@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
package/dist/ts-plugin.js CHANGED
@@ -1,147 +1,9 @@
1
- import { addCapabilityEdit, CAPABILITY_DIAGNOSTIC, CAPABILITY_UNCHECKED, checkCapabilities, isPluginSource, } from "./capability-check.js";
2
- const FIX_NAME = "vestraAddCapability";
3
- /** The nearest manifest.json at or above a file, with its capabilities. */
4
- function manifestFor(ts, file) {
5
- let directory = file.replaceAll("\\", "/");
6
- for (;;) {
7
- const parent = directory.slice(0, directory.lastIndexOf("/"));
8
- if (!parent || parent === directory)
9
- return undefined;
10
- directory = parent;
11
- const path = `${directory}/manifest.json`;
12
- if (!ts.sys.fileExists(path))
13
- continue;
14
- try {
15
- const manifest = JSON.parse(ts.sys.readFile(path) ?? "");
16
- if (!Array.isArray(manifest.capabilities))
17
- return undefined;
18
- return {
19
- path,
20
- directory,
21
- capabilities: manifest.capabilities.filter((each) => typeof each === "string"),
22
- };
23
- }
24
- catch {
25
- return undefined;
26
- }
27
- }
28
- }
29
- /**
30
- * The manifest's text for the quick fix. The TypeScript server applies a
31
- * code fix only to files it knows, and editors do not hand it JSON files
32
- * (VS Code does not), so the manifest is made known first; its text is then
33
- * the server's: an open buffer when the editor shares one, else the file on
34
- * disk (VS Code: the saved manifest, not unsaved edits).
35
- */
36
- function manifestText(ts, info, path) {
37
- const service = info.project?.projectService;
38
- const script = service && ts.server?.toNormalizedPath
39
- ? service.getOrCreateScriptInfoForNormalizedPath(ts.server.toNormalizedPath(path), false)
40
- : undefined;
41
- const snapshot = script?.getSnapshot();
42
- return snapshot
43
- ? snapshot.getText(0, snapshot.getLength())
44
- : ts.sys.readFile(path);
45
- }
46
1
  /** @internal The plugin factory tsserver calls (`ts-plugin/index.js`). */
47
- export default function init(modules) {
48
- const ts = modules.typescript;
2
+ export default function init(_modules) {
49
3
  return {
50
4
  create(info) {
51
- const service = info.languageService;
52
- const log = (message) => info.project?.projectService?.logger?.info(`[@vestra-player/sdk/ts-plugin] ${message}`);
53
- const none = { findings: [], unchecked: [] };
54
- const results = (file) => {
55
- const manifest = manifestFor(ts, file);
56
- const program = service.getProgram();
57
- if (!manifest || !program || !isPluginSource(manifest.directory, file))
58
- return none;
59
- try {
60
- return checkCapabilities(ts, program, {
61
- files: [file],
62
- capabilities: manifest.capabilities,
63
- });
64
- }
65
- catch (error) {
66
- log(`check failed: ${error.stack ?? String(error)}`);
67
- return none;
68
- }
69
- };
70
- const findings = (file) => results(file).findings;
71
- const proxy = Object.create(null);
72
- for (const key of Object.keys(service)) {
73
- const member = service[key];
74
- proxy[key] =
75
- typeof member === "function" ? member.bind(service) : member;
76
- }
77
- proxy.getSemanticDiagnostics = (file) => {
78
- const prior = service.getSemanticDiagnostics(file);
79
- const source = service.getProgram()?.getSourceFile(file);
80
- const { findings: missing, unchecked } = results(file);
81
- return [
82
- ...prior,
83
- ...missing.map((finding) => ({
84
- file: source,
85
- start: finding.start,
86
- length: finding.length,
87
- messageText: finding.message,
88
- category: ts.DiagnosticCategory.Error,
89
- code: CAPABILITY_DIAGNOSTIC,
90
- source: "vestra",
91
- })),
92
- ...unchecked.map((call) => ({
93
- file: source,
94
- start: call.start,
95
- length: call.length,
96
- messageText: call.message,
97
- category: ts.DiagnosticCategory.Warning,
98
- code: CAPABILITY_UNCHECKED,
99
- source: "vestra",
100
- })),
101
- ];
102
- };
103
- proxy.getSupportedCodeFixes = (file) => [
104
- ...service.getSupportedCodeFixes(file),
105
- String(CAPABILITY_DIAGNOSTIC),
106
- ];
107
- proxy.getCodeFixesAtPosition = (file, start, end, errorCodes, format, preferences) => {
108
- const prior = service.getCodeFixesAtPosition(file, start, end, errorCodes, format, preferences);
109
- if (!errorCodes.includes(CAPABILITY_DIAGNOSTIC))
110
- return prior;
111
- const manifest = manifestFor(ts, file);
112
- if (!manifest)
113
- return prior;
114
- const text = manifestText(ts, info, manifest.path);
115
- if (text === undefined)
116
- return prior;
117
- const wanted = new Set(findings(file)
118
- .filter((finding) => finding.start <= end && finding.start + finding.length >= start)
119
- .map((finding) => finding.capability));
120
- const fixes = [];
121
- for (const capability of wanted) {
122
- const edit = addCapabilityEdit(ts, text, capability);
123
- if (!edit)
124
- continue;
125
- fixes.push({
126
- fixName: FIX_NAME,
127
- description: `Add '${capability}' to manifest.json`,
128
- changes: [
129
- {
130
- fileName: manifest.path,
131
- textChanges: [
132
- {
133
- span: { start: edit.start, length: edit.length },
134
- newText: edit.newText,
135
- },
136
- ],
137
- },
138
- ],
139
- });
140
- }
141
- return [...prior, ...fixes];
142
- };
143
- log("enabled");
144
- return proxy;
5
+ info.project?.projectService?.logger?.info("[@vestra-player/sdk/ts-plugin] does nothing since SDK 1.9.0 (no manifest capabilities); remove it from tsconfig.json");
6
+ return info.languageService;
145
7
  },
146
8
  };
147
9
  }
package/dist/wire.d.ts CHANGED
@@ -17,7 +17,6 @@ export interface PluginInfo {
17
17
  id: string;
18
18
  apiVersion: string;
19
19
  entry: string;
20
- capabilities: string[];
21
20
  }
22
21
  export interface PackageValidation {
23
22
  token: string;
@@ -170,7 +169,7 @@ export type PropertyWrite = {
170
169
  *
171
170
  * Common codes: `stale` (the condition no longer holds; nothing was done),
172
171
  * `invalid` (bad argument), `missing` (unknown target), `capability`
173
- * (undeclared capability), `busy`, `conflict`, `unavailable`, `unsupported`
172
+ * (a built-in-only request from another plugin), `busy`, `conflict`, `unavailable`, `unsupported`
174
173
  * (refused, not executed), `backend` (load or parse failure), `failed`,
175
174
  * `timeout`, `aborted`, `limit` (a player limit such as the command count),
176
175
  * `disabled` (the plugin is stopping).
@@ -201,7 +200,6 @@ export type PropertyWrite = {
201
200
  * A definite refusal, as opposed to a lost reply: the SDK does not retry
202
201
  * it, and the plugin sees an `Error` with `code`.
203
202
  *
204
- * @capability None.
205
203
  * @since 1.0.0
206
204
  * @category Testing
207
205
  */
@@ -238,8 +236,6 @@ export interface PackageInfo {
238
236
  state: "starting" | "running" | "disabled" | "failed" | "stopped";
239
237
  /** Why it failed, when `state` is `failed`; else `null`. */
240
238
  error: string | null;
241
- /** The capabilities its manifest declares. */
242
- capabilities: string[];
243
239
  /** Its directory on disk. */
244
240
  directory: string;
245
241
  /** One of the player's built-in plugins. */
@@ -436,7 +432,7 @@ export interface WireTimeline {
436
432
  /** The ranges. */
437
433
  ranges?: WireRange[];
438
434
  }
439
- /** A panel position (`ui.mount`'s `slot`). */
435
+ /** A panel position (`ui.mount`'s `slot` parameter). */
440
436
  export type MountSlot = "bottom" | "sidebar" | "backdrop" | "adjust";
441
437
  /** The backdrop as `layout.state` reports it; `null` without one. */
442
438
  export interface LayoutBackdrop {
@@ -782,7 +778,7 @@ export declare function createWire(transport: Transport): {
782
778
  }[]>;
783
779
  set: (id: string | null) => Promise<void>;
784
780
  };
785
- /** The binding table: list, user overlay (`bindings.manage`). */
781
+ /** The binding table: list, user overlay. */
786
782
  bindings: {
787
783
  list: () => Promise<BindingTable>;
788
784
  set: (plugin: string, command: string, inputs: string[]) => Promise<void>;
@@ -791,19 +787,19 @@ export declare function createWire(transport: Transport): {
791
787
  command: string;
792
788
  }) => Promise<void>;
793
789
  };
794
- /** File drops: providers by extension, panel listeners (`ui.drop`). */
790
+ /** File drops: providers by extension, panel listeners. */
795
791
  drops: {
796
792
  provide: (id: string, extensions: string[]) => Promise<void>;
797
793
  withdraw: (id: string) => Promise<void>;
798
794
  listen: (listen: boolean) => Promise<void>;
799
795
  };
800
- /** The palette (`ui.theme` to change it). */
796
+ /** The palette: read it, change it. */
801
797
  appearance: {
802
798
  set: (theme: string) => Promise<void>;
803
799
  /** The interface language for the next start. */
804
800
  setLanguage: (language: string) => Promise<void>;
805
801
  };
806
- /** Settings pages in the player's options window (`ui.settings`). */
802
+ /** Settings pages in the player's options window. */
807
803
  settings: {
808
804
  register: (options: {
809
805
  id: string;
@@ -957,8 +953,7 @@ export declare function createWire(transport: Transport): {
957
953
  system: () => Promise<WireSystemInfo>;
958
954
  };
959
955
  /**
960
- * The rendering choice: `state` needs no capability, `setPreference` and
961
- * `restart` need `rendering.manage`.
956
+ * The rendering choice: `state`, `setPreference` and `restart`.
962
957
  */
963
958
  rendering: {
964
959
  state: () => Promise<WireRenderingState>;
package/dist/wire.js CHANGED
@@ -26,7 +26,7 @@ export const API_VERSION = "vestra/1";
26
26
  *
27
27
  * Common codes: `stale` (the condition no longer holds; nothing was done),
28
28
  * `invalid` (bad argument), `missing` (unknown target), `capability`
29
- * (undeclared capability), `busy`, `conflict`, `unavailable`, `unsupported`
29
+ * (a built-in-only request from another plugin), `busy`, `conflict`, `unavailable`, `unsupported`
30
30
  * (refused, not executed), `backend` (load or parse failure), `failed`,
31
31
  * `timeout`, `aborted`, `limit` (a player limit such as the command count),
32
32
  * `disabled` (the plugin is stopping).
@@ -57,7 +57,6 @@ export const API_VERSION = "vestra/1";
57
57
  * A definite refusal, as opposed to a lost reply: the SDK does not retry
58
58
  * it, and the plugin sees an `Error` with `code`.
59
59
  *
60
- * @capability None.
61
60
  * @since 1.0.0
62
61
  * @category Testing
63
62
  */
@@ -110,25 +109,25 @@ export function createWire(transport) {
110
109
  devices: () => transport.request("player.audioDevices"),
111
110
  set: (id) => transport.request("player.setAudioDevice", { id }),
112
111
  },
113
- /** The binding table: list, user overlay (`bindings.manage`). */
112
+ /** The binding table: list, user overlay. */
114
113
  bindings: {
115
114
  list: () => transport.request("bindings.list"),
116
115
  set: (plugin, command, inputs) => transport.request("bindings.set", { plugin, command, inputs }),
117
116
  reset: (ref) => transport.request("bindings.reset", ref ?? {}),
118
117
  },
119
- /** File drops: providers by extension, panel listeners (`ui.drop`). */
118
+ /** File drops: providers by extension, panel listeners. */
120
119
  drops: {
121
120
  provide: (id, extensions) => transport.request("drops.provide", { id, extensions }),
122
121
  withdraw: (id) => transport.request("drops.withdraw", { id }),
123
122
  listen: (listen) => transport.request("drops.listen", { listen }),
124
123
  },
125
- /** The palette (`ui.theme` to change it). */
124
+ /** The palette: read it, change it. */
126
125
  appearance: {
127
126
  set: (theme) => transport.request("appearance.set", { theme }),
128
127
  /** The interface language for the next start. */
129
128
  setLanguage: (language) => transport.request("appearance.setLanguage", { language }),
130
129
  },
131
- /** Settings pages in the player's options window (`ui.settings`). */
130
+ /** Settings pages in the player's options window. */
132
131
  settings: {
133
132
  register: (options) => transport.request("settings.register", options),
134
133
  set: (id, property, write) => transport.request("settings.set", { id, property, ...write }),
@@ -253,8 +252,7 @@ export function createWire(transport) {
253
252
  system: () => transport.request("app.system"),
254
253
  },
255
254
  /**
256
- * The rendering choice: `state` needs no capability, `setPreference` and
257
- * `restart` need `rendering.manage`.
255
+ * The rendering choice: `state`, `setPreference` and `restart`.
258
256
  */
259
257
  rendering: {
260
258
  state: () => transport.request("rendering.state"),
package/llms.txt CHANGED
@@ -1,12 +1,12 @@
1
1
  # Vestra Player SDK
2
2
 
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/.
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/.
4
4
 
5
5
  ## Read the documentation
6
6
 
7
7
  - **Command line** (any coding agent): `npx -p @vestra-player/sdk vestra-plugin docs [path] [--page N]` prints one node of the tree; `npx -p @vestra-player/sdk vestra-plugin docs --search <words>` lists the matching paths. In a project that depends on the SDK, `npx vestra-plugin docs` is enough.
8
8
  - **In a Node.js program**: `import { docs, searchDocs } from "@vestra-player/sdk/docs"`; `docs(path, { page })` and `searchDocs(query, { page })` return the same text.
9
- - **Paths**: `/` lists the top level; every answer lists the paths one level down with a one-line summary. `/API/<category>/<symbol>/<member>` is one declaration with its signature, parameters, return value, errors, capability, player version and examples, for example `/API/Media/Snapshot/dispose`. `/Guides/<group>/<page>` is a page of the site, for example `/Guides/Guides/Test a plugin` (the file name works too: `/Guides/Guides/testing`). Case, spaces and punctuation do not matter, the leading `/` is optional, `.` works like `/`, a name alone finds its declaration (`TestHost`, `Snapshot.export`, `plugin.player`), and `#heading` opens the page of a long answer that has that section.
9
+ - **Paths**: `/` lists the top level; every answer lists the paths one level down with a one-line summary. `/API/<category>/<symbol>/<member>` is one declaration with its signature, parameters, return value, errors, the SDK and player versions it needs, and examples, for example `/API/Media/Snapshot/dispose`. `/Guides/<group>/<page>` is a page of the site, for example `/Guides/Guides/Test a plugin` (the file name works too: `/Guides/Guides/testing`). Case, spaces and punctuation do not matter, the leading `/` is optional, `.` works like `/`, a name alone finds its declaration (`TestHost`, `Snapshot.export`, `plugin.player`), and `#heading` opens the page of a long answer that has that section.
10
10
  - **Size**: every answer is at most 8 KB; a longer one ends with the number of its next page (`--page 2`).
11
11
  - **Before writing code**, read `/Guides/Tutorial` and `/Guides/Guides/Design rules`, then the API of what you use. Test with `/Guides/Guides/Test a plugin`.
12
12
 
@@ -20,7 +20,7 @@
20
20
 
21
21
  - `/Guides/Tutorial`: Write a first plugin for Vestra Player: a menu item that shows the playback position, then the three styles a plugin can use, and how to test and publish it.
22
22
  - `/Guides/Guides`: One page per task, from adding a window to publishing a plugin, plus the design rules and troubleshooting.
23
- - `/Guides/Reference`: Lookup tables that span many symbols, from manifest fields and capabilities to the test host, mostly generated from the SDK's code.
23
+ - `/Guides/Reference`: Lookup tables that span many symbols, from manifest fields to the test host, mostly generated from the SDK's code.
24
24
  - `/Guides/Examples`: Complete, tested example plugins with a screenshot each and a step-by-step walkthrough of their code.
25
25
 
26
26
  ## API
@@ -35,5 +35,5 @@
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`: 34 entries: CapabilityInfo, CAPABILITY_INFO, MESSAGE_LIMIT, COMMAND_LIMITS, MENU_IDS, BAR_BUTTON_ICONS, BAR_BUTTON_LIMITS, BuiltinSubmenu, BUILTIN_SUBMENUS, BuiltinCommand, BUILTIN_COMMANDS, LOCALES,…
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,…
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.8.0",
3
+ "version": "1.9.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": {
@@ -54,7 +54,6 @@
54
54
  "api-surface": "node scripts/api-surface.mjs",
55
55
  "bench": "node scripts/bench.mjs",
56
56
  "build": "node scripts/build.mjs",
57
- "capabilities:sync": "node scripts/capabilities-sync.mjs",
58
57
  "check": "tsc -p tsconfig.check.json && node scripts/check-layers.mjs",
59
58
  "doc-lint": "node scripts/doc-lint.mjs",
60
59
  "docs": "typedoc",
@@ -1,107 +0,0 @@
1
- /**
2
- * What one manifest capability is for: the members it opens, the
3
- * capabilities they also need, and how the plugin store describes it. An
4
- * entry of {@link CAPABILITY_INFO}.
5
- *
6
- * @since 1.5.14
7
- *
8
- * @category Testing
9
- */
10
- export interface CapabilityInfo {
11
- /**
12
- * The members this capability opens, as `Interface.member` (for example
13
- * `Commands.add` is `plugin.commands.add`). A call to one of them without
14
- * the capability fails with code `capability`; `Plugin.video.filter` is
15
- * `plugin.video.filter`. A member can be listed
16
- * under more than one capability when it needs all of them
17
- * (`Panel.onChange` needs `ui.mount` and `events`).
18
- */
19
- readonly apis: readonly string[];
20
- /**
21
- * Capabilities every member in {@link CapabilityInfo.apis} also needs:
22
- * declare them as well. What only one member or one option needs
23
- * (`Plugin.video.filter` also needs `events`) is documented at that member.
24
- */
25
- readonly requires: readonly string[];
26
- /**
27
- * How the plugin store and the player's install confirmation describe the
28
- * capability to the user, in English (the player translates it). Two
29
- * capabilities can share one description (`media.read` and
30
- * `media.control`); the store then shows it once.
31
- */
32
- readonly label: string;
33
- /**
34
- * `true` when the store highlights the capability as one to think about
35
- * before installing (it reaches outside the plugin's own features: the
36
- * clipboard, every shortcut, the keychain, other plugins).
37
- */
38
- readonly risky: boolean;
39
- /**
40
- * `true` when only the player's built-in plugins may declare it
41
- * (`commands.run`, `palette.lead`): the player refuses a package of any
42
- * other plugin that declares it, and its calls fail with `capability`.
43
- * `vestra-plugin check` reports it.
44
- *
45
- * @since 1.7.9
46
- */
47
- readonly builtinOnly: boolean;
48
- }
49
- /**
50
- * Every manifest capability the player knows (`vestra/1`), in the player's
51
- * order, with the members it opens, the capabilities they also need and the
52
- * store's wording. Built from the player's own capability table (its
53
- * `src/host/capabilities.json`, copied into the SDK) and the requests each
54
- * member sends, the same rule `vestra-plugin check` and the SDK's
55
- * TypeScript plugin apply; the player's tests check that the copy is
56
- * current.
57
- *
58
- * A member not listed under any capability needs none (`plugin.tools`,
59
- * `plugin.storage`, `plugin.system`, `plugin.app`, `plugin.ui`,
60
- * `plugin.i18n`, reading `plugin.window.state`, `plugin.appearance.theme`,
61
- * `plugin.packages.list` and `plugin.rendering.state`).
62
- *
63
- * @example Check in a test that the manifest declares every required capability
64
- * The test fails, naming the missing capability, when the manifest declares
65
- * a capability without one its members also need. It reads the plugin's own
66
- * `manifest.json` and looks each declared name up in `CAPABILITY_INFO`,
67
- * whose `requires` lists the capabilities that must be declared with it;
68
- * at run time the player would refuse such a call with code `capability`.
69
- * ```ts
70
- * import assert from "node:assert/strict";
71
- * import { readFile } from "node:fs/promises";
72
- * import { CAPABILITY_INFO } from "@vestra-player/sdk/testing";
73
- *
74
- * const manifest: { capabilities: string[] } = JSON.parse(
75
- * await readFile(new URL("../manifest.json", import.meta.url), "utf8"),
76
- * );
77
- * for (const capability of manifest.capabilities)
78
- * // An unknown name has no entry: `vestra-plugin check` reports it.
79
- * for (const needed of CAPABILITY_INFO[capability]?.requires ?? [])
80
- * assert.ok(manifest.capabilities.includes(needed), needed);
81
- * ```
82
- *
83
- * @since 1.5.14
84
- *
85
- * @category Testing
86
- */
87
- export declare const CAPABILITY_INFO: Readonly<Record<string, CapabilityInfo>>;
88
- /**
89
- * Manifest capabilities the player knows (`vestra/1`): the keys of
90
- * {@link CAPABILITY_INFO}, in the player's order. The same list as the
91
- * player's `host/capabilities.json`; the player's tests check that they agree.
92
- */
93
- export declare const CAPABILITIES: readonly string[];
94
- /** The plugin API version this SDK implements (`manifest.apiVersion`). */
95
- export declare const API_VERSION = "vestra/1";
96
- /**
97
- * The longest message a plugin may send the player, in UTF-8 bytes of one
98
- * protocol line with its newline (1 MiB). The player stops a plugin that
99
- * writes a longer one, so the plugin's side refuses such a request before
100
- * sending it: it rejects with code `limit`. Property values meet
101
- * {@link UI_VALUE_LIMITS} before this.
102
- *
103
- * @since 1.5.14
104
- *
105
- * @category Testing
106
- */
107
- export declare const MESSAGE_LIMIT: number;
@@ -1,69 +0,0 @@
1
- import { capabilityInfo } from "./capability-rules.js";
2
- /**
3
- * Every manifest capability the player knows (`vestra/1`), in the player's
4
- * order, with the members it opens, the capabilities they also need and the
5
- * store's wording. Built from the player's own capability table (its
6
- * `src/host/capabilities.json`, copied into the SDK) and the requests each
7
- * member sends, the same rule `vestra-plugin check` and the SDK's
8
- * TypeScript plugin apply; the player's tests check that the copy is
9
- * current.
10
- *
11
- * A member not listed under any capability needs none (`plugin.tools`,
12
- * `plugin.storage`, `plugin.system`, `plugin.app`, `plugin.ui`,
13
- * `plugin.i18n`, reading `plugin.window.state`, `plugin.appearance.theme`,
14
- * `plugin.packages.list` and `plugin.rendering.state`).
15
- *
16
- * @example Check in a test that the manifest declares every required capability
17
- * The test fails, naming the missing capability, when the manifest declares
18
- * a capability without one its members also need. It reads the plugin's own
19
- * `manifest.json` and looks each declared name up in `CAPABILITY_INFO`,
20
- * whose `requires` lists the capabilities that must be declared with it;
21
- * at run time the player would refuse such a call with code `capability`.
22
- * ```ts
23
- * import assert from "node:assert/strict";
24
- * import { readFile } from "node:fs/promises";
25
- * import { CAPABILITY_INFO } from "@vestra-player/sdk/testing";
26
- *
27
- * const manifest: { capabilities: string[] } = JSON.parse(
28
- * await readFile(new URL("../manifest.json", import.meta.url), "utf8"),
29
- * );
30
- * for (const capability of manifest.capabilities)
31
- * // An unknown name has no entry: `vestra-plugin check` reports it.
32
- * for (const needed of CAPABILITY_INFO[capability]?.requires ?? [])
33
- * assert.ok(manifest.capabilities.includes(needed), needed);
34
- * ```
35
- *
36
- * @since 1.5.14
37
- *
38
- * @category Testing
39
- */
40
- export const CAPABILITY_INFO = Object.freeze(Object.fromEntries(Object.entries(capabilityInfo()).map(([name, info]) => [
41
- name,
42
- Object.freeze({
43
- apis: Object.freeze(info.apis),
44
- requires: Object.freeze(info.requires),
45
- label: info.label,
46
- risky: info.risky,
47
- builtinOnly: info.builtinOnly,
48
- }),
49
- ])));
50
- /**
51
- * Manifest capabilities the player knows (`vestra/1`): the keys of
52
- * {@link CAPABILITY_INFO}, in the player's order. The same list as the
53
- * player's `host/capabilities.json`; the player's tests check that they agree.
54
- */
55
- export const CAPABILITIES = Object.freeze(Object.keys(CAPABILITY_INFO));
56
- /** The plugin API version this SDK implements (`manifest.apiVersion`). */
57
- export const API_VERSION = "vestra/1";
58
- /**
59
- * The longest message a plugin may send the player, in UTF-8 bytes of one
60
- * protocol line with its newline (1 MiB). The player stops a plugin that
61
- * writes a longer one, so the plugin's side refuses such a request before
62
- * sending it: it rejects with code `limit`. Property values meet
63
- * {@link UI_VALUE_LIMITS} before this.
64
- *
65
- * @since 1.5.14
66
- *
67
- * @category Testing
68
- */
69
- export const MESSAGE_LIMIT = 1024 * 1024;