@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
|
@@ -2,6 +2,12 @@ import type { Json } from "../../wire.ts";
|
|
|
2
2
|
import type { SourceState } from "../../source.ts";
|
|
3
3
|
import type { TestHost } from "./index.ts";
|
|
4
4
|
import type { Handler, Internals } from "./internals.ts";
|
|
5
|
+
/**
|
|
6
|
+
* Broadcast the source state `host.source` became from `previous`, then
|
|
7
|
+
* the discrete source events it adds (`source.opening`, `source.ready`,
|
|
8
|
+
* `source.ended`), as the player sends them after it.
|
|
9
|
+
*/
|
|
10
|
+
export declare function emitSource(host: TestHost, previous: SourceState, reload?: boolean): void;
|
|
5
11
|
export declare function initialSource(): SourceState;
|
|
6
12
|
export declare const readyCapabilities: {
|
|
7
13
|
pause: boolean;
|
|
@@ -13,6 +13,17 @@ import { isTextValue } from "../../i18n.js";
|
|
|
13
13
|
import { taken } from "./transport.js";
|
|
14
14
|
import { declaredText, hostText } from "./i18n.js";
|
|
15
15
|
import { timelineChanged } from "./layout.js";
|
|
16
|
+
import { sourceEvents } from "./source-events.js";
|
|
17
|
+
/**
|
|
18
|
+
* Broadcast the source state `host.source` became from `previous`, then
|
|
19
|
+
* the discrete source events it adds (`source.opening`, `source.ready`,
|
|
20
|
+
* `source.ended`), as the player sends them after it.
|
|
21
|
+
*/
|
|
22
|
+
export function emitSource(host, previous, reload = false) {
|
|
23
|
+
host.emit("source.state", host.source);
|
|
24
|
+
for (const [name, data] of sourceEvents(previous, host.source, reload))
|
|
25
|
+
host.emit(name, structuredClone(data));
|
|
26
|
+
}
|
|
16
27
|
export function initialSource() {
|
|
17
28
|
return {
|
|
18
29
|
kind: "media",
|
|
@@ -145,12 +156,13 @@ export function sourceIntent(host, inner, intent) {
|
|
|
145
156
|
inner.selected = Number(intent.producerId);
|
|
146
157
|
if (intent.kind === "open" || intent.kind === "close")
|
|
147
158
|
inner.selected = null;
|
|
159
|
+
const previous = host.source;
|
|
148
160
|
host.source = next;
|
|
149
161
|
host.subtitles.source = {
|
|
150
162
|
generation: next.stamp.generation,
|
|
151
163
|
phase: next.phase,
|
|
152
164
|
};
|
|
153
|
-
host.
|
|
165
|
+
emitSource(host, previous, intent.kind === "restart");
|
|
154
166
|
cancelResolutions(host, inner);
|
|
155
167
|
return { ticket: { stamp: next.stamp, cycle: next.cycle, owner: 1 } };
|
|
156
168
|
}
|
|
@@ -389,6 +401,7 @@ export function setSource(host, inner, patch) {
|
|
|
389
401
|
// (the player reads this as the end arrives).
|
|
390
402
|
if (patch.phase === "ended" && host.source.phase !== "ended")
|
|
391
403
|
inner.endKeepsPause = inner.stepped || host.source.paused;
|
|
404
|
+
const previous = host.source;
|
|
392
405
|
host.source = {
|
|
393
406
|
...host.source,
|
|
394
407
|
...patch,
|
|
@@ -400,7 +413,7 @@ export function setSource(host, inner, patch) {
|
|
|
400
413
|
generation: host.source.stamp.generation,
|
|
401
414
|
phase: host.source.phase,
|
|
402
415
|
};
|
|
403
|
-
host
|
|
416
|
+
emitSource(host, previous);
|
|
404
417
|
// Like the player (reference §6.3): loading shows the backdrop.
|
|
405
418
|
if (patch.phase === "loading" && host.backdrop && !host.backdrop.effective)
|
|
406
419
|
host.setBackdropEffective(true);
|
|
@@ -423,7 +423,7 @@ export function processingHandlers(host, inner) {
|
|
|
423
423
|
host.setVideoRenderOwner(null);
|
|
424
424
|
return null;
|
|
425
425
|
},
|
|
426
|
-
// The player's
|
|
426
|
+
// The player's request layer and `video_shaders.rs`.
|
|
427
427
|
"video.shaders.set": (p) => {
|
|
428
428
|
const idProblem = shaderIdProblem(p.id);
|
|
429
429
|
if (idProblem)
|
|
@@ -436,7 +436,6 @@ export function servicesHandlers(host, inner) {
|
|
|
436
436
|
origin: "installed",
|
|
437
437
|
state: enabled ? "running" : "disabled",
|
|
438
438
|
error: null,
|
|
439
|
-
capabilities: [...manifest.capabilities],
|
|
440
439
|
directory: `/test-host/packages/${manifest.id}`,
|
|
441
440
|
builtin: false,
|
|
442
441
|
source,
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The discrete source events of the test host: `source.opening`,
|
|
3
|
+
* `source.ready` and `source.ended`, derived from two consecutive source
|
|
4
|
+
* states by the player's rules (player `src/host/src/source_events.rs`;
|
|
5
|
+
* the cases of its tests are repeated in test/source-events.test.ts).
|
|
6
|
+
*
|
|
7
|
+
* A playthrough is one load of a source (`stamp.generation`, `cycle`); it
|
|
8
|
+
* is in playback while `loading` or `ready`. One that leaves playback gets
|
|
9
|
+
* `ended` (its last state: the state that says it ended, or the last one
|
|
10
|
+
* before a replacement or a close); a new one gets `opening`, then
|
|
11
|
+
* `ready`. A new cycle of the same source that is not loading is a seek
|
|
12
|
+
* away from the end: it plays on, nothing opens. The test host's restart
|
|
13
|
+
* goes to `ready` at once, so it says it is a new load (`reload`).
|
|
14
|
+
*
|
|
15
|
+
* Internal to the SDK; not exported from `@vestra-player/sdk/testing`.
|
|
16
|
+
*/
|
|
17
|
+
import type { SourceState } from "../../source.ts";
|
|
18
|
+
export type SourceEventName = "source.opening" | "source.ready" | "source.ended";
|
|
19
|
+
/** The events `next` adds to `previous`, in order. */
|
|
20
|
+
export declare function sourceEvents(previous: SourceState, next: SourceState, reload?: boolean): [SourceEventName, unknown][];
|
|
21
|
+
/**
|
|
22
|
+
* `source.ended` with `reason: "quit"` for a source in playback (the
|
|
23
|
+
* player quits; only a running plugin gets it).
|
|
24
|
+
*/
|
|
25
|
+
export declare function quitEvent(state: SourceState): {
|
|
26
|
+
state: SourceState;
|
|
27
|
+
reason: string;
|
|
28
|
+
} | null;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
const inPlayback = (s) => s.source !== null && (s.phase === "loading" || s.phase === "ready");
|
|
2
|
+
const samePlaythrough = (a, b) => a.stamp.generation === b.stamp.generation && a.cycle === b.cycle;
|
|
3
|
+
/** `source.ended`'s data for a playthrough that ended in `state`. */
|
|
4
|
+
function endedIn(state) {
|
|
5
|
+
const reason = state.terminalReason;
|
|
6
|
+
if (state.phase === "error")
|
|
7
|
+
return reason !== null && typeof reason === "object"
|
|
8
|
+
? { state, reason: "error", error: reason.failed }
|
|
9
|
+
: { state, reason: "error" };
|
|
10
|
+
return {
|
|
11
|
+
state,
|
|
12
|
+
reason: reason === "natural" || reason === "replaced" ? reason : "stopped",
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/** The events `next` adds to `previous`, in order. */
|
|
16
|
+
export function sourceEvents(previous, next, reload = false) {
|
|
17
|
+
const events = [];
|
|
18
|
+
const open = next.source !== null;
|
|
19
|
+
const same = samePlaythrough(previous, next);
|
|
20
|
+
const resumed = !reload &&
|
|
21
|
+
previous.source !== null &&
|
|
22
|
+
previous.stamp.generation === next.stamp.generation &&
|
|
23
|
+
previous.cycle !== next.cycle &&
|
|
24
|
+
previous.phase === "ended" &&
|
|
25
|
+
next.phase !== "loading";
|
|
26
|
+
const begins = open && !same && !resumed;
|
|
27
|
+
if (inPlayback(previous) && !(same && inPlayback(next))) {
|
|
28
|
+
if (same && open)
|
|
29
|
+
events.push(["source.ended", endedIn(next)]);
|
|
30
|
+
else if (!open && next.stamp.generation === previous.stamp.generation)
|
|
31
|
+
events.push(["source.ended", { state: previous, reason: "stopped" }]);
|
|
32
|
+
else
|
|
33
|
+
events.push(["source.ended", { state: previous, reason: "replaced" }]);
|
|
34
|
+
}
|
|
35
|
+
if (begins) {
|
|
36
|
+
events.push([
|
|
37
|
+
"source.opening",
|
|
38
|
+
{
|
|
39
|
+
state: next,
|
|
40
|
+
previous: previous.source !== null
|
|
41
|
+
? { sourceId: previous.stamp.generation }
|
|
42
|
+
: null,
|
|
43
|
+
},
|
|
44
|
+
]);
|
|
45
|
+
if (next.phase === "ready" || next.phase === "ended")
|
|
46
|
+
events.push(["source.ready", { state: next }]);
|
|
47
|
+
if (next.phase === "ended" || next.phase === "error")
|
|
48
|
+
events.push(["source.ended", endedIn(next)]);
|
|
49
|
+
}
|
|
50
|
+
else if (same && previous.phase === "loading" && open) {
|
|
51
|
+
if (next.phase === "ready" || next.phase === "ended")
|
|
52
|
+
events.push(["source.ready", { state: next }]);
|
|
53
|
+
// Loading straight to its end: ready, then ended.
|
|
54
|
+
const at = events.findIndex(([name]) => name === "source.ended");
|
|
55
|
+
if (next.phase === "ended" && at >= 0)
|
|
56
|
+
events.push(...events.splice(at, 1));
|
|
57
|
+
}
|
|
58
|
+
return events;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* `source.ended` with `reason: "quit"` for a source in playback (the
|
|
62
|
+
* player quits; only a running plugin gets it).
|
|
63
|
+
*/
|
|
64
|
+
export function quitEvent(state) {
|
|
65
|
+
return inPlayback(state) ? { state, reason: "quit" } : null;
|
|
66
|
+
}
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
import { rmSync } from "node:fs";
|
|
10
10
|
import { HostError } from "../../wire.js";
|
|
11
11
|
import { WAKE_EVENTS } from "../connection.js";
|
|
12
|
+
import { hearEvent } from "./triggers.js";
|
|
12
13
|
export const tick = () => new Promise((resolve) => setImmediate(resolve));
|
|
13
14
|
/**
|
|
14
15
|
* Refusals for a position or resolver another plugin holds: not activation
|
|
@@ -49,6 +50,10 @@ export function on(_host, inner, event, listener) {
|
|
|
49
50
|
}
|
|
50
51
|
/** Implements `TestHost.emit`. */
|
|
51
52
|
export function emit(host, inner, event, data) {
|
|
53
|
+
// Trigger conditions first (the player evaluates them before it sends
|
|
54
|
+
// the state); a parked plugin hears nothing, a wake event wakes it.
|
|
55
|
+
if (hearEvent(host, inner, event, data))
|
|
56
|
+
return;
|
|
52
57
|
if ([
|
|
53
58
|
"source.state",
|
|
54
59
|
"playback.backend",
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { Json } from "../../wire.ts";
|
|
2
|
+
import { matchedRange } from "../when.ts";
|
|
3
|
+
import type { ConditionFacts, ConditionJson } from "../when.ts";
|
|
4
|
+
import type { TestHost } from "./index.ts";
|
|
5
|
+
import type { Handler, Internals } from "./internals.ts";
|
|
6
|
+
/**
|
|
7
|
+
* One kept trigger condition, as `TestHost.triggers` lists it.
|
|
8
|
+
*
|
|
9
|
+
* @since 1.10.0
|
|
10
|
+
* @category Testing
|
|
11
|
+
*/
|
|
12
|
+
export interface KeptTrigger {
|
|
13
|
+
/** The trigger: its name, or its place among the unnamed ones. */
|
|
14
|
+
readonly trigger: number | string;
|
|
15
|
+
/** The condition in the wire form. */
|
|
16
|
+
readonly when: Json;
|
|
17
|
+
/** Its sequence number. */
|
|
18
|
+
readonly seq: number;
|
|
19
|
+
/** It holds now ("entered"). */
|
|
20
|
+
readonly entered: boolean;
|
|
21
|
+
}
|
|
22
|
+
interface Kept {
|
|
23
|
+
trigger: number | string;
|
|
24
|
+
when: ConditionJson;
|
|
25
|
+
seq: number;
|
|
26
|
+
/** The source its position list belongs to. */
|
|
27
|
+
bound: number | null;
|
|
28
|
+
/** Entered, with the range it is in. */
|
|
29
|
+
entered: {
|
|
30
|
+
range: number | null;
|
|
31
|
+
} | null;
|
|
32
|
+
/** The run that gave it. */
|
|
33
|
+
run: number;
|
|
34
|
+
}
|
|
35
|
+
/** What the player keeps for the plugin's triggers. */
|
|
36
|
+
declare class TriggerState {
|
|
37
|
+
readonly kept: Map<string, Kept>;
|
|
38
|
+
seq: number;
|
|
39
|
+
/** The run (process generation): a park, a wake and an upgrade start one. */
|
|
40
|
+
run: number;
|
|
41
|
+
/** How many unnamed triggers this version declared. */
|
|
42
|
+
unnamed: number | null;
|
|
43
|
+
/** The virtual wall clock (Unix ms). */
|
|
44
|
+
now: number;
|
|
45
|
+
parked: boolean;
|
|
46
|
+
/** The wake events the plugin listened to when it was parked. */
|
|
47
|
+
wakes: Set<string>;
|
|
48
|
+
/** What waits for the next start: (merge key, event, data). */
|
|
49
|
+
backlog: [string, string, unknown][];
|
|
50
|
+
waking: Promise<void> | undefined;
|
|
51
|
+
/** The backlog is delivered now (at the woken plugin's ready). */
|
|
52
|
+
flushing: boolean;
|
|
53
|
+
/** Starts the plugin again (`startPlugin`); `entry`: other code (an upgrade). */
|
|
54
|
+
start: ((entry?: (plugin: never) => unknown) => Promise<void>) | undefined;
|
|
55
|
+
/** Stops the running plugin with a reason. */
|
|
56
|
+
stop: ((reason: string) => Promise<void>) | undefined;
|
|
57
|
+
/** Evaluating: no evaluation inside another. */
|
|
58
|
+
busy: boolean;
|
|
59
|
+
}
|
|
60
|
+
export declare function triggerState(host: TestHost): TriggerState;
|
|
61
|
+
/** The facts the player's conditions read, from the host. */
|
|
62
|
+
export declare function conditionFacts(host: TestHost, state?: TriggerState): ConditionFacts;
|
|
63
|
+
/** Evaluates `only` (or every kept condition) and sends what flipped (T1, T10). */
|
|
64
|
+
export declare function evaluateTriggers(host: TestHost, inner: Internals, only?: Kept): void;
|
|
65
|
+
/**
|
|
66
|
+
* `emit` of `event`: the trigger conditions are evaluated first for the
|
|
67
|
+
* player's own state changes; a wake event for a parked plugin that listened
|
|
68
|
+
* to it is held and wakes it (`true`: not delivered now).
|
|
69
|
+
*/
|
|
70
|
+
export declare function hearEvent(host: TestHost, inner: Internals, event: string, data: unknown): boolean;
|
|
71
|
+
/** `TestHost.triggers`. */
|
|
72
|
+
export declare function keptTriggers(host: TestHost): KeptTrigger[];
|
|
73
|
+
/** `TestHost.advance`: the clock and, while playing, the position move by `ms`. */
|
|
74
|
+
export declare function advance(host: TestHost, inner: Internals, ms: number): Promise<void>;
|
|
75
|
+
/** `TestHost.park`: the player puts the plugin in standby. */
|
|
76
|
+
export declare function park(host: TestHost, _inner: Internals): Promise<void>;
|
|
77
|
+
/** `TestHost.upgrade`: another version replaces the plugin (§4.2). */
|
|
78
|
+
export declare function upgrade(host: TestHost, _inner: Internals, entry?: (plugin: never) => unknown): Promise<void>;
|
|
79
|
+
/** The default handlers of this area's wire methods, by method name. */
|
|
80
|
+
export declare function triggersHandlers(host: TestHost, inner: Internals): Record<string, Handler>;
|
|
81
|
+
/** `matchedRange` for tests of the host's position lists. */
|
|
82
|
+
export { matchedRange };
|