@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.
Files changed (106) hide show
  1. package/CHANGELOG.md +64 -2
  2. package/README.md +2 -2
  3. package/bin/vestra-plugin.mjs +98 -106
  4. package/capability-scan.json +21 -1
  5. package/dist/api-requests.d.ts +15 -39
  6. package/dist/api-requests.js +28 -50
  7. package/dist/capability-scan.d.ts +1 -1
  8. package/dist/capability-scan.js +8 -9
  9. package/dist/condition-table.d.ts +1889 -0
  10. package/dist/condition-table.js +562 -0
  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/i18n-tools.d.ts +7 -0
  15. package/dist/i18n-tools.js +66 -3
  16. package/dist/index.d.ts +4 -5
  17. package/dist/manifest.d.ts +5 -0
  18. package/dist/manifest.js +9 -24
  19. package/dist/member-uses.d.ts +61 -0
  20. package/dist/member-uses.js +160 -0
  21. package/dist/player-runtime.d.ts +4 -2
  22. package/dist/player-runtime.js +4 -2
  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 +1 -12
  28. package/dist/plugin/connection.d.ts +38 -8
  29. package/dist/plugin/connection.js +126 -37
  30. package/dist/plugin/drops.js +1 -1
  31. package/dist/plugin/index.d.ts +7 -0
  32. package/dist/plugin/index.js +22 -15
  33. package/dist/plugin/media.js +0 -12
  34. package/dist/plugin/mpv.js +39 -12
  35. package/dist/plugin/packages.js +1 -2
  36. package/dist/plugin/player/events.d.ts +17 -7
  37. package/dist/plugin/player/events.js +26 -9
  38. package/dist/plugin/player.d.ts +37 -13
  39. package/dist/plugin/player.js +133 -22
  40. package/dist/plugin/scope.d.ts +4 -1
  41. package/dist/plugin/scope.js +8 -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 +24 -37
  50. package/dist/plugin/testing/index.d.ts +133 -116
  51. package/dist/plugin/testing/index.js +198 -125
  52. package/dist/plugin/testing/media.d.ts +6 -0
  53. package/dist/plugin/testing/media.js +15 -2
  54. package/dist/plugin/testing/processing.js +1 -1
  55. package/dist/plugin/testing/services.js +0 -1
  56. package/dist/plugin/testing/source-events.d.ts +28 -0
  57. package/dist/plugin/testing/source-events.js +66 -0
  58. package/dist/plugin/testing/transport.js +5 -0
  59. package/dist/plugin/testing/triggers.d.ts +82 -0
  60. package/dist/plugin/testing/triggers.js +448 -0
  61. package/dist/plugin/timeline.d.ts +5 -6
  62. package/dist/plugin/timeline.js +7 -11
  63. package/dist/plugin/triggers.d.ts +55 -0
  64. package/dist/plugin/triggers.js +233 -0
  65. package/dist/plugin/types/base.d.ts +77 -87
  66. package/dist/plugin/types/commands.d.ts +384 -68
  67. package/dist/plugin/types/packages.d.ts +17 -55
  68. package/dist/plugin/types/playback.d.ts +382 -152
  69. package/dist/plugin/types/plugin-wire.d.ts +6 -36
  70. package/dist/plugin/types/processing.d.ts +10 -49
  71. package/dist/plugin/types/services.d.ts +11 -70
  72. package/dist/plugin/types/snapshots.d.ts +7 -60
  73. package/dist/plugin/types/sources.d.ts +2 -11
  74. package/dist/plugin/types/subtitles.d.ts +5 -26
  75. package/dist/plugin/types/ui-content.d.ts +1 -16
  76. package/dist/plugin/types/ui-layout.d.ts +53 -79
  77. package/dist/plugin/types/ui-locale.d.ts +5 -23
  78. package/dist/plugin/types/ui-shell.d.ts +13 -59
  79. package/dist/plugin/view/layout.js +1 -1
  80. package/dist/plugin/view.js +0 -2
  81. package/dist/plugin/when.d.ts +78 -4
  82. package/dist/plugin/when.js +182 -14
  83. package/dist/plugin/window.d.ts +1 -1
  84. package/dist/plugin/window.js +1 -1
  85. package/dist/plugin/wire-facade.js +1 -2
  86. package/dist/processing.d.ts +2 -3
  87. package/dist/protocol.d.ts +14 -0
  88. package/dist/protocol.js +14 -0
  89. package/dist/request-queue.js +1 -1
  90. package/dist/slint-version.d.ts +7 -0
  91. package/dist/slint-version.js +7 -0
  92. package/dist/subtitles.d.ts +1 -1
  93. package/dist/ts-plugin.d.ts +8 -15
  94. package/dist/ts-plugin.js +3 -141
  95. package/dist/wire.d.ts +22 -12
  96. package/dist/wire.js +17 -8
  97. package/llms.txt +6 -6
  98. package/package.json +1 -2
  99. package/dist/capabilities.d.ts +0 -107
  100. package/dist/capabilities.js +0 -69
  101. package/dist/capability-check.d.ts +0 -176
  102. package/dist/capability-check.js +0 -461
  103. package/dist/capability-rules.d.ts +0 -125
  104. package/dist/capability-rules.js +0 -192
  105. package/dist/host-capabilities.d.ts +0 -10
  106. package/dist/host-capabilities.js +0 -492
