@vestra-player/sdk 1.11.1 → 1.11.3
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 +23 -0
- package/dist/docs-tree.json.gz +0 -0
- package/dist/docs.js +12 -2
- package/dist/manifest.js +27 -7
- package/dist/plugin/connection.d.ts +14 -0
- package/dist/plugin/connection.js +16 -0
- package/dist/plugin/media.js +4 -2
- package/dist/plugin/passes.js +1 -0
- package/dist/plugin/player.d.ts +32 -3
- package/dist/plugin/player.js +88 -29
- package/dist/plugin/scope.js +3 -1
- package/dist/plugin/subtitles.js +25 -10
- package/dist/plugin/testing/errors.d.ts +39 -0
- package/dist/plugin/testing/errors.js +78 -0
- package/dist/plugin/testing/index.d.ts +83 -1
- package/dist/plugin/testing/index.js +140 -19
- package/dist/plugin/types/playback.d.ts +23 -18
- package/dist/plugin/types/plugin-wire.d.ts +10 -10
- package/dist/plugin/types/ui-shell.d.ts +12 -3
- package/llms.txt +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.11.3
|
|
4
|
+
|
|
5
|
+
Nobody must change anything. A control without `ifCurrent` (pause, seek, speed, restart, close, a step, a loop, an audio track), a capture and a scrub now act on the current state: while a stream (or anything else that holds `source.state`) keeps `player.state` current, nothing changes; otherwise the SDK reads the state first, so a plugin that read the state once and keeps no stream is no longer refused with `stale` after any pause, seek or new file by someone else. Calls made together share one read and go out in the order they were made; `stale` still comes when the source changes between that read and the call, and an explicit `ifCurrent` is sent as given. The `stale` todos of the `menus`, `adjust-panel` and `three-ways` examples pass, and the golden traces of `examples/menus` and `examples/adjust-panel` gain that read (with the speed now applied) instead of listing `stale`.
|
|
6
|
+
|
|
7
|
+
## 1.11.2
|
|
8
|
+
|
|
9
|
+
Additions and fixes only; nobody must change anything except a plugin test that relies on a host error the plugin does not handle (below).
|
|
10
|
+
|
|
11
|
+
- **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.
|
|
12
|
+
- **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`.
|
|
13
|
+
- **Repository:** CodeQL, Scorecard, osv-scanner, semgrep (examples) and dependency review in CI; SECURITY.md.
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
**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).
|
|
17
|
+
|
|
18
|
+
- **`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.
|
|
19
|
+
- **`TestHost.expectError(code)`** (new): expect one such error; one that never comes fails `stop()`. **`TestHost.loggedErrors`** (new) lists them all.
|
|
20
|
+
- 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.
|
|
21
|
+
- `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.
|
|
22
|
+
- **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.
|
|
23
|
+
- **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`).
|
|
24
|
+
- **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.
|
|
25
|
+
|
|
3
26
|
## 1.11.1
|
|
4
27
|
|
|
5
28
|
**NVIDIA motion smoothing** (T8; needs player 0.11.1, which ships the NVIDIA engine). Additions only; nobody must change anything.
|
package/dist/docs-tree.json.gz
CHANGED
|
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()
|
|
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
|
-
|
|
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,
|
|
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(
|
|
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
|
-
|
|
154
|
-
|
|
155
|
-
|
|
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
|
/**
|
|
@@ -187,6 +194,13 @@ export declare class Connection {
|
|
|
187
194
|
* once more here.
|
|
188
195
|
*/
|
|
189
196
|
follow(event: string, why?: Why): Disposable;
|
|
197
|
+
/**
|
|
198
|
+
* Whether `event` is subscribed at the player now: something holds it
|
|
199
|
+
* (a listener, a hold, a stream, a handle that follows the source), so a
|
|
200
|
+
* state copy kept by it follows the player's events. False while a
|
|
201
|
+
* held-only group waits for a holder, and when nothing started it.
|
|
202
|
+
*/
|
|
203
|
+
following(event: string): boolean;
|
|
190
204
|
/**
|
|
191
205
|
* A binding (or a command's function field) reads `event`'s state: its
|
|
192
206
|
* reason joins what the player is told while a plugin listener, hold or
|
|
@@ -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
|
/**
|
|
@@ -445,6 +452,15 @@ export class Connection {
|
|
|
445
452
|
follow(event, why) {
|
|
446
453
|
return this.#hold(event, why, "never");
|
|
447
454
|
}
|
|
455
|
+
/**
|
|
456
|
+
* Whether `event` is subscribed at the player now: something holds it
|
|
457
|
+
* (a listener, a hold, a stream, a handle that follows the source), so a
|
|
458
|
+
* state copy kept by it follows the player's events. False while a
|
|
459
|
+
* held-only group waits for a holder, and when nothing started it.
|
|
460
|
+
*/
|
|
461
|
+
following(event) {
|
|
462
|
+
return this.#events.get(event)?.off !== undefined;
|
|
463
|
+
}
|
|
448
464
|
#hold(event, why, catchUp, listens = true) {
|
|
449
465
|
const group = this.#events.get(event);
|
|
450
466
|
if (!group)
|
package/dist/plugin/media.js
CHANGED
|
@@ -261,7 +261,8 @@ export function mediaCapture(scope) {
|
|
|
261
261
|
const service = serviceOf(runtime);
|
|
262
262
|
const player = playerOf(runtime);
|
|
263
263
|
// The source now: a capture needs one, even from a plugin that never
|
|
264
|
-
// read the state
|
|
264
|
+
// read the state; read first when the copy does not follow the
|
|
265
|
+
// player (`PlayerService.current`).
|
|
265
266
|
const at = options.ifCurrent ?? (await player.current());
|
|
266
267
|
const { expected } = player.expected(at);
|
|
267
268
|
if (!expected)
|
|
@@ -444,7 +445,8 @@ function mediaSources(scope) {
|
|
|
444
445
|
const expected = options?.ifCurrent === undefined
|
|
445
446
|
? undefined
|
|
446
447
|
: playerOf(scope.runtime).expected(options.ifCurrent).expected;
|
|
447
|
-
|
|
448
|
+
// In its turn among the plugin's calls on the source.
|
|
449
|
+
return playerOf(scope.runtime).inTurn(() => host().remember(expected));
|
|
448
450
|
},
|
|
449
451
|
get: async (value) => host().get(token(value)),
|
|
450
452
|
locate: async (value) => host().locate(token(value)),
|
package/dist/plugin/passes.js
CHANGED
package/dist/plugin/player.d.ts
CHANGED
|
@@ -42,8 +42,6 @@ export declare class PlayerService implements StreamSource {
|
|
|
42
42
|
* a read that failed is tried again by the next call.
|
|
43
43
|
*/
|
|
44
44
|
read(): Promise<void>;
|
|
45
|
-
/** Whether the mirror is registered yet. */
|
|
46
|
-
get started(): boolean;
|
|
47
45
|
/**
|
|
48
46
|
* Register the SDK's copy of the state (a mirror of `source.state`; a
|
|
49
47
|
* plugin listens through `watch`, `follow` and `player.on`). It hears
|
|
@@ -52,8 +50,23 @@ export declare class PlayerService implements StreamSource {
|
|
|
52
50
|
* starts. Resolves at once.
|
|
53
51
|
*/
|
|
54
52
|
start(): Promise<void>;
|
|
55
|
-
/**
|
|
53
|
+
/**
|
|
54
|
+
* The state as the player has it now, for a call that acts on the
|
|
55
|
+
* current state (a capture): the copy as it is while it follows the
|
|
56
|
+
* player's events, else read first ({@link fresh}).
|
|
57
|
+
*/
|
|
56
58
|
current(): Promise<PlayerState>;
|
|
59
|
+
/**
|
|
60
|
+
* Wait until the copy is the player's current state, for a call that
|
|
61
|
+
* acts on it (a control, a step, a capture, a scrub). While something
|
|
62
|
+
* holds `source.state` the copy follows the player's events: nothing to
|
|
63
|
+
* wait for. Otherwise it is the newest snapshot the plugin has, which an
|
|
64
|
+
* admitted intent since (a pause, a seek, a new file, by anyone) made
|
|
65
|
+
* stale: it is read first. Calls in a burst share one read ({@link inTurn}
|
|
66
|
+
* keeps their order). A read that fails leaves the copy as it was; the
|
|
67
|
+
* call goes on with it.
|
|
68
|
+
*/
|
|
69
|
+
fresh(): Promise<void> | undefined;
|
|
57
70
|
/** Drop anything older than what was already delivered. */
|
|
58
71
|
accept(raw: SourceState): void;
|
|
59
72
|
/**
|
|
@@ -113,6 +126,22 @@ export declare class PlayerService implements StreamSource {
|
|
|
113
126
|
expected(state: PlayerState | undefined): {
|
|
114
127
|
expected?: SourceStamp;
|
|
115
128
|
};
|
|
129
|
+
/**
|
|
130
|
+
* Send a call in its turn among the plugin's calls on the source: at
|
|
131
|
+
* once (in the same tick) when no read is on its way, else right after
|
|
132
|
+
* that read, with the calls that waited for it in the order they were
|
|
133
|
+
* made. `read`: the call acts on the current state, so a read starts
|
|
134
|
+
* first when the copy does not follow the player ({@link fresh}).
|
|
135
|
+
*/
|
|
136
|
+
inTurn<T>(send: () => Promise<T>, read?: boolean): Promise<T>;
|
|
137
|
+
/**
|
|
138
|
+
* `send` with the stamp a call sends, in its turn ({@link inTurn}):
|
|
139
|
+
* `ifCurrent`'s when given (as it is), else the current state's, read
|
|
140
|
+
* first when the copy does not follow the player.
|
|
141
|
+
*/
|
|
142
|
+
withStamp<T>(ifCurrent: PlayerState | undefined, send: (stamp: {
|
|
143
|
+
expected?: SourceStamp;
|
|
144
|
+
}) => Promise<T>): Promise<T>;
|
|
116
145
|
control(intent: SourceIntent, options?: Conditional): Promise<void>;
|
|
117
146
|
/** Close only if `generation` is still the player's source. */
|
|
118
147
|
closeIfCurrent(generation: number): Promise<void>;
|
package/dist/plugin/player.js
CHANGED
|
@@ -175,6 +175,10 @@ export class PlayerService {
|
|
|
175
175
|
#started = false;
|
|
176
176
|
/** `read()`'s one read, once asked for. */
|
|
177
177
|
#read;
|
|
178
|
+
/** The read that calls acting on the current state wait for (`fresh`). */
|
|
179
|
+
#fresh;
|
|
180
|
+
/** The sends waiting for that read, in the order they were made (`inTurn`). */
|
|
181
|
+
#waiting = [];
|
|
178
182
|
output;
|
|
179
183
|
constructor(runtime) {
|
|
180
184
|
this.runtime = runtime;
|
|
@@ -211,10 +215,6 @@ export class PlayerService {
|
|
|
211
215
|
}
|
|
212
216
|
})());
|
|
213
217
|
}
|
|
214
|
-
/** Whether the mirror is registered yet. */
|
|
215
|
-
get started() {
|
|
216
|
-
return this.#started;
|
|
217
|
-
}
|
|
218
218
|
/**
|
|
219
219
|
* Register the SDK's copy of the state (a mirror of `source.state`; a
|
|
220
220
|
* plugin listens through `watch`, `follow` and `player.on`). It hears
|
|
@@ -229,11 +229,45 @@ export class PlayerService {
|
|
|
229
229
|
this.runtime.on("source.state", (data) => this.accept(data), "held", true);
|
|
230
230
|
return Promise.resolve();
|
|
231
231
|
}
|
|
232
|
-
/**
|
|
232
|
+
/**
|
|
233
|
+
* The state as the player has it now, for a call that acts on the
|
|
234
|
+
* current state (a capture): the copy as it is while it follows the
|
|
235
|
+
* player's events, else read first ({@link fresh}).
|
|
236
|
+
*/
|
|
233
237
|
async current() {
|
|
234
238
|
await this.start();
|
|
239
|
+
const fresh = this.fresh();
|
|
240
|
+
if (fresh)
|
|
241
|
+
await fresh;
|
|
235
242
|
return this.state;
|
|
236
243
|
}
|
|
244
|
+
/**
|
|
245
|
+
* Wait until the copy is the player's current state, for a call that
|
|
246
|
+
* acts on it (a control, a step, a capture, a scrub). While something
|
|
247
|
+
* holds `source.state` the copy follows the player's events: nothing to
|
|
248
|
+
* wait for. Otherwise it is the newest snapshot the plugin has, which an
|
|
249
|
+
* admitted intent since (a pause, a seek, a new file, by anyone) made
|
|
250
|
+
* stale: it is read first. Calls in a burst share one read ({@link inTurn}
|
|
251
|
+
* keeps their order). A read that fails leaves the copy as it was; the
|
|
252
|
+
* call goes on with it.
|
|
253
|
+
*/
|
|
254
|
+
fresh() {
|
|
255
|
+
if (this.#fresh)
|
|
256
|
+
return this.#fresh;
|
|
257
|
+
// Note: `following` stays true when the subscription failed (its
|
|
258
|
+
// `off` is then a rejected promise); the copy is then sent as it is.
|
|
259
|
+
if (this.runtime.following("source.state"))
|
|
260
|
+
return undefined;
|
|
261
|
+
const fresh = this.refresh().then(() => { }, () => { });
|
|
262
|
+
// Once read: cleared, then the waiting sends go out in one go, in the
|
|
263
|
+
// order they were made; a call after them starts a read of its own.
|
|
264
|
+
this.#fresh = fresh.then(() => {
|
|
265
|
+
this.#fresh = undefined;
|
|
266
|
+
for (const send of this.#waiting.splice(0))
|
|
267
|
+
send();
|
|
268
|
+
});
|
|
269
|
+
return this.#fresh;
|
|
270
|
+
}
|
|
237
271
|
/** Drop anything older than what was already delivered. */
|
|
238
272
|
accept(raw) {
|
|
239
273
|
if (raw.eventSequence < this.raw.eventSequence)
|
|
@@ -394,12 +428,38 @@ export class PlayerService {
|
|
|
394
428
|
const raw = raws.get(state ?? this.state);
|
|
395
429
|
return raw && raw.eventSequence >= 0 ? { expected: raw.stamp } : {};
|
|
396
430
|
}
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
431
|
+
/**
|
|
432
|
+
* Send a call in its turn among the plugin's calls on the source: at
|
|
433
|
+
* once (in the same tick) when no read is on its way, else right after
|
|
434
|
+
* that read, with the calls that waited for it in the order they were
|
|
435
|
+
* made. `read`: the call acts on the current state, so a read starts
|
|
436
|
+
* first when the copy does not follow the player ({@link fresh}).
|
|
437
|
+
*/
|
|
438
|
+
inTurn(send, read = false) {
|
|
439
|
+
if (!(read ? this.fresh() : this.#fresh))
|
|
440
|
+
return send();
|
|
441
|
+
return new Promise((resolve, reject) => {
|
|
442
|
+
this.#waiting.push(() => {
|
|
443
|
+
try {
|
|
444
|
+
resolve(send());
|
|
445
|
+
}
|
|
446
|
+
catch (error) {
|
|
447
|
+
reject(error);
|
|
448
|
+
}
|
|
449
|
+
});
|
|
401
450
|
});
|
|
402
451
|
}
|
|
452
|
+
/**
|
|
453
|
+
* `send` with the stamp a call sends, in its turn ({@link inTurn}):
|
|
454
|
+
* `ifCurrent`'s when given (as it is), else the current state's, read
|
|
455
|
+
* first when the copy does not follow the player.
|
|
456
|
+
*/
|
|
457
|
+
withStamp(ifCurrent, send) {
|
|
458
|
+
return this.inTurn(() => send(this.expected(ifCurrent)), !ifCurrent);
|
|
459
|
+
}
|
|
460
|
+
async control(intent, options) {
|
|
461
|
+
await this.withStamp(options?.ifCurrent, (stamp) => this.submit({ ...intent, ...stamp }));
|
|
462
|
+
}
|
|
403
463
|
/** Close only if `generation` is still the player's source. */
|
|
404
464
|
async closeIfCurrent(generation) {
|
|
405
465
|
const raw = this.runtime.reads
|
|
@@ -500,14 +560,14 @@ class ScrubHandle {
|
|
|
500
560
|
#service;
|
|
501
561
|
constructor(service) {
|
|
502
562
|
this.#service = service;
|
|
503
|
-
// A scrub follows the source. When
|
|
504
|
-
//
|
|
505
|
-
//
|
|
506
|
-
|
|
507
|
-
const fresh = service.
|
|
508
|
-
let ready = !
|
|
563
|
+
// A scrub follows the source. When the copy did not follow it yet (the
|
|
564
|
+
// mirror starts now, or nothing held `source.state`), the gesture
|
|
565
|
+
// starts from the state read now, not from the plugin's old copy.
|
|
566
|
+
void service.start();
|
|
567
|
+
const fresh = service.fresh();
|
|
568
|
+
let ready = !fresh;
|
|
509
569
|
this.#allowed = { ...service.raw.stamp };
|
|
510
|
-
if (
|
|
570
|
+
if (fresh)
|
|
511
571
|
void fresh.then(() => {
|
|
512
572
|
ready = true;
|
|
513
573
|
if (this.#active && !this.#pending)
|
|
@@ -521,7 +581,7 @@ class ScrubHandle {
|
|
|
521
581
|
this.end();
|
|
522
582
|
});
|
|
523
583
|
this.#queue = new Latest(async ({ seconds, keyframes }) => {
|
|
524
|
-
if (
|
|
584
|
+
if (fresh)
|
|
525
585
|
await fresh;
|
|
526
586
|
if (!this.#active)
|
|
527
587
|
throw superseded;
|
|
@@ -743,12 +803,15 @@ export function player(scope) {
|
|
|
743
803
|
throw abortError();
|
|
744
804
|
let ticket;
|
|
745
805
|
try {
|
|
746
|
-
|
|
806
|
+
// In its turn: after a read on its way for earlier controls.
|
|
807
|
+
ticket = await service().inTurn(() => service().submit({
|
|
747
808
|
kind: "open",
|
|
748
809
|
source,
|
|
749
810
|
startPaused: options.paused ?? false,
|
|
750
|
-
...(options.ifCurrent
|
|
751
|
-
|
|
811
|
+
...(options.ifCurrent
|
|
812
|
+
? service().expected(options.ifCurrent)
|
|
813
|
+
: {}),
|
|
814
|
+
}, { signal, accepted: (accepted) => (ticket = accepted) }));
|
|
752
815
|
}
|
|
753
816
|
catch (error) {
|
|
754
817
|
// Cancelling a pending open (e.g. a URL still being resolved) closes it.
|
|
@@ -815,8 +878,7 @@ export function player(scope) {
|
|
|
815
878
|
};
|
|
816
879
|
},
|
|
817
880
|
async addAudioTrack(path, options = {}) {
|
|
818
|
-
const
|
|
819
|
-
const added = await scope.runtime.host.audio.add(path, options.select ?? true, expected);
|
|
881
|
+
const added = await service().withStamp(options.ifCurrent, ({ expected }) => scope.runtime.host.audio.add(path, options.select ?? true, expected));
|
|
820
882
|
await service()
|
|
821
883
|
.refresh()
|
|
822
884
|
.catch(() => { });
|
|
@@ -827,8 +889,7 @@ export function player(scope) {
|
|
|
827
889
|
throw failure("invalid", "unit is frame or keyframe");
|
|
828
890
|
if (direction !== "backward" && direction !== "forward")
|
|
829
891
|
throw failure("invalid", "direction is backward or forward");
|
|
830
|
-
|
|
831
|
-
await scope.runtime.host.step.step(unit, direction, expected);
|
|
892
|
+
await service().withStamp(options.ifCurrent, ({ expected }) => scope.runtime.host.step.step(unit, direction, expected));
|
|
832
893
|
await service()
|
|
833
894
|
.refresh()
|
|
834
895
|
.catch(() => { });
|
|
@@ -868,19 +929,17 @@ export function player(scope) {
|
|
|
868
929
|
(!Number.isInteger(count) || count < 1 || count > 1_000_000))
|
|
869
930
|
throw failure("invalid", "count must be an integer 1–1000000");
|
|
870
931
|
}
|
|
871
|
-
|
|
872
|
-
await scope.runtime.host.marks.setLoop(loop && {
|
|
932
|
+
await service().withStamp(options.ifCurrent, ({ expected }) => scope.runtime.host.marks.setLoop(loop && {
|
|
873
933
|
a: loop.a,
|
|
874
934
|
b: loop.b,
|
|
875
935
|
...(loop.count === undefined ? {} : { count: loop.count }),
|
|
876
|
-
}, expected);
|
|
936
|
+
}, expected));
|
|
877
937
|
await service()
|
|
878
938
|
.refresh()
|
|
879
939
|
.catch(() => { });
|
|
880
940
|
},
|
|
881
941
|
async selectAudioTrack(id, options = {}) {
|
|
882
|
-
|
|
883
|
-
await scope.runtime.host.audio.select(id, expected);
|
|
942
|
+
await service().withStamp(options.ifCurrent, ({ expected }) => scope.runtime.host.audio.select(id, expected));
|
|
884
943
|
return service().refresh();
|
|
885
944
|
},
|
|
886
945
|
};
|
package/dist/plugin/scope.js
CHANGED
|
@@ -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) {
|
package/dist/plugin/subtitles.js
CHANGED
|
@@ -3,6 +3,7 @@ import { createHash } from "node:crypto";
|
|
|
3
3
|
import { isTextValue, textProblem } from "../i18n.js";
|
|
4
4
|
import { Latest } from "./latest.js";
|
|
5
5
|
import { abortError, failure, sleep, uncertain } from "./errors.js";
|
|
6
|
+
import { playerOf } from "./player.js";
|
|
6
7
|
/**
|
|
7
8
|
* The player's limits on subtitle files a plugin loads with
|
|
8
9
|
* {@link Subtitles.load}, which `TestHost` enforces with the player's codes.
|
|
@@ -98,13 +99,12 @@ class SubtitleService {
|
|
|
98
99
|
}, "held", true);
|
|
99
100
|
runtime.on("playback.backend", () => void this.refresh().catch(() => { }), "held", true);
|
|
100
101
|
this.style = new Latest(async ({ style, options }) => {
|
|
101
|
-
|
|
102
|
-
await this.#mutate(++this.#operation, (operationId) => runtime.host.subtitles.style({
|
|
102
|
+
await this.inTurn(options, (expected) => this.#mutate(++this.#operation, (operationId) => runtime.host.subtitles.style({
|
|
103
103
|
operationId,
|
|
104
104
|
revision: ++this.#styleRevision,
|
|
105
105
|
expected,
|
|
106
106
|
style,
|
|
107
|
-
}));
|
|
107
|
+
})));
|
|
108
108
|
});
|
|
109
109
|
}
|
|
110
110
|
watch(watcher) {
|
|
@@ -208,12 +208,28 @@ class SubtitleService {
|
|
|
208
208
|
}
|
|
209
209
|
/** Default: the selection as it is now. `ifCurrent` pins an older one. */
|
|
210
210
|
async expected(options) {
|
|
211
|
-
const pinned =
|
|
211
|
+
const pinned = this.#pinned(options);
|
|
212
212
|
if (pinned)
|
|
213
|
-
return pinned
|
|
213
|
+
return pinned;
|
|
214
214
|
await this.refresh();
|
|
215
215
|
return this.raw.selection.stamp;
|
|
216
216
|
}
|
|
217
|
+
#pinned(options) {
|
|
218
|
+
const pinned = options?.ifCurrent && raws.get(options.ifCurrent);
|
|
219
|
+
return pinned ? pinned.selection.stamp : undefined;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* `send` with the selection stamp ({@link expected}), in its turn among
|
|
223
|
+
* the plugin's calls on the source (`PlayerService.inTurn`): its first
|
|
224
|
+
* request goes out in the same tick, or right after a read of the source
|
|
225
|
+
* on its way for an earlier control.
|
|
226
|
+
*/
|
|
227
|
+
inTurn(options, send) {
|
|
228
|
+
return playerOf(this.#runtime).inTurn(() => {
|
|
229
|
+
const pinned = this.#pinned(options);
|
|
230
|
+
return pinned ? send(pinned) : this.expected(options).then(send);
|
|
231
|
+
});
|
|
232
|
+
}
|
|
217
233
|
nextOperation() {
|
|
218
234
|
return ++this.#operation;
|
|
219
235
|
}
|
|
@@ -302,9 +318,8 @@ export function subtitles(scope) {
|
|
|
302
318
|
const role = options?.role ?? "primary";
|
|
303
319
|
if (role !== "primary" && role !== "secondary")
|
|
304
320
|
throw failure("invalid", 'role must be "primary" or "secondary"');
|
|
305
|
-
const expected = await service().expected(options);
|
|
306
321
|
const chosen = track && target(track);
|
|
307
|
-
return service().mutate((id) => host().select(chosen, expected, id, role));
|
|
322
|
+
return service().inTurn(options, (expected) => service().mutate((id) => host().select(chosen, expected, id, role)));
|
|
308
323
|
},
|
|
309
324
|
async load(srt, options) {
|
|
310
325
|
const format = options?.format ?? "srt";
|
|
@@ -327,7 +342,8 @@ export function subtitles(scope) {
|
|
|
327
342
|
[...title].length > 200))
|
|
328
343
|
throw failure("invalid", "title needs 1–200 characters");
|
|
329
344
|
const svc = service();
|
|
330
|
-
|
|
345
|
+
// In its turn among the plugin's calls on the source.
|
|
346
|
+
const current = await playerOf(scope.runtime).inTurn(() => svc.refresh());
|
|
331
347
|
const expected = await svc.expected(options);
|
|
332
348
|
const uploadId = svc.nextUpload();
|
|
333
349
|
const resourceId = `external-${uploadId}`;
|
|
@@ -390,8 +406,7 @@ export function subtitles(scope) {
|
|
|
390
406
|
const chosen = target(track);
|
|
391
407
|
if (chosen.kind !== "external" || !service().owned.has(chosen.resourceId))
|
|
392
408
|
throw failure("invalid", "只能移除本插件加载的字幕");
|
|
393
|
-
const
|
|
394
|
-
const state = await service().mutate((id) => host().remove(chosen.resourceId, expected, id));
|
|
409
|
+
const state = await service().inTurn(options, (expected) => service().mutate((id) => host().remove(chosen.resourceId, expected, id)));
|
|
395
410
|
service().owned.delete(chosen.resourceId);
|
|
396
411
|
return state;
|
|
397
412
|
},
|
|
@@ -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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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 (
|
|
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 (
|
|
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
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
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
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
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
|
}
|
|
@@ -386,10 +386,14 @@ export interface Chapter {
|
|
|
386
386
|
start: number;
|
|
387
387
|
}
|
|
388
388
|
/**
|
|
389
|
-
* Controls act on the state
|
|
390
|
-
*
|
|
391
|
-
*
|
|
392
|
-
*
|
|
389
|
+
* Controls act on the current state by default. While a
|
|
390
|
+
* {@link Player.stream} (or anything else that follows the source) keeps
|
|
391
|
+
* `player.state` current, that is the state they act on; otherwise the SDK
|
|
392
|
+
* reads the state first (calls made together share one read). If another
|
|
393
|
+
* plugin or the user changed the source in between, the call fails with
|
|
394
|
+
* code `stale` and nothing happens. Pass `ifCurrent` to pin the call to an
|
|
395
|
+
* older snapshot instead (for example the state when a dialog opened); it
|
|
396
|
+
* is sent as given.
|
|
393
397
|
*
|
|
394
398
|
* The SDK refreshes `player.state` after its own operations, so a plugin's
|
|
395
399
|
* consecutive calls do not make each other stale. {@link Player.open} is
|
|
@@ -419,7 +423,7 @@ export interface Chapter {
|
|
|
419
423
|
* @category Playback
|
|
420
424
|
*/
|
|
421
425
|
export interface Conditional {
|
|
422
|
-
/** The state the call is conditional on; default: the current `player.state
|
|
426
|
+
/** The state the call is conditional on; default: the current state (read first when no stream keeps `player.state` current). */
|
|
423
427
|
ifCurrent?: PlayerState;
|
|
424
428
|
}
|
|
425
429
|
/**
|
|
@@ -939,8 +943,9 @@ export interface StateStream {
|
|
|
939
943
|
* has: from `read()`, `refresh()`, an event's data and this plugin's own
|
|
940
944
|
* calls, and while a {@link Player.stream} is open, every change. Every
|
|
941
945
|
* control is
|
|
942
|
-
* conditional: it acts on the state
|
|
943
|
-
* `
|
|
946
|
+
* conditional: it acts on the current state (read first when no stream
|
|
947
|
+
* keeps `state` current) or on the one given as `ifCurrent`, and fails
|
|
948
|
+
* with `stale` when the source changed meanwhile: another file, a close, or any
|
|
944
949
|
* pause, seek or speed change by the user or another plugin (see
|
|
945
950
|
* {@link Conditional}). The player keeps the source when a plugin stops;
|
|
946
951
|
* only the plugin's own handles (a stream, its sequence provider, its
|
|
@@ -1074,12 +1079,12 @@ export interface Player {
|
|
|
1074
1079
|
*
|
|
1075
1080
|
*
|
|
1076
1081
|
* @example Push the speed to a panel as it changes
|
|
1077
|
-
* A
|
|
1082
|
+
* A tab in the adjust column shows the playback speed. The listener gets each
|
|
1078
1083
|
* `source.state` event's data and writes the text with `set`; no update
|
|
1079
1084
|
* pass runs and the SDK keeps no copy of the state for this.
|
|
1080
1085
|
* ```ts
|
|
1081
|
-
* const
|
|
1082
|
-
* plugin.player.on("source.state", (s) =>
|
|
1086
|
+
* const panel = plugin.panels.mount("adjust", "ui/speed.slint", { title: "Speed" });
|
|
1087
|
+
* plugin.player.on("source.state", (s) => panel.set({ rate: `${s.rate.toFixed(2)}×` }));
|
|
1083
1088
|
* ```
|
|
1084
1089
|
*
|
|
1085
1090
|
* @see [Tutorial](../../../docs/tutorial/index.md)
|
|
@@ -1346,8 +1351,8 @@ export interface Player {
|
|
|
1346
1351
|
*
|
|
1347
1352
|
* @example Pause, but only the file the user was watching
|
|
1348
1353
|
* A "pause on lock" helper pauses the current file and does nothing when
|
|
1349
|
-
* another file was opened in between. The call
|
|
1350
|
-
*
|
|
1354
|
+
* another file was opened in between. The call acts on the current state
|
|
1355
|
+
* by default; `stale` means the source changed and the
|
|
1351
1356
|
* pause was not applied, which is the intended outcome here.
|
|
1352
1357
|
* ```ts
|
|
1353
1358
|
* try {
|
|
@@ -1377,13 +1382,13 @@ export interface Player {
|
|
|
1377
1382
|
*
|
|
1378
1383
|
* @example Jump back ten seconds
|
|
1379
1384
|
* Playback jumps ten seconds back, never before the start. The target is
|
|
1380
|
-
* computed from the
|
|
1381
|
-
* opened another file meanwhile the seek
|
|
1382
|
-
* landing in the wrong file.
|
|
1385
|
+
* computed from the state read now, and the seek is pinned to it
|
|
1386
|
+
* (`ifCurrent`), so if the user opened another file meanwhile the seek
|
|
1387
|
+
* fails with `stale` instead of landing in the wrong file.
|
|
1383
1388
|
* ```ts
|
|
1384
|
-
* const
|
|
1385
|
-
* if (position !== null &&
|
|
1386
|
-
* await plugin.player.seek(Math.max(0, position - 10)); // seconds
|
|
1389
|
+
* const now = await plugin.player.refresh();
|
|
1390
|
+
* if (now.position !== null && now.can.seek)
|
|
1391
|
+
* await plugin.player.seek(Math.max(0, now.position - 10), { ifCurrent: now }); // seconds
|
|
1387
1392
|
* ```
|
|
1388
1393
|
*
|
|
1389
1394
|
* @since 1.0.0
|
|
@@ -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
|
|
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(
|
|
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
|
|
45
|
-
* const view = plugin.wire.view(
|
|
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
|
|
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
|
|
99
|
-
* await
|
|
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
|
|
270
|
-
* await
|
|
271
|
-
* const view = plugin.wire.view(
|
|
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"`:
|
|
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.
|
|
3
|
+
> @vestra-player/sdk 1.11.3: 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
|
|