@vestra-player/sdk 1.8.0 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +64 -2
- package/README.md +2 -2
- package/bin/vestra-plugin.mjs +98 -106
- package/capability-scan.json +21 -1
- package/dist/api-requests.d.ts +15 -39
- package/dist/api-requests.js +28 -50
- package/dist/capability-scan.d.ts +1 -1
- package/dist/capability-scan.js +8 -9
- package/dist/condition-table.d.ts +1889 -0
- package/dist/condition-table.js +562 -0
- package/dist/docs-tree.json.gz +0 -0
- package/dist/docs.d.ts +1 -1
- package/dist/docs.js +1 -1
- package/dist/i18n-tools.d.ts +7 -0
- package/dist/i18n-tools.js +66 -3
- package/dist/index.d.ts +4 -5
- package/dist/manifest.d.ts +5 -0
- package/dist/manifest.js +9 -24
- package/dist/member-uses.d.ts +61 -0
- package/dist/member-uses.js +160 -0
- package/dist/player-runtime.d.ts +4 -2
- package/dist/player-runtime.js +4 -2
- package/dist/plugin/appearance.d.ts +1 -1
- package/dist/plugin/appearance.js +2 -2
- package/dist/plugin/bindings.d.ts +1 -1
- package/dist/plugin/bindings.js +2 -2
- package/dist/plugin/commands.js +1 -12
- package/dist/plugin/connection.d.ts +38 -8
- package/dist/plugin/connection.js +126 -37
- package/dist/plugin/drops.js +1 -1
- package/dist/plugin/index.d.ts +7 -0
- package/dist/plugin/index.js +22 -15
- package/dist/plugin/media.js +0 -12
- package/dist/plugin/mpv.js +39 -12
- package/dist/plugin/packages.js +1 -2
- package/dist/plugin/player/events.d.ts +17 -7
- package/dist/plugin/player/events.js +26 -9
- package/dist/plugin/player.d.ts +37 -13
- package/dist/plugin/player.js +133 -22
- package/dist/plugin/scope.d.ts +4 -1
- package/dist/plugin/scope.js +8 -0
- package/dist/plugin/services.d.ts +4 -4
- package/dist/plugin/services.js +7 -29
- package/dist/plugin/settings.js +1 -1
- package/dist/plugin/shaders.js +0 -2
- package/dist/plugin/stream.d.ts +2 -1
- package/dist/plugin/stream.js +2 -2
- package/dist/plugin/testing/commands.d.ts +3 -10
- package/dist/plugin/testing/commands.js +24 -37
- package/dist/plugin/testing/index.d.ts +133 -116
- package/dist/plugin/testing/index.js +198 -125
- package/dist/plugin/testing/media.d.ts +6 -0
- package/dist/plugin/testing/media.js +15 -2
- package/dist/plugin/testing/processing.js +1 -1
- package/dist/plugin/testing/services.js +0 -1
- package/dist/plugin/testing/source-events.d.ts +28 -0
- package/dist/plugin/testing/source-events.js +66 -0
- package/dist/plugin/testing/transport.js +5 -0
- package/dist/plugin/testing/triggers.d.ts +82 -0
- package/dist/plugin/testing/triggers.js +448 -0
- package/dist/plugin/timeline.d.ts +5 -6
- package/dist/plugin/timeline.js +7 -11
- package/dist/plugin/triggers.d.ts +55 -0
- package/dist/plugin/triggers.js +233 -0
- package/dist/plugin/types/base.d.ts +77 -87
- package/dist/plugin/types/commands.d.ts +384 -68
- package/dist/plugin/types/packages.d.ts +17 -55
- package/dist/plugin/types/playback.d.ts +382 -152
- package/dist/plugin/types/plugin-wire.d.ts +6 -36
- package/dist/plugin/types/processing.d.ts +10 -49
- package/dist/plugin/types/services.d.ts +11 -70
- package/dist/plugin/types/snapshots.d.ts +7 -60
- package/dist/plugin/types/sources.d.ts +2 -11
- package/dist/plugin/types/subtitles.d.ts +5 -26
- package/dist/plugin/types/ui-content.d.ts +1 -16
- package/dist/plugin/types/ui-layout.d.ts +53 -79
- package/dist/plugin/types/ui-locale.d.ts +5 -23
- package/dist/plugin/types/ui-shell.d.ts +13 -59
- package/dist/plugin/view/layout.js +1 -1
- package/dist/plugin/view.js +0 -2
- package/dist/plugin/when.d.ts +78 -4
- package/dist/plugin/when.js +182 -14
- package/dist/plugin/window.d.ts +1 -1
- package/dist/plugin/window.js +1 -1
- package/dist/plugin/wire-facade.js +1 -2
- package/dist/processing.d.ts +2 -3
- package/dist/protocol.d.ts +14 -0
- package/dist/protocol.js +14 -0
- package/dist/request-queue.js +1 -1
- package/dist/slint-version.d.ts +7 -0
- package/dist/slint-version.js +7 -0
- package/dist/subtitles.d.ts +1 -1
- package/dist/ts-plugin.d.ts +8 -15
- package/dist/ts-plugin.js +3 -141
- package/dist/wire.d.ts +22 -12
- package/dist/wire.js +17 -8
- package/llms.txt +6 -6
- package/package.json +1 -2
- package/dist/capabilities.d.ts +0 -107
- package/dist/capabilities.js +0 -69
- package/dist/capability-check.d.ts +0 -176
- package/dist/capability-check.js +0 -461
- package/dist/capability-rules.d.ts +0 -125
- package/dist/capability-rules.js +0 -192
- package/dist/host-capabilities.d.ts +0 -10
- package/dist/host-capabilities.js +0 -492
package/dist/plugin/player.js
CHANGED
|
@@ -6,7 +6,7 @@ import { HostError } from "../wire.js";
|
|
|
6
6
|
import { Latest } from "./latest.js";
|
|
7
7
|
import { abortError, failure, quiet, sleep, uncertain } from "./errors.js";
|
|
8
8
|
import { openStream, resolvedStream } from "./stream.js";
|
|
9
|
-
import { checkOn, playerOn } from "./player/events.js";
|
|
9
|
+
import { SOURCE_EVENTS, checkOn, playerOn } from "./player/events.js";
|
|
10
10
|
import { validStep } from "./player/rules.js";
|
|
11
11
|
const raws = new WeakMap();
|
|
12
12
|
const empty = {
|
|
@@ -42,6 +42,7 @@ const audioTrack = (track) => Object.freeze({
|
|
|
42
42
|
codec: track.codec,
|
|
43
43
|
title: track.title,
|
|
44
44
|
language: track.language,
|
|
45
|
+
streamIndex: track.streamIndex ?? null,
|
|
45
46
|
});
|
|
46
47
|
/**
|
|
47
48
|
* The key of `plugin.player.state` in the runtime's field tracking
|
|
@@ -156,14 +157,13 @@ function sourceFailure(error) {
|
|
|
156
157
|
* One per plugin: the state store and the operation book client.
|
|
157
158
|
*
|
|
158
159
|
* The state copy (a mirror of `source.state`) follows the player's events
|
|
159
|
-
* from
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
* arrive; `start` is then called by the first use of the state (a read of
|
|
160
|
+
* from `plugin.player.subscribe()` on (`subscribe`, first in `activate`
|
|
161
|
+
* as the plugin writes it). Before that no event can arrive; `start` is
|
|
162
|
+
* then called by the first use of the state (a read of
|
|
163
163
|
* `plugin.player.state`, `onChange`, `isCurrent`, a media handle, a
|
|
164
164
|
* scrub, a stream, a filter, a shader or view request, a capture) and
|
|
165
|
-
* subscribes nothing
|
|
166
|
-
*
|
|
165
|
+
* subscribes nothing until `subscribe()`, which subscribes it and, after
|
|
166
|
+
* `read()`, reads the state once more (`#catchUp`).
|
|
167
167
|
*/
|
|
168
168
|
export class PlayerService {
|
|
169
169
|
runtime;
|
|
@@ -180,6 +180,8 @@ export class PlayerService {
|
|
|
180
180
|
#started = false;
|
|
181
181
|
/** The read that followed the subscription (resolved: none was needed). */
|
|
182
182
|
#fresh = Promise.resolve();
|
|
183
|
+
/** `read()`'s one read, once asked for. */
|
|
184
|
+
#read;
|
|
183
185
|
output;
|
|
184
186
|
constructor(runtime) {
|
|
185
187
|
this.runtime = runtime;
|
|
@@ -195,9 +197,41 @@ export class PlayerService {
|
|
|
195
197
|
await this.refresh().catch(() => { });
|
|
196
198
|
});
|
|
197
199
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
200
|
+
/**
|
|
201
|
+
* `plugin.player.read()`: read the source state and the timeline now, and
|
|
202
|
+
* from now on read the state again after the plugin's own actions
|
|
203
|
+
* (`Connection.reads`). Idempotent: one read, however often it is called;
|
|
204
|
+
* a read that failed is tried again by the next call.
|
|
205
|
+
*/
|
|
206
|
+
read() {
|
|
207
|
+
return (this.#read ??= (async () => {
|
|
208
|
+
this.runtime.reads = true;
|
|
209
|
+
try {
|
|
210
|
+
await Promise.all([
|
|
211
|
+
this.refresh(),
|
|
212
|
+
this.runtime.reread("timeline.changed"),
|
|
213
|
+
]);
|
|
214
|
+
}
|
|
215
|
+
catch (error) {
|
|
216
|
+
this.#read = undefined;
|
|
217
|
+
throw error;
|
|
218
|
+
}
|
|
219
|
+
})());
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* `plugin.player.subscribe()`: turn event delivery on and follow
|
|
223
|
+
* `source.state` now. Idempotent.
|
|
224
|
+
*/
|
|
225
|
+
subscribe() {
|
|
226
|
+
if (this.runtime.delivering)
|
|
227
|
+
return;
|
|
228
|
+
this.runtime.deliver();
|
|
229
|
+
// A copy started on demand heard nothing so far; it is subscribed now,
|
|
230
|
+
// and a change before that sent no event.
|
|
231
|
+
if (this.#started)
|
|
232
|
+
this.#catchUp();
|
|
233
|
+
else
|
|
234
|
+
void this.start();
|
|
201
235
|
}
|
|
202
236
|
/** Whether the mirror follows the player's events yet. */
|
|
203
237
|
get started() {
|
|
@@ -206,23 +240,23 @@ export class PlayerService {
|
|
|
206
240
|
/**
|
|
207
241
|
* Follow `source.state` from now on: the SDK's copy of the state (a
|
|
208
242
|
* mirror; a plugin listens through `watch` and the bindings that read
|
|
209
|
-
* `state`). Then read the state once more (
|
|
210
|
-
* `
|
|
211
|
-
*
|
|
212
|
-
* `reread: false`: subscribed before the start-up read
|
|
213
|
-
* (`createPlugin`), which then is that read.
|
|
243
|
+
* `state`). Then read the state once more (after `read()` and
|
|
244
|
+
* `subscribe()`): a change between that read and the subscription sent
|
|
245
|
+
* no event to this plugin. Resolves when that read is in.
|
|
214
246
|
*/
|
|
215
|
-
start(
|
|
247
|
+
start() {
|
|
216
248
|
if (this.#started)
|
|
217
249
|
return this.#fresh;
|
|
218
250
|
this.#started = true;
|
|
219
251
|
this.runtime.on("source.state", (data) => this.accept(data), "events", true);
|
|
220
|
-
|
|
221
|
-
this.runtime.can("playback.read") &&
|
|
222
|
-
this.runtime.can("events"))
|
|
223
|
-
this.#fresh = this.refresh().then(() => { }, () => { });
|
|
252
|
+
this.#catchUp();
|
|
224
253
|
return this.#fresh;
|
|
225
254
|
}
|
|
255
|
+
/** Read the state once more after a subscription, when it is read at all. */
|
|
256
|
+
#catchUp() {
|
|
257
|
+
if (this.runtime.reads && this.runtime.delivering)
|
|
258
|
+
this.#fresh = this.refresh().then(() => { }, () => { });
|
|
259
|
+
}
|
|
226
260
|
/** The state as the player has it now, for a call that needs a source. */
|
|
227
261
|
async current() {
|
|
228
262
|
await this.start();
|
|
@@ -245,6 +279,21 @@ export class PlayerService {
|
|
|
245
279
|
// A precise pass: only the bindings that read a changed field.
|
|
246
280
|
this.runtime.changed(PLAYER, changed);
|
|
247
281
|
}
|
|
282
|
+
/**
|
|
283
|
+
* A source event's data (`source.opening`, `source.ready`,
|
|
284
|
+
* `source.ended`) as the listener gets it: `state` as a
|
|
285
|
+
* {@link PlayerState}. The state of an opening or a ready is the
|
|
286
|
+
* player's newest, so `plugin.player.state` takes it first (when it is
|
|
287
|
+
* newer than what the plugin has): `isCurrent(state)` and `ifCurrent`
|
|
288
|
+
* then hold after a wake too, without a read. An ended source's state
|
|
289
|
+
* is not the player's current one and is not taken.
|
|
290
|
+
*/
|
|
291
|
+
sourceEvent(event, data) {
|
|
292
|
+
const message = data;
|
|
293
|
+
if (event !== "source.ended")
|
|
294
|
+
this.accept(message.state);
|
|
295
|
+
return { ...message, state: view(message.state) };
|
|
296
|
+
}
|
|
248
297
|
watch(watcher) {
|
|
249
298
|
void this.start();
|
|
250
299
|
this.#watchers.add(watcher);
|
|
@@ -256,6 +305,22 @@ export class PlayerService {
|
|
|
256
305
|
},
|
|
257
306
|
};
|
|
258
307
|
}
|
|
308
|
+
/**
|
|
309
|
+
* `watch`, for `plugin.player.stream`: the copy hears `source.state` while
|
|
310
|
+
* the watcher is open, with or without `subscribe()`, and the plugin
|
|
311
|
+
* counts as listening to it (`Connection.follow`).
|
|
312
|
+
*/
|
|
313
|
+
follow(watcher, why) {
|
|
314
|
+
void this.start();
|
|
315
|
+
this.#watchers.add(watcher);
|
|
316
|
+
const followed = this.runtime.follow("source.state", why);
|
|
317
|
+
return {
|
|
318
|
+
dispose: async () => {
|
|
319
|
+
this.#watchers.delete(watcher);
|
|
320
|
+
await followed.dispose();
|
|
321
|
+
},
|
|
322
|
+
};
|
|
323
|
+
}
|
|
259
324
|
async refresh() {
|
|
260
325
|
this.accept(await this.runtime.host.source.state());
|
|
261
326
|
return this.state;
|
|
@@ -322,7 +387,7 @@ export class PlayerService {
|
|
|
322
387
|
}
|
|
323
388
|
/** Close only if `generation` is still the player's source. */
|
|
324
389
|
async closeIfCurrent(generation) {
|
|
325
|
-
const raw = this.runtime.
|
|
390
|
+
const raw = this.runtime.reads
|
|
326
391
|
? (await this.refresh(), this.raw)
|
|
327
392
|
: this.raw;
|
|
328
393
|
if (raw.stamp.generation !== generation || raw.phase === "empty")
|
|
@@ -385,7 +450,7 @@ class MediaHandle {
|
|
|
385
450
|
return abort();
|
|
386
451
|
options.signal?.addEventListener("abort", abort, { once: true });
|
|
387
452
|
// Without event delivery the state only moves when read.
|
|
388
|
-
if (!service.runtime.
|
|
453
|
+
if (!service.runtime.delivering)
|
|
389
454
|
poll = setInterval(() => void service.refresh().catch(() => { }), 100);
|
|
390
455
|
check();
|
|
391
456
|
});
|
|
@@ -585,12 +650,58 @@ export function player(scope) {
|
|
|
585
650
|
},
|
|
586
651
|
});
|
|
587
652
|
},
|
|
653
|
+
stream(listener) {
|
|
654
|
+
if (typeof listener !== "function")
|
|
655
|
+
throw failure("invalid", "stream takes a function");
|
|
656
|
+
const copy = service();
|
|
657
|
+
const site = scope.runtime.callSite();
|
|
658
|
+
let open = true;
|
|
659
|
+
let called = false;
|
|
660
|
+
// `player.state` is updated first (`accept`), then the listener runs,
|
|
661
|
+
// then an update pass (`run`).
|
|
662
|
+
const call = () => {
|
|
663
|
+
if (!open)
|
|
664
|
+
return;
|
|
665
|
+
called = true;
|
|
666
|
+
scope.run(listener, copy.state);
|
|
667
|
+
};
|
|
668
|
+
const followed = copy.follow(call, () => {
|
|
669
|
+
const at = site();
|
|
670
|
+
return at ? `a stream opened at ${at}` : "a stream";
|
|
671
|
+
});
|
|
672
|
+
// The current state once: read now. An event that came first was
|
|
673
|
+
// the current state already, and the read then changed nothing.
|
|
674
|
+
void copy
|
|
675
|
+
.refresh()
|
|
676
|
+
.catch(() => { })
|
|
677
|
+
.then(() => {
|
|
678
|
+
if (!called)
|
|
679
|
+
call();
|
|
680
|
+
});
|
|
681
|
+
const handle = {
|
|
682
|
+
dispose: async () => {
|
|
683
|
+
if (!open)
|
|
684
|
+
return;
|
|
685
|
+
open = false;
|
|
686
|
+
scope.forget(handle);
|
|
687
|
+
await followed.dispose();
|
|
688
|
+
},
|
|
689
|
+
};
|
|
690
|
+
scope.add(handle);
|
|
691
|
+
return Object.freeze({
|
|
692
|
+
stop: () => void handle.dispose(),
|
|
693
|
+
});
|
|
694
|
+
},
|
|
588
695
|
refresh: () => service().refresh(),
|
|
696
|
+
subscribe: () => service().subscribe(),
|
|
697
|
+
read: () => service().read(),
|
|
589
698
|
on(event, listener) {
|
|
590
699
|
// Checked first; the copy then starts before the listener subscribes
|
|
591
700
|
// (it hears each event first in any case).
|
|
592
701
|
checkOn(event, listener);
|
|
593
702
|
scope.followCopy(event);
|
|
703
|
+
if (SOURCE_EVENTS.has(event))
|
|
704
|
+
return playerOn(scope, event, listener, (data) => service().sourceEvent(event, data));
|
|
594
705
|
return playerOn(scope, event, listener);
|
|
595
706
|
},
|
|
596
707
|
isCurrent(state) {
|
package/dist/plugin/scope.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import type { MotionEngine } from "./types.ts";
|
|
3
3
|
import type { Change } from "./passes.ts";
|
|
4
4
|
import type { Runtime } from "./runtime.ts";
|
|
5
|
-
import type { Disposable, DisposeInfo, Plugin, PluginError, Scope, StopReason } from "./types.ts";
|
|
5
|
+
import type { Disposable, DisposeInfo, Plugin, PluginError, Scope, StopReason, Trigger } from "./types.ts";
|
|
6
6
|
export declare class ScopeImpl implements Plugin {
|
|
7
7
|
#private;
|
|
8
8
|
readonly runtime: Runtime;
|
|
@@ -11,6 +11,8 @@ export declare class ScopeImpl implements Plugin {
|
|
|
11
11
|
get dataDirectory(): string;
|
|
12
12
|
get stopReason(): StopReason | undefined;
|
|
13
13
|
get disposed(): boolean;
|
|
14
|
+
/** The plugin itself, not a scope made with `scope()`. */
|
|
15
|
+
get root(): boolean;
|
|
14
16
|
/**
|
|
15
17
|
* Start the SDK's copy that `event` keeps current (`plugin.commands.keys`,
|
|
16
18
|
* `plugin.timeline`, `plugin.appearance`), for `player.on`; nothing for
|
|
@@ -60,6 +62,7 @@ export declare class ScopeImpl implements Plugin {
|
|
|
60
62
|
readonly wire: import("./types.ts").Wire;
|
|
61
63
|
get app(): import("./types.ts").App;
|
|
62
64
|
scope(): Scope;
|
|
65
|
+
trigger(name?: string): Trigger;
|
|
63
66
|
add<T extends Disposable>(item: T): T;
|
|
64
67
|
/** Handles call this when disposed directly, so the scope forgets them. */
|
|
65
68
|
forget(item: Disposable): void;
|
package/dist/plugin/scope.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { failure, toError } from "./errors.js";
|
|
2
2
|
import { commands, keysOf, palette } from "./commands.js";
|
|
3
|
+
import { triggersOf } from "./triggers.js";
|
|
3
4
|
import { WHEN } from "./when.js";
|
|
4
5
|
import { dialogs } from "./services/dialogs.js";
|
|
5
6
|
import { ui } from "./view/image.js";
|
|
@@ -60,6 +61,10 @@ export class ScopeImpl {
|
|
|
60
61
|
get disposed() {
|
|
61
62
|
return this.#disposed || (this.#parent?.disposed ?? false);
|
|
62
63
|
}
|
|
64
|
+
/** The plugin itself, not a scope made with `scope()`. */
|
|
65
|
+
get root() {
|
|
66
|
+
return this.#parent === undefined;
|
|
67
|
+
}
|
|
63
68
|
/**
|
|
64
69
|
* Start the SDK's copy that `event` keeps current (`plugin.commands.keys`,
|
|
65
70
|
* `plugin.timeline`, `plugin.appearance`), for `player.on`; nothing for
|
|
@@ -114,6 +119,9 @@ export class ScopeImpl {
|
|
|
114
119
|
scope() {
|
|
115
120
|
return this.add(new ScopeImpl(this.runtime, this));
|
|
116
121
|
}
|
|
122
|
+
trigger(name) {
|
|
123
|
+
return triggersOf(this.runtime).declare(this, name);
|
|
124
|
+
}
|
|
117
125
|
add(item) {
|
|
118
126
|
if (this.#disposed)
|
|
119
127
|
void item.dispose().catch(() => { });
|
|
@@ -73,8 +73,8 @@ export declare function system(scope: ScopeImpl): System;
|
|
|
73
73
|
* `invalid`. The store itself can still refuse (`unsupported` without a
|
|
74
74
|
* system store, `unavailable` when it cannot be reached, `failed` when the
|
|
75
75
|
* user denies access): only
|
|
76
|
-
* those codes get the "could not be saved" message, anything else (
|
|
77
|
-
*
|
|
76
|
+
* those codes get the "could not be saved" message, anything else (an
|
|
77
|
+
* invalid name) is a bug and is thrown on.
|
|
78
78
|
* ```ts
|
|
79
79
|
* import type { Plugin, PluginError } from "@vestra-player/sdk";
|
|
80
80
|
* declare const plugin: Plugin;
|
|
@@ -114,12 +114,12 @@ export declare const SECRET_LIMITS: Readonly<{
|
|
|
114
114
|
export declare const secrets: (scope: ScopeImpl) => Secrets;
|
|
115
115
|
export declare const rendering: (scope: ScopeImpl) => Rendering;
|
|
116
116
|
/**
|
|
117
|
-
* `plugin.video.upscaling`:
|
|
117
|
+
* `plugin.video.upscaling`: the player
|
|
118
118
|
* answers once its GPU check ran (the first call starts it).
|
|
119
119
|
*/
|
|
120
120
|
export declare const videoUpscaling: (scope: ScopeImpl) => VideoUpscaling;
|
|
121
121
|
/**
|
|
122
|
-
* `plugin.video.motion(engine)`: both requests
|
|
122
|
+
* `plugin.video.motion(engine)`: both requests
|
|
123
123
|
* name the engine; the event names it too and leaves out each plugin's own
|
|
124
124
|
* `mode`, which the SDK keeps from the answers per engine (only this
|
|
125
125
|
* plugin's `set` changes it).
|
package/dist/plugin/services.js
CHANGED
|
@@ -47,7 +47,7 @@ export const host = (scope) => ({
|
|
|
47
47
|
await scope.runtime.host.host.run(action, seconds);
|
|
48
48
|
// Like the player's own controls: `player.state` shows the result (the
|
|
49
49
|
// player's state copy registered how to read it again).
|
|
50
|
-
if (scope.runtime.
|
|
50
|
+
if (scope.runtime.reads)
|
|
51
51
|
await scope.runtime.reread("source.state");
|
|
52
52
|
},
|
|
53
53
|
});
|
|
@@ -417,8 +417,8 @@ export function system(scope) {
|
|
|
417
417
|
* `invalid`. The store itself can still refuse (`unsupported` without a
|
|
418
418
|
* system store, `unavailable` when it cannot be reached, `failed` when the
|
|
419
419
|
* user denies access): only
|
|
420
|
-
* those codes get the "could not be saved" message, anything else (
|
|
421
|
-
*
|
|
420
|
+
* those codes get the "could not be saved" message, anything else (an
|
|
421
|
+
* invalid name) is a bug and is thrown on.
|
|
422
422
|
* ```ts
|
|
423
423
|
* import type { Plugin, PluginError } from "@vestra-player/sdk";
|
|
424
424
|
* declare const plugin: Plugin;
|
|
@@ -458,8 +458,6 @@ export const SECRET_LIMITS = Object.freeze({
|
|
|
458
458
|
const SECRET = new RegExp(`^[a-z0-9._-]{1,${SECRET_LIMITS.nameChars}}$`);
|
|
459
459
|
export const secrets = (scope) => {
|
|
460
460
|
const named = (name) => {
|
|
461
|
-
if (!scope.runtime.can("secrets"))
|
|
462
|
-
throw failure("capability", "secrets must be declared in manifest");
|
|
463
461
|
if (typeof name !== "string" || !SECRET.test(name))
|
|
464
462
|
throw failure("invalid", `secret names are 1–${SECRET_LIMITS.nameChars} of a-z, 0-9, ., _ and -`);
|
|
465
463
|
return name;
|
|
@@ -479,33 +477,23 @@ export const secrets = (scope) => {
|
|
|
479
477
|
};
|
|
480
478
|
const PREFERENCES = new Set(["auto", "gpu", "software"]);
|
|
481
479
|
export const rendering = (scope) => {
|
|
482
|
-
const manage = () => {
|
|
483
|
-
if (!scope.runtime.can("rendering.manage"))
|
|
484
|
-
throw failure("capability", "rendering.manage must be declared in manifest");
|
|
485
|
-
};
|
|
486
480
|
return {
|
|
487
481
|
state: async () => (await scope.runtime.host.rendering.state()),
|
|
488
482
|
async setPreference(preference) {
|
|
489
|
-
manage();
|
|
490
483
|
if (typeof preference !== "string" || !PREFERENCES.has(preference))
|
|
491
484
|
throw failure("invalid", 'the rendering preference is "auto", "gpu" or "software"');
|
|
492
485
|
return (await scope.runtime.host.rendering.setPreference(preference));
|
|
493
486
|
},
|
|
494
487
|
async restartPlayer() {
|
|
495
|
-
manage();
|
|
496
488
|
await scope.runtime.host.rendering.restart();
|
|
497
489
|
},
|
|
498
490
|
};
|
|
499
491
|
};
|
|
500
492
|
/**
|
|
501
|
-
* `plugin.video.upscaling`:
|
|
493
|
+
* `plugin.video.upscaling`: the player
|
|
502
494
|
* answers once its GPU check ran (the first call starts it).
|
|
503
495
|
*/
|
|
504
496
|
export const videoUpscaling = (scope) => {
|
|
505
|
-
const declared = () => {
|
|
506
|
-
if (!scope.runtime.can("video.upscaling"))
|
|
507
|
-
throw failure("capability", "video.upscaling must be declared in manifest");
|
|
508
|
-
};
|
|
509
497
|
// This plugin's own request, kept from every answer for `onChange`: the
|
|
510
498
|
// event leaves it out (it is each plugin's own), and only this plugin's
|
|
511
499
|
// `set` changes it.
|
|
@@ -515,21 +503,18 @@ export const videoUpscaling = (scope) => {
|
|
|
515
503
|
};
|
|
516
504
|
return {
|
|
517
505
|
async state() {
|
|
518
|
-
declared();
|
|
519
506
|
return noted(await scope.runtime.host.video.upscalingState());
|
|
520
507
|
},
|
|
521
508
|
async set(enabled) {
|
|
522
|
-
declared();
|
|
523
509
|
if (typeof enabled !== "boolean")
|
|
524
510
|
throw failure("invalid", "enabled must be true or false");
|
|
525
511
|
return noted(await scope.runtime.host.video.upscalingSet(enabled));
|
|
526
512
|
},
|
|
527
513
|
onChange(listener) {
|
|
528
|
-
declared();
|
|
529
514
|
const watch = scope.runtime.on("video.upscaling.changed", (data) => scope.run(listener, {
|
|
530
515
|
...data,
|
|
531
516
|
enabled: enabledOf.get(scope.runtime) ?? false,
|
|
532
|
-
}),
|
|
517
|
+
}), null);
|
|
533
518
|
return scope.add({
|
|
534
519
|
dispose: async () => {
|
|
535
520
|
scope.forget(watch);
|
|
@@ -546,7 +531,7 @@ const MOTION_MODES = ["off", "double", "display"];
|
|
|
546
531
|
/** The engines `plugin.video.motion(engine)` accepts. */
|
|
547
532
|
const MOTION_ENGINES = ["amd", "nvidia"];
|
|
548
533
|
/**
|
|
549
|
-
* `plugin.video.motion(engine)`: both requests
|
|
534
|
+
* `plugin.video.motion(engine)`: both requests
|
|
550
535
|
* name the engine; the event names it too and leaves out each plugin's own
|
|
551
536
|
* `mode`, which the SDK keeps from the answers per engine (only this
|
|
552
537
|
* plugin's `set` changes it).
|
|
@@ -554,10 +539,6 @@ const MOTION_ENGINES = ["amd", "nvidia"];
|
|
|
554
539
|
export const videoMotion = (scope, engine) => {
|
|
555
540
|
if (typeof engine !== "string" || !MOTION_ENGINES.includes(engine))
|
|
556
541
|
throw failure("invalid", 'engine must be "amd" or "nvidia"');
|
|
557
|
-
const declared = () => {
|
|
558
|
-
if (!scope.runtime.can("video.motion"))
|
|
559
|
-
throw failure("capability", "video.motion must be declared in manifest");
|
|
560
|
-
};
|
|
561
542
|
const modes = () => {
|
|
562
543
|
let map = modeOf.get(scope.runtime);
|
|
563
544
|
if (!map)
|
|
@@ -570,17 +551,14 @@ export const videoMotion = (scope, engine) => {
|
|
|
570
551
|
};
|
|
571
552
|
return {
|
|
572
553
|
async state() {
|
|
573
|
-
declared();
|
|
574
554
|
return noted(await scope.runtime.host.video.motionState(engine));
|
|
575
555
|
},
|
|
576
556
|
async set(mode) {
|
|
577
|
-
declared();
|
|
578
557
|
if (typeof mode !== "string" || !MOTION_MODES.includes(mode))
|
|
579
558
|
throw failure("invalid", 'mode must be "off", "double" or "display"');
|
|
580
559
|
return noted(await scope.runtime.host.video.motionSet(engine, mode));
|
|
581
560
|
},
|
|
582
561
|
onChange(listener) {
|
|
583
|
-
declared();
|
|
584
562
|
const watch = scope.runtime.on("video.motion.changed", (data) => {
|
|
585
563
|
const state = data;
|
|
586
564
|
// Another engine's change is not this handle's.
|
|
@@ -590,7 +568,7 @@ export const videoMotion = (scope, engine) => {
|
|
|
590
568
|
...state,
|
|
591
569
|
mode: modes().get(engine) ?? "off",
|
|
592
570
|
});
|
|
593
|
-
},
|
|
571
|
+
}, null);
|
|
594
572
|
return scope.add({
|
|
595
573
|
dispose: async () => {
|
|
596
574
|
scope.forget(watch);
|
package/dist/plugin/settings.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Pages of the player's options window (`plugin.settings
|
|
1
|
+
/** Pages of the player's options window (`plugin.settings`). */
|
|
2
2
|
import { failure, quiet } from "./errors.js";
|
|
3
3
|
import { exported, ViewBase } from "./view/base.js";
|
|
4
4
|
const CATEGORIES = [
|
package/dist/plugin/shaders.js
CHANGED
|
@@ -137,8 +137,6 @@ class ShaderHandle {
|
|
|
137
137
|
}
|
|
138
138
|
export function videoShaders(scope, id) {
|
|
139
139
|
const runtime = scope.runtime;
|
|
140
|
-
if (!runtime.can("processing.video"))
|
|
141
|
-
throw failure("capability", "processing.video must be declared in manifest");
|
|
142
140
|
const name = id ?? DEFAULT_SHADERS_ID;
|
|
143
141
|
const problem = shaderIdProblem(name);
|
|
144
142
|
if (problem)
|
package/dist/plugin/stream.d.ts
CHANGED
|
@@ -12,7 +12,8 @@ import type { ResolvedStream, Stream, StreamOptions } from "./types.ts";
|
|
|
12
12
|
export interface StreamSource {
|
|
13
13
|
readonly runtime: {
|
|
14
14
|
readonly host: Wire;
|
|
15
|
-
|
|
15
|
+
/** `plugin.player.read()` was called: the state is read after own actions. */
|
|
16
|
+
readonly reads: boolean;
|
|
16
17
|
};
|
|
17
18
|
/** The newest source state seen. */
|
|
18
19
|
readonly raw: SourceState;
|
package/dist/plugin/stream.js
CHANGED
|
@@ -190,7 +190,7 @@ async function retirement(service, generation, error) {
|
|
|
190
190
|
const code = error?.code;
|
|
191
191
|
if (code !== "unavailable" && code !== "stale")
|
|
192
192
|
return undefined;
|
|
193
|
-
const readable = service.runtime.
|
|
193
|
+
const readable = service.runtime.reads;
|
|
194
194
|
if (readable)
|
|
195
195
|
await service.refresh().catch(() => { });
|
|
196
196
|
const raw = service.raw;
|
|
@@ -198,7 +198,7 @@ async function retirement(service, generation, error) {
|
|
|
198
198
|
return null;
|
|
199
199
|
if (raw.phase === "error")
|
|
200
200
|
return failure("stream", service.state.error ?? "无法打开此媒体");
|
|
201
|
-
// Without `
|
|
201
|
+
// Without `plugin.player.read()` the state may be behind: no failure was seen.
|
|
202
202
|
return readable ? undefined : null;
|
|
203
203
|
}
|
|
204
204
|
/** Start-up timeouts say which step ran out of time. */
|
|
@@ -24,16 +24,9 @@ export declare function splitCommandKey(_host: TestHost, _inner: Internals, key:
|
|
|
24
24
|
command: string;
|
|
25
25
|
};
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*/
|
|
31
|
-
export declare const pluginCapabilities: WeakMap<TestHost, readonly string[]>;
|
|
32
|
-
/**
|
|
33
|
-
* `bindings.list`, as the player's (binding_manager.rs `list`, player
|
|
34
|
-
* 0.8.0): a `focus: "panel"` command of a plugin whose manifest declares no
|
|
35
|
-
* `ui.mount` can never fire from a key, so it is left out; it stays declared
|
|
36
|
-
* (its stored binding is no orphan, `bindings.set` accepts it).
|
|
27
|
+
* `bindings.list`, as the player's (binding_manager.rs `list`): every
|
|
28
|
+
* declared command, a `focus: "panel"` one included (since 1.9.0 no
|
|
29
|
+
* manifest says whether the plugin mounts a panel).
|
|
37
30
|
*/
|
|
38
31
|
export declare function bindingTable(host: TestHost, inner: Internals): {
|
|
39
32
|
commands: {
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
import { HostError } from "../../wire.js";
|
|
10
10
|
import { BAR_BUTTON_ICONS, BAR_BUTTON_LIMITS, BUILTIN_COMMANDS, COMMAND_LIMITS, MENU_IDS, thenProblem, } from "../../commands.js";
|
|
11
11
|
import { canonical, keyLabel } from "../bindings.js";
|
|
12
|
-
import { evaluate } from "../when.js";
|
|
12
|
+
import { evaluate, readsPositionOrTime } from "../when.js";
|
|
13
|
+
import { conditionFacts } from "./triggers.js";
|
|
13
14
|
import { PALETTE_LEAD_LIMITS, PALETTE_LEAD_STATES } from "../../commands.js";
|
|
14
15
|
import { menuKeys, textKey } from "../../i18n.js";
|
|
15
16
|
import { commandInvalid, commandConflict, commandText, menuTextKey, checkDeclaration, } from "./declarations.js";
|
|
@@ -89,23 +90,14 @@ export function splitCommandKey(_host, _inner, key) {
|
|
|
89
90
|
return { plugin: key.slice(0, at), command: key.slice(at + 1) };
|
|
90
91
|
}
|
|
91
92
|
/**
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*/
|
|
96
|
-
export const pluginCapabilities = new WeakMap();
|
|
97
|
-
/**
|
|
98
|
-
* `bindings.list`, as the player's (binding_manager.rs `list`, player
|
|
99
|
-
* 0.8.0): a `focus: "panel"` command of a plugin whose manifest declares no
|
|
100
|
-
* `ui.mount` can never fire from a key, so it is left out; it stays declared
|
|
101
|
-
* (its stored binding is no orphan, `bindings.set` accepts it).
|
|
93
|
+
* `bindings.list`, as the player's (binding_manager.rs `list`): every
|
|
94
|
+
* declared command, a `focus: "panel"` one included (since 1.9.0 no
|
|
95
|
+
* manifest says whether the plugin mounts a panel).
|
|
102
96
|
*/
|
|
103
97
|
export function bindingTable(host, inner) {
|
|
104
98
|
const all = bindingRows(host, inner);
|
|
105
|
-
const capabilities = pluginCapabilities.get(host);
|
|
106
|
-
const hidden = capabilities !== undefined && !capabilities.includes("ui.mount");
|
|
107
99
|
const declared = new Set(all.map((c) => `${c.plugin}/${c.command}`));
|
|
108
|
-
const commands = all
|
|
100
|
+
const commands = all;
|
|
109
101
|
const orphans = [...host.bindings.overlay]
|
|
110
102
|
.filter(([key]) => !declared.has(key))
|
|
111
103
|
.map(([key, inputs]) => ({
|
|
@@ -154,31 +146,24 @@ function bindingRows(host, inner) {
|
|
|
154
146
|
});
|
|
155
147
|
return commands;
|
|
156
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* A command's `when` as the player refuses it (`conditions.rs`
|
|
151
|
+
* `Conditions::parse`): a position or time condition is a trigger's.
|
|
152
|
+
*/
|
|
153
|
+
function commandWhenChecked(when) {
|
|
154
|
+
if (!when || typeof when !== "object")
|
|
155
|
+
return;
|
|
156
|
+
for (const [name, condition] of Object.entries(when))
|
|
157
|
+
if (condition && readsPositionOrTime(condition))
|
|
158
|
+
throw new HostError("invalid", `${name}: a position or time condition is for a trigger (plugin.trigger), not a command's state`);
|
|
159
|
+
}
|
|
157
160
|
/** A command's state as the player shows it: its conditions evaluated. */
|
|
158
161
|
export function commandShown(host, _inner, sent, when) {
|
|
159
162
|
if (!when)
|
|
160
163
|
return sent;
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
const facts =
|
|
164
|
-
phase: source.phase,
|
|
165
|
-
paused: source.paused,
|
|
166
|
-
kind: source.kind === "producer" ? "stream" : "media",
|
|
167
|
-
can: {
|
|
168
|
-
pause: capabilities.pause,
|
|
169
|
-
seek: capabilities.seek,
|
|
170
|
-
rate: capabilities.rate,
|
|
171
|
-
restart: capabilities.restart,
|
|
172
|
-
close: capabilities.close,
|
|
173
|
-
snapshot: capabilities.snapshotSource,
|
|
174
|
-
// As the player: the flags merged into the source state.
|
|
175
|
-
next: source.sequence?.next === true,
|
|
176
|
-
previous: source.sequence?.previous === true,
|
|
177
|
-
},
|
|
178
|
-
fullscreen: host.mainWindow.fullscreen,
|
|
179
|
-
theme: host.appearance,
|
|
180
|
-
language: host.language,
|
|
181
|
-
};
|
|
164
|
+
// As the player: the same facts as a trigger's (next and previous are
|
|
165
|
+
// the flags merged into the source state).
|
|
166
|
+
const facts = conditionFacts(host);
|
|
182
167
|
const shown = { ...sent };
|
|
183
168
|
if (when.enabled) {
|
|
184
169
|
shown.enabled = evaluate(when.enabled, facts);
|
|
@@ -347,6 +332,7 @@ export function commandsHandlers(host, inner) {
|
|
|
347
332
|
host.commands.size + host.coreCommands.size + hostOnly.length >=
|
|
348
333
|
COMMAND_LIMITS.total)
|
|
349
334
|
throw new HostError("limit", "command registry limit reached");
|
|
335
|
+
commandWhenChecked(p.when);
|
|
350
336
|
let sent = p.state;
|
|
351
337
|
host.commands.set(id, {
|
|
352
338
|
declaration,
|
|
@@ -403,6 +389,7 @@ export function commandsHandlers(host, inner) {
|
|
|
403
389
|
catch (error) {
|
|
404
390
|
throw new HostError("command", error.message);
|
|
405
391
|
}
|
|
392
|
+
commandWhenChecked(p.when);
|
|
406
393
|
command.revision = Number(p.revision);
|
|
407
394
|
command.state = p.state;
|
|
408
395
|
if (p.when)
|
|
@@ -432,10 +419,10 @@ export function commandsHandlers(host, inner) {
|
|
|
432
419
|
};
|
|
433
420
|
}
|
|
434
421
|
/// ---------------------------------------------------------------- built-in only: commands.run, palette.lead
|
|
435
|
-
/** The player's refusal of a built-in-only
|
|
422
|
+
/** The player's refusal of a built-in-only request to any other plugin. */
|
|
436
423
|
function builtinOnly(host) {
|
|
437
424
|
if (!host.builtin)
|
|
438
|
-
throw new HostError("capability", "this
|
|
425
|
+
throw new HostError("capability", "this is for built-in plugins only");
|
|
439
426
|
}
|
|
440
427
|
/** The palette's rows: the player's core commands and the plugin's own. */
|
|
441
428
|
function rows(host) {
|