@vestra-player/sdk 1.7.19 → 1.8.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 +38 -0
- package/bin/vestra-plugin.mjs +128 -0
- package/capability-scan.json +367 -0
- package/dist/api-requests.js +4 -0
- package/dist/capability-check.d.ts +43 -0
- package/dist/capability-check.js +90 -0
- package/dist/capability-scan.d.ts +95 -0
- package/dist/capability-scan.js +250 -0
- package/dist/commands.d.ts +35 -0
- package/dist/commands.js +42 -1
- package/dist/docs-tree.json.gz +0 -0
- package/dist/host-capabilities.js +15 -0
- package/dist/mpv.d.ts +139 -0
- package/dist/mpv.js +496 -0
- package/dist/player-runtime.d.ts +2 -1
- package/dist/player-runtime.js +2 -1
- package/dist/plugin/commands.js +5 -2
- package/dist/plugin/mpv.d.ts +3 -0
- package/dist/plugin/mpv.js +98 -0
- package/dist/plugin/scope.d.ts +1 -0
- package/dist/plugin/scope.js +2 -0
- package/dist/plugin/testing/commands.js +37 -9
- package/dist/plugin/testing/index.d.ts +52 -1
- package/dist/plugin/testing/index.js +55 -0
- package/dist/plugin/testing/mpv.d.ts +7 -0
- package/dist/plugin/testing/mpv.js +90 -0
- package/dist/plugin/types/base.d.ts +9 -2
- package/dist/plugin/types/commands.d.ts +34 -10
- package/dist/plugin/types/playback.d.ts +185 -0
- package/dist/plugin/types/processing.d.ts +11 -3
- package/dist/wire.d.ts +16 -1
- package/dist/wire.js +11 -0
- package/llms.txt +2 -2
- package/package.json +4 -2
- package/slint/vestra/widgets.slint +12 -4
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `plugin.mpv`: the mpv pass-through (L1). The checks here are the
|
|
3
|
+
* player's own, made early with the same table (`src/mpv.ts`); what only
|
|
4
|
+
* the player can tell (another plugin's label, mpv's answer) is its.
|
|
5
|
+
*/
|
|
6
|
+
import { mpvCommandProblem, mpvCommandRefusal, mpvNameProblem, mpvPropertyRefusal, } from "../mpv.js";
|
|
7
|
+
import { failure } from "./errors.js";
|
|
8
|
+
/** One per plugin: the properties observed and their listeners. */
|
|
9
|
+
class Observers {
|
|
10
|
+
#runtime;
|
|
11
|
+
#names = new Map();
|
|
12
|
+
#started = false;
|
|
13
|
+
constructor(runtime) {
|
|
14
|
+
this.#runtime = runtime;
|
|
15
|
+
}
|
|
16
|
+
/** One `mpv.observe` per name, however many listeners. */
|
|
17
|
+
add(name, listener, report) {
|
|
18
|
+
if (!this.#started) {
|
|
19
|
+
this.#started = true;
|
|
20
|
+
// Sent to the plugin that observes: no subscription of its own.
|
|
21
|
+
this.#runtime.raw("mpv.property", (data) => {
|
|
22
|
+
const event = data;
|
|
23
|
+
for (const each of [...(this.#names.get(event.name) ?? [])])
|
|
24
|
+
each(event.value);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
let listeners = this.#names.get(name);
|
|
28
|
+
if (!listeners) {
|
|
29
|
+
listeners = new Set();
|
|
30
|
+
this.#names.set(name, listeners);
|
|
31
|
+
this.#runtime.starting(this.#runtime.host.mpv.observeProperty(name), report);
|
|
32
|
+
}
|
|
33
|
+
listeners.add(listener);
|
|
34
|
+
}
|
|
35
|
+
async remove(name, listener) {
|
|
36
|
+
const listeners = this.#names.get(name);
|
|
37
|
+
if (!listeners?.delete(listener) || listeners.size)
|
|
38
|
+
return;
|
|
39
|
+
this.#names.delete(name);
|
|
40
|
+
await this.#runtime.host.mpv.unobserveProperty(name).catch(() => { });
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export const mpv = (scope) => {
|
|
44
|
+
/** Refuse at once without `mpv`, as the player does. */
|
|
45
|
+
const declared = () => {
|
|
46
|
+
if (!scope.runtime.can("mpv"))
|
|
47
|
+
throw failure("capability", "mpv must be declared in manifest");
|
|
48
|
+
};
|
|
49
|
+
const named = (name, write) => {
|
|
50
|
+
declared();
|
|
51
|
+
const problem = mpvNameProblem(name);
|
|
52
|
+
if (problem)
|
|
53
|
+
throw failure("invalid", problem);
|
|
54
|
+
const refused = mpvPropertyRefusal(name, write);
|
|
55
|
+
if (refused)
|
|
56
|
+
throw failure("refused", refused);
|
|
57
|
+
return name;
|
|
58
|
+
};
|
|
59
|
+
const observers = () => scope.runtime.service("mpv.observers", () => new Observers(scope.runtime));
|
|
60
|
+
return {
|
|
61
|
+
async command(args) {
|
|
62
|
+
declared();
|
|
63
|
+
const problem = mpvCommandProblem(args);
|
|
64
|
+
if (problem)
|
|
65
|
+
throw failure("invalid", problem);
|
|
66
|
+
const refused = mpvCommandRefusal(args);
|
|
67
|
+
if (refused)
|
|
68
|
+
throw failure("refused", refused);
|
|
69
|
+
const answer = await scope.runtime.host.mpv.command([...args]);
|
|
70
|
+
return (answer?.result ?? null);
|
|
71
|
+
},
|
|
72
|
+
async get(name) {
|
|
73
|
+
const answer = await scope.runtime.host.mpv.get(named(name, false));
|
|
74
|
+
return (answer?.value ?? null);
|
|
75
|
+
},
|
|
76
|
+
async set(name, value) {
|
|
77
|
+
const property = named(name, true);
|
|
78
|
+
if (value === undefined)
|
|
79
|
+
throw failure("invalid", "set takes a value");
|
|
80
|
+
await scope.runtime.host.mpv.set(property, value);
|
|
81
|
+
},
|
|
82
|
+
observe(name, listener) {
|
|
83
|
+
const property = named(name, false);
|
|
84
|
+
if (typeof listener !== "function")
|
|
85
|
+
throw failure("invalid", "observe takes a property name and a listener");
|
|
86
|
+
// Like `player.on`: no full update pass after it.
|
|
87
|
+
const deliver = (value) => scope.runQuiet(listener, value);
|
|
88
|
+
observers().add(property, deliver, (error) => scope.report(error));
|
|
89
|
+
const handle = {
|
|
90
|
+
dispose: async () => {
|
|
91
|
+
scope.forget(handle);
|
|
92
|
+
await observers().remove(property, deliver);
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
return scope.add(handle);
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
};
|
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);
|
|
@@ -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";
|
|
@@ -516,17 +517,21 @@ function listed(host, inner, row) {
|
|
|
516
517
|
...(!state.enabled && display.reason ? { reason: display.reason } : {}),
|
|
517
518
|
};
|
|
518
519
|
}
|
|
519
|
-
/**
|
|
520
|
+
/**
|
|
521
|
+
* `palette.lead.set` texts: at most this many characters each
|
|
522
|
+
* (`PALETTE_LEAD_LIMITS`). `status.text` is a working status's; an end
|
|
523
|
+
* state's may be longer (`statusEndText`, since 1.8.0).
|
|
524
|
+
*/
|
|
520
525
|
const LEAD_TEXTS = {
|
|
521
|
-
title:
|
|
522
|
-
placeholder:
|
|
523
|
-
empty:
|
|
524
|
-
note:
|
|
525
|
-
"status.text":
|
|
526
|
-
"status.note":
|
|
526
|
+
title: PALETTE_LEAD_LIMITS.title,
|
|
527
|
+
placeholder: PALETTE_LEAD_LIMITS.placeholder,
|
|
528
|
+
empty: PALETTE_LEAD_LIMITS.empty,
|
|
529
|
+
note: PALETTE_LEAD_LIMITS.note,
|
|
530
|
+
"status.text": PALETTE_LEAD_LIMITS.statusText,
|
|
531
|
+
"status.note": PALETTE_LEAD_LIMITS.statusNote,
|
|
527
532
|
};
|
|
528
533
|
/** `palette.lead.set`'s `status.state` (absent or null: `working`). */
|
|
529
|
-
const LEAD_STATES =
|
|
534
|
+
const LEAD_STATES = PALETTE_LEAD_STATES;
|
|
530
535
|
/** The default handlers of `commands.run` and `palette.lead`. */
|
|
531
536
|
export function builtinHandlers(host, inner) {
|
|
532
537
|
return {
|
|
@@ -635,7 +640,17 @@ export function builtinHandlers(host, inner) {
|
|
|
635
640
|
},
|
|
636
641
|
"palette.lead.set": (p) => {
|
|
637
642
|
builtinOnly(host);
|
|
638
|
-
|
|
643
|
+
const status = p.status;
|
|
644
|
+
// An end state's text may fill the strip's two lines (1.8.0). Any
|
|
645
|
+
// other state, a wrong one included, has the working limit: the
|
|
646
|
+
// checks keep their order (texts, icon, state).
|
|
647
|
+
const end = typeof status?.state === "string" &&
|
|
648
|
+
status.state !== "working" &&
|
|
649
|
+
LEAD_STATES.includes(status.state);
|
|
650
|
+
for (const [name, limit] of Object.entries(LEAD_TEXTS)) {
|
|
651
|
+
const max = end && name === "status.text"
|
|
652
|
+
? PALETTE_LEAD_LIMITS.statusEndText
|
|
653
|
+
: limit;
|
|
639
654
|
const [first, second] = name.split(".");
|
|
640
655
|
const value = second
|
|
641
656
|
? p[first]?.[second]
|
|
@@ -660,6 +675,19 @@ export function builtinHandlers(host, inner) {
|
|
|
660
675
|
state !== null &&
|
|
661
676
|
!LEAD_STATES.includes(state))
|
|
662
677
|
throw new HostError("invalid", `status.state is one of ${LEAD_STATES.join(", ")}`);
|
|
678
|
+
// The strip's own text (1.8.0), checked last: for a working status
|
|
679
|
+
// only, then as a text of the strip's one line.
|
|
680
|
+
const strip = status?.strip;
|
|
681
|
+
if (strip !== undefined && strip !== null) {
|
|
682
|
+
if (end)
|
|
683
|
+
throw new HostError("invalid", "status.strip is for a working status");
|
|
684
|
+
const shown = declaredText(host, inner, strip, "status.strip");
|
|
685
|
+
const length = [...shown].length;
|
|
686
|
+
if (length < 1 ||
|
|
687
|
+
length > PALETTE_LEAD_LIMITS.statusStrip ||
|
|
688
|
+
/[\0\n\r]/.test(shown))
|
|
689
|
+
throw new HostError("invalid", `status.strip must be 1–${PALETTE_LEAD_LIMITS.statusStrip} characters on one line`);
|
|
690
|
+
}
|
|
663
691
|
host.paletteLead = { ...p };
|
|
664
692
|
},
|
|
665
693
|
"palette.lead.clear": () => {
|
|
@@ -1990,6 +1990,57 @@ export declare class TestHost implements Transport {
|
|
|
1990
1990
|
active: boolean;
|
|
1991
1991
|
};
|
|
1992
1992
|
};
|
|
1993
|
+
/**
|
|
1994
|
+
* The mpv pass-through (`plugin.mpv`), without an mpv: `commands` are
|
|
1995
|
+
* the commands the plugin sent, in order (they do nothing else);
|
|
1996
|
+
* `properties` is what `get` answers and `set` writes (a property not in
|
|
1997
|
+
* it fails `backend`, "mpv: property not found"); `labels` are the
|
|
1998
|
+
* owners of filter labels by `"vf/<label>"` or `"af/<label>"` (preset
|
|
1999
|
+
* another plugin's id to test `conflict`); `observed` are the properties
|
|
2000
|
+
* the plugin observes. The player's refusals apply (`refused`,
|
|
2001
|
+
* `invalid`, the limit of 64 observed properties), from the same table
|
|
2002
|
+
* as the player's.
|
|
2003
|
+
*
|
|
2004
|
+
* @since 1.8.0
|
|
2005
|
+
*/
|
|
2006
|
+
readonly mpv: {
|
|
2007
|
+
/** The commands the plugin sent, in order, as their arrays. */
|
|
2008
|
+
commands: (string | number | boolean)[][];
|
|
2009
|
+
/** Property values by name: what `get` answers and `set` writes. */
|
|
2010
|
+
properties: Map<string, Json>;
|
|
2011
|
+
/** The owner (a plugin id) of each filter label, by `"vf/<label>"` or `"af/<label>"`. */
|
|
2012
|
+
labels: Map<string, string>;
|
|
2013
|
+
/** The properties the plugin observes now. */
|
|
2014
|
+
observed: Set<string>;
|
|
2015
|
+
};
|
|
2016
|
+
/**
|
|
2017
|
+
* Simulate mpv changing a property: store the value and send it to the
|
|
2018
|
+
* plugin if it observes the property (`plugin.mpv.observe`).
|
|
2019
|
+
*
|
|
2020
|
+
* @param name - The property, as mpv names it.
|
|
2021
|
+
* @param value - Its new value.
|
|
2022
|
+
*
|
|
2023
|
+
* @capability None.
|
|
2024
|
+
*
|
|
2025
|
+
* @example The frame rate behind the filters changes
|
|
2026
|
+
* The plugin's listener hears the value the test gives the property.
|
|
2027
|
+
* `setMpvProperty` stores it and sends the `mpv.property` event that
|
|
2028
|
+
* the player sends to an observer; `settle` lets it arrive.
|
|
2029
|
+
* ```ts
|
|
2030
|
+
* import assert from "node:assert/strict";
|
|
2031
|
+
* declare const host: TestHost;
|
|
2032
|
+
* // ---cut---
|
|
2033
|
+
* const seen: unknown[] = [];
|
|
2034
|
+
* plugin.mpv.observe("estimated-vf-fps", (fps) => seen.push(fps));
|
|
2035
|
+
* await host.settle();
|
|
2036
|
+
* host.setMpvProperty("estimated-vf-fps", 59.94);
|
|
2037
|
+
* await host.settle();
|
|
2038
|
+
* assert.deepEqual(seen, [null, 59.94]); // no value at first, then the change
|
|
2039
|
+
* ```
|
|
2040
|
+
*
|
|
2041
|
+
* @since 1.8.0
|
|
2042
|
+
*/
|
|
2043
|
+
setMpvProperty(name: string, value: Json): void;
|
|
1993
2044
|
/**
|
|
1994
2045
|
* The player's secret store for this plugin: name → value. Preset entries
|
|
1995
2046
|
* to simulate stored secrets; inject failures with
|
|
@@ -2269,7 +2320,7 @@ export declare class TestHost implements Transport {
|
|
|
2269
2320
|
display: MotionReason | null;
|
|
2270
2321
|
/** GPU rendering is still starting: a `rendering` reason then lets `set` keep the request. */
|
|
2271
2322
|
renderingStarting: boolean;
|
|
2272
|
-
/** The
|
|
2323
|
+
/** The converter's input rate (`MotionState.sourceFps`); `null`: not known yet (nothing is active). */
|
|
2273
2324
|
sourceFps: number | null;
|
|
2274
2325
|
/** The measured output rate while active; `null`: twice `sourceFps`. */
|
|
2275
2326
|
outputFps: number | null;
|
|
@@ -90,6 +90,7 @@ import { registerCoreActions, windowFacts, coreActionsHandlers, } from "./core-a
|
|
|
90
90
|
import { translate, i18nHandlers } from "./i18n.js";
|
|
91
91
|
import { mountOther, unmountOther, mounted, setTimelineRanges, setTimelineLayer, layoutHandlers, } from "./layout.js";
|
|
92
92
|
import { osdHandlers } from "./osd.js";
|
|
93
|
+
import { mpvHandlers, setMpvProperty } from "./mpv.js";
|
|
93
94
|
import { packageDirectories } from "./slint-types.js";
|
|
94
95
|
import { failStream, jobsHandlers } from "./jobs.js";
|
|
95
96
|
import { motionState, upscalingState, failVideoRender, failVideoShaders, upscalingDecoding, processingHandlers, } from "./processing.js";
|
|
@@ -1476,6 +1477,59 @@ export class TestHost {
|
|
|
1476
1477
|
active: false,
|
|
1477
1478
|
},
|
|
1478
1479
|
};
|
|
1480
|
+
/**
|
|
1481
|
+
* The mpv pass-through (`plugin.mpv`), without an mpv: `commands` are
|
|
1482
|
+
* the commands the plugin sent, in order (they do nothing else);
|
|
1483
|
+
* `properties` is what `get` answers and `set` writes (a property not in
|
|
1484
|
+
* it fails `backend`, "mpv: property not found"); `labels` are the
|
|
1485
|
+
* owners of filter labels by `"vf/<label>"` or `"af/<label>"` (preset
|
|
1486
|
+
* another plugin's id to test `conflict`); `observed` are the properties
|
|
1487
|
+
* the plugin observes. The player's refusals apply (`refused`,
|
|
1488
|
+
* `invalid`, the limit of 64 observed properties), from the same table
|
|
1489
|
+
* as the player's.
|
|
1490
|
+
*
|
|
1491
|
+
* @since 1.8.0
|
|
1492
|
+
*/
|
|
1493
|
+
mpv = {
|
|
1494
|
+
/** The commands the plugin sent, in order, as their arrays. */
|
|
1495
|
+
commands: [],
|
|
1496
|
+
/** Property values by name: what `get` answers and `set` writes. */
|
|
1497
|
+
properties: new Map(),
|
|
1498
|
+
/** The owner (a plugin id) of each filter label, by `"vf/<label>"` or `"af/<label>"`. */
|
|
1499
|
+
labels: new Map(),
|
|
1500
|
+
/** The properties the plugin observes now. */
|
|
1501
|
+
observed: new Set(),
|
|
1502
|
+
};
|
|
1503
|
+
/**
|
|
1504
|
+
* Simulate mpv changing a property: store the value and send it to the
|
|
1505
|
+
* plugin if it observes the property (`plugin.mpv.observe`).
|
|
1506
|
+
*
|
|
1507
|
+
* @param name - The property, as mpv names it.
|
|
1508
|
+
* @param value - Its new value.
|
|
1509
|
+
*
|
|
1510
|
+
* @capability None.
|
|
1511
|
+
*
|
|
1512
|
+
* @example The frame rate behind the filters changes
|
|
1513
|
+
* The plugin's listener hears the value the test gives the property.
|
|
1514
|
+
* `setMpvProperty` stores it and sends the `mpv.property` event that
|
|
1515
|
+
* the player sends to an observer; `settle` lets it arrive.
|
|
1516
|
+
* ```ts
|
|
1517
|
+
* import assert from "node:assert/strict";
|
|
1518
|
+
* declare const host: TestHost;
|
|
1519
|
+
* // ---cut---
|
|
1520
|
+
* const seen: unknown[] = [];
|
|
1521
|
+
* plugin.mpv.observe("estimated-vf-fps", (fps) => seen.push(fps));
|
|
1522
|
+
* await host.settle();
|
|
1523
|
+
* host.setMpvProperty("estimated-vf-fps", 59.94);
|
|
1524
|
+
* await host.settle();
|
|
1525
|
+
* assert.deepEqual(seen, [null, 59.94]); // no value at first, then the change
|
|
1526
|
+
* ```
|
|
1527
|
+
*
|
|
1528
|
+
* @since 1.8.0
|
|
1529
|
+
*/
|
|
1530
|
+
setMpvProperty(name, value) {
|
|
1531
|
+
setMpvProperty(this, name, value);
|
|
1532
|
+
}
|
|
1479
1533
|
/**
|
|
1480
1534
|
* The player's secret store for this plugin: name → value. Preset entries
|
|
1481
1535
|
* to simulate stored secrets; inject failures with
|
|
@@ -2813,6 +2867,7 @@ export class TestHost {
|
|
|
2813
2867
|
...i18nHandlers(this, this.#inner),
|
|
2814
2868
|
...layoutHandlers(this, this.#inner),
|
|
2815
2869
|
...osdHandlers(this, this.#inner),
|
|
2870
|
+
...mpvHandlers(this, this.#inner),
|
|
2816
2871
|
...jobsHandlers(this, this.#inner),
|
|
2817
2872
|
...processingHandlers(this, this.#inner),
|
|
2818
2873
|
...mediaHandlers(this, this.#inner),
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Json } from "../../wire.ts";
|
|
2
|
+
import type { TestHost } from "./index.ts";
|
|
3
|
+
import type { Handler, Internals } from "./internals.ts";
|
|
4
|
+
/** Implements `TestHost.setMpvProperty`. */
|
|
5
|
+
export declare function setMpvProperty(host: TestHost, name: string, value: Json): void;
|
|
6
|
+
/** The default handlers of this area's wire methods, by method name. */
|
|
7
|
+
export declare function mpvHandlers(host: TestHost, _inner: Internals): Record<string, Handler>;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The mpv pass-through (`mpv.command`, `mpv.get`, `mpv.set`,
|
|
3
|
+
* `mpv.observe`, `mpv.unobserve`): the player's refusals from the shared
|
|
4
|
+
* table (`src/mpv.ts`), a record of what was sent, a store of property
|
|
5
|
+
* values and the owners of filter labels. No mpv: a command does nothing
|
|
6
|
+
* but be recorded.
|
|
7
|
+
*
|
|
8
|
+
* Part of `TestHost` (`./index.ts`): functions over the host and its private
|
|
9
|
+
* state (`Internals`, `./internals.ts`) that the class delegates to.
|
|
10
|
+
* Internal to the SDK; not exported from `@vestra-player/sdk/testing`.
|
|
11
|
+
*/
|
|
12
|
+
import { MPV_LIMITS, mpvCommandProblem, mpvCommandRefusal, mpvFilterChange, mpvNameProblem, mpvPropertyRefusal, } from "../../mpv.js";
|
|
13
|
+
import { HostError } from "../../wire.js";
|
|
14
|
+
/** The property a request names, checked as the player checks it. */
|
|
15
|
+
function property(name, write) {
|
|
16
|
+
const problem = mpvNameProblem(name);
|
|
17
|
+
if (problem)
|
|
18
|
+
throw new HostError("invalid", problem);
|
|
19
|
+
const refused = mpvPropertyRefusal(name, write);
|
|
20
|
+
if (refused)
|
|
21
|
+
throw new HostError("refused", refused);
|
|
22
|
+
return name;
|
|
23
|
+
}
|
|
24
|
+
/** Implements `TestHost.setMpvProperty`. */
|
|
25
|
+
export function setMpvProperty(host, name, value) {
|
|
26
|
+
host.mpv.properties.set(name, value);
|
|
27
|
+
if (host.mpv.observed.has(name))
|
|
28
|
+
host.emit("mpv.property", { name, value });
|
|
29
|
+
}
|
|
30
|
+
/** The default handlers of this area's wire methods, by method name. */
|
|
31
|
+
export function mpvHandlers(host, _inner) {
|
|
32
|
+
return {
|
|
33
|
+
"mpv.command": (p) => {
|
|
34
|
+
const problem = mpvCommandProblem(p.args);
|
|
35
|
+
if (problem)
|
|
36
|
+
throw new HostError("invalid", problem);
|
|
37
|
+
const args = p.args;
|
|
38
|
+
const refused = mpvCommandRefusal(args);
|
|
39
|
+
if (refused)
|
|
40
|
+
throw new HostError("refused", refused);
|
|
41
|
+
// A filter label has one owner; the player removes a stopped
|
|
42
|
+
// plugin's filters, a test host has only the one plugin.
|
|
43
|
+
const change = mpvFilterChange(args);
|
|
44
|
+
if (change) {
|
|
45
|
+
const key = `${change.stage}/${change.label}`;
|
|
46
|
+
const owner = host.mpv.labels.get(key);
|
|
47
|
+
if (owner !== undefined && owner !== host.manifestId)
|
|
48
|
+
throw new HostError("conflict", `the filter label @${change.label} belongs to ${owner}`);
|
|
49
|
+
const remove = change.operation === "remove" ||
|
|
50
|
+
(change.operation === "toggle" && owner !== undefined);
|
|
51
|
+
if (remove)
|
|
52
|
+
host.mpv.labels.delete(key);
|
|
53
|
+
else
|
|
54
|
+
host.mpv.labels.set(key, host.manifestId);
|
|
55
|
+
}
|
|
56
|
+
host.mpv.commands.push([...args]);
|
|
57
|
+
return { result: null };
|
|
58
|
+
},
|
|
59
|
+
"mpv.get": (p) => {
|
|
60
|
+
const name = property(p.name, false);
|
|
61
|
+
if (!host.mpv.properties.has(name))
|
|
62
|
+
throw new HostError("backend", "mpv: property not found");
|
|
63
|
+
return { value: host.mpv.properties.get(name) };
|
|
64
|
+
},
|
|
65
|
+
"mpv.set": (p) => {
|
|
66
|
+
const name = property(p.name, true);
|
|
67
|
+
if (p.value === undefined)
|
|
68
|
+
throw new HostError("invalid", "set takes a value");
|
|
69
|
+
setMpvProperty(host, name, p.value);
|
|
70
|
+
},
|
|
71
|
+
"mpv.observe": (p) => {
|
|
72
|
+
const name = property(p.name, false);
|
|
73
|
+
if (!host.mpv.observed.has(name) &&
|
|
74
|
+
host.mpv.observed.size >= MPV_LIMITS.observed)
|
|
75
|
+
throw new HostError("limit", `a plugin observes at most ${MPV_LIMITS.observed} mpv properties`);
|
|
76
|
+
host.mpv.observed.add(name);
|
|
77
|
+
// The current value first, as mpv sends it (nothing: null).
|
|
78
|
+
queueMicrotask(() => {
|
|
79
|
+
if (host.mpv.observed.has(name))
|
|
80
|
+
host.emit("mpv.property", {
|
|
81
|
+
name,
|
|
82
|
+
value: host.mpv.properties.get(name) ?? null,
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
},
|
|
86
|
+
"mpv.unobserve": (p) => {
|
|
87
|
+
host.mpv.observed.delete(property(p.name, false));
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
}
|
|
@@ -12,7 +12,7 @@ import type { PropValue, View } from "./ui-content.ts";
|
|
|
12
12
|
import type { Panel, Window } from "./ui-layout.ts";
|
|
13
13
|
import type { Bindings, Commands, Host, Palette, When } from "./commands.ts";
|
|
14
14
|
import type { Packages } from "./packages.ts";
|
|
15
|
-
import type { Player, Timeline } from "./playback.ts";
|
|
15
|
+
import type { Mpv, Player, Timeline } from "./playback.ts";
|
|
16
16
|
import type { AudioFilter, RenderOptions, VideoFilter, MotionEngine, VideoMotion, VideoShaders, VideoUpscaling, VideoView } from "./processing.ts";
|
|
17
17
|
import type { Clipboard, Power, Rendering, RenderingReason, Secrets, Storage, System, Tools } from "./services.ts";
|
|
18
18
|
import type { MediaCapture } from "./snapshots.ts";
|
|
@@ -103,7 +103,8 @@ export interface Disposable {
|
|
|
103
103
|
* | `conflict` | Another plugin owns the resource (the sequence provider, the display layer, the backdrop, a menu path, the command palette's lead row), or this plugin already uses the id (a window or command id). |
|
|
104
104
|
* | `unavailable` | Not possible right now (no ready media, no user interface, fullscreen, a disabled core action). |
|
|
105
105
|
* | `unsupported` | Not possible on this system, build or source (a platform gap, software rendering, a source that cannot seek, a filter on a generated stream, an export the player cannot make as asked: a stream copy, a source bitrate it cannot tell). |
|
|
106
|
-
* | `backend` | Loading or resolving failed; `message` is the backend's reason. |
|
|
106
|
+
* | `backend` | Loading or resolving failed, or mpv failed a command or a property of {@link Mpv}; `message` is the backend's reason. |
|
|
107
|
+
* | `refused` | {@link Mpv}: a command or a property the pass-through does not carry (it would start a program, load code, write files, end the player, or change what the player manages); `message` names it and why. |
|
|
107
108
|
* | `failed` | The operation ran and failed (`media.ready()` load error, a non-zero `tools.run` exit, the system refused). |
|
|
108
109
|
* | `replaced` | Accepted, but another source replaced it before it finished. |
|
|
109
110
|
* | `ended` | {@link Media.ready}: the media already played to the end. |
|
|
@@ -348,6 +349,12 @@ export interface Scope extends Disposable {
|
|
|
348
349
|
readonly system: System;
|
|
349
350
|
/** Small secrets in the system's secret store (`secrets`). */
|
|
350
351
|
readonly secrets: Secrets;
|
|
352
|
+
/**
|
|
353
|
+
* mpv's own commands and properties, sent as they are (`mpv`).
|
|
354
|
+
*
|
|
355
|
+
* @since 1.8.0
|
|
356
|
+
*/
|
|
357
|
+
readonly mpv: Mpv;
|
|
351
358
|
/** The main window: fullscreen, video area, size, level, pointer hiding. */
|
|
352
359
|
readonly window: MainWindow;
|
|
353
360
|
/** The player's version and components, and the system it runs on. */
|
|
@@ -1175,21 +1175,44 @@ export interface PaletteLeadOptions {
|
|
|
1175
1175
|
* the top of the main window, as its `state` says.
|
|
1176
1176
|
*/
|
|
1177
1177
|
status?: {
|
|
1178
|
-
/**
|
|
1178
|
+
/**
|
|
1179
|
+
* The status text, on one line: up to 80 characters while working; up
|
|
1180
|
+
* to 160 for an end state, which the strip shows on up to two lines
|
|
1181
|
+
* (since 1.8.0; 80 before).
|
|
1182
|
+
*/
|
|
1179
1183
|
text: string | Text;
|
|
1180
1184
|
/** On the right of the row (up to 40 characters). */
|
|
1181
1185
|
note?: string | Text;
|
|
1186
|
+
/**
|
|
1187
|
+
* What the status strip shows instead of `text` while working (1–80
|
|
1188
|
+
* characters on one line), for a row that says more than the strip
|
|
1189
|
+
* needs: the row reads "Vestra is working · Planning…", the strip
|
|
1190
|
+
* "Planning…". Absent: the strip shows `text`. Only for a working
|
|
1191
|
+
* status: an end state is shown in the strip alone, so its `text` is
|
|
1192
|
+
* the strip's, and `strip` with one is `invalid`. Like a working
|
|
1193
|
+
* `text`, it does not change the strip once {@link Commands.run} has
|
|
1194
|
+
* shown a step of the ticket there.
|
|
1195
|
+
*
|
|
1196
|
+
* Sent only when set: players before it refuse the field (`invalid`,
|
|
1197
|
+
* through `ready`, or `update` rejects).
|
|
1198
|
+
*
|
|
1199
|
+
* @since 1.8.0
|
|
1200
|
+
*/
|
|
1201
|
+
strip?: string | Text;
|
|
1182
1202
|
/**
|
|
1183
1203
|
* Still working or ended. Absent: `"working"`.
|
|
1184
1204
|
*
|
|
1185
1205
|
* - `"working"`: the work goes on. The strip shows the text with a
|
|
1186
1206
|
* moving line and a Stop button (Stop is Enter on the status row)
|
|
1187
1207
|
* and stays until the status changes or is removed.
|
|
1188
|
-
* - `"done"`, `"failed"`, `"note"`: an end state
|
|
1189
|
-
* sentence for the user, such as an answer
|
|
1190
|
-
*
|
|
1191
|
-
*
|
|
1192
|
-
*
|
|
1208
|
+
* - `"done"`, `"failed"`, `"note"`, `"stopped"`: an end state
|
|
1209
|
+
* (finished; failed; a sentence for the user, such as an answer; the
|
|
1210
|
+
* user stopped the work). The player shows it with a check, in the
|
|
1211
|
+
* danger colour, plain, or plain with its icon dimmed, then removes
|
|
1212
|
+
* it by itself after a few seconds (about 2 s, 6 s, 4–10 s by
|
|
1213
|
+
* length, and 2 s; longer while the pointer is on it). `"stopped"`
|
|
1214
|
+
* (since 1.8.0) says that nothing came of the request, which `"note"`
|
|
1215
|
+
* cannot: use it for the text shown after Stop. It is shown once: not kept,
|
|
1193
1216
|
* not shown again later (when the plugin is stopped or woken), and
|
|
1194
1217
|
* the row goes back to its usual form. The plugin needs no timer of
|
|
1195
1218
|
* its own and may call {@link PaletteLead.done} right after setting
|
|
@@ -1199,13 +1222,14 @@ export interface PaletteLeadOptions {
|
|
|
1199
1222
|
* strip, a `"working"` text changes only the palette's status row,
|
|
1200
1223
|
* until an end state, `status: null` or the end of the ticket.
|
|
1201
1224
|
*
|
|
1202
|
-
* Players before the status strip refuse the field (`invalid`)
|
|
1203
|
-
*
|
|
1204
|
-
* (through `ready`,
|
|
1225
|
+
* Players before the status strip refuse the field (`invalid`), and
|
|
1226
|
+
* players before SDK 1.8.0's refuse `"stopped"`; a built-in plugin
|
|
1227
|
+
* ships with its player. Any other value: `invalid` (through `ready`,
|
|
1228
|
+
* or `update` rejects).
|
|
1205
1229
|
*
|
|
1206
1230
|
* @since 1.7.15
|
|
1207
1231
|
*/
|
|
1208
|
-
state?: "working" | "done" | "failed" | "note";
|
|
1232
|
+
state?: "working" | "done" | "failed" | "note" | "stopped";
|
|
1209
1233
|
} | null;
|
|
1210
1234
|
}
|
|
1211
1235
|
/**
|