@vestra-player/sdk 1.6.22 → 1.7.1
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 +53 -0
- package/bin/vestra-plugin.mjs +34 -12
- package/dist/api-requests.d.ts +22 -0
- package/dist/api-requests.js +38 -0
- package/dist/capability-check.d.ts +48 -0
- package/dist/capability-check.js +219 -51
- package/dist/capability-rules.d.ts +21 -0
- package/dist/capability-rules.js +32 -1
- package/dist/commands.d.ts +8 -0
- package/dist/commands.js +11 -11
- package/dist/docs-tree.json.gz +0 -0
- package/dist/plugin/commands.js +43 -13
- package/dist/plugin/connection.d.ts +37 -0
- package/dist/plugin/connection.js +34 -0
- package/dist/plugin/index.js +12 -2
- package/dist/plugin/media.js +3 -1
- package/dist/plugin/packages.js +3 -1
- package/dist/plugin/passes.d.ts +38 -1
- package/dist/plugin/passes.js +89 -5
- package/dist/plugin/player/events.d.ts +9 -0
- package/dist/plugin/player/events.js +43 -0
- package/dist/plugin/player/rules.d.ts +7 -0
- package/dist/plugin/player/rules.js +11 -0
- package/dist/plugin/player.d.ts +37 -4
- package/dist/plugin/player.js +85 -12
- package/dist/plugin/resolvers.js +2 -3
- package/dist/plugin/runtime.d.ts +2 -3
- package/dist/plugin/runtime.js +8 -2
- package/dist/plugin/scope.d.ts +9 -0
- package/dist/plugin/scope.js +24 -0
- package/dist/plugin/services.js +4 -5
- package/dist/plugin/state.d.ts +3 -0
- package/dist/plugin/state.js +81 -0
- package/dist/plugin/stream.d.ts +27 -3
- package/dist/plugin/testing/core-actions.js +1 -1
- package/dist/plugin/testing/services.js +1 -1
- package/dist/plugin/types/base.d.ts +78 -2
- package/dist/plugin/types/commands.d.ts +17 -1
- package/dist/plugin/types/playback.d.ts +156 -1
- package/dist/plugin/types/plugin-wire.d.ts +589 -0
- package/dist/plugin/types/plugin-wire.js +1 -0
- package/dist/plugin/types/ui-content.d.ts +23 -4
- package/dist/plugin/types/ui-shell.d.ts +1 -0
- package/dist/plugin/types.d.ts +4 -2
- package/dist/plugin/view/base.d.ts +10 -3
- package/dist/plugin/view/base.js +30 -6
- package/dist/plugin/view/binder.js +8 -1
- package/dist/plugin/view/writer.d.ts +49 -4
- package/dist/plugin/view/writer.js +383 -17
- package/dist/plugin/wire-facade.d.ts +4 -0
- package/dist/plugin/wire-facade.js +190 -0
- package/dist/ts-plugin.d.ts +3 -0
- package/dist/ts-plugin.js +18 -6
- package/dist/wire.d.ts +233 -20
- package/llms.txt +3 -3
- package/package.json +1 -1
- package/slint/vestra/focus.slint +33 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,58 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.7.1
|
|
4
|
+
|
|
5
|
+
**Who must change: nobody.** Tables follow the playlist's trimmed list keys: a data refresh of `BUILTIN_COMMANDS`; no API change, `apiVersion` stays `vestra/1`. A plugin whose tests compare a key against the table sees the player's current one.
|
|
6
|
+
|
|
7
|
+
- **`BUILTIN_COMMANDS`**: the built-in playlist (0.2.6) no longer gives its list commands keys that shadow a player key while the list has focus. Play (`vestra.playlist/playlist.play`) keeps `Enter` and loses `P`; Remove Selected (`playlist.remove`) keeps `Delete` and loses `Backspace`; Add Files… (`playlist.list-add`, was `Ctrl+I`), Add Folder… (`playlist.list-add-folder`, `Ctrl+O`), Add Link… (`playlist.list-link`, `Ctrl+U`), Remove Invalid Items (`playlist.remove-invalid`, `Ctrl+T`), Move to Top (`playlist.move-top`, `Ctrl+Home`), Open List File… (`playlist.list-open-list`, `F3`), Save List… (`playlist.list-save-list`, `F2`), Close List (`playlist.close`, `F6`) and Playlist Settings… (`playlist.settings`, `F5`) have no default key, and so no panel scope. Ids, titles and the other list keys are unchanged; `BUILTIN_SUBMENUS` is unchanged. The table in [Reference: commands](docs/reference/commands.md#built-in-commands) follows.
|
|
8
|
+
|
|
9
|
+
## 1.7.0
|
|
10
|
+
|
|
11
|
+
**Who must change: nobody.** The one change a plugin can observe is `Command.set`, which now re-evaluates only its own command instead of running a full update pass: a binding that reads a variable changed together with `cmd.set(…)` outside a handler the SDK runs (a timer, a socket) needs `plugin.update()` after the change, or the variable in `plugin.state` (details under Step 2). Steps 2 and 3 of the SDK refactor (`doc/specs/sdk-refactor.md` §4 in the player repository) and the documentation refactor for the three ways to write a plugin. `apiVersion` stays `vestra/1`, no new capability, no player version needed; every existing golden trace keeps its wire lines and subscriptions, only the update-pass counts drop.
|
|
12
|
+
|
|
13
|
+
- **New API** (additive, `@since 1.7.0`): `plugin.player.on(event, listener)` for the ten `HostEvent`s, typed `EventPayload<E>`; `plugin.state(initial)`, tracked fields whose writes re-run only their readers; `plugin.wire` (experimental, not semver), the protocol for a plugin's own direct messages: `request`, `on`, `view(v).write`/`writeRows`, `commands.register`; exported wire types: `Wire`, `WireView`, `WireCommands`, `WireCommand`, `WireCommandOptions`, `WireCommandState`, `PropertyWrite`, `RowOp`, `HostEvent`, `EventPayload`, `EventPayloads` and the payload shapes (`WindowFacts`, `PackageInfo`, `WireSource`, `CommandKeys`, `WireTimeline`, `WireMark`, `WireRange`, `WireUpscalingState`, `WireUpscalingReason`, `WireRenderingReason`).
|
|
14
|
+
- **New API, Slint library**: `@vestra/focus.slint` exports `global VestraFocus { callback release(); }`; a panel calls `VestraFocus.release()` to give the keyboard focus back to the video after the user played or opened an item from a list (Enter, a double click) or pressed Esc, so the arrows control the player again (main window: the video area; floating sidebar window: its own key scope; elsewhere nothing). Player 0.7.6. Clicks keep their effect on the focus: a click on an empty part of a panel gives the panel the focus, so its `focus: "panel"` bindings apply; a click on a button or a row's `TouchArea` leaves the focus where it was. Documented in [Focus and keyboard](docs/explanation/ui.md#focus-and-keyboard) and [Reference: theme › Focus](docs/reference/theme.md#focus).
|
|
15
|
+
- **Behaviour**: the update passes and the row diff run only for what needs them. A view joins the passes on its first `bind()` (before that `set()` sends whole values), a command only when a state field is a function, and nothing runs while nothing is bound; `Command.set` re-evaluates that command only (above). A property is written either through the view (`set()`/`bind()`) or through `plugin.wire.view(v)`, not both (`invalid`). Raw subscriptions through `plugin.wire.request` to the SDK's own events are refused (use `plugin.wire.on`); other events need `why` or `mirror: true`.
|
|
16
|
+
- **Documentation**: a new chapter, "Three ways to write a plugin", with `examples/three-ways`; generated Events and Messages reference pages; style B and C versions of `signal-generator` and `panel-menu`; a "Layers and stability" section in How the player runs and talks to plugins.
|
|
17
|
+
|
|
18
|
+
**Step 2 of the SDK refactor, "framework optional"** (`doc/specs/sdk-refactor.md` §4 in the player repository): the update passes and the row diff are used only by what needs them, and two new members. On the wire every existing line stays; there are fewer passes. `apiVersion` stays `vestra/1`, no new capability, no player version needed.
|
|
19
|
+
|
|
20
|
+
- **New: `plugin.player.on(event, listener)`** for each of the ten events (`HostEvent`: `source.state`, `playback.backend`, `window.state`, `packages.changed`, `bindings.changed`, `commands.keys`, `timeline.changed`, `appearance.changed`, `resolvers.fileTypes`, `video.upscaling.changed`). The listener gets a copy of the event's data as the player sent it, typed `EventPayload<E>` (`EventPayloads`); the subscription counts as a listener and carries `why` with the call site (`a listener added at main.ts:12`); no state copy is made for it. Unlike other handlers, no full update pass follows the listener: it pushes its own values (`view.set`), a write to `plugin.state` re-runs that field's readers, `plugin.update()` everything. Disposable and owned by the scope. New exported types `HostEvent`, `EventPayloads`, `EventPayload` (Playback). `vestra-plugin check` checks it by its event name (Step 3, below).
|
|
21
|
+
- **New: `plugin.state(initial)`** (`Scope.state`): a tracked object of the same fields. A read inside a `bind` function or a command's state function records the field like a read of `plugin.player.state`; a write that changes a field (`Object.is`) runs one precise update pass that evaluates only those readers. Reads anywhere else are plain reads. One level: a field holding an object is compared by identity. It belongs to the calling scope: once that scope is disposed it is a plain object whose reads and writes schedule nothing. A `bind` function that writes a field it reads would loop; the SDK stops after 100 passes in a row that each changed what they read and reports it once to `onError` (`limit`); the limit counts passes, not loops, so a legitimate chain of bindings deeper than 100 (each writing a field the next one reads) is cut too, and the rest waits for the next full pass. The replacement for manual `plugin.update()` after the plugin's own asynchronous state (`src/plugin/state.ts`).
|
|
22
|
+
- **A view takes part in the update passes from its first `bind()`.** Until then `set()` goes straight to the view's writer: every value is sent whole (large lists in parts with `more`, the value limits checked, one write in flight per view), only the properties `set()` named are looked at, and no row-patch base is kept; when the view opens, what differs from its initial properties (a `set()` during the open, an initial list over one request's size) is sent right after; of such a list only the rows the open did not carry go, as inserts on the initial rows, as long as the list still begins with those rows when it is sent (a later `set()` or `bind()`, a write delayed by a back-off, are seen); otherwise, or when the player answers that insert with `stale`, the whole value goes. From the first `bind()` on, `set()` values take the bound way as before (compared, lists patched), so mixing both stays correct. Row-patch planning stays in the writer (`view/writer.ts`), used only for bound views.
|
|
23
|
+
- **A command takes part in the update passes only when a state field is a function.** A command of values and `plugin.when` conditions is registered once and never re-evaluated; a function given to `set` binds it from then on.
|
|
24
|
+
- **Behaviour change, `Command.set`: it re-evaluates that command only**, sending its state in a microtask (several calls send one `commands.update`), instead of running a full pass over every binding and command of the plugin. A binding that reads a plugin variable changed together with `cmd.set(…)` outside a handler the SDK runs (a timer, a socket) no longer refreshes with it: call `plugin.update()` after the change, or keep the variable in `plugin.state`. Inside a command's `run` or a view callback nothing changes (the pass after the handler still runs). None of the player's built-in plugins or the known third-party plugins relies on it.
|
|
25
|
+
- **No pass runs while nothing is bound**: `plugin.update()` and the pass after each handler cost nothing in a plugin without bindings.
|
|
26
|
+
- The player's state copy subscribes `source.state` as before: from the start, before the start-up read, whenever the manifest declares `events` (internally it now starts through `PlayerService.start`, which a plugin without `events` reaches on first use, where it subscribes nothing).
|
|
27
|
+
- Views and commands keep the order of evaluation of their making (a view bound later is evaluated where it was made), so the order of writes within a pass and of the `why` lines is unchanged.
|
|
28
|
+
- **Layer check**: the pending L1 → L2 edges are gone. `plugin.host.run` asks the connection to read the player's state again (`Connection.rereads`), `openStream` and file resolver streams use their own `StreamSource` shape that the player's state copy fills, a package operation's end tells the passes through the connection's `signals`; `validStep` is in `player/rules.ts`. `player.ts` and `state.ts` join the framework list, `player/events.ts` and `player/rules.ts` the primitives, and a rule 6 fails an L0/L1 file that calls the passes by name: `.update()` and `.passes` on any object, `invalidate`, `depends`, `reading`, `part`, `observe`, `reader`, `needsFull` on any object but the connection's `signals`, `runtime.bind`/`runtime.changed` (a textual check: destructured aliases are not seen).
|
|
29
|
+
- **Golden traces rewritten** (`test/fixtures/traces/`), each change reviewed: compared with 1.6.21, every `(method, params)` line and every subscription of every existing scenario is unchanged; only the pass counts drop, in each phase the same or fewer. Passes in total: hello 4 → 0, markdown 4 → 0, menus 12 → 8, video 18 → 14, subtitles 11 → 8, playback 20 → 17, playlist 17 → 15, adjust-panel 11 → 8, blur 10 → 8, bookmark 9 → 7, signal-generator 7 → 5, theme-widgets 8 → 7, i18n 4 → 3, panel-menu 4 → 2, info 8 → 6, workshop 5 → 4; binding evaluations fewer in all but playback and signal-generator (video 945 → 626, subtitles 277 → 152, info 16 → 6). Changed fixtures (counts only): `builtins-info`, `-playback`, `-playlist`, `-subtitles`, `-video`, `-workshop`, `examples-adjust-panel`, `-blur`, `-bookmark`, `-hello`, `-i18n`, `-markdown`, `-menus`, `-panel-menu`, `-signal-generator`, `-theme-widgets`; the host scenarios are unchanged. New: `styles-speed-a` and `styles-speed-b`, the plan's speed display (§3) in style A (`bind`, an `enabled` function) and style B (`player.on` + `set`, constant command), from `test/plugins/speed-*`; style B runs no update pass in any phase.
|
|
30
|
+
- Tests: `test/framework-optional.test.ts` (a view only `set()` sends whole values and no patch; mixed `set()`/`bind()` stays patch-correct; constant commands send one `commands.register` and no `commands.update` over 20 passes; `Command.set` without a full pass; without `events` nothing subscribes; with `events` a late first read is current; `player.on` payloads equal the wire data, named, no mirror of its own, every event, dispose unsubscribes; `plugin.state` re-runs exactly its readers; `HostEvent` equals the wire's list and each event's capability is the player's) and `test/framework-optional-edges.test.ts` (the review's cases: a `set()` while a never-bound panel mounts or window opens, an initial list over one request on a never-bound panel, `set()` then `bind()`, `Command.set` and other bindings, a first read with `events` but no `playback.read`, `plugin.state` as a plain object, the loop guard, a disposed scope's state, unbound churn, `player.on` refusals and its scope, no full pass per `player.on` event in a bound plugin). The API surface snapshot gains the new members only.
|
|
31
|
+
- Follow-up, unchanged here: a sequence provider (`player.provideSequence`) still takes part in every pass even when `canNext`/`canPrevious` are values.
|
|
32
|
+
|
|
33
|
+
**Step 3 of the SDK refactor, `plugin.wire`** (spec §3.3 and §4 Step 3): one new experimental member, the existing ones unchanged, every existing golden trace unchanged. No new capability, no player version needed.
|
|
34
|
+
|
|
35
|
+
- **New, experimental: `plugin.wire`** (`Scope.wire`, type `Wire`, Plugin category; `src/plugin/wire-facade.ts`): the protocol and the primitives for a plugin's own direct messages. Every member is `@experimental` and says "the wire protocol is not semver; this member changes with versions": a method or event can change with a player version and a member of `plugin.wire` in any SDK release, without a deprecation period. Prefer the typed members.
|
|
36
|
+
- `request(method, params)`: one request as given, the player's answer typed by the caller; the player checks the capability. Nothing of the SDK in between (no limits, revisions, retries, activation wait). Guarded, with `invalid`: `events.subscribe` and `events.unsubscribe` of one of the ten `HostEvent`s (the player keeps one subscription and one mark per name, and the SDK owns those: listen with `on`, stop by disposing what it returned), and `events.subscribe` of any other event without `why` (a non-empty list of strings) or `mirror: true`, so the player's decision to keep a plugin running (lazy activation) cannot be fooled. Such a subscription to a newer player's event is the plugin's: the SDK does not count it, the plugin unsubscribes it.
|
|
37
|
+
- `on(event, listener)`: a `HostEvent` is subscribed as `player.on` does it, always a listener with its `why` (`a listener added at main.ts:12`), never a mirror; any other name (`commands.execute`, `ui.callback`, a newer player's event subscribed with `request`) is heard without a subscription. The data is a copy, typed `unknown`; no update pass follows.
|
|
38
|
+
- `view(v).write(property, PropertyWrite)` and `.writeRows(property, RowOp[])`: a window's, panel's or settings page's property written below the comparison and the row diff. One write in flight per property (a whole value drops the writes still waiting, which resolve `false`), a `seq` on whole values and lists over one request in parts with a player that takes row patches, row operations numbered on the property's last direct write and split per request; no limits checked (the player's apply). `unavailable` while the view does not show, and for a write the player answers after the view closed or showed its initial properties again; such a write is no base for rows. After a window is shown again a direct property shows its default: `writeRows` without a whole direct write since then is refused with `stale` before anything is sent (write the whole value first). `writeRows` without row patches: `unsupported`. Disposing the view resolves the writes still waiting with `false`.
|
|
39
|
+
- `commands.register({ id, declaration, state?, when?, run? })`: the player's declaration as given, a state of values, `run` on a pick; `WireCommand.update(state, when?)` sends the next revision; without `when` the conditions sent before stay. `commands.add` and `commands.register` share one table of removals in flight, so an id removed by one and added again by the other waits for the removal (no `conflict`). Never evaluated in the update passes. Waited for during activation like `commands.add`, so `TestHost`'s `strictDeclarations` fails `startPlugin` on a refused declaration and the player's runner logs and skips it.
|
|
40
|
+
- **One track per property.** A property written with `plugin.wire.view(v)` is the plugin's: `set()` naming it throws `invalid` ("property `rows` is written directly; bind it or write it, not both"), a `bind()` that returns it is reported to `onError` once with `invalid` (its other values still count), and a direct write of a property that was `set()` or bound throws `invalid` ("… is set or bound; …"). The SDK's record of what the player shows stays correct for the properties it compares.
|
|
41
|
+
- **New exported types**: `Wire`, `WireView`, `WireCommands`, `WireCommand`, `WireCommandOptions`, `WireCommandState`, and the wire's `PropertyWrite` and `RowOp` (Plugin category, documented to the full standard). `HostEvent`, `EventPayload` as in Step 2. The wire shapes `EventPayloads` names are exported and documented too (Playback): `WindowFacts`, `PackageInfo` with `WireSource`, `CommandKeys`, `WireTimeline` with `WireMark` and `WireRange`, `WireUpscalingState` with `WireUpscalingReason` and `WireRenderingReason`, and the fields of the events whose data has no named type (`playback.backend`, `appearance.changed`, `resolvers.fileTypes`); a `wire.on` listener can type its data with them. The API reference builds again (`npm run docs`).
|
|
42
|
+
- **Capability check by name**: `vestra-plugin check` and the editor plugin check `plugin.player.on` and `plugin.wire.on` by their event name (`events`, `bindings.manage`, `commands`, `video.upscaling`; nothing for `packages.changed` or an event that arrives unasked) and `plugin.wire.request` by its method name through the player's table, with the string fields of its parameters (`{ event: "bindings.changed" }`), when the types fix the name to one string (a literal, a constant). A computed name, a union of several, the member taken other than by a direct call (`const { request } = plugin.wire`), or a method the player's table does not know, is listed as **unchecked**: `file:line:column: unchecked: …` on standard output and `unchecked` in `check --json`, a warning in the editor (code 95302); it never fails the check. `plugin.wire.commands.register` needs `commands` (in `CAPABILITY_INFO` and the capability table).
|
|
43
|
+
- **Layer check rule 7**: under `src/plugin/` only `wire-facade.ts` (besides `connection.ts`, which defines `Connection.request`, and the test host) sends a request by a method name; `wire-facade.ts` is L1 and reaches a view's writer through a symbol of `view/writer.ts`, loading no view class or binder.
|
|
44
|
+
- **Golden traces**: every existing scenario unchanged. New `styles-speed-c`, the plan's speed display in style C (`test/plugins/speed-c`: `wire.on`, `wire.view(bar).write`, `wire.commands.register`): its trace equals style B's line for line, the subscription included (both are a listener with its `why`; only style A's is a mirror), and it runs no update pass.
|
|
45
|
+
- Tests: `test/wire-review.test.ts` (the review's probes as regression tests: a cut list bound to another list before its delayed flush, a `stale` insert falling back to the whole value, lists changed while opening, `commands.add`/`register` reusing an id both ways, raw subscriptions to the SDK's events refused, direct writes across a close and reopen (in parts, whole and as a patch: `unavailable`, no base for rows), `writeRows` without a whole write, disposal, one track with camelCase names, direct writes beside a bound list in parts, conditions kept by `update`), `test/wire-facade.test.ts` (raw requests reach the same `TestHost` handlers as the typed clients, refusals keep their code; `events.subscribe` without marks and `events.unsubscribe` refused and nothing sent, with `why` or `mirror` sent as given; `wire.on` subscribes with `why`, never `mirror`, other names without a subscription, dispose stops it; direct writes numbered, patched, sent in parts, replaced while waiting, `unavailable` on a closed window, `unsupported` rows without patches; one track per property both ways and for a binding; `view` of another plugin refused; bare registration, run, update, conflict, dispose; a refused declaration fails `startPlugin`) and `test/capability-check.test.ts` (a literal and a constant method, `events.subscribe` by its `event` field, requires, a union, an unknown or computed method unchecked, `player.on`/`wire.on` by event name, `check` and `check --json` with an unchecked call). The API surface snapshot gains the new members only.
|
|
46
|
+
- Documentation tooling: `doc-lint` and the documentation tree read a method's signature comment when its own comment holds only a modifier tag (`@experimental`).
|
|
47
|
+
|
|
48
|
+
**Documentation refactor for the three plugin styles** (spec §5): documentation, examples and checks only.
|
|
49
|
+
|
|
50
|
+
- **New page, Explanation: "Three ways to write a plugin"** (`docs/explanation/three-ways.md`): style A (`bind()`, the default), B (`plugin.player.on` + `set()`) and C (`plugin.wire`) compared on four scenarios side by side, each with the steps that differ on the way to the player and when to choose which: the speed display, a status line pushed on every frame of an `openStream` emulator (60 Hz), a list of 20,000 keyed rows (A's row patch, B's whole list in parts, C's own `writeRows`), and a command waiting for an asynchronous answer (`plugin.state`, the manual `plugin.update()` it replaces, B's `Command.set`, C's `WireCommand.update`); then what an author needs per style. Its code comes from the new example **`examples/three-ways`** (`style-a.ts`, `style-b.ts`, `style-c.ts`, one entry per style; `main.ts` runs A), whose tests run every scenario in every style against `TestHost` (the per-frame scenario with a stand-in for `openStream`; the real stream is signal-generator's test).
|
|
51
|
+
- **New generated reference pages**: **Events** (`docs/reference/events.md`, `scripts/doc-tables/events.mjs`): every `HostEvent` with its payload (type and summary from `EventPayloads`), the SDK members that subscribe to it (from `API_REQUESTS`), whether it wakes a stopped plugin (`WAKE_EVENTS`) and its capability (the player's table). **Messages** (`docs/reference/messages.md`, `scripts/doc-tables/messages.mjs`): every request method of the player's capability table, one table per capability with its residency, the capability rule (by parameter, if declared), the parameters and result the SDK's own client sends (read with the TypeScript checker), the error codes the sending members document, and its stability ("SDK member: …", otherwise "`plugin.wire` only"); methods under a `.*` wildcard that the SDK sends get rows of their own. The generator fails when a method the SDK sends names no public member (`WRAPPED_BY` lists the handles' own requests, such as `ui.set` for `Window.set`). The "Introduced in" column of both is "—" until the player's `capabilities.json` gains a version per method (and event); the pages say so.
|
|
52
|
+
- **Examples policy**: each example keeps one main version; `signal-generator` and `panel-menu` also come as `main-b.ts` and `main-c.ts` (styles B and C), with an "In style B and C" section in their walkthroughs, and their tests run against each entry file.
|
|
53
|
+
- **How the player runs and talks to plugins**: "Plugin code never sees a method name" now holds for styles A and B; style C uses the names of the two new tables. New section **Layers and stability**: the framework (L2) and primitives (L1) are semver; `plugin.wire` and the two tables change with versions. Detail moved to the generated tables and condensed to stay under the page limit (4,513 words before, 4,497 now). **How a plugin runs** (the update pass): layer names, `plugin.state` fields and `player.on` listeners, and when a manual `plugin.update()` is still needed; **The player's Rust core** says where L2 and L1 meet the player's broadcasts. `Wire` and `Player.on` link the chapter and the events table.
|
|
54
|
+
- **Checks**: `doc-lint` enforces two more rules: every `HostEvent` has a payload with a summary and a row in the events table; every `@experimental` declaration and method says that the wire protocol is not semver and changes with versions (fields and inherited members are covered by their declaration). `test/docs-tree.test.ts` checks the chapter's code and both tables in the documentation tree. `llms.txt` regenerated.
|
|
55
|
+
|
|
3
56
|
## 1.6.22
|
|
4
57
|
|
|
5
58
|
**Who must change: nobody.** Tables follow the menu's Adjustments and Effects and Sidebar items: a data refresh of `BUILTIN_COMMANDS`; no API change, `apiVersion` stays `vestra/1`. A plugin whose tests compare a title or path against the table sees the player's current one.
|
package/bin/vestra-plugin.mjs
CHANGED
|
@@ -15,7 +15,9 @@
|
|
|
15
15
|
* check strict type check of the plugin's .ts files and tests/*.ts
|
|
16
16
|
* (then every use of an API member whose capability manifest.json
|
|
17
17
|
* does not declare: file:line, member, capability; fails on any;
|
|
18
|
-
*
|
|
18
|
+
* a plugin.wire.request or event listener whose name the check
|
|
19
|
+
* cannot read is listed as unchecked, without failing; --json
|
|
20
|
+
* prints the findings and the unchecked calls as JSON)
|
|
19
21
|
* build check, then write dist/: .ts → .js with types stripped, other
|
|
20
22
|
* package files copied, dist/manifest.json with `version`
|
|
21
23
|
* test node --test on tests/*.test.{ts,mjs}
|
|
@@ -328,12 +330,13 @@ async function check(target, report = null) {
|
|
|
328
330
|
);
|
|
329
331
|
if (!sources.length) {
|
|
330
332
|
say(`${target.name}: no TypeScript to check`);
|
|
331
|
-
report?.push({ plugin: target.name, findings: [] });
|
|
333
|
+
report?.push({ plugin: target.name, findings: [], unchecked: [] });
|
|
332
334
|
return;
|
|
333
335
|
}
|
|
334
336
|
const tsc = compiler("typescript/lib/tsc.js");
|
|
335
337
|
const scratch = await mkdtemp(join(tmpdir(), "vestra-plugin-check-"));
|
|
336
338
|
let findings;
|
|
339
|
+
let unchecked;
|
|
337
340
|
try {
|
|
338
341
|
const config = join(scratch, "tsconfig.json");
|
|
339
342
|
await writeFile(config, JSON.stringify(checkConfig(target, sources)));
|
|
@@ -344,16 +347,23 @@ async function check(target, report = null) {
|
|
|
344
347
|
)
|
|
345
348
|
fail(`${target.name}: type check failed`);
|
|
346
349
|
say(`${target.name}: type check passed (${sources.length} files)`);
|
|
347
|
-
findings = await capabilityFindings(target, config);
|
|
350
|
+
({ findings, unchecked } = await capabilityFindings(target, config));
|
|
348
351
|
} finally {
|
|
349
352
|
await rm(scratch, { recursive: true, force: true });
|
|
350
353
|
}
|
|
351
|
-
if (report) report.push({ plugin: target.name, findings });
|
|
352
|
-
else
|
|
354
|
+
if (report) report.push({ plugin: target.name, findings, unchecked });
|
|
355
|
+
else {
|
|
353
356
|
for (const finding of findings)
|
|
354
357
|
console.error(
|
|
355
358
|
`${relative(process.cwd(), finding.file) || finding.file}:${finding.line}:${finding.column}: ${finding.message} (request ${finding.method})`,
|
|
356
359
|
);
|
|
360
|
+
// Calls whose capability depends on a name the check cannot read
|
|
361
|
+
// (plugin.wire.request with a computed method): a note, never a failure.
|
|
362
|
+
for (const call of unchecked)
|
|
363
|
+
console.log(
|
|
364
|
+
`${relative(process.cwd(), call.file) || call.file}:${call.line}:${call.column}: unchecked: ${call.message}`,
|
|
365
|
+
);
|
|
366
|
+
}
|
|
357
367
|
if (findings.length) {
|
|
358
368
|
const missing = [...new Set(findings.map((each) => each.capability))];
|
|
359
369
|
fail(
|
|
@@ -377,8 +387,10 @@ async function check(target, report = null) {
|
|
|
377
387
|
}
|
|
378
388
|
|
|
379
389
|
/**
|
|
380
|
-
* Uses of API members whose capability the manifest does not declare
|
|
381
|
-
*
|
|
390
|
+
* Uses of API members whose capability the manifest does not declare
|
|
391
|
+
* (`findings`), and calls whose capability depends on a name the check
|
|
392
|
+
* cannot read (`unchecked`: `plugin.wire.request` with a computed method),
|
|
393
|
+
* in the plugin's production files (not tests/), with the type check's
|
|
382
394
|
* compiler options (src/capability-check.ts).
|
|
383
395
|
*/
|
|
384
396
|
async function capabilityFindings(target, config) {
|
|
@@ -397,14 +409,23 @@ async function capabilityFindings(target, config) {
|
|
|
397
409
|
const files = (await sourceFiles(target)).typescript.map((file) =>
|
|
398
410
|
join(target.directory, file),
|
|
399
411
|
);
|
|
400
|
-
if (!parsed || !files.length) return [];
|
|
412
|
+
if (!parsed || !files.length) return { findings: [], unchecked: [] };
|
|
401
413
|
const program = ts.createProgram(parsed.fileNames, parsed.options);
|
|
402
414
|
const capabilities = Array.isArray(target.manifest.capabilities)
|
|
403
415
|
? target.manifest.capabilities
|
|
404
416
|
: [];
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
417
|
+
const { findings, unchecked } = capabilityCheck.checkCapabilities(
|
|
418
|
+
ts,
|
|
419
|
+
program,
|
|
420
|
+
{ files, capabilities },
|
|
421
|
+
);
|
|
422
|
+
return {
|
|
423
|
+
findings: findings.map((finding) => ({
|
|
424
|
+
...finding,
|
|
425
|
+
file: resolve(finding.file),
|
|
426
|
+
})),
|
|
427
|
+
unchecked: unchecked.map((call) => ({ ...call, file: resolve(call.file) })),
|
|
428
|
+
};
|
|
408
429
|
}
|
|
409
430
|
|
|
410
431
|
/** Slint source without its comments (string literals kept as they are). */
|
|
@@ -957,7 +978,8 @@ async function main() {
|
|
|
957
978
|
console.error(`✖ ${error.message}`);
|
|
958
979
|
failed.push(directory);
|
|
959
980
|
if (report) {
|
|
960
|
-
if (report.length === reported)
|
|
981
|
+
if (report.length === reported)
|
|
982
|
+
report.push({ findings: [], unchecked: [] });
|
|
961
983
|
report[reported].error = error.message;
|
|
962
984
|
}
|
|
963
985
|
}
|
package/dist/api-requests.d.ts
CHANGED
|
@@ -34,3 +34,25 @@ export interface ApiRequest {
|
|
|
34
34
|
}
|
|
35
35
|
/** @internal */
|
|
36
36
|
export declare const API_REQUESTS: Readonly<Record<string, readonly ApiRequest[]>>;
|
|
37
|
+
/**
|
|
38
|
+
* 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`.
|
|
42
|
+
*
|
|
43
|
+
* @internal
|
|
44
|
+
*/
|
|
45
|
+
export declare const SUBSCRIBED_EVENTS: readonly string[];
|
|
46
|
+
/**
|
|
47
|
+
* Members whose requests depend on an argument (SDK 1.7.0), which
|
|
48
|
+
* `API_REQUESTS` cannot list: the event name of a listener (`event`: a
|
|
49
|
+
* subscribed event's `events.subscribe`, nothing for the others) or the
|
|
50
|
+
* method name of a request (`method`: that method, with the string
|
|
51
|
+
* fields of the second argument as its parameters). The capability check
|
|
52
|
+
* reads the argument when its type is one string (a literal, a constant),
|
|
53
|
+
* and reports the call as unchecked otherwise (a computed name, a union of
|
|
54
|
+
* several, the member taken by destructuring or as a value).
|
|
55
|
+
*
|
|
56
|
+
* @internal
|
|
57
|
+
*/
|
|
58
|
+
export declare const ARGUMENT_APIS: Readonly<Record<string, "event" | "method">>;
|
package/dist/api-requests.js
CHANGED
|
@@ -153,4 +153,42 @@ export const API_REQUESTS = Object.freeze({
|
|
|
153
153
|
"VideoUpscaling.state": [{ method: "video.upscaling.state" }],
|
|
154
154
|
"VideoUpscaling.set": [{ method: "video.upscaling.set" }],
|
|
155
155
|
"VideoUpscaling.onChange": [listen("video.upscaling.changed")],
|
|
156
|
+
"WireCommands.register": [{ method: "commands.register" }],
|
|
157
|
+
});
|
|
158
|
+
/**
|
|
159
|
+
* The events whose listener subscribes (`events.subscribe` with the event
|
|
160
|
+
* name): the plugin API's `HostEvent`. Other names a plugin listens to
|
|
161
|
+
* (`commands.execute`, `ui.callback`) arrive unasked and need nothing.
|
|
162
|
+
* test/wire-facade.test.ts keeps it equal to `HostEvent`.
|
|
163
|
+
*
|
|
164
|
+
* @internal
|
|
165
|
+
*/
|
|
166
|
+
export const SUBSCRIBED_EVENTS = Object.freeze([
|
|
167
|
+
"source.state",
|
|
168
|
+
"playback.backend",
|
|
169
|
+
"window.state",
|
|
170
|
+
"packages.changed",
|
|
171
|
+
"bindings.changed",
|
|
172
|
+
"commands.keys",
|
|
173
|
+
"timeline.changed",
|
|
174
|
+
"appearance.changed",
|
|
175
|
+
"resolvers.fileTypes",
|
|
176
|
+
"video.upscaling.changed",
|
|
177
|
+
]);
|
|
178
|
+
/**
|
|
179
|
+
* Members whose requests depend on an argument (SDK 1.7.0), which
|
|
180
|
+
* `API_REQUESTS` cannot list: the event name of a listener (`event`: a
|
|
181
|
+
* subscribed event's `events.subscribe`, nothing for the others) or the
|
|
182
|
+
* method name of a request (`method`: that method, with the string
|
|
183
|
+
* fields of the second argument as its parameters). The capability check
|
|
184
|
+
* reads the argument when its type is one string (a literal, a constant),
|
|
185
|
+
* and reports the call as unchecked otherwise (a computed name, a union of
|
|
186
|
+
* several, the member taken by destructuring or as a value).
|
|
187
|
+
*
|
|
188
|
+
* @internal
|
|
189
|
+
*/
|
|
190
|
+
export const ARGUMENT_APIS = Object.freeze({
|
|
191
|
+
"Player.on": "event",
|
|
192
|
+
"Wire.on": "event",
|
|
193
|
+
"Wire.request": "method",
|
|
156
194
|
});
|
|
@@ -15,6 +15,14 @@
|
|
|
15
15
|
* (their object comes from a call that is checked) and options that need
|
|
16
16
|
* more (a `processed` capture, a file resolver).
|
|
17
17
|
*
|
|
18
|
+
* Members whose capability depends on an argument (SDK 1.7.0:
|
|
19
|
+
* `plugin.player.on` and `plugin.wire.on` by event name,
|
|
20
|
+
* `plugin.wire.request` by method name, `ARGUMENT_APIS`) are checked by
|
|
21
|
+
* that argument when its type fixes it to one string (a literal, a
|
|
22
|
+
* constant); otherwise (a computed name, a union of several, the member
|
|
23
|
+
* taken by destructuring or as a value) the call is reported as unchecked
|
|
24
|
+
* ({@link checkCapabilities}), and the player still checks it.
|
|
25
|
+
*
|
|
18
26
|
* The TypeScript module is passed in, never imported: the CLI uses the
|
|
19
27
|
* SDK's own compiler, the editor its TypeScript server's.
|
|
20
28
|
*
|
|
@@ -26,6 +34,11 @@ import type { CapabilityRules } from "./capability-rules.ts";
|
|
|
26
34
|
export declare const SDK_MODULE = "@vestra-player/sdk";
|
|
27
35
|
/** @internal The diagnostic code the editor shows (and its quick fix keys on). */
|
|
28
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;
|
|
29
42
|
/** @internal One use of a member whose capability is not declared. */
|
|
30
43
|
export interface CapabilityFinding {
|
|
31
44
|
/** The source file, as the program names it. */
|
|
@@ -56,6 +69,25 @@ export interface CheckOptions {
|
|
|
56
69
|
/** Default: the SDK's rules. */
|
|
57
70
|
readonly rules?: CapabilityRules;
|
|
58
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* @internal A call whose capability the checker cannot tell (SDK 1.7.0): a
|
|
74
|
+
* member of `ARGUMENT_APIS` (`plugin.wire.request`, `player.on`,
|
|
75
|
+
* `wire.on`) whose name argument is not a string the types fix, or a method
|
|
76
|
+
* the player's table does 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
|
+
}
|
|
59
91
|
/**
|
|
60
92
|
* Every use, in `options.files`, of a member whose capability the manifest
|
|
61
93
|
* does not declare, in file and position order.
|
|
@@ -63,6 +95,22 @@ export interface CheckOptions {
|
|
|
63
95
|
* @internal
|
|
64
96
|
*/
|
|
65
97
|
export declare function findUndeclaredCapabilities(ts: typeof TS, program: TS.Program, options: CheckOptions): CapabilityFinding[];
|
|
98
|
+
/**
|
|
99
|
+
* The capability check (SDK 1.7.0): the uses of members whose capability
|
|
100
|
+
* the manifest does not declare (`findings`, as
|
|
101
|
+
* {@link findUndeclaredCapabilities}), and the calls whose capability
|
|
102
|
+
* depends on a name the checker cannot read (`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
|
+
};
|
|
66
114
|
/**
|
|
67
115
|
* Whether a file belongs to the plugin's production code, given the
|
|
68
116
|
* directory of its `manifest.json`: not in `tests/`, `node_modules/`,
|