package/CHANGELOG.md CHANGED
@@ -1,12 +1,74 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.10.0
4
+
5
+ **Events, triggers and the state stream: a plugin can learn what happens in the player without staying up for it.** Who must change: nobody. Everything below is an addition or a correction of the docs, except two behaviour changes (the update pass after an `mpv.observe` listener, and a timeline layer's range limit); `subscribe()` and `onChange()` keep working unchanged. Needs player 0.10.0 for the source events, triggers, what the player keeps through standby, and 1000 ranges; an older player sends no source events, refuses the `triggers.*` requests and more than 100 ranges, and everything else works with it.
6
+
7
+ **Four ways to get the player's state.** Read it once (`player.read()`, `player.refresh()`, unchanged); hear a discrete event (`player.on("source.ready", fn)`, new events below); hand the player a condition and be told when it turns true and when it turns false (`plugin.trigger()`, new); or follow every change while something shows it (`player.stream(fn)`, new). The first three let the plugin go to standby: the player wakes it for an event or a trigger. Only the stream keeps it running, while it is open ([How plugins work](docs/guides/how-plugins-work.md)).
8
+
9
+ - **Source events** (new, need player 0.10.0): `source.opening` (a source starts to open; `{ state, previous }`, `previous` naming the source open before it, `null` when none was), `source.ready` (it is loaded: duration, tracks and seekability known; `{ state }`) and `source.ended` (it left playback; `{ state, reason, error? }`, `reason` one of `natural`, `stopped`, `replaced`, `error`, `quit`, and `state` that source's last state, with its last position). Once each per source, in that order; a replaced source's `ended` comes before the next one's `opening`. `state` is a `PlayerState`, so it can be passed as `ifCurrent`; for `opening` and `ready` it also becomes `player.state`. `player.on` takes them with typed data (`SourceEvent`, `SourceEventPayloads`), without `subscribe()`. They wake a plugin in standby, so a listener does not keep its plugin running; a plugin in standby gets no `ended` with `quit`. `TestHost` sends them when a source opens, becomes ready and ends ([Events](docs/reference/events.md)).
10
+ - **Triggers** (new, need player 0.10.0): `plugin.trigger(name?)`, called on the plugin (not on a scope made with `plugin.scope()`) in the synchronous part of `activate()`, with `.firesOn(condition)`, `.enter(fn)`, `.leave(fn)` and `.off()`. The player keeps the condition and evaluates it, also while the plugin is in standby, and wakes the plugin when it flips; `enter` and `leave` get `{ state, range? }`, and one trigger's functions run one after another. A condition already true when given is entered at once; the same condition given again changes nothing, so `activate()` may hand it over at every start. Without a name a trigger is known by its place among the unnamed ones, and its condition is cleared when the plugin is updated; with a name it survives an update. A notification nobody handles removes its condition. At most 64 triggers per plugin (`TRIGGER_LIMITS`).
11
+ - **The `when` language grows**: `duration`, `volume`, `rate` (one interval `{ min?, max? }`, `min ≤ value < max`), `audioTrack(id)`, `subtitleTrack(id)` (the primary subtitle track), `audioDevice(id)`, `muted`, `maximized` (never while fullscreen), `pip` and `looping` (an A-B loop is set). They work in a trigger and in a command's `enabled` and `checked` alike (player 0.10.0). Two more are for triggers only, and the player refuses them in a command's state: `time({ min?, max? })` (the wall clock in Unix milliseconds; never before the bound) and `position.in(ranges, { lead })` (the position is in one of the ranges, or less than `lead` media seconds before its start; at most 1000 ranges, bound to the source current when the player receives it; `enter` gets the matched range). A fact that cannot be read counts as false ([Command state](docs/guides/command-state.md)).
12
+ - **`plugin.player.stream(fn)`** (new, with `StateStream`): follow the player's state while something shows it continuously (a window with the position, a meter). `fn` gets the current state once (one read right after the call), then every change the player sends; `player.state` is updated before each call and an update pass runs after it. It needs no `subscribe()`: the stream's own subscription ends with its last `stop()` (or its scope), and `player.state` then keeps the last snapshot. While a stream is open the player keeps the plugin running (a listener, named in its log as `a stream opened at main.ts:12`); after the last `stop()` nothing of it does, so a plugin that holds nothing else goes to standby after its idle time. A stream open when the plugin becomes ready counts as a listener held at the ready: the plugin keeps running for that run. Uses the existing `events.subscribe` and `events.unsubscribe` messages, so it works with older players too.
13
+ - **The player keeps a plugin's static state through standby** (player 0.10.0; nothing changes in the SDK): its timeline layer (marks and ranges) and the always-on-top and cursor settings it wrote no longer keep it running. The layer stays drawn and the settings in effect while the plugin is stopped; after a wake its next write replaces them; a new source still clears every layer; a crash, disable, uninstall, reload, update and the quit remove them. `TestHost.keepsRunning` never counted them.
14
+ - **`TestHost`** keeps and evaluates trigger conditions as the player does and gains `triggers` (what it keeps), `now` and `advance(ms)` (a virtual clock that also moves the playback position, so a range is entered at its time without waiting), `park()` and `parked` (the plugin stops and its subscriptions, conditions, layer and window settings stay; an event or a flip wakes it again), and `upgrade(activate?)` (unnamed conditions cleared, named ones kept). The runner calls `PluginInstance.activate(entry)` (new) instead of `entry` itself, so the triggers `activate()` declares are known.
15
+ - **`plugin.mpv.observe`: an update pass follows each listener**, as after every other handler the SDK calls (the guide always said so; since 1.8.0 the listener ran without one, so a binding that read a value the listener set showed it only at the next full pass). `player.on` stays the one listener without a full pass; the guide now says so.
16
+ - **`plugin.mpv.observe`: every listener gets the current value first.** A second listener of a property the plugin already observes (one `mpv.observe` per property) got nothing until the next change; it now gets the value kept from the first, just after `observe` returns, unless a newer one reaches it first.
17
+ - **`AudioTrack.streamIndex`** (new): the container stream number of an embedded audio track (`ffmpeg -map 0:<n>`), `null` for an external track or when the player cannot tell, as `SubtitleTrack.streamIndex`. Optional in the type (the SDK always sets it), so that an `AudioTrack` a plugin writes out in full, such as a test fixture, still type-checks. The player already sends it; `TestHost` passes on what `setSource({ audioTracks })` gives.
18
+ - **Timeline ranges: 1000 per layer** (was 100), as many as marks: `TIMELINE_LIMITS.ranges` is 1000, and `TestHost` refuses the 1001st. An older player still refuses more than 100.
19
+ - **`vestra-plugin i18n extract` and `i18n check` fail, saying why**, when a text is called through a name of its own (`const { text } = plugin.i18n; text("…")`) while the plugin directory does not resolve the types of `@vestra-player/sdk`: such a call was left out of `messages.pot` silently. The message names each call and what to do (install the dependencies, or call `plugin.i18n.text` directly).
20
+ - **`vestra-plugin check` compiles the plugin's `.slint` files** as the player does at install (Slint 1.18.1, the `@vestra` library, `fluent-dark`) when the npm package `slint-ui` at that version is installed in the plugin project; an error fails the check with file, line and column. The SDK does not install the compiler (a native module of about 25 MB under Slint's own licence): `npm install -D slint-ui@1.18.1`. Without it the check says the files were not compiled and passes ([CLI](docs/reference/cli.md)).
21
+ - **Docs.** The design rules and the player's interface spec no longer ask for `font-feature: tnum` (Slint 1.18 has no such property; a time or counter whose digits must not shift uses `Theme.font-mono`). `Mpv` no longer names the capability `mpv` (gone in 1.9.0): the capability scan's `player` category discloses it. The mpv reference's rules table shows `all` where it showed an unrendered `${code(…)}`. The 1.8.0 and 1.9.0 entries below no longer name internal planning documents. What keeps a plugin running: an mpv filter or observer, and a filter chain taken up after the ready, keep it running for the rest of that run, also after they are removed (the player judges again at the next start); a listener added after the ready keeps it running while the listener exists ([How plugins work](docs/guides/how-plugins-work.md#what-keeps-a-plugin-running), [mpv](docs/reference/mpv.md#properties-and-observers)). What stays while a plugin is stopped now names its trigger conditions besides the kept layer and window settings.
22
+
23
+ The API surface snapshot gains `AudioTrack.streamIndex`, the source events (`SourceEvent`, `SourceEventPayloads`), `Player.stream` and `StateStream`, the trigger types (`Plugin.trigger`, `Trigger`, `TriggerEvent`, `PositionRange`, the new `When` members) and the test host's (`TestHost.triggers`, `now`, `advance`, `park`, `parked`, `upgrade`, `KeptTrigger`, `TRIGGER_LIMITS`); `TIMELINE_LIMITS`' line changes its `ranges` value from 100 to 1000 (the one changed line, the ruled limit change).
24
+
25
+ ## 1.9.0
26
+
27
+ **Who must change: every plugin with a `capabilities` field, and every plugin that follows the player's state.** Manifest capabilities are gone. A manifest says who the plugin is; what the store shows the user comes only from the capability scan of the code ([Capability scan](docs/reference/scan.md)). The two declarations that changed how a plugin ran are now calls, and nothing else is declared or checked. Needs player 0.9.0, which removes its gate in the same release; `apiVersion` stays `vestra/1`.
28
+
29
+ **Migration** (first lines of `activate`, then delete the field):
30
+
31
+ ```ts
32
+ export default async function activate(plugin: Plugin) {
33
+ plugin.player.subscribe(); // was "events"
34
+ await plugin.player.read(); // was "playback.read"
35
+ // …the rest unchanged
36
+ }
37
+ ```
38
+
39
+ Keep only the lines whose declaration the manifest had; a plugin that had neither adds nothing. Set `minPlayerVersion` to `0.9.0`: an older player requires the field. Remove `@vestra-player/sdk/ts-plugin` from `tsconfig.json`, `capabilities` from `startPlugin(…)` options in tests, and `--json` from `vestra-plugin check`.
40
+
41
+ **New: the explicit calls.**
42
+
43
+ - **`plugin.player.subscribe()`** (sync, idempotent): turns on event delivery for this run and subscribes the state copy now. Until it is called, a listener of `source.state`, `playback.backend`, `window.state`, `timeline.changed`, `appearance.changed` or `resolvers.fileTypes` never runs, as without `events` before (the one-time warning in the log now names `subscribe()`); a listener added earlier starts to hear events at the call. The other events (`packages.changed`, `bindings.changed`, `commands.keys`, `video.upscaling.changed`, `video.motion.changed`) arrive from the first listener, as they did with their own declarations.
44
+ - **`await plugin.player.read()`** (idempotent; a failed read is tried again by the next call): reads `source.state` and `timeline.marks` and turns on the re-reads after the plugin's own actions (`host.run`, closing a `Media`, a stream's end), as `playback.read` did. Before it, `plugin.player.state` is the empty state. `subscribe()` after `read()` reads the state once more, since a change between the two sent no event.
45
+ - **Command keys and the layout state start on first use** (`plugin.commands.keys`, `plugin.panels.*.state`), with no declaration.
46
+ - **Wire order** (the one intended shift): the start-up `window.state` read now comes first, because it is answered before `activate` begins; the player-state requests follow it, one round trip later. Proof: with the explicit calls first in `activate`, all 19 golden scenarios equal their declared traces after that one transformation (recorded on both paths while both still existed; `test/explicit-calls.test.ts` keeps the request sequences); in this release the 14 traces it changes were regenerated (list below) and the others are byte-identical.
47
+
48
+ **Removed: everything that reads declarations** (no legacy path).
49
+
50
+ - **Manifest field `capabilities`**: an error everywhere the SDK reads a manifest (`vestra-plugin check`/`build`/`pack`, `startPlugin`), with a message that names the change and the two calls (`CAPABILITIES_REMOVED`). An error, not a warning, because the player refuses unknown manifest fields and an ignored list would leave a plugin that silently stops hearing events or reading the state; the message says exactly what to write instead.
51
+ - **Early refusals with `capability`** (`media.sources`, `playback.control` for `media.sources.open`, `mpv`, `secrets`, `rendering.manage`, `video.upscaling`, `video.motion`, `processing.video`, `timeline.marks`, `commands.run`, `palette.lead`): the calls are sent and the player answers. `capability` remains the player's (and `TestHost`'s) code for the built-in-only requests (`commands.list`, `commands.run`, `palette.lead.*`) from a plugin that is not built in.
52
+ - **`CAPABILITY_INFO` and `CapabilityInfo`** (`./testing`), **`CAPABILITIES`, `CAPABILITY_INFO`, `HOST_CAPABILITIES`** (`./runtime`), the copy of the player's capability table (`src/host-capabilities.ts`, `npm run capabilities:sync`), the capability checker and its rules, the `@capability` doc tag and the [Capabilities](https://vestrasys.github.io/vestra-player-sdk/documents/Reference.html) reference page.
53
+ - **`vestra-plugin check`**: no capability step; `--json` (which only reported it) fails with a message.
54
+ - **`@vestra-player/sdk/ts-plugin`**: no checker and no quick fix; the module stays as a no-op so that a `tsconfig.json` that lists it still loads (remove it; a later major removes the module).
55
+ - **`PluginInfo.capabilities`, `PackageManifest.capabilities`** and `TestHost.packages[].capabilities`.
56
+ - **`startPlugin`'s `capabilities` option.** `id` now means "start with this id and read no manifest".
57
+ - **`TestHost` `bindings.list`** lists a plugin's `focus: "panel"` commands without a `ui.mount` declaration to look at (player 0.8.0 left them out). Everything else in `TestHost` is unchanged.
58
+
59
+ **Player side: panels compile one by one, when first shown** (player 0.9.0; no API change). A panel shown at once (the bottom bar, the backdrop, the current tab of an open column) still compiles at the mount and rejects `ready` with `ui-prepare`; a tab mounted in the background compiles when it is first shown (an adjust tab when the column opens), and a failure then reaches `onError` as `ui-prepare`, the tab staying empty until the plugin mounts it again. Mounting or unmounting a panel no longer rebuilds the main window, so other panels keep their component state; a panel gets a new instance only when its place is made again (a column closed and opened, the fullscreen overlay, the floating sidebar) or after the player unloaded it (at most 4 loaded per column). Docs follow (`Panel`, `Panel.ready`, `ui-prepare`, the guides).
60
+
61
+ **Kept**: the capability scan and `capability-scan.json` (its test now covers every method the SDK sends instead of the removed table), `API_REQUESTS` (the message and event tables), the message and event reference pages (by area; the events table says which events wait for `subscribe()`).
62
+
63
+ **Golden traces regenerated** (the intended `window.state` shift; nothing else differs): `builtins-info`, `builtins-playback`, `builtins-playlist`, `builtins-subtitles`, `builtins-video`, `examples-adjust-panel`, `examples-blur`, `examples-bookmark`, `examples-menus`, `examples-signal-generator`, `styles-speed-a`, `styles-speed-b`, `styles-speed-c`, `host-start-taken`. The 11 examples and the three style plugins were migrated (field deleted, the calls inserted, `minPlayerVersion` 0.9.0); built-ins at the pinned player commit, which still declare, start through the same calls (`test/explicit.ts`) until they are migrated and re-pinned.
64
+
3
65
  ## 1.8.0
