@vestra-player/sdk 1.8.0 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +64 -2
- package/README.md +2 -2
- package/bin/vestra-plugin.mjs +98 -106
- package/capability-scan.json +21 -1
- package/dist/api-requests.d.ts +15 -39
- package/dist/api-requests.js +28 -50
- package/dist/capability-scan.d.ts +1 -1
- package/dist/capability-scan.js +8 -9
- package/dist/condition-table.d.ts +1889 -0
- package/dist/condition-table.js +562 -0
- package/dist/docs-tree.json.gz +0 -0
- package/dist/docs.d.ts +1 -1
- package/dist/docs.js +1 -1
- package/dist/i18n-tools.d.ts +7 -0
- package/dist/i18n-tools.js +66 -3
- package/dist/index.d.ts +4 -5
- package/dist/manifest.d.ts +5 -0
- package/dist/manifest.js +9 -24
- package/dist/member-uses.d.ts +61 -0
- package/dist/member-uses.js +160 -0
- package/dist/player-runtime.d.ts +4 -2
- package/dist/player-runtime.js +4 -2
- package/dist/plugin/appearance.d.ts +1 -1
- package/dist/plugin/appearance.js +2 -2
- package/dist/plugin/bindings.d.ts +1 -1
- package/dist/plugin/bindings.js +2 -2
- package/dist/plugin/commands.js +1 -12
- package/dist/plugin/connection.d.ts +38 -8
- package/dist/plugin/connection.js +126 -37
- package/dist/plugin/drops.js +1 -1
- package/dist/plugin/index.d.ts +7 -0
- package/dist/plugin/index.js +22 -15
- package/dist/plugin/media.js +0 -12
- package/dist/plugin/mpv.js +39 -12
- package/dist/plugin/packages.js +1 -2
- package/dist/plugin/player/events.d.ts +17 -7
- package/dist/plugin/player/events.js +26 -9
- package/dist/plugin/player.d.ts +37 -13
- package/dist/plugin/player.js +133 -22
- package/dist/plugin/scope.d.ts +4 -1
- package/dist/plugin/scope.js +8 -0
- package/dist/plugin/services.d.ts +4 -4
- package/dist/plugin/services.js +7 -29
- package/dist/plugin/settings.js +1 -1
- package/dist/plugin/shaders.js +0 -2
- package/dist/plugin/stream.d.ts +2 -1
- package/dist/plugin/stream.js +2 -2
- package/dist/plugin/testing/commands.d.ts +3 -10
- package/dist/plugin/testing/commands.js +24 -37
- package/dist/plugin/testing/index.d.ts +133 -116
- package/dist/plugin/testing/index.js +198 -125
- package/dist/plugin/testing/media.d.ts +6 -0
- package/dist/plugin/testing/media.js +15 -2
- package/dist/plugin/testing/processing.js +1 -1
- package/dist/plugin/testing/services.js +0 -1
- package/dist/plugin/testing/source-events.d.ts +28 -0
- package/dist/plugin/testing/source-events.js +66 -0
- package/dist/plugin/testing/transport.js +5 -0
- package/dist/plugin/testing/triggers.d.ts +82 -0
- package/dist/plugin/testing/triggers.js +448 -0
- package/dist/plugin/timeline.d.ts +5 -6
- package/dist/plugin/timeline.js +7 -11
- package/dist/plugin/triggers.d.ts +55 -0
- package/dist/plugin/triggers.js +233 -0
- package/dist/plugin/types/base.d.ts +77 -87
- package/dist/plugin/types/commands.d.ts +384 -68
- package/dist/plugin/types/packages.d.ts +17 -55
- package/dist/plugin/types/playback.d.ts +382 -152
- package/dist/plugin/types/plugin-wire.d.ts +6 -36
- package/dist/plugin/types/processing.d.ts +10 -49
- package/dist/plugin/types/services.d.ts +11 -70
- package/dist/plugin/types/snapshots.d.ts +7 -60
- package/dist/plugin/types/sources.d.ts +2 -11
- package/dist/plugin/types/subtitles.d.ts +5 -26
- package/dist/plugin/types/ui-content.d.ts +1 -16
- package/dist/plugin/types/ui-layout.d.ts +53 -79
- package/dist/plugin/types/ui-locale.d.ts +5 -23
- package/dist/plugin/types/ui-shell.d.ts +13 -59
- package/dist/plugin/view/layout.js +1 -1
- package/dist/plugin/view.js +0 -2
- package/dist/plugin/when.d.ts +78 -4
- package/dist/plugin/when.js +182 -14
- package/dist/plugin/window.d.ts +1 -1
- package/dist/plugin/window.js +1 -1
- package/dist/plugin/wire-facade.js +1 -2
- package/dist/processing.d.ts +2 -3
- package/dist/protocol.d.ts +14 -0
- package/dist/protocol.js +14 -0
- package/dist/request-queue.js +1 -1
- package/dist/slint-version.d.ts +7 -0
- package/dist/slint-version.js +7 -0
- package/dist/subtitles.d.ts +1 -1
- package/dist/ts-plugin.d.ts +8 -15
- package/dist/ts-plugin.js +3 -141
- package/dist/wire.d.ts +22 -12
- package/dist/wire.js +17 -8
- package/llms.txt +6 -6
- package/package.json +1 -2
- package/dist/capabilities.d.ts +0 -107
- package/dist/capabilities.js +0 -69
- package/dist/capability-check.d.ts +0 -176
- package/dist/capability-check.js +0 -461
- package/dist/capability-rules.d.ts +0 -125
- package/dist/capability-rules.js +0 -192
- package/dist/host-capabilities.d.ts +0 -10
- package/dist/host-capabilities.js +0 -492
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
|
-
* (
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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 }),
|
|
@@ -233,6 +232,17 @@ export function createWire(transport) {
|
|
|
233
232
|
observeProperty: (name) => transport.request("mpv.observe", { name }),
|
|
234
233
|
unobserveProperty: (name) => transport.request("mpv.unobserve", { name }),
|
|
235
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
|
+
},
|
|
236
246
|
/** The system's secret store, per plugin (`secrets`). */
|
|
237
247
|
secrets: {
|
|
238
248
|
get: (name) => transport.request("secrets.get", { name }),
|
|
@@ -253,8 +263,7 @@ export function createWire(transport) {
|
|
|
253
263
|
system: () => transport.request("app.system"),
|
|
254
264
|
},
|
|
255
265
|
/**
|
|
256
|
-
* The rendering choice: `state
|
|
257
|
-
* `restart` need `rendering.manage`.
|
|
266
|
+
* The rendering choice: `state`, `setPreference` and `restart`.
|
|
258
267
|
*/
|
|
259
268
|
rendering: {
|
|
260
269
|
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.
|
|
3
|
+
> @vestra-player/sdk 1.10.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,
|
|
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,20 +20,20 @@
|
|
|
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
|
|
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
|
|
27
27
|
|
|
28
|
-
- `/API/Commands`:
|
|
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`:
|
|
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`: 34 entries:
|
|
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.
|
|
3
|
+
"version": "1.10.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",
|
package/dist/capabilities.d.ts
DELETED
|
@@ -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;
|
package/dist/capabilities.js
DELETED
|
@@ -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;
|
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The capability checker: every use of a plugin API member whose capability
|
|
3
|
-
* the plugin's `manifest.json` does not declare. `vestra-plugin check` (and
|
|
4
|
-
* so `build` and `pack`) and the TypeScript language-service plugin
|
|
5
|
-
* (`@vestra-player/sdk/ts-plugin`) both run it; the rule is
|
|
6
|
-
* `capability-rules.ts` (the player's table and the SDK's requests).
|
|
7
|
-
*
|
|
8
|
-
* It is type-aware: a use is a property access, an element access with a
|
|
9
|
-
* literal name or a destructured property whose symbol is the SDK's
|
|
10
|
-
* declaration of a member in the table, however the object was reached
|
|
11
|
-
* (`plugin.player.seek`, `const { player } = plugin; player.seek`, a
|
|
12
|
-
* parameter typed `Player`, a `Panel` from `panels.mount`). Not detected:
|
|
13
|
-
* access with a computed name (`player[name]`), values typed `any` or
|
|
14
|
-
* `unknown`, plain JavaScript without types, members inherited from `View`
|
|
15
|
-
* (their object comes from a call that is checked) and options that need
|
|
16
|
-
* more (a `processed` capture, a file resolver).
|
|
17
|
-
*
|
|
18
|
-
* Members whose capability depends on an argument (`plugin.player.on` and
|
|
19
|
-
* `plugin.wire.on` by event name, `plugin.wire.request` by method name,
|
|
20
|
-
* `ARGUMENT_APIS`) are checked by that argument when its type fixes it to one
|
|
21
|
-
* string (a literal, a constant); otherwise (a computed name, a union of
|
|
22
|
-
* several, the member taken by destructuring or as a value) the call is
|
|
23
|
-
* reported as unchecked ({@link checkCapabilities}), and the player still
|
|
24
|
-
* checks it.
|
|
25
|
-
*
|
|
26
|
-
* The TypeScript module is passed in, never imported: the CLI uses the
|
|
27
|
-
* SDK's own compiler, the editor its TypeScript server's.
|
|
28
|
-
*
|
|
29
|
-
* @internal
|
|
30
|
-
*/
|
|
31
|
-
import type TS from "typescript";
|
|
32
|
-
import type { CapabilityRules } from "./capability-rules.ts";
|
|
33
|
-
/** @internal The module plugins import the API types from. */
|
|
34
|
-
export declare const SDK_MODULE = "@vestra-player/sdk";
|
|
35
|
-
/** @internal The diagnostic code the editor shows (and its quick fix keys on). */
|
|
36
|
-
export declare const CAPABILITY_DIAGNOSTIC = 95301;
|
|
37
|
-
/**
|
|
38
|
-
* @internal The warning code the editor shows for a call whose capability
|
|
39
|
-
* the checker cannot read (`plugin.wire.request` with a computed method).
|
|
40
|
-
*/
|
|
41
|
-
export declare const CAPABILITY_UNCHECKED = 95302;
|
|
42
|
-
/** @internal One use of a member whose capability is not declared. */
|
|
43
|
-
export interface CapabilityFinding {
|
|
44
|
-
/** The source file, as the program names it. */
|
|
45
|
-
readonly file: string;
|
|
46
|
-
/** 1-based line and column of the member's name. */
|
|
47
|
-
readonly line: number;
|
|
48
|
-
readonly column: number;
|
|
49
|
-
/** Offset and length of the member's name in the file. */
|
|
50
|
-
readonly start: number;
|
|
51
|
-
readonly length: number;
|
|
52
|
-
/** The member, `Interface.member` (`Player.seek`). */
|
|
53
|
-
readonly api: string;
|
|
54
|
-
/** The capability to declare. */
|
|
55
|
-
readonly capability: string;
|
|
56
|
-
/** The request that needs it. */
|
|
57
|
-
readonly method: string;
|
|
58
|
-
/** The declared-or-needed capability whose `requires` names it. */
|
|
59
|
-
readonly requiredBy?: string;
|
|
60
|
-
/** One line for people. */
|
|
61
|
-
readonly message: string;
|
|
62
|
-
}
|
|
63
|
-
/** @internal */
|
|
64
|
-
export interface CheckOptions {
|
|
65
|
-
/** The files to check (others in the program are only read for types). */
|
|
66
|
-
readonly files: readonly string[];
|
|
67
|
-
/** The manifest's `capabilities`. */
|
|
68
|
-
readonly capabilities: readonly string[];
|
|
69
|
-
/** Default: the SDK's rules. */
|
|
70
|
-
readonly rules?: CapabilityRules;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* @internal A call whose capability the checker cannot tell: a member of
|
|
74
|
-
* `ARGUMENT_APIS` (`plugin.wire.request`, `player.on`, `wire.on`) whose name
|
|
75
|
-
* argument is not a string the types fix, or a method the player's table does
|
|
76
|
-
* not know. The player still checks it at run time.
|
|
77
|
-
*/
|
|
78
|
-
export interface UncheckedCall {
|
|
79
|
-
readonly file: string;
|
|
80
|
-
/** 1-based line and column of the member's name. */
|
|
81
|
-
readonly line: number;
|
|
82
|
-
readonly column: number;
|
|
83
|
-
/** Offset and length of the member's name in the file. */
|
|
84
|
-
readonly start: number;
|
|
85
|
-
readonly length: number;
|
|
86
|
-
/** The member, `Interface.member` (`Wire.request`). */
|
|
87
|
-
readonly api: string;
|
|
88
|
-
/** One line for people. */
|
|
89
|
-
readonly message: string;
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Every use, in `options.files`, of a member whose capability the manifest
|
|
93
|
-
* does not declare, in file and position order.
|
|
94
|
-
*
|
|
95
|
-
* @internal
|
|
96
|
-
*/
|
|
97
|
-
export declare function findUndeclaredCapabilities(ts: typeof TS, program: TS.Program, options: CheckOptions): CapabilityFinding[];
|
|
98
|
-
/**
|
|
99
|
-
* The capability check: the uses of members whose capability the manifest does
|
|
100
|
-
* not declare (`findings`, as {@link findUndeclaredCapabilities}), and the
|
|
101
|
-
* calls whose capability depends on a name the checker cannot read
|
|
102
|
-
* (`unchecked`).
|
|
103
|
-
*
|
|
104
|
-
* A call of `plugin.player.on` or `plugin.wire.on` is checked by its event
|
|
105
|
-
* name, one of `plugin.wire.request` by its method name and the string
|
|
106
|
-
* fields of its parameters (`{ event: "…" }`), when the types fix them.
|
|
107
|
-
*
|
|
108
|
-
* @internal
|
|
109
|
-
*/
|
|
110
|
-
export declare function checkCapabilities(ts: typeof TS, program: TS.Program, options: CheckOptions): {
|
|
111
|
-
findings: CapabilityFinding[];
|
|
112
|
-
unchecked: UncheckedCall[];
|
|
113
|
-
};
|
|
114
|
-
/**
|
|
115
|
-
* Whether a file belongs to the plugin's production code, given the
|
|
116
|
-
* directory of its `manifest.json`: not in `tests/`, `node_modules/`,
|
|
117
|
-
* `dist/`, `vendor/` or a dot directory (what `vestra-plugin build` leaves
|
|
118
|
-
* out), and not a declaration file.
|
|
119
|
-
*
|
|
120
|
-
* @internal
|
|
121
|
-
*/
|
|
122
|
-
export declare function isPluginSource(directory: string, file: string): boolean;
|
|
123
|
-
/**
|
|
124
|
-
* The edit that adds a capability to a manifest's `capabilities` array, in
|
|
125
|
-
* the array's own layout; `undefined` when the text has no such array.
|
|
126
|
-
*
|
|
127
|
-
* @internal
|
|
128
|
-
*/
|
|
129
|
-
export declare function addCapabilityEdit(ts: typeof TS, text: string, capability: string): {
|
|
130
|
-
start: number;
|
|
131
|
-
length: number;
|
|
132
|
-
newText: string;
|
|
133
|
-
} | undefined;
|
|
134
|
-
/** @internal One use of an SDK member, where {@link findMemberUses} found it. */
|
|
135
|
-
export interface MemberUse {
|
|
136
|
-
readonly file: string;
|
|
137
|
-
/** 1-based line and column of the member's name. */
|
|
138
|
-
readonly line: number;
|
|
139
|
-
readonly column: number;
|
|
140
|
-
/** The member, as it was asked for (`Clipboard.readText`). */
|
|
141
|
-
readonly api: string;
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* @internal A request sent by name (`plugin.wire.request("clipboard.readText")`):
|
|
145
|
-
* the method when the types fix it to one string, else `undefined` (a
|
|
146
|
-
* computed name, a union of several, the member taken as a value).
|
|
147
|
-
*/
|
|
148
|
-
export interface RequestUse {
|
|
149
|
-
readonly file: string;
|
|
150
|
-
readonly line: number;
|
|
151
|
-
readonly column: number;
|
|
152
|
-
readonly method: string | undefined;
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* Every use, in `files`, of the SDK members named by `apis`
|
|
156
|
-
* (`Interface.member`), and every request sent by name
|
|
157
|
-
* (`ARGUMENT_APIS`' `method` members: `Wire.request`), in file and position
|
|
158
|
-
* order. The same type-aware resolution as {@link checkCapabilities}, for
|
|
159
|
-
* any list of members: a use is a property access, an element access with
|
|
160
|
-
* a literal name or a destructured property whose symbol is the SDK's
|
|
161
|
-
* declaration of the member. It reads no manifest and no capability rule
|
|
162
|
-
* (the capability scan, `capability-scan.ts`, gives it its own lists).
|
|
163
|
-
*
|
|
164
|
-
* `resolved` is `false` when the program has no import of
|
|
165
|
-
* `@vestra-player/sdk` that resolves: nothing can be found by type then.
|
|
166
|
-
*
|
|
167
|
-
* @internal
|
|
168
|
-
*/
|
|
169
|
-
export declare function findMemberUses(ts: typeof TS, program: TS.Program, options: {
|
|
170
|
-
readonly files: readonly string[];
|
|
171
|
-
readonly apis: Iterable<string>;
|
|
172
|
-
}): {
|
|
173
|
-
resolved: boolean;
|
|
174
|
-
uses: MemberUse[];
|
|
175
|
-
requests: RequestUse[];
|
|
176
|
-
};
|