@vestra-player/sdk 1.7.20 → 1.9.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 +72 -0
- package/README.md +2 -2
- package/bin/vestra-plugin.mjs +139 -100
- package/capability-scan.json +369 -0
- package/dist/api-requests.d.ts +11 -36
- package/dist/api-requests.js +22 -47
- package/dist/capability-scan.d.ts +95 -0
- package/dist/capability-scan.js +249 -0
- package/dist/commands.d.ts +35 -0
- package/dist/commands.js +42 -1
- package/dist/docs-tree.json.gz +0 -0
- package/dist/docs.d.ts +1 -1
- package/dist/docs.js +1 -1
- 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/mpv.d.ts +139 -0
- package/dist/mpv.js +496 -0
- package/dist/player-runtime.d.ts +3 -3
- package/dist/player-runtime.js +3 -3
- 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 +6 -14
- package/dist/plugin/connection.d.ts +26 -7
- package/dist/plugin/connection.js +68 -36
- package/dist/plugin/drops.js +1 -1
- package/dist/plugin/index.js +9 -15
- package/dist/plugin/media.js +0 -12
- package/dist/plugin/mpv.d.ts +3 -0
- package/dist/plugin/mpv.js +91 -0
- package/dist/plugin/packages.js +1 -2
- package/dist/plugin/player/events.d.ts +4 -3
- package/dist/plugin/player/events.js +7 -6
- package/dist/plugin/player.d.ts +21 -13
- package/dist/plugin/player.js +56 -21
- package/dist/plugin/scope.d.ts +1 -0
- package/dist/plugin/scope.js +2 -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 +43 -24
- package/dist/plugin/testing/index.d.ts +75 -114
- package/dist/plugin/testing/index.js +83 -102
- package/dist/plugin/testing/mpv.d.ts +7 -0
- package/dist/plugin/testing/mpv.js +90 -0
- package/dist/plugin/testing/processing.js +1 -1
- package/dist/plugin/testing/services.js +0 -1
- package/dist/plugin/timeline.d.ts +2 -3
- package/dist/plugin/timeline.js +4 -8
- package/dist/plugin/types/base.d.ts +49 -88
- package/dist/plugin/types/commands.d.ts +44 -77
- package/dist/plugin/types/packages.d.ts +17 -55
- package/dist/plugin/types/playback.d.ts +302 -135
- 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/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/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 +5 -5
- package/package.json +4 -3
- package/slint/vestra/widgets.slint +12 -4
- package/dist/capabilities.d.ts +0 -107
- package/dist/capabilities.js +0 -69
- package/dist/capability-check.d.ts +0 -133
- package/dist/capability-check.js +0 -371
- 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 -477
package/dist/plugin/player.js
CHANGED
|
@@ -156,14 +156,13 @@ function sourceFailure(error) {
|
|
|
156
156
|
* One per plugin: the state store and the operation book client.
|
|
157
157
|
*
|
|
158
158
|
* 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
|
|
159
|
+
* from `plugin.player.subscribe()` on (`subscribe`, first in `activate`
|
|
160
|
+
* as the plugin writes it). Before that no event can arrive; `start` is
|
|
161
|
+
* then called by the first use of the state (a read of
|
|
163
162
|
* `plugin.player.state`, `onChange`, `isCurrent`, a media handle, a
|
|
164
163
|
* scrub, a stream, a filter, a shader or view request, a capture) and
|
|
165
|
-
* subscribes nothing
|
|
166
|
-
*
|
|
164
|
+
* subscribes nothing until `subscribe()`, which subscribes it and, after
|
|
165
|
+
* `read()`, reads the state once more (`#catchUp`).
|
|
167
166
|
*/
|
|
168
167
|
export class PlayerService {
|
|
169
168
|
runtime;
|
|
@@ -180,6 +179,8 @@ export class PlayerService {
|
|
|
180
179
|
#started = false;
|
|
181
180
|
/** The read that followed the subscription (resolved: none was needed). */
|
|
182
181
|
#fresh = Promise.resolve();
|
|
182
|
+
/** `read()`'s one read, once asked for. */
|
|
183
|
+
#read;
|
|
183
184
|
output;
|
|
184
185
|
constructor(runtime) {
|
|
185
186
|
this.runtime = runtime;
|
|
@@ -195,9 +196,41 @@ export class PlayerService {
|
|
|
195
196
|
await this.refresh().catch(() => { });
|
|
196
197
|
});
|
|
197
198
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
199
|
+
/**
|
|
200
|
+
* `plugin.player.read()`: read the source state and the timeline now, and
|
|
201
|
+
* from now on read the state again after the plugin's own actions
|
|
202
|
+
* (`Connection.reads`). Idempotent: one read, however often it is called;
|
|
203
|
+
* a read that failed is tried again by the next call.
|
|
204
|
+
*/
|
|
205
|
+
read() {
|
|
206
|
+
return (this.#read ??= (async () => {
|
|
207
|
+
this.runtime.reads = true;
|
|
208
|
+
try {
|
|
209
|
+
await Promise.all([
|
|
210
|
+
this.refresh(),
|
|
211
|
+
this.runtime.reread("timeline.changed"),
|
|
212
|
+
]);
|
|
213
|
+
}
|
|
214
|
+
catch (error) {
|
|
215
|
+
this.#read = undefined;
|
|
216
|
+
throw error;
|
|
217
|
+
}
|
|
218
|
+
})());
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* `plugin.player.subscribe()`: turn event delivery on and follow
|
|
222
|
+
* `source.state` now. Idempotent.
|
|
223
|
+
*/
|
|
224
|
+
subscribe() {
|
|
225
|
+
if (this.runtime.delivering)
|
|
226
|
+
return;
|
|
227
|
+
this.runtime.deliver();
|
|
228
|
+
// A copy started on demand heard nothing so far; it is subscribed now,
|
|
229
|
+
// and a change before that sent no event.
|
|
230
|
+
if (this.#started)
|
|
231
|
+
this.#catchUp();
|
|
232
|
+
else
|
|
233
|
+
void this.start();
|
|
201
234
|
}
|
|
202
235
|
/** Whether the mirror follows the player's events yet. */
|
|
203
236
|
get started() {
|
|
@@ -206,23 +239,23 @@ export class PlayerService {
|
|
|
206
239
|
/**
|
|
207
240
|
* Follow `source.state` from now on: the SDK's copy of the state (a
|
|
208
241
|
* 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.
|
|
242
|
+
* `state`). Then read the state once more (after `read()` and
|
|
243
|
+
* `subscribe()`): a change between that read and the subscription sent
|
|
244
|
+
* no event to this plugin. Resolves when that read is in.
|
|
214
245
|
*/
|
|
215
|
-
start(
|
|
246
|
+
start() {
|
|
216
247
|
if (this.#started)
|
|
217
248
|
return this.#fresh;
|
|
218
249
|
this.#started = true;
|
|
219
250
|
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(() => { }, () => { });
|
|
251
|
+
this.#catchUp();
|
|
224
252
|
return this.#fresh;
|
|
225
253
|
}
|
|
254
|
+
/** Read the state once more after a subscription, when it is read at all. */
|
|
255
|
+
#catchUp() {
|
|
256
|
+
if (this.runtime.reads && this.runtime.delivering)
|
|
257
|
+
this.#fresh = this.refresh().then(() => { }, () => { });
|
|
258
|
+
}
|
|
226
259
|
/** The state as the player has it now, for a call that needs a source. */
|
|
227
260
|
async current() {
|
|
228
261
|
await this.start();
|
|
@@ -322,7 +355,7 @@ export class PlayerService {
|
|
|
322
355
|
}
|
|
323
356
|
/** Close only if `generation` is still the player's source. */
|
|
324
357
|
async closeIfCurrent(generation) {
|
|
325
|
-
const raw = this.runtime.
|
|
358
|
+
const raw = this.runtime.reads
|
|
326
359
|
? (await this.refresh(), this.raw)
|
|
327
360
|
: this.raw;
|
|
328
361
|
if (raw.stamp.generation !== generation || raw.phase === "empty")
|
|
@@ -385,7 +418,7 @@ class MediaHandle {
|
|
|
385
418
|
return abort();
|
|
386
419
|
options.signal?.addEventListener("abort", abort, { once: true });
|
|
387
420
|
// Without event delivery the state only moves when read.
|
|
388
|
-
if (!service.runtime.
|
|
421
|
+
if (!service.runtime.delivering)
|
|
389
422
|
poll = setInterval(() => void service.refresh().catch(() => { }), 100);
|
|
390
423
|
check();
|
|
391
424
|
});
|
|
@@ -586,6 +619,8 @@ export function player(scope) {
|
|
|
586
619
|
});
|
|
587
620
|
},
|
|
588
621
|
refresh: () => service().refresh(),
|
|
622
|
+
subscribe: () => service().subscribe(),
|
|
623
|
+
read: () => service().read(),
|
|
589
624
|
on(event, listener) {
|
|
590
625
|
// Checked first; the copy then starts before the listener subscribes
|
|
591
626
|
// (it hears each event first in any case).
|
package/dist/plugin/scope.d.ts
CHANGED
|
@@ -47,6 +47,7 @@ export declare class ScopeImpl implements Plugin {
|
|
|
47
47
|
readonly storage: import("./types.ts").Storage;
|
|
48
48
|
readonly system: import("./types.ts").System;
|
|
49
49
|
readonly secrets: import("./types.ts").Secrets;
|
|
50
|
+
readonly mpv: import("./types.ts").Mpv;
|
|
50
51
|
readonly rendering: import("./types.ts").Rendering;
|
|
51
52
|
readonly window: import("./types.ts").MainWindow;
|
|
52
53
|
readonly bindings: import("./types.ts").Bindings;
|
package/dist/plugin/scope.js
CHANGED
|
@@ -23,6 +23,7 @@ import { mainWindow } from "./window.js";
|
|
|
23
23
|
import { bindingsApi } from "./bindings.js";
|
|
24
24
|
import { trackedState } from "./state.js";
|
|
25
25
|
import { wire } from "./wire-facade.js";
|
|
26
|
+
import { mpv } from "./mpv.js";
|
|
26
27
|
import { clipboard, host, power, rendering, secrets, storage, system, tools, videoMotion, videoUpscaling, } from "./services.js";
|
|
27
28
|
/**
|
|
28
29
|
* The SDK's state copies that a player event keeps current, by event: a
|
|
@@ -96,6 +97,7 @@ export class ScopeImpl {
|
|
|
96
97
|
storage = storage(this);
|
|
97
98
|
system = system(this);
|
|
98
99
|
secrets = secrets(this);
|
|
100
|
+
mpv = mpv(this);
|
|
99
101
|
rendering = rendering(this);
|
|
100
102
|
window = mainWindow(this);
|
|
101
103
|
bindings = bindingsApi(this);
|
|
@@ -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: {
|
|
@@ -10,6 +10,7 @@ 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
12
|
import { evaluate } from "../when.js";
|
|
13
|
+
import { PALETTE_LEAD_LIMITS, PALETTE_LEAD_STATES } from "../../commands.js";
|
|
13
14
|
import { menuKeys, textKey } from "../../i18n.js";
|
|
14
15
|
import { commandInvalid, commandConflict, commandText, menuTextKey, checkDeclaration, } from "./declarations.js";
|
|
15
16
|
import { declaredText, commandDisplay } from "./i18n.js";
|
|
@@ -88,23 +89,14 @@ export function splitCommandKey(_host, _inner, key) {
|
|
|
88
89
|
return { plugin: key.slice(0, at), command: key.slice(at + 1) };
|
|
89
90
|
}
|
|
90
91
|
/**
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*/
|
|
95
|
-
export const pluginCapabilities = new WeakMap();
|
|
96
|
-
/**
|
|
97
|
-
* `bindings.list`, as the player's (binding_manager.rs `list`, player
|
|
98
|
-
* 0.8.0): a `focus: "panel"` command of a plugin whose manifest declares no
|
|
99
|
-
* `ui.mount` can never fire from a key, so it is left out; it stays declared
|
|
100
|
-
* (its stored binding is no orphan, `bindings.set` accepts it).
|
|
92
|
+
* `bindings.list`, as the player's (binding_manager.rs `list`): every
|
|
93
|
+
* declared command, a `focus: "panel"` one included (since 1.9.0 no
|
|
94
|
+
* manifest says whether the plugin mounts a panel).
|
|
101
95
|
*/
|
|
102
96
|
export function bindingTable(host, inner) {
|
|
103
97
|
const all = bindingRows(host, inner);
|
|
104
|
-
const capabilities = pluginCapabilities.get(host);
|
|
105
|
-
const hidden = capabilities !== undefined && !capabilities.includes("ui.mount");
|
|
106
98
|
const declared = new Set(all.map((c) => `${c.plugin}/${c.command}`));
|
|
107
|
-
const commands = all
|
|
99
|
+
const commands = all;
|
|
108
100
|
const orphans = [...host.bindings.overlay]
|
|
109
101
|
.filter(([key]) => !declared.has(key))
|
|
110
102
|
.map(([key, inputs]) => ({
|
|
@@ -431,10 +423,10 @@ export function commandsHandlers(host, inner) {
|
|
|
431
423
|
};
|
|
432
424
|
}
|
|
433
425
|
/// ---------------------------------------------------------------- built-in only: commands.run, palette.lead
|
|
434
|
-
/** The player's refusal of a built-in-only
|
|
426
|
+
/** The player's refusal of a built-in-only request to any other plugin. */
|
|
435
427
|
function builtinOnly(host) {
|
|
436
428
|
if (!host.builtin)
|
|
437
|
-
throw new HostError("capability", "this
|
|
429
|
+
throw new HostError("capability", "this is for built-in plugins only");
|
|
438
430
|
}
|
|
439
431
|
/** The palette's rows: the player's core commands and the plugin's own. */
|
|
440
432
|
function rows(host) {
|
|
@@ -516,17 +508,21 @@ function listed(host, inner, row) {
|
|
|
516
508
|
...(!state.enabled && display.reason ? { reason: display.reason } : {}),
|
|
517
509
|
};
|
|
518
510
|
}
|
|
519
|
-
/**
|
|
511
|
+
/**
|
|
512
|
+
* `palette.lead.set` texts: at most this many characters each
|
|
513
|
+
* (`PALETTE_LEAD_LIMITS`). `status.text` is a working status's; an end
|
|
514
|
+
* state's may be longer (`statusEndText`, since 1.8.0).
|
|
515
|
+
*/
|
|
520
516
|
const LEAD_TEXTS = {
|
|
521
|
-
title:
|
|
522
|
-
placeholder:
|
|
523
|
-
empty:
|
|
524
|
-
note:
|
|
525
|
-
"status.text":
|
|
526
|
-
"status.note":
|
|
517
|
+
title: PALETTE_LEAD_LIMITS.title,
|
|
518
|
+
placeholder: PALETTE_LEAD_LIMITS.placeholder,
|
|
519
|
+
empty: PALETTE_LEAD_LIMITS.empty,
|
|
520
|
+
note: PALETTE_LEAD_LIMITS.note,
|
|
521
|
+
"status.text": PALETTE_LEAD_LIMITS.statusText,
|
|
522
|
+
"status.note": PALETTE_LEAD_LIMITS.statusNote,
|
|
527
523
|
};
|
|
528
524
|
/** `palette.lead.set`'s `status.state` (absent or null: `working`). */
|
|
529
|
-
const LEAD_STATES =
|
|
525
|
+
const LEAD_STATES = PALETTE_LEAD_STATES;
|
|
530
526
|
/** The default handlers of `commands.run` and `palette.lead`. */
|
|
531
527
|
export function builtinHandlers(host, inner) {
|
|
532
528
|
return {
|
|
@@ -635,7 +631,17 @@ export function builtinHandlers(host, inner) {
|
|
|
635
631
|
},
|
|
636
632
|
"palette.lead.set": (p) => {
|
|
637
633
|
builtinOnly(host);
|
|
638
|
-
|
|
634
|
+
const status = p.status;
|
|
635
|
+
// An end state's text may fill the strip's two lines (1.8.0). Any
|
|
636
|
+
// other state, a wrong one included, has the working limit: the
|
|
637
|
+
// checks keep their order (texts, icon, state).
|
|
638
|
+
const end = typeof status?.state === "string" &&
|
|
639
|
+
status.state !== "working" &&
|
|
640
|
+
LEAD_STATES.includes(status.state);
|
|
641
|
+
for (const [name, limit] of Object.entries(LEAD_TEXTS)) {
|
|
642
|
+
const max = end && name === "status.text"
|
|
643
|
+
? PALETTE_LEAD_LIMITS.statusEndText
|
|
644
|
+
: limit;
|
|
639
645
|
const [first, second] = name.split(".");
|
|
640
646
|
const value = second
|
|
641
647
|
? p[first]?.[second]
|
|
@@ -660,6 +666,19 @@ export function builtinHandlers(host, inner) {
|
|
|
660
666
|
state !== null &&
|
|
661
667
|
!LEAD_STATES.includes(state))
|
|
662
668
|
throw new HostError("invalid", `status.state is one of ${LEAD_STATES.join(", ")}`);
|
|
669
|
+
// The strip's own text (1.8.0), checked last: for a working status
|
|
670
|
+
// only, then as a text of the strip's one line.
|
|
671
|
+
const strip = status?.strip;
|
|
672
|
+
if (strip !== undefined && strip !== null) {
|
|
673
|
+
if (end)
|
|
674
|
+
throw new HostError("invalid", "status.strip is for a working status");
|
|
675
|
+
const shown = declaredText(host, inner, strip, "status.strip");
|
|
676
|
+
const length = [...shown].length;
|
|
677
|
+
if (length < 1 ||
|
|
678
|
+
length > PALETTE_LEAD_LIMITS.statusStrip ||
|
|
679
|
+
/[\0\n\r]/.test(shown))
|
|
680
|
+
throw new HostError("invalid", `status.strip must be 1–${PALETTE_LEAD_LIMITS.statusStrip} characters on one line`);
|
|
681
|
+
}
|
|
663
682
|
host.paletteLead = { ...p };
|
|
664
683
|
},
|
|
665
684
|
"palette.lead.clear": () => {
|