4
66
 
5
- **Who must change: nobody.** Pure additions and a product-data sync (user rulings 2026-11-13, plan A): the 31 existing capabilities, their members, what each needs and every existing behaviour of the SDK and of `TestHost` are as in 1.7.20; the existing tests and golden traces pass unchanged. A plugin that does nothing keeps working on every player. A plugin that uses an addition needs the player released with this SDK (`minPlayerVersion`); `apiVersion` stays `vestra/1`.
67
+ **Who must change: nobody.** Pure additions and a product-data sync: the 31 existing capabilities, their members, what each needs and every existing behaviour of the SDK and of `TestHost` are as in 1.7.20; the existing tests and golden traces pass unchanged. A plugin that does nothing keeps working on every player. A plugin that uses an addition needs the player released with this SDK (`minPlayerVersion`); `apiVersion` stays `vestra/1`.
6
68
 
7
69
  **mpv pass-through** (a new capability and member). `plugin.mpv` sends mpv's own commands and properties to the player's mpv. Intended users: a GPU vendor's motion-smoothing or upscaling plugin (a filter and its options, without a new player method per feature, as 1.7.19 needed), a shader or scaler pack that sets renderer options, a statistics panel that observes mpv's measurements.
8
70
 
9
- - **Capability `mpv`** (new, the 32nd; **risky**: the store highlights it; not built-in only; residency `live`), shown as "Control the playback engine (mpv) directly: send its commands and change its options". It crosses a boundary (§1.6): what it sets is the user's player beyond the plugin's own contributions and stays after the plugin stops. It is the last row of the player's table; no existing capability changes.
71
+ - **Capability `mpv`** (new, the 32nd; **risky**: the store highlights it; not built-in only; residency `live`), shown as "Control the playback engine (mpv) directly: send its commands and change its options". It crosses a boundary: what it sets is the user's player beyond the plugin's own contributions and stays after the plugin stops. It is the last row of the player's table; no existing capability changes.
10
72
  - **`Mpv`** (`plugin.mpv`): `command(args)` (the command's name and its arguments as an array; resolves with mpv's result), `get(name)`, `set(name, value)`, `observe(name, listener)` (the current value first, then each change, at most every 100 ms; a `Disposable`). Values are `MpvValue` (JSON). Messages: `mpv.command`, `mpv.get`, `mpv.set`, `mpv.observe`, `mpv.unobserve`, and the event `mpv.property`, sent to the observer without a subscription. The channel is the contract; the names and what they do are mpv's and can change with a player version.
