@vestra-player/sdk 1.11.1 → 1.11.2

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 CHANGED
@@ -1,5 +1,24 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.11.2
4
+
5
+ Additions and fixes only; nobody must change anything except a plugin test that relies on a host error the plugin does not handle (below).
6
+
7
+ - **Security fixes (CodeQL):** `vestra-plugin docs` path handling and the table rule parser no longer backtrack polynomially on long input; the manifest check opens each icon, readme and changelog file once and reads through that handle. Behaviour is unchanged.
8
+ - **Examples:** new screenshots (player 0.11.1); `three-ways` shows its speed as an adjust-column tab and cycles on S (the bottom bar belongs to the player's control bar; design rule "Not the bottom bar"); listeners before the first await in `adjust-panel` and `three-ways`; window items under `@tools`.
9
+ - **Repository:** CodeQL, Scorecard, osv-scanner, semgrep (examples) and dependency review in CI; SECURITY.md.
10
+
11
+
12
+ **Tests catch a control made with an old state** (the SDK's control semantics are unchanged). Since 1.11.0 a plugin that read the state once (`await player.read()`) and later pauses, seeks, steps or sets the speed sends the stamp of that copy (`expected`), and the player refuses it with `stale` once the user changed the source. Tests did not see it: no test changed the source between activation and a command, and a refusal the plugin left to its log passed. Who must change: a plugin test that relies on a host error the plugin does not handle (below).
13
+
14
+ - **`TestHost.strictErrors`** (new, default `true`): a host error the plugin logged because nothing handled it (no `try`/`catch`, no `plugin.onError`; also a failure the SDK reports beside a status, such as a shader or render failure) fails the test: the next `host.settle()` (and so `command(id).run()`) rejects with it, or else `stop()`, after its cleanup. The message names the error and says to call `host.expectError(code)`, or to set `strictErrors = false` to only log host errors as before. Errors logged while the plugin stops (`stop`, `park`, `disconnect`) only go to the log.
15
+ - **`TestHost.expectError(code)`** (new): expect one such error; one that never comes fails `stop()`. **`TestHost.loggedErrors`** (new) lists them all.
16
+ - The runtime tells `TestHost` of an error that reaches the plugin's log (`Connection.logged`, internal); the player's runner does not set it and logs as before.
17
+ - `TestHost.openElsewhere` says that it advances the source stamp as the player does, also for the path already open, and that a core action (`coreAction("play-pause").run()`) is a new intent.
18
+ - **Docs**: the testing guide's new section [Change the source in your tests](docs/guides/testing.md#change-the-source-in-your-tests) (the guide is now two pages; `docs-tree.test.ts` takes the page header), and the test host reference.
19
+ - **Golden traces** fail on a host error a scenario does not list (`KNOWN_ERRORS`): `examples/menus` and `examples/adjust-panel` list their `stale` (TODO: until the pending decision on the control semantics or a fix of the examples). The SDK's own tests of refusals expect theirs (`portability`, `round4a`, `video-primitives`).
20
+ - **Examples**: `menus`, `adjust-panel`, `three-ways` and `bookmark` run their controls after a file opened after activation, another file, the same file again and a pause. The ones the player refuses today are `todo` with a TODO: every speed of `menus`, `adjust-panel`'s Normal Speed with the column closed, and `three-ways`' Next Keyframe in styles A and B after a pause.
21
+
3
22
  ## 1.11.1
4
23
 
5
24
  **NVIDIA motion smoothing** (T8; needs player 0.11.1, which ships the NVIDIA engine). Additions only; nobody must change anything.
Binary file
package/dist/docs.js CHANGED
@@ -126,7 +126,16 @@ function distance(a, b) {
126
126
  }
127
127
  /** A path as typed: its segments and `#anchor`. */
128
128
  function parse(path) {
129
- let text = path.trim().replace(/^["'<]+|["'>]+$/g, "");
129
+ let text = path.trim();
130
+ // Quotes and <> around it go; a scan from each end, not a regular
131
+ // expression (`["'>]+$` can be quadratic on a long run of quotes).
132
+ let start = 0;
133
+ while (start < text.length && `"'<`.includes(text[start]))
134
+ start++;
135
+ let end = text.length;
136
+ while (end > start && `"'>`.includes(text[end - 1]))
137
+ end--;
138
+ text = text.slice(start, end);
130
139
  try {
131
140
  text = decodeURIComponent(text);
132
141
  }
@@ -247,7 +256,8 @@ const slug = (heading) => heading
247
256
  .replace(/[^\p{L}\p{N}\s_-]/gu, "")
248
257
  .replace(/\s/g, "-");
249
258
  const FENCE = /^\s*```/;
250
- const TABLE_RULE = /^\s*\|?\s*:?-{3,}:?\s*(\|\s*:?-{3,}:?\s*)*\|?\s*$/;
259
+ // No two `\s*` next to each other (`\s*\|?\s*` is quadratic on spaces).
260
+ const TABLE_RULE = /^\s*(?:\|\s*)?:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)*(?:\|\s*)?$/;
251
261
  /**
252
262
  * Lines into pages: the first at most `first` bytes, the others `rest`.
253
263
  * A code fence cut by a page break is closed and opened again; a table's
package/dist/manifest.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * player's `src/host/src/packages/manifest.rs` (the player's tests compare the limits).
4
4
  * Paths in the manifest are checked against the plugin directory.
5
5
  */
6
- import { existsSync, lstatSync, readFileSync, realpathSync } from "node:fs";
6
+ import { closeSync, existsSync, fstatSync, openSync, readFileSync, realpathSync, } from "node:fs";
7
7
  import { join, sep } from "node:path";
8
8
  import { API_VERSION } from "./protocol.js";
9
9
  export const MANIFEST_LIMITS = Object.freeze({
@@ -140,19 +140,39 @@ export function manifestProblems(manifest, directory) {
140
140
  if (!extensions.some((x) => value.toLowerCase().endsWith(x)))
141
141
  return void problem(`${field} must be a ${extensions.join(" or ")} file`);
142
142
  const path = join(directory, value);
143
- if (!existsSync(path))
144
- return void problem(`${field} file ${value} is missing`);
145
143
  let real;
146
144
  try {
147
145
  real = realpathSync(path);
148
146
  }
149
147
  catch {
150
- return void problem(`${field} file ${value} is unreadable`);
148
+ return void problem(existsSync(path)
149
+ ? `${field} file ${value} is unreadable`
150
+ : `${field} file ${value} is missing`);
151
151
  }
152
152
  const root = realpathSync(directory);
153
- if (!real.startsWith(root + sep) || lstatSync(real).isDirectory())
154
- return void problem(`${field} must name a file inside the package`);
155
- const bytes = readFileSync(real);
153
+ const outside = () => void problem(`${field} must name a file inside the package`);
154
+ if (!real.startsWith(root + sep))
155
+ return outside();
156
+ // Opened once: the file checked (not a directory) is the file read,
157
+ // whatever happens to the path meanwhile.
158
+ let handle;
159
+ try {
160
+ handle = openSync(real, "r");
161
+ }
162
+ catch (error) {
163
+ if (error.code === "EISDIR")
164
+ return outside();
165
+ throw error;
166
+ }
167
+ let bytes;
168
+ try {
169
+ if (fstatSync(handle).isDirectory())
170
+ return outside();
171
+ bytes = readFileSync(handle);
172
+ }
173
+ finally {
174
+ closeSync(handle);
175
+ }
156
176
  if (bytes.length > max)
157
177
  return void problem(`${field} file exceeds ${max / 1024} KB`);
158
178
  return bytes;
@@ -105,6 +105,13 @@ export declare class Connection {
105
105
  * a listener), the log before.
106
106
  */
107
107
  reportMirror: (error: unknown) => void;
108
+ /**
109
+ * Told of every error that reaches the plugin's log because nothing in
110
+ * the plugin handled it (no `onError` listener). `TestHost` sets it to
111
+ * fail a test on a host error the test did not expect; the player's
112
+ * runner leaves it unset. The error is logged either way.
113
+ */
114
+ logged: ((error: unknown) => void) | undefined;
108
115
  /** The framework's ears ({@link StateSignals}); silent until `Runtime` sets them. */
109
116
  signals: StateSignals;
110
117
  /**
@@ -129,6 +129,13 @@ export class Connection {
129
129
  * a listener), the log before.
130
130
  */
131
131
  reportMirror = (error) => console.error(`[${this.manifest.id}]`, error);
132
+ /**
133
+ * Told of every error that reaches the plugin's log because nothing in
134
+ * the plugin handled it (no `onError` listener). `TestHost` sets it to
135
+ * fail a test on a host error the test did not expect; the player's
136
+ * runner leaves it unset. The error is logged either way.
137
+ */
138
+ logged = undefined;
132
139
  /** The framework's ears ({@link StateSignals}); silent until `Runtime` sets them. */
133
140
  signals = SILENT;
134
141
  /**
@@ -397,6 +397,7 @@ export class Passes {
397
397
  }
398
398
  catch (error) {
399
399
  console.error(`[${this.#connection.manifest.id}] binding failed:`, error);
400
+ this.#connection.logged?.(error);
400
401
  }
401
402
  finally {
402
403
  this.#pass = undefined;
@@ -189,8 +189,10 @@ export class ScopeImpl {
189
189
  }
190
190
  else if (this.#parent)
191
191
  this.#parent.report(coded);
192
- else
192
+ else {
193
193
  console.error(`[${this.id}]`, coded);
194
+ this.runtime.logged?.(coded);
195
+ }
194
196
  }
195
197
  /** Invoke plugin code on its behalf: report failures, then refresh bindings. */
196
198
  run(handler, ...args) {
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Host errors the plugin logged (SDK 1.11.2): a refusal or failure with a
3
+ * code (`HostError`, e.g. `stale`, `invalid`, `disabled`) that nothing in
4
+ * the plugin handled, so it reached the plugin's log, as the player's log
5
+ * would show it. Under `TestHost.strictErrors` (the default) such an error
6
+ * fails the test at the next `settle()` (also `command(…).run()`) or at
7
+ * `stop()`, unless the test expected it with `expectError(code)`.
8
+ *
9
+ * Part of `TestHost` (`./index.ts`). Internal to the SDK; not exported from
10
+ * `@vestra-player/sdk/testing`.
11
+ */
12
+ import { HostError } from "../../wire.ts";
13
+ import type { TestHost } from "./index.ts";
14
+ /** One host's book of logged errors and expectations. */
15
+ export declare class ErrorBook {
16
+ /** Every host error the plugin logged, expected or not, in order. */
17
+ readonly logged: HostError[];
18
+ /** Logged errors no expectation covered, not yet thrown. */
19
+ readonly unexpected: HostError[];
20
+ /** Codes the test expects, one entry per expected error. */
21
+ readonly expected: string[];
22
+ /** Above 0 while `startPlugin` itself settles (activation, `stop`, `park`). */
23
+ suspended: number;
24
+ }
25
+ /** The book of each host (`TestHost` makes it in its constructor). */
26
+ export declare const errorBooks: WeakMap<TestHost, ErrorBook>;
27
+ /**
28
+ * The runtime's `logged` hook (`Connection.logged`): note an error that
29
+ * reached the plugin's log. Errors without a code of the host's kind (a
30
+ * `TypeError` in the plugin's code) are not counted.
31
+ */
32
+ export declare function noteLogged(host: TestHost, error: unknown): void;
33
+ /**
34
+ * Throw the unexpected host errors logged since the last check, once
35
+ * (they are cleared), when the host is strict.
36
+ */
37
+ export declare function checkErrors(host: TestHost): void;
38
+ /** At `stop()`: the unexpected errors, then the expected ones that never came. */
39
+ export declare function checkErrorsAtStop(host: TestHost): void;
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Host errors the plugin logged (SDK 1.11.2): a refusal or failure with a
3
+ * code (`HostError`, e.g. `stale`, `invalid`, `disabled`) that nothing in
4
+ * the plugin handled, so it reached the plugin's log, as the player's log
5
+ * would show it. Under `TestHost.strictErrors` (the default) such an error
6
+ * fails the test at the next `settle()` (also `command(…).run()`) or at
7
+ * `stop()`, unless the test expected it with `expectError(code)`.
8
+ *
9
+ * Part of `TestHost` (`./index.ts`). Internal to the SDK; not exported from
10
+ * `@vestra-player/sdk/testing`.
11
+ */
12
+ import { HostError } from "../../wire.js";
13
+ /** One host's book of logged errors and expectations. */
14
+ export class ErrorBook {
15
+ /** Every host error the plugin logged, expected or not, in order. */
16
+ logged = [];
17
+ /** Logged errors no expectation covered, not yet thrown. */
18
+ unexpected = [];
19
+ /** Codes the test expects, one entry per expected error. */
20
+ expected = [];
21
+ /** Above 0 while `startPlugin` itself settles (activation, `stop`, `park`). */
22
+ suspended = 0;
23
+ }
24
+ /** The book of each host (`TestHost` makes it in its constructor). */
25
+ export const errorBooks = new WeakMap();
26
+ /**
27
+ * The runtime's `logged` hook (`Connection.logged`): note an error that
28
+ * reached the plugin's log. Errors without a code of the host's kind (a
29
+ * `TypeError` in the plugin's code) are not counted.
30
+ */
31
+ export function noteLogged(host, error) {
32
+ const book = errorBooks.get(host);
33
+ if (!book || !(error instanceof HostError))
34
+ return;
35
+ book.logged.push(error);
36
+ const index = book.expected.indexOf(error.code);
37
+ if (index >= 0)
38
+ book.expected.splice(index, 1);
39
+ else
40
+ book.unexpected.push(error);
41
+ }
42
+ /** Why a host error fails a test, and how to expect it instead. */
43
+ function unexpectedMessage(host, errors) {
44
+ const lines = errors.map((error) => ` ${error.code}: ${error.message}`);
45
+ const code = errors[0].code;
46
+ return [
47
+ `${host.manifestId} logged ${errors.length === 1 ? "a host error" : `${errors.length} host errors`} the test did not expect:`,
48
+ ...lines,
49
+ `Nothing in the plugin handled ${errors.length === 1 ? "it" : "them"} (the player's log shows the same). If the test means it, call`,
50
+ `host.expectError(${JSON.stringify(code)}) before the step that causes it; host.strictErrors = false only logs host errors.`,
51
+ ].join("\n");
52
+ }
53
+ /**
54
+ * Throw the unexpected host errors logged since the last check, once
55
+ * (they are cleared), when the host is strict.
56
+ */
57
+ export function checkErrors(host) {
58
+ const book = errorBooks.get(host);
59
+ if (!book || book.suspended > 0 || !book.unexpected.length)
60
+ return;
61
+ const errors = book.unexpected.splice(0);
62
+ if (!host.strictErrors)
63
+ return;
64
+ const error = new Error(unexpectedMessage(host, errors));
65
+ error.cause = errors[0];
66
+ throw error;
67
+ }
68
+ /** At `stop()`: the unexpected errors, then the expected ones that never came. */
69
+ export function checkErrorsAtStop(host) {
70
+ checkErrors(host);
71
+ const book = errorBooks.get(host);
72
+ if (!book || !book.expected.length)
73
+ return;
74
+ const missing = book.expected.splice(0);
75
+ if (!host.strictErrors)
76
+ return;
77
+ throw new Error(`${host.manifestId}: the test expected ${missing.map((code) => `\`${code}\``).join(", ")} (host.expectError), but the plugin never logged ${missing.length === 1 ? "it" : "them"}`);
78
+ }
@@ -2744,6 +2744,17 @@ export declare class TestHost implements Transport {
2744
2744
  * `sourceId`, then the given phase. Calls the plugin made against the old
2745
2745
  * state now fail with `stale`.
2746
2746
  *
2747
+ * The source stamp advances exactly as in the player: a new generation
2748
+ * and a new intent, also when `source` is the path already open (the
2749
+ * user opened the same file again). Call it after `startPlugin` to test
2750
+ * what the user does while the plugin runs: a file opened after
2751
+ * activation, another file, the same one again. A control the plugin
2752
+ * then makes with the state it read before (`player.setRate`,
2753
+ * `seek`, `step`, …) is refused with `stale`, as in the player. The
2754
+ * user's own pause, seek or speed change is a core action
2755
+ * (`coreAction("play-pause").run()`): a new intent, which makes an older
2756
+ * state stale too. `setSource` changes the facts only.
2757
+ *
2747
2758
  * @param source - The path or URL.
2748
2759
  * @param phase - The phase to end in (default `"ready"`).
2749
2760
  *
@@ -3207,10 +3218,81 @@ export declare class TestHost implements Transport {
3207
3218
  * assert.equal(importWindow.props["status-text"], expected);
3208
3219
  * ```
3209
3220
  *
3210
- * @throws Never.
3221
+ * @throws `Error` (rejects) The plugin logged a host error the test did
3222
+ * not expect ({@link TestHost.strictErrors}, SDK 1.11.2); the message
3223
+ * names it and says how to expect it ({@link TestHost.expectError}).
3211
3224
  * @since 1.0.0
3212
3225
  */
3213
3226
  settle(ms?: number): Promise<void>;
3227
+ /**
3228
+ * Whether a host error the plugin logged fails the test (default `true`).
3229
+ * A host error is a refusal or failure with a code (`stale`, `invalid`,
3230
+ * `disabled`, …) that nothing in the plugin handled: no `try`/`catch`
3231
+ * around the call and no `plugin.onError` listener, so the player would
3232
+ * only write it to its log. The next {@link TestHost.settle} (so also
3233
+ * `command(…).run()`) rejects with it, or else `stop()`; the message
3234
+ * names the error and how to expect it. A test that means it calls
3235
+ * {@link TestHost.expectError} first. Set `false` to only log host
3236
+ * errors, as before SDK 1.11.2. {@link TestHost.loggedErrors} lists them
3237
+ * either way.
3238
+ *
3239
+ * @example Expect a refusal the plugin does not handle
3240
+ * The user opens another file, then runs a command that controls the
3241
+ * old one with a state the plugin read before: the player refuses it with
3242
+ * `stale`, and the plugin leaves the refusal to its log. The test says so
3243
+ * before it runs the command; without `expectError` the run rejects.
3244
+ * ```ts
3245
+ * declare const host: TestHost;
3246
+ * // ---cut---
3247
+ * host.openElsewhere("/media/other.mp4");
3248
+ * host.expectError("stale");
3249
+ * await host.command("rate-2").run();
3250
+ * ```
3251
+ *
3252
+ * @since 1.11.2
3253
+ */
3254
+ strictErrors: boolean;
3255
+ /**
3256
+ * Expect the plugin to log one host error with `code` (each call
3257
+ * expects one more). An expected error does not fail the test; one that
3258
+ * never comes fails `stop()` (under {@link TestHost.strictErrors}).
3259
+ *
3260
+ * @param code - The error's code, e.g. `"stale"`.
3261
+ *
3262
+ * @example A control after the user changed the source
3263
+ * The plugin read the state once and sets the speed with its old copy;
3264
+ * after the user opened another file the player refuses the control.
3265
+ * ```ts
3266
+ * import assert from "node:assert/strict";
3267
+ * declare const host: TestHost;
3268
+ * // ---cut---
3269
+ * host.openElsewhere("/media/other.mp4");
3270
+ * host.expectError("stale");
3271
+ * await host.command("rate-2").run();
3272
+ * assert.equal(host.loggedErrors.at(-1)?.code, "stale");
3273
+ * ```
3274
+ *
3275
+ * @since 1.11.2
3276
+ */
3277
+ expectError(code: string): void;
3278
+ /**
3279
+ * Every host error the plugin logged (expected or not), oldest first:
3280
+ * errors with a code that nothing in the plugin handled.
3281
+ *
3282
+ * @example Check that nothing was refused
3283
+ * The test asserts that the plugin left no refusal to its log. The list
3284
+ * keeps every host error the plugin did not handle, also those the test
3285
+ * expected with `expectError`, so it is empty only when none came.
3286
+ * ```ts
3287
+ * import assert from "node:assert/strict";
3288
+ * declare const host: TestHost;
3289
+ * // ---cut---
3290
+ * assert.deepEqual(host.loggedErrors.map((error) => error.code), []);
3291
+ * ```
3292
+ *
3293
+ * @since 1.11.2
3294
+ */
3295
+ get loggedErrors(): readonly HostError[];
3214
3296
  /**
3215
3297
  * Close the fake stream servers and delete the host's temporary
3216
3298
  * directories. `stop()` from {@link startPlugin} calls it. It never
@@ -87,6 +87,7 @@ import { LOCALES, LIST_SEPARATORS, loadPackageCatalog, TEXT_LIMITS, } from "../.
87
87
  import { Internals } from "./internals.js";
88
88
  import { sendFacts } from "./facts.js";
89
89
  import { revokeRun, revokers } from "./revoke.js";
90
+ import { checkErrors, checkErrorsAtStop, ErrorBook, errorBooks, noteLogged, } from "./errors.js";
90
91
  import { on, emit, settle, close, keepsRunning, transportHandlers, tick, takenErrors, tellResidency, } from "./transport.js";
91
92
  import { bindingClaims, bindingKey, keysChanged, press, barButtons, commandsHandlers, builtinHandlers, runPaletteLead, } from "./commands.js";
92
93
  import { registerCoreActions, windowFacts, coreActionsHandlers, } from "./core-actions.js";
@@ -1873,6 +1874,7 @@ export class TestHost {
1873
1874
  */
1874
1875
  constructor() {
1875
1876
  revokers.set(this, (reason) => this.#revoke(reason));
1877
+ errorBooks.set(this, new ErrorBook());
1876
1878
  this.subtitles = {
1877
1879
  presentation: {
1878
1880
  revision: 1,
@@ -2310,6 +2312,17 @@ export class TestHost {
2310
2312
  * `sourceId`, then the given phase. Calls the plugin made against the old
2311
2313
  * state now fail with `stale`.
2312
2314
  *
2315
+ * The source stamp advances exactly as in the player: a new generation
2316
+ * and a new intent, also when `source` is the path already open (the
2317
+ * user opened the same file again). Call it after `startPlugin` to test
2318
+ * what the user does while the plugin runs: a file opened after
2319
+ * activation, another file, the same one again. A control the plugin
2320
+ * then makes with the state it read before (`player.setRate`,
2321
+ * `seek`, `step`, …) is refused with `stale`, as in the player. The
2322
+ * user's own pause, seek or speed change is a core action
2323
+ * (`coreAction("play-pause").run()`): a new intent, which makes an older
2324
+ * state stale too. `setSource` changes the facts only.
2325
+ *
2313
2326
  * @param source - The path or URL.
2314
2327
  * @param phase - The phase to end in (default `"ready"`).
2315
2328
  *
@@ -2790,11 +2803,87 @@ export class TestHost {
2790
2803
  * assert.equal(importWindow.props["status-text"], expected);
2791
2804
  * ```
2792
2805
  *
2793
- * @throws Never.
2806
+ * @throws `Error` (rejects) The plugin logged a host error the test did
2807
+ * not expect ({@link TestHost.strictErrors}, SDK 1.11.2); the message
2808
+ * names it and says how to expect it ({@link TestHost.expectError}).
2794
2809
  * @since 1.0.0
2795
2810
  */
2796
- settle(ms = 0) {
2797
- return settle(this, this.#inner, ms);
2811
+ async settle(ms = 0) {
2812
+ await settle(this, this.#inner, ms);
2813
+ checkErrors(this);
2814
+ }
2815
+ /**
2816
+ * Whether a host error the plugin logged fails the test (default `true`).
2817
+ * A host error is a refusal or failure with a code (`stale`, `invalid`,
2818
+ * `disabled`, …) that nothing in the plugin handled: no `try`/`catch`
2819
+ * around the call and no `plugin.onError` listener, so the player would
2820
+ * only write it to its log. The next {@link TestHost.settle} (so also
2821
+ * `command(…).run()`) rejects with it, or else `stop()`; the message
2822
+ * names the error and how to expect it. A test that means it calls
2823
+ * {@link TestHost.expectError} first. Set `false` to only log host
2824
+ * errors, as before SDK 1.11.2. {@link TestHost.loggedErrors} lists them
2825
+ * either way.
2826
+ *
2827
+ * @example Expect a refusal the plugin does not handle
2828
+ * The user opens another file, then runs a command that controls the
2829
+ * old one with a state the plugin read before: the player refuses it with
2830
+ * `stale`, and the plugin leaves the refusal to its log. The test says so
2831
+ * before it runs the command; without `expectError` the run rejects.
2832
+ * ```ts
2833
+ * declare const host: TestHost;
2834
+ * // ---cut---
2835
+ * host.openElsewhere("/media/other.mp4");
2836
+ * host.expectError("stale");
2837
+ * await host.command("rate-2").run();
2838
+ * ```
2839
+ *
2840
+ * @since 1.11.2
2841
+ */
2842
+ strictErrors = true;
2843
+ /**
2844
+ * Expect the plugin to log one host error with `code` (each call
2845
+ * expects one more). An expected error does not fail the test; one that
2846
+ * never comes fails `stop()` (under {@link TestHost.strictErrors}).
2847
+ *
2848
+ * @param code - The error's code, e.g. `"stale"`.
2849
+ *
2850
+ * @example A control after the user changed the source
2851
+ * The plugin read the state once and sets the speed with its old copy;
2852
+ * after the user opened another file the player refuses the control.
2853
+ * ```ts
2854
+ * import assert from "node:assert/strict";
2855
+ * declare const host: TestHost;
2856
+ * // ---cut---
2857
+ * host.openElsewhere("/media/other.mp4");
2858
+ * host.expectError("stale");
2859
+ * await host.command("rate-2").run();
2860
+ * assert.equal(host.loggedErrors.at(-1)?.code, "stale");
2861
+ * ```
2862
+ *
2863
+ * @since 1.11.2
2864
+ */
2865
+ expectError(code) {
2866
+ errorBooks.get(this).expected.push(code);
2867
+ }
2868
+ /**
2869
+ * Every host error the plugin logged (expected or not), oldest first:
2870
+ * errors with a code that nothing in the plugin handled.
2871
+ *
2872
+ * @example Check that nothing was refused
2873
+ * The test asserts that the plugin left no refusal to its log. The list
2874
+ * keeps every host error the plugin did not handle, also those the test
2875
+ * expected with `expectError`, so it is empty only when none came.
2876
+ * ```ts
2877
+ * import assert from "node:assert/strict";
2878
+ * declare const host: TestHost;
2879
+ * // ---cut---
2880
+ * assert.deepEqual(host.loggedErrors.map((error) => error.code), []);
2881
+ * ```
2882
+ *
2883
+ * @since 1.11.2
2884
+ */
2885
+ get loggedErrors() {
2886
+ return errorBooks.get(this).logged;
2798
2887
  }
2799
2888
  /**
2800
2889
  * Close the fake stream servers and delete the host's temporary
@@ -3148,6 +3237,8 @@ export async function startPlugin(activate, options = {}) {
3148
3237
  // Unlike the player's runner, which logs a refused command declaration
3149
3238
  // and activates the rest: a plugin's tests show the refusal.
3150
3239
  { strictDeclarations: true });
3240
+ // Host errors nothing in the plugin handled (`TestHost.strictErrors`).
3241
+ started.plugin.runtime.logged = (error) => noteLogged(host, error);
3151
3242
  await started.activate(entry);
3152
3243
  // Like the player: a position or resolver another plugin holds is not an
3153
3244
  // activation failure.
@@ -3163,22 +3254,44 @@ export async function startPlugin(activate, options = {}) {
3163
3254
  }
3164
3255
  return started;
3165
3256
  };
3166
- let instance = await run(activate);
3257
+ // Its own waits never throw a logged host error: activation's surfaces
3258
+ // at the test's next `settle()`; one logged while the run stops (a
3259
+ // request refused with `disabled` once `runtime.stop` went out) is the
3260
+ // stop's own and only logged.
3261
+ const book = errorBooks.get(host);
3262
+ const quietly = async (work) => {
3263
+ book.suspended++;
3264
+ try {
3265
+ await work();
3266
+ }
3267
+ finally {
3268
+ book.suspended--;
3269
+ }
3270
+ };
3271
+ const stopping = async (work) => {
3272
+ const before = book.unexpected.length;
3273
+ await quietly(work);
3274
+ book.unexpected.splice(before);
3275
+ };
3276
+ let instance;
3277
+ await quietly(async () => {
3278
+ instance = await run(activate);
3279
+ });
3167
3280
  const triggers = triggerState(host);
3168
3281
  let code = activate;
3169
- triggers.start = async (entry) => {
3282
+ triggers.start = (entry) => quietly(async () => {
3170
3283
  if (entry)
3171
3284
  code = entry;
3172
3285
  instance = await run(code);
3173
- };
3174
- triggers.stop = async (reason) => {
3286
+ });
3287
+ triggers.stop = (reason) => stopping(async () => {
3175
3288
  await instance.dispose({ reason });
3176
3289
  await host.settle();
3177
3290
  // Standby and an upgrade stop the run: the player revokes what it held.
3178
3291
  revokeRun(host, reason);
3179
3292
  await host.settle();
3180
- };
3181
- await host.settle();
3293
+ });
3294
+ await quietly(() => host.settle());
3182
3295
  tellResidency(host);
3183
3296
  // Zero declared parameters (`stop.length === 0`) and a `()` overload, so
3184
3297
  // `t.after(stop)`, `promise.then(stop)` and done-callback test runners
@@ -3194,14 +3307,19 @@ export async function startPlugin(activate, options = {}) {
3194
3307
  const quit = reason === "quit" ? quitEvent(host.source) : null;
3195
3308
  if (quit) {
3196
3309
  host.emit("source.ended", structuredClone(quit));
3197
- await host.settle();
3310
+ await quietly(() => host.settle());
3198
3311
  }
3199
- if (!triggers.parked)
3200
- await instance.dispose({ reason });
3201
- await host.settle();
3202
- revokeRun(host, typeof reason === "string" ? reason : undefined);
3203
- await host.settle();
3312
+ await stopping(async () => {
3313
+ if (!triggers.parked)
3314
+ await instance.dispose({ reason });
3315
+ await host.settle();
3316
+ revokeRun(host, typeof reason === "string" ? reason : undefined);
3317
+ await host.settle();
3318
+ });
3204
3319
  host.close();
3320
+ // After the cleanup: a host error the test did not expect, or one it
3321
+ // expected that never came, fails the test here.
3322
+ checkErrorsAtStop(host);
3205
3323
  };
3206
3324
  return {
3207
3325
  /** The test host the plugin talks to. */
@@ -3225,11 +3343,14 @@ export async function startPlugin(activate, options = {}) {
3225
3343
  */
3226
3344
  async disconnect() {
3227
3345
  host.loseConnection();
3228
- await instance.dispose({ reason: "host-lost" });
3229
- await host.settle();
3230
- revokeRun(host, "host-lost");
3231
- await host.settle();
3346
+ await stopping(async () => {
3347
+ await instance.dispose({ reason: "host-lost" });
3348
+ await host.settle();
3349
+ revokeRun(host, "host-lost");
3350
+ await host.settle();
3351
+ });
3232
3352
  host.close();
3353
+ checkErrorsAtStop(host);
3233
3354
  },
3234
3355
  };
3235
3356
  }
@@ -1074,12 +1074,12 @@ export interface Player {
1074
1074
  *
1075
1075
  *
1076
1076
  * @example Push the speed to a panel as it changes
1077
- * A bottom panel shows the playback speed. The listener gets each
1077
+ * A tab in the adjust column shows the playback speed. The listener gets each
1078
1078
  * `source.state` event's data and writes the text with `set`; no update
1079
1079
  * pass runs and the SDK keeps no copy of the state for this.
1080
1080
  * ```ts
1081
- * const bar = plugin.panels.mount("bottom", "ui/bar.slint");
1082
- * plugin.player.on("source.state", (s) => bar.set({ rate: `${s.rate.toFixed(2)}×` }));
1081
+ * const panel = plugin.panels.mount("adjust", "ui/speed.slint", { title: "Speed" });
1082
+ * plugin.player.on("source.state", (s) => panel.set({ rate: `${s.rate.toFixed(2)}×` }));
1083
1083
  * ```
1084
1084
  *
1085
1085
  * @see [Tutorial](../../../docs/tutorial/index.md)
@@ -36,13 +36,13 @@ import type { View } from "./ui-content.ts";
36
36
  * [Events](../../../docs/reference/events.md).
37
37
  *
38
38
  * @example Show the speed with direct messages
39
- * A bottom panel shows the playback speed, written by the plugin itself
39
+ * A tab in the adjust column shows the playback speed, written by the plugin itself
40
40
  * from the raw `source.state` event. The listener types the payload, which
41
- * is `unknown` here, and `view(bar).write` sends the text as a property
41
+ * is `unknown` here, and `view(panel).write` sends the text as a property
42
42
  * write; the SDK keeps no copy of the state and compares nothing.
43
43
  * ```ts
44
- * const bar = plugin.panels.mount("bottom", "ui/bar.slint");
45
- * const view = plugin.wire.view(bar);
44
+ * const panel = plugin.panels.mount("adjust", "ui/speed.slint", { title: "Speed" });
45
+ * const view = plugin.wire.view(panel);
46
46
  * plugin.wire.on("source.state", (data) => {
47
47
  * const s = data as { rate: number }; // the plugin types the payload
48
48
  * void view.write("rate", { value: `${s.rate.toFixed(2)}×` });
@@ -91,12 +91,12 @@ export interface Wire {
91
91
  * @throws `disabled` (rejects) The plugin is stopping.
92
92
  *
93
93
  * @example Write a panel property without the SDK
94
- * The plugin's bottom panel shows "1.00×" in its `rate` property, written
94
+ * The plugin's adjust tab shows "1.00×" in its `rate` property, written
95
95
  * with the player's own request. The parameters are the protocol's
96
96
  * (`property`, `value`); the player checks the value.
97
97
  * ```ts
98
- * const bar = plugin.panels.mount("bottom", "ui/bar.slint");
99
- * await bar.ready;
98
+ * const panel = plugin.panels.mount("adjust", "ui/speed.slint", { title: "Speed" });
99
+ * await panel.ready;
100
100
  * await plugin.wire.request("ui.setMount", { property: "rate", value: "1.00×" });
101
101
  * ```
102
102
  *
@@ -266,9 +266,9 @@ export interface WireView {
266
266
  * plugin's own loop. The write goes out at once; if the player is still
267
267
  * busy with the previous one, only the newest count waits.
268
268
  * ```ts
269
- * const bar = plugin.panels.mount("bottom", "ui/bar.slint");
270
- * await bar.ready;
271
- * const view = plugin.wire.view(bar);
269
+ * const panel = plugin.panels.mount("sidebar", "ui/counter.slint", { title: "Frames" });
270
+ * await panel.ready;
271
+ * const view = plugin.wire.view(panel);
272
272
  * let frames = 0;
273
273
  * const tick = setInterval(() => void view.write("frames", { value: ++frames }), 100); // newest waits
274
274
  * plugin.onDispose(() => clearInterval(tick));
@@ -323,7 +323,10 @@ export interface BackdropSlot {
323
323
  * `"adjust"`. Each {@link Panel} has its own bridge, state, `toggle()` and
324
324
  * `setInteraction()`; disposing one leaves the others, and stopping the plugin
325
325
  * unmounts them all. The bottom bar and the backdrop hold one panel for all
326
- * plugins; the sidebar and the adjust column one tab per plugin.
326
+ * plugins; the sidebar and the adjust column one tab per plugin. The bottom
327
+ * bar is the player's control bar, a panel of the built-in `vestra.playback`:
328
+ * another plugin's mount there is refused, so do not plan on it; use
329
+ * `"adjust"`, `"sidebar"` or a window.
327
330
  * {@link Panels.bottom}, {@link Panels.sidebar} and {@link Panels.adjust}
328
331
  * describe the positions, whoever mounted there.
329
332
  *
@@ -353,7 +356,11 @@ export interface Panels {
353
356
  * resolves. Handlers and bindings made right after `mount()` (in the same
354
357
  * synchronous code) are part of the first values.
355
358
  *
356
- * - `"bottom"`: under the video, as wide as the video column, as tall as the
359
+ * - `"bottom"`: **held by the player's control bar** (the built-in
360
+ * `vestra.playback`), so another plugin's mount there rejects `ready` with
361
+ * `conflict` and shows nothing (the plugin keeps running, with the warning
362
+ * `slot-occupied`); a plugin does not plan on it. The bar itself sits
363
+ * under the video, as wide as the video column, as tall as the
357
364
  * component's preferred height. It may draw above its slot into the video
358
365
  * area (negative `y`); the player does not clip it. In fullscreen it
359
366
  * floats over the video and shows only while the pointer is in its band
@@ -429,7 +436,9 @@ export interface Panels {
429
436
  * following the playback position and seeking when dragged. Bindings and
430
437
  * handlers made right after `mount` are part of the first values;
431
438
  * `ready` resolves once the main window shows the bar, and rejects with
432
- * `conflict` when another plugin's panel holds the bottom bar.
439
+ * `conflict` when another plugin's panel holds the bottom bar. This is
440
+ * the built-in `vestra.playback`'s case: on a player with its control
441
+ * bar, any other plugin gets `conflict` here.
433
442
  * ```ts
434
443
  * const bar = plugin.panels.mount("bottom", "ui/bar.slint");
435
444
  * // Sent again whenever the position changes, while a stream is open.
package/llms.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  # Vestra Player SDK
2
2
 
3
- > @vestra-player/sdk 1.11.1: write plugins for Vestra Player in TypeScript (plugin API `vestra/1`). A plugin is a folder with `manifest.json` and an entry module whose default export `activate(plugin)` the player calls. The documentation is a tree of short pages read by path, like `go doc`: the same pages and API as https://vestrasys.github.io/vestra-player-sdk/.
3
+ > @vestra-player/sdk 1.11.2: 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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vestra-player/sdk",
3
- "version": "1.11.1",
3
+ "version": "1.11.2",
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": {