11
73
  - **Refused** with the new error code **`refused`** (the message names the command or property and why), by a closed rule: what starts a program, loads scripts or configuration, opens a control channel or talks to mpv's other clients, makes the player write or delete files, ends the player, drives its keyboard and mouse, reaches the clipboard, or changes what the player manages itself (the source and the playlist, the position, the tracks, the output and the window, the subtitle style, the renderer options of `plugin.video`, the filter chains as a whole). Reading is not refused, except the clipboard. It is not a sandbox: a plugin does the first four with Node. The table is data shared with the player (`MPV_RULES`, `MPV_LIMITS`, exported from `./runtime` for its agreement test) and printed in the new reference page [mpv](docs/reference/mpv.md). mpv's own errors arrive as `backend` with mpv's words ("mpv: property not found").
12
74
  - **Ownership**: a filter is added as `["vf", "add", "@label:…"]` (`af`; `add`, `pre`, `toggle`, `remove`) with a label of the plugin's own, not starting with `vestra-`. The label has one owner (`conflict` for another plugin), the player removes a plugin's filters and observers when it stops, and keeps a plugin that has one running. The player's own filters (the typed chains, the upscaler, motion smoothing) stay beside it; a pass-through filter does not reach snapshots and exports, which the typed chains do. A property a plugin set stays set until the player quits.
package/README.md CHANGED
@@ -41,7 +41,7 @@ npm i -D @vestra-player/sdk # Node.js 26 or newer
41
41
  "version": "0.1.0",
42
42
  "apiVersion": "vestra/1",
43
43
  "entry": "main.ts",
44
- "capabilities": ["commands", "ui.osd"]
44
+ "minPlayerVersion": "0.9.0"
45
45
  }
46
46
  ```
47
47
 
@@ -81,7 +81,7 @@ The [documentation site](https://vestrasys.github.io/vestra-player-sdk/) is the
81
81
 
82
82
  - **[Tutorial](https://vestrasys.github.io/vestra-player-sdk/documents/Tutorial.html)**: one page: what a plugin is (a process that talks to the player), the three ways to write one with an example each, where things live, and running, testing and publishing.
83
83
  - **[Guides](https://vestrasys.github.io/vestra-player-sdk/documents/Guides.html)**: one task each (goal, steps, often a complete example): windows, settings and translations, playback, storage, window state, sliders, subtitles, video filters, the GPU switch, menu state that needs no running plugin (`plugin.when`), testing, publishing, your own store, documentation for coding agents; the design rules every plugin follows; and troubleshooting.
84
- - **[Reference](https://vestrasys.github.io/vestra-player-sdk/documents/Reference.html)**: capabilities, manifest fields, limits, menus and bindings, platforms, theme, error codes, events, messages, translations, the test host, and the [command line](https://vestrasys.github.io/vestra-player-sdk/documents/Command_line.html) (`vestra-plugin check`, `test`, `build`, `pack`, `i18n extract`, `i18n check`).
84
+ - **[Reference](https://vestrasys.github.io/vestra-player-sdk/documents/Reference.html)**: manifest fields, limits, menus and bindings, platforms, theme, error codes, events, messages, translations, the test host, and the [command line](https://vestrasys.github.io/vestra-player-sdk/documents/Command_line.html) (`vestra-plugin check`, `test`, `build`, `pack`, `i18n extract`, `i18n check`).
85
85
  - **[Examples](https://vestrasys.github.io/vestra-player-sdk/documents/Examples.html)**: the walkthroughs above.
86
86
  - **[API](https://vestrasys.github.io/vestra-player-sdk/modules/_vestra-player_sdk.html)**: every type and member of `@vestra-player/sdk` and `@vestra-player/sdk/testing`.
87
87
 
@@ -13,12 +13,10 @@
13
13
  * A plugin directory holds manifest.json; the default is the current
14
14
  * directory. Works in any project that depends on @vestra-player/sdk.
15
15
  *
16
- * check strict type check of the plugin's .ts files and tests/*.ts
17
- * (then every use of an API member whose capability manifest.json
18
- * does not declare: file:line, member, capability; fails on any;
19
- * a plugin.wire.request or event listener whose name the check
20
- * cannot read is listed as unchecked, without failing; --json
21
- * prints the findings and the unchecked calls as JSON)
16
+ * check the manifest, then a strict type check of the plugin's .ts
17
+ * files and tests/*.ts; with slint-ui at the player's Slint
18
+ * version installed, every .slint file compiled as the player
19
+ * compiles it at install (errors with line and column)
22
20
  * build check, then write dist/: .ts → .js with types stripped, other
23
21
  * package files copied, dist/manifest.json with `version`
24
22
  * test node --test on tests/*.test.{ts,mjs}
@@ -105,8 +103,8 @@ const i18n = await import(pathToFileURL(join(sdkRoot, "dist/i18n.js")).href);
105
103
  const i18nTools = await import(
106
104
  pathToFileURL(join(sdkRoot, "dist/i18n-tools.js")).href
107
105
  );
108
- const capabilityCheck = await import(
109
- pathToFileURL(join(sdkRoot, "dist/capability-check.js")).href
106
+ const { PLAYER_SLINT } = await import(
107
+ pathToFileURL(join(sdkRoot, "dist/slint-version.js")).href
110
108
  );
111
109
  const SDK = "@vestra-player/sdk";
112
110
 
@@ -319,10 +317,79 @@ function checkConfig(target, sources) {
319
317
  };
320
318
  }
321
319
 
322
- async function check(target, report = null) {
323
- const say = report ? () => {} : (line) => console.log(line);
320
+ /**
321
+ * Compile every .slint file of the plugin as the player does when it
322
+ * installs a package (`package_validate.rs`): Slint's own compiler at the
323
+ * player's version, the library `@vestra` (the SDK's copy, `slint/vestra/`),
324
+ * the style `fluent-dark`; an error fails, except "No component found" (a
325
+ * file of globals or of components for others to import, compiled by its
326
+ * importers). The compiler is the npm package `slint-ui` (a native module,
327
+ * about 25 MB, under Slint's own licence), which the SDK does not install:
328
+ * an author or a CI adds it (`npm install -D slint-ui@<version>`). Without
329
+ * it, or at another version, the step says so and passes.
330
+ */
331
+ async function slintStep(target, say) {
332
+ const { slint } = await sourceFiles(target);
333
+ if (!slint.length) return;
334
+ const manifest = resolveFrom(target.directory, "slint-ui/package.json");
335
+ const version = manifest
336
+ ? JSON.parse(await readFile(manifest, "utf8")).version
337
+ : null;
338
+ if (version !== PLAYER_SLINT) {
339
+ say(
340
+ `${target.name}: slint: ${slint.length} .slint file(s) not compiled: ${version ? `slint-ui ${version} is installed, the player uses Slint ${PLAYER_SLINT}` : "slint-ui is not installed"}; to compile them as the player does, npm install -D slint-ui@${PLAYER_SLINT}`,
341
+ );
342
+ return;
343
+ }
344
+ let compiler;
345
+ try {
346
+ // The package itself (CommonJS), by its directory.
347
+ compiler = createRequire(manifest)(dirname(manifest));
348
+ } catch (error) {
349
+ say(
350
+ `${target.name}: slint: not compiled: slint-ui ${version} does not load (${error.message})`,
351
+ );
352
+ return;
353
+ }
354
+ const errors = [];
355
+ for (const file of slint) {
356
+ const path = join(target.directory, file);
357
+ try {
358
+ compiler.loadFile(path, {
359
+ style: "fluent-dark",
360
+ libraryPaths: { vestra: join(sdkRoot, "slint", "vestra") },
361
+ quiet: true,
362
+ });
363
+ } catch (error) {
364
+ const diagnostics = error?.diagnostics;
365
+ if (!Array.isArray(diagnostics)) throw error;
366
+ for (const d of diagnostics) {
367
+ if (d.message === "No component found") continue;
368
+ const where = d.fileName
369
+ ? relative(target.directory, resolve(target.directory, d.fileName))
370
+ .split(sep)
371
+ .join("/")
372
+ : file.split(sep).join("/");
373
+ errors.push(`${where}:${d.lineNumber}:${d.columnNumber}: ${d.message}`);
374
+ }
375
+ }
376
+ }
377
+ for (const line of [...new Set(errors)])
378
+ say(`${target.name}: slint: ${line}`);
379
+ if (errors.length)
380
+ fail(
381
+ `${target.name}: ${slint.length} .slint file(s) compiled with Slint ${version}: ${new Set(errors).size} error(s), the player would refuse the package`,
382
+ );
383
+ say(
384
+ `${target.name}: slint: ${slint.length} file(s) compiled with Slint ${version}`,
385
+ );
386
+ }
387
+
388
+ async function check(target) {
389
+ const say = (line) => console.log(line);
324
390
  for (const hint of target.hints ?? []) say(`${target.name}: hint: ${hint}`);
325
- dependencies(target, !!report);
391
+ dependencies(target);
392
+ await slintStep(target, say);
326
393
  const own = (await files(target.directory)).filter(
327
394
  (file) => isTypeScript(file) || file.endsWith(".mts"),
328
395
  );
@@ -336,48 +403,19 @@ async function check(target, report = null) {
336
403
  );
337
404
  if (!sources.length) {
338
405
  say(`${target.name}: no TypeScript to check`);
339
- report?.push({ plugin: target.name, findings: [], unchecked: [] });
340
406
  return;
341
407
  }
342
408
  const tsc = compiler("typescript/lib/tsc.js");
343
409
  const scratch = await mkdtemp(join(tmpdir(), "vestra-plugin-check-"));
344
- let findings;
345
- let unchecked;
346
410
  try {
347
411
  const config = join(scratch, "tsconfig.json");
348
412
  await writeFile(config, JSON.stringify(checkConfig(target, sources)));
349
- if (
350
- run(process.execPath, [tsc, "-p", config], {
351
- stdio: report ? ["ignore", process.stderr, "inherit"] : "inherit",
352
- }) !== 0
353
- )
413
+ if (run(process.execPath, [tsc, "-p", config], { stdio: "inherit" }) !== 0)
354
414
  fail(`${target.name}: type check failed`);
355
415
  say(`${target.name}: type check passed (${sources.length} files)`);
356
- ({ findings, unchecked } = await capabilityFindings(target, config));
357
416
  } finally {
358
417
  await rm(scratch, { recursive: true, force: true });
359
418
  }
360
- if (report) report.push({ plugin: target.name, findings, unchecked });
361
- else {
362
- for (const finding of findings)
363
- console.error(
364
- `${relative(process.cwd(), finding.file) || finding.file}:${finding.line}:${finding.column}: ${finding.message} (request ${finding.method})`,
365
- );
366
- // Calls whose capability depends on a name the check cannot read
367
- // (plugin.wire.request with a computed method): a note, never a failure.
368
- for (const call of unchecked)
369
- console.log(
370
- `${relative(process.cwd(), call.file) || call.file}:${call.line}:${call.column}: unchecked: ${call.message}`,
371
- );
372
- }
373
- if (findings.length) {
374
- const missing = [...new Set(findings.map((each) => each.capability))];
375
- fail(
376
- `${target.name}: ${findings.length} use${findings.length === 1 ? "" : "s"} of undeclared capabilities; add ${missing.map((each) => `"${each}"`).join(", ")} to manifest.json "capabilities" (or stop using those members)`,
377
- );
378
- }
379
- say(`${target.name}: capabilities declared for every API use`);
380
- if (report) return;
381
419
  for (const line of await forWarnings(target))
382
420
  console.log(`${target.name}: warning: ${line}`);
383
421
  // Translation warnings never fail the check.
@@ -392,48 +430,6 @@ async function check(target, report = null) {
392
430
  }
393
431
  }
394
432
 
395
- /**
396
- * Uses of API members whose capability the manifest does not declare
397
- * (`findings`), and calls whose capability depends on a name the check
398
- * cannot read (`unchecked`: `plugin.wire.request` with a computed method),
399
- * in the plugin's production files (not tests/), with the type check's
400
- * compiler options (src/capability-check.ts).
401
- */
402
- async function capabilityFindings(target, config) {
403
- const ts = await typescript();
404
- const parsed = ts.getParsedCommandLineOfConfigFile(
405
- config,
406
- {},
407
- {
408
- ...ts.sys,
409
- onUnRecoverableConfigFileDiagnostic: (diagnostic) =>
410
- fail(
411
- `${target.name}: ${ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")}`,
412
- ),
413
- },
414
- );
415
- const files = (await sourceFiles(target)).typescript.map((file) =>
416
- join(target.directory, file),
417
- );
418
- if (!parsed || !files.length) return { findings: [], unchecked: [] };
419
- const program = ts.createProgram(parsed.fileNames, parsed.options);
420
- const capabilities = Array.isArray(target.manifest.capabilities)
421
- ? target.manifest.capabilities
422
- : [];
423
- const { findings, unchecked } = capabilityCheck.checkCapabilities(
424
- ts,
425
- program,
426
- { files, capabilities },
427
- );
428
- return {
429
- findings: findings.map((finding) => ({
430
- ...finding,
431
- file: resolve(finding.file),
432
- })),
433
- unchecked: unchecked.map((call) => ({ ...call, file: resolve(call.file) })),
434
- };
435
- }
436
-
437
433
  /** Slint source without its comments (string literals kept as they are). */
438
434
  function slintCode(text) {
439
435
  let out = "";
@@ -535,13 +531,20 @@ async function extraction(target) {
535
531
  ts.sys,
536
532
  target.directory,
537
533
  );
538
- return i18nTools.extract({
539
- directory: target.directory,
540
- manifest: target.manifest,
541
- slint,
542
- typescript: sources,
543
- compilerOptions: parsed.options,
544
- });
534
+ try {
535
+ return i18nTools.extract({
536
+ directory: target.directory,
537
+ manifest: target.manifest,
538
+ slint,
539
+ typescript: sources,
540
+ compilerOptions: parsed.options,
541
+ });
542
+ } catch (error) {
543
+ // A text that would be left out silently: fail and say why.
544
+ if (error?.code === "sdk-types")
545
+ fail(`${target.name}: i18n: ${error.message}`);
546
+ throw error;
547
+ }
545
548
  }
546
549
 
547
550
  async function i18nReport(target) {
@@ -996,7 +999,6 @@ async function scanCommand(args) {
996
999
 
997
1000
  const USAGE = [
998
1001
  "usage: vestra-plugin <check|build|test|pack> [plugin-dir...] [--version x.y.z] [--out dir]",
999
- " vestra-plugin check [plugin-dir...] --json",
1000
1002
  " vestra-plugin scan [plugin-dir...]",
1001
1003
  " vestra-plugin i18n extract [plugin-dir...] [--locale <lang>]...",
1002
1004
  " vestra-plugin i18n check [plugin-dir...]",
@@ -1079,12 +1081,10 @@ async function main() {
1079
1081
  }
1080
1082
  if (locales.length && subcommand !== "extract")
1081
1083
  fail("--locale applies to i18n extract");
1082
- const jsonIndex = args.indexOf("--json");
1083
- const report = jsonIndex >= 0 ? [] : null;
1084
- if (report) {
1085
- args.splice(jsonIndex, 1);
1086
- if (command !== "check") fail("--json applies to check");
1087
- }
1084
+ if (args.includes("--json"))
1085
+ fail(
1086
+ "--json was removed in SDK 1.9.0 with the capability check it reported (manifest capabilities are gone); check prints its result as text",
1087
+ );
1088
1088
  const flag = option("--version");
1089
1089
  const out = option("--out");
1090
1090
  const directories = args.length ? args : ["."];
@@ -1092,12 +1092,11 @@ async function main() {
1092
1092
  fail("--version applies to a single plugin");
1093
1093
  const failed = [];
1094
1094
  for (const directory of directories) {
1095
- const reported = report?.length ?? 0;
1096
1095
  try {
1097
1096
  const target = await plugin(directory);
1098
1097
  if (subcommand === "extract") await i18nExtract(target, locales);
1099
1098
  else if (subcommand === "check") await i18nCheck(target);
1100
- else if (command === "check") await check(target, report);
1099
+ else if (command === "check") await check(target);
1101
1100
  else if (command === "build") await build(target, flag);
1102
1101
  else if (command === "pack") await pack(target, flag, out);
1103
1102
  else await test(target);
@@ -1105,15 +1104,8 @@ async function main() {
1105
1104
  if (!error.expected) throw error;
1106
1105
  console.error(`✖ ${error.message}`);
1107
1106
  failed.push(directory);
1108
- if (report) {
1109
- if (report.length === reported)
1110
- report.push({ findings: [], unchecked: [] });
1111
- report[reported].error = error.message;
1112
- }
1113
1107
  }
1114
- if (report) report[reported] = { directory, ...report[reported] };
1115
1108
  }
1116
- if (report) console.log(JSON.stringify(report, null, 2));
1117
1109
  if (failed.length) {
1118
1110
  console.error(
1119
1111
  `${subcommand ? `i18n ${subcommand}` : command} failed for: ${failed.join(", ")}`,
@@ -1,5 +1,5 @@
1
1
  {
2
- "about": "The capability scan's table (docs/reference/scan.md): which API members and which requests of the player's protocol cross a boundary the user should know about, by category. Hand-maintained: every method of the public API and every method of the player's capability table is in exactly one list, a category's or none's (test/capability-scan.test.ts). `vestra-plugin scan` reports the categories a plugin uses. It changes nothing at run time: the manifest's capabilities gate the API as before.",
2
+ "about": "The capability scan's table (docs/reference/scan.md): which API members and which requests of the player's protocol cross a boundary the user should know about, by category. Hand-maintained: every method of the public API is in exactly one list, a category's or none's, and every request the SDK sends has a category by name or prefix (test/capability-scan.test.ts). `vestra-plugin scan` reports the categories a plugin uses. It changes nothing at run time; since SDK 1.9.0 it is the only disclosure (manifests declare nothing).",
3
3
  "version": 1,
4
4
  "categories": {
5
5
  "player": {
@@ -164,6 +164,7 @@
164
164
  "Player.openStream",
165
165
  "Player.previous",
166
166
  "Player.provideSequence",
167
+ "Player.read",
167
168
  "Player.refresh",
168
169
  "Player.restart",
169
170
  "Player.scrub",
@@ -177,6 +178,9 @@
177
178
  "Player.setStepSeek",
178
179
  "Player.stats",
179
180
  "Player.step",
181
+ "Player.stream",
182
+ "Player.subscribe",
183
+ "Plugin.trigger",
180
184
  "Power.preventSleep",
181
185
  "RenderOptions.onStatus",
182
186
  "RenderOptions.set",
@@ -208,6 +212,7 @@
208
212
  "Settings.show",
209
213
  "SidebarSlot.setDetached",
210
214
  "Snapshot.export",
215
+ "StateStream.stop",
211
216
  "Storage.json",
212
217
  "Stream.onStop",
213
218
  "Stream.stop",
@@ -226,6 +231,10 @@
226
231
  "TimelineLayer.setRanges",
227
232
  "Tools.available",
228
233
  "Tools.run",
234
+ "Trigger.enter",
235
+ "Trigger.firesOn",
236
+ "Trigger.leave",
237
+ "Trigger.off",
229
238
  "Ui.image",
230
239
  "Ui.markdown",
231
240
  "Ui.remoteImage",
@@ -244,10 +253,18 @@
244
253
  "View.on",
245
254
  "View.set",
246
255
  "WebResolverOptions.resolve",
256
+ "When.audioDevice",
257
+ "When.audioTrack",
247
258
  "When.can",
259
+ "When.duration",
248
260
  "When.language",
249
261
  "When.phase",
262
+ "When.position.in",
263
+ "When.rate",
264
+ "When.subtitleTrack",
250
265
  "When.theme",
266
+ "When.time",
267
+ "When.volume",
251
268
  "Window.close",
252
269
  "Window.hide",
253
270
  "Window.onClose",
@@ -338,6 +355,9 @@
338
355
  "timeline.marks",
339
356
  "timeline.set",
340
357
  "timeline.setRanges",
358
+ "triggers.declare",
359
+ "triggers.off",
360
+ "triggers.set",
341
361
  "ui.close",
342
362
  "ui.interaction",
343
363
  "ui.markdownScan",
@@ -1,25 +1,15 @@
1
1
  /**
2
- * Which player requests each member of the plugin API sends: the SDK's half
3
- * of the capability rule (the player's half, what each request needs, is
4
- * `HOST_CAPABILITIES`). A member is written `Interface.member` as in
5
- * `CAPABILITY_INFO`; members declared on `Scope` are written `Plugin.…`.
2
+ * Which player requests each member of the plugin API sends, written
3
+ * `Interface.member`; members declared on `Scope` are written `Plugin.…`.
4
+ * The generated reference pages read it: the Stability column of the
5
+ * message table (docs/reference/messages.md) and the members of each event
6
+ * (docs/reference/events.md). For a listener the row is the
7
+ * `events.subscribe` with its event name.
6
8
  *
7
- * List the requests that decide the member's capabilities: the one it
8
- * sends to do its work, and for a listener the `events.subscribe` with its
9
- * event name. A string parameter that the player's rule reads (`event`,
10
- * `stage`) is given in `params`. `also: true` marks a request whose
11
- * capability the member needs on top of its own (documented at the member,
12
- * not listed in its capability's `CAPABILITY_INFO.apis`).
13
- *
14
- * Members that need no capability are left out, apart from a few that show
15
- * a rule's "none" case. Members of objects that another listed member
16
- * returns (a `Window` from `Windows.create`, a `Panel` from `Panels.mount`)
17
- * are left out too: the call that created the object already needs the
18
- * capability.
19
- *
20
- * Order matters for `CAPABILITY_INFO`: each capability lists its members in
21
- * this table's order. test/capability-rules.test.ts checks every method and
22
- * parameter against the player's table.
9
+ * A row lists the request the member sends to do its work. Members whose
10
+ * requests come from a handle another member returned (a `Window` from
11
+ * `Windows.create`) are listed in the message table's `WRAPPED_BY`
12
+ * (scripts/doc-tables/messages.mjs) instead.
23
13
  *
24
14
  * @internal
25
15
  */
@@ -27,32 +17,18 @@
27
17
  export interface ApiRequest {
28
18
  /** The wire method (`source.submit`). */
29
19
  readonly method: string;
30
- /** String parameters the player's rule for the method reads. */
20
+ /** String parameters that name what is meant (`event`, `stage`). */
31
21
  readonly params?: Readonly<Record<string, string>>;
32
- /** A further capability, documented at the member. */
33
- readonly also?: true;
34
22
  }
35
23
  /** @internal */
36
24
  export declare const API_REQUESTS: Readonly<Record<string, readonly ApiRequest[]>>;
37
25
  /**
38
26
  * The events whose listener subscribes (`events.subscribe` with the event
39
- * name): the plugin API's `HostEvent`. Other names a plugin listens to
40
- * (`commands.execute`, `ui.callback`) arrive unasked and need nothing.
41
- * test/wire-facade.test.ts keeps it equal to `HostEvent`.
27
+ * name): the plugin API's `HostEvent` and `SourceEvent`. Other names a
28
+ * plugin listens to (`commands.execute`, `ui.callback`) arrive unasked and
29
+ * need nothing.
30
+ * test/wire-facade.test.ts keeps it equal to `EVENT_NEEDS`.
42
31
  *
43
32
  * @internal
44
33
  */
45
34
  export declare const SUBSCRIBED_EVENTS: readonly string[];
46
- /**
47
- * Members whose requests depend on an argument, which `API_REQUESTS` cannot
48
- * list: the event name of a listener (`event`: a subscribed event's
49
- * `events.subscribe`, nothing for the others) or the method name of a request
50
- * (`method`: that method, with the string fields of the second argument as its
51
- * parameters). The capability check reads the argument when its type is one
52
- * string (a literal, a constant), and reports the call as unchecked otherwise
53
- * (a computed name, a union of several, the member taken by destructuring or as
54
- * a value).
55
- *
56
- * @internal
57
- */
58
- export declare const ARGUMENT_APIS: Readonly<Record<string, "event" | "method">>;