@vestra-player/sdk 1.7.4 → 1.7.6
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 +19 -0
- package/dist/api-requests.js +0 -4
- package/dist/commands.js +1 -0
- package/dist/docs-tree.json.gz +0 -0
- package/dist/plugin/appearance.d.ts +19 -1
- package/dist/plugin/appearance.js +6 -74
- package/dist/plugin/commands.d.ts +16 -0
- package/dist/plugin/commands.js +3 -27
- package/dist/plugin/connection.d.ts +6 -0
- package/dist/plugin/connection.js +30 -2
- package/dist/plugin/index.js +2 -0
- package/dist/plugin/passes.js +0 -4
- package/dist/plugin/player/events.d.ts +2 -0
- package/dist/plugin/player/events.js +6 -2
- package/dist/plugin/player.js +8 -2
- package/dist/plugin/resolvers.js +0 -97
- package/dist/plugin/scope.d.ts +6 -0
- package/dist/plugin/scope.js +22 -3
- package/dist/plugin/testing/core-actions.d.ts +7 -0
- package/dist/plugin/testing/core-actions.js +66 -8
- package/dist/plugin/testing/index.d.ts +32 -12
- package/dist/plugin/testing/index.js +32 -12
- package/dist/plugin/testing/internals.d.ts +10 -0
- package/dist/plugin/testing/internals.js +10 -0
- package/dist/plugin/testing/media.d.ts +7 -1
- package/dist/plugin/testing/media.js +46 -3
- package/dist/plugin/testing/transport.js +3 -2
- package/dist/plugin/timeline.d.ts +2 -4
- package/dist/plugin/timeline.js +4 -27
- package/dist/plugin/types/commands.d.ts +8 -28
- package/dist/plugin/types/playback.d.ts +18 -24
- package/dist/plugin/types/sources.d.ts +0 -50
- package/dist/plugin/types/ui-locale.d.ts +4 -36
- package/dist/plugin/window.d.ts +0 -2
- package/dist/plugin/window.js +0 -4
- package/dist/wire.d.ts +1 -1
- package/llms.txt +1 -1
- package/package.json +1 -1
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import { HostError } from "../../wire.js";
|
|
10
10
|
import { validStep } from "../player/rules.js";
|
|
11
11
|
import { hostText } from "./i18n.js";
|
|
12
|
-
import { sourceIntent, audioCondition } from "./media.js";
|
|
12
|
+
import { atEndAlready, sourceIntent, audioCondition } from "./media.js";
|
|
13
13
|
export function coreFacts(host, _inner) {
|
|
14
14
|
const s = host.source;
|
|
15
15
|
const ready = s.phase === "ready";
|
|
@@ -18,7 +18,9 @@ export function coreFacts(host, _inner) {
|
|
|
18
18
|
ready,
|
|
19
19
|
ended,
|
|
20
20
|
toggle: (s.capabilities.pause && ready) || (ended && s.capabilities.restart),
|
|
21
|
-
|
|
21
|
+
// After the end too: the seek leaves the end and plays on (player
|
|
22
|
+
// 2026-11-09).
|
|
23
|
+
step: s.capabilities.seek && (ready || ended) && s.position !== null,
|
|
22
24
|
rate: s.capabilities.rate && ready,
|
|
23
25
|
close: s.capabilities.close && s.phase !== "empty",
|
|
24
26
|
};
|
|
@@ -40,6 +42,35 @@ export function frameCheck(host, inner, forward) {
|
|
|
40
42
|
return noBack;
|
|
41
43
|
return null;
|
|
42
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* One frame step that `frameCheck` allowed, as the player runs it: recorded
|
|
47
|
+
* in `steps`; back from the end an exact seek one frame (`stats` fps, else
|
|
48
|
+
* 30) before the position that stays paused; on the first frame nothing
|
|
49
|
+
* moves; any other step marks an end it reaches as keeping the pause.
|
|
50
|
+
*/
|
|
51
|
+
export function frameStep(host, inner, forward) {
|
|
52
|
+
host.steps.push({
|
|
53
|
+
unit: "frame",
|
|
54
|
+
direction: forward ? "forward" : "backward",
|
|
55
|
+
});
|
|
56
|
+
const s = host.source;
|
|
57
|
+
if (!forward && s.position !== null && s.position <= 0.001)
|
|
58
|
+
return;
|
|
59
|
+
if (!forward && s.phase === "ended") {
|
|
60
|
+
const fps = host.stats.video?.fps;
|
|
61
|
+
const frame = 1 / (fps && Number.isFinite(fps) && fps > 0 ? fps : 30);
|
|
62
|
+
inner.holdPause = true;
|
|
63
|
+
sourceIntent(host, inner, {
|
|
64
|
+
kind: "control",
|
|
65
|
+
control: {
|
|
66
|
+
kind: "seek",
|
|
67
|
+
seconds: Math.max(0, (s.position ?? 0) - frame),
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
inner.stepped = true;
|
|
73
|
+
}
|
|
43
74
|
/** The same enabled rules and reasons as the player's core actions. */
|
|
44
75
|
export function coreState(host, inner, action) {
|
|
45
76
|
const f = coreFacts(host, inner);
|
|
@@ -217,10 +248,7 @@ export function runCore(host, inner, action, seconds) {
|
|
|
217
248
|
return;
|
|
218
249
|
case "frame-back":
|
|
219
250
|
case "frame-forward":
|
|
220
|
-
host
|
|
221
|
-
unit: "frame",
|
|
222
|
-
direction: action === "frame-back" ? "backward" : "forward",
|
|
223
|
-
});
|
|
251
|
+
frameStep(host, inner, action === "frame-forward");
|
|
224
252
|
return;
|
|
225
253
|
case "seek-backward":
|
|
226
254
|
case "seek-forward": {
|
|
@@ -232,6 +260,7 @@ export function runCore(host, inner, action, seconds) {
|
|
|
232
260
|
// after the target (none: the exact target), backward on the last at
|
|
233
261
|
// or before it; only sources with moving video that can seek.
|
|
234
262
|
const keyframes = host.stepSeekKeyframes &&
|
|
263
|
+
s.phase === "ready" && // after the end: an exact seek
|
|
235
264
|
host.keyframes !== null &&
|
|
236
265
|
s.hasVideo !== false &&
|
|
237
266
|
s.capabilities.seek;
|
|
@@ -318,13 +347,42 @@ export function coreActionsHandlers(host, inner) {
|
|
|
318
347
|
audioCondition(host, inner, p.expected);
|
|
319
348
|
const s = host.source;
|
|
320
349
|
const reason = p.unit === "keyframe"
|
|
321
|
-
? s.phase === "ready"
|
|
350
|
+
? (s.phase === "ready" || s.phase === "ended") &&
|
|
351
|
+
s.capabilities.seek &&
|
|
352
|
+
s.hasVideo !== false
|
|
322
353
|
? null
|
|
323
354
|
: hostText(host, inner, "Not supported by the current source")
|
|
324
355
|
: frameCheck(host, inner, p.direction === "forward");
|
|
325
356
|
if (reason)
|
|
326
357
|
throw new HostError("unsupported", reason);
|
|
327
|
-
|
|
358
|
+
if (p.unit === "frame")
|
|
359
|
+
frameStep(host, inner, p.direction === "forward");
|
|
360
|
+
else {
|
|
361
|
+
host.steps.push({
|
|
362
|
+
unit: String(p.unit),
|
|
363
|
+
direction: String(p.direction),
|
|
364
|
+
});
|
|
365
|
+
// Like the player after the end: Previous Keyframe is a source seek
|
|
366
|
+
// to the last keyframe before the position (1 ms back; the exact
|
|
367
|
+
// target when no keyframes are modelled) that stays paused; Next
|
|
368
|
+
// Keyframe goes nowhere (the plugin says so).
|
|
369
|
+
const target = Math.max(0, (s.position ?? 0) - 0.001);
|
|
370
|
+
// "Already at the end" is decided on the raw target, as the player.
|
|
371
|
+
if (s.phase === "ended" &&
|
|
372
|
+
p.direction === "backward" &&
|
|
373
|
+
!atEndAlready(host, target)) {
|
|
374
|
+
const landed = host.keyframes === null
|
|
375
|
+
? target
|
|
376
|
+
: host.keyframes
|
|
377
|
+
.filter((k) => k <= target)
|
|
378
|
+
.reduce((a, k) => Math.max(a, k), 0);
|
|
379
|
+
inner.holdPause = true;
|
|
380
|
+
sourceIntent(host, inner, {
|
|
381
|
+
kind: "control",
|
|
382
|
+
control: { kind: "seek", seconds: landed, keyframes: true },
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
}
|
|
328
386
|
},
|
|
329
387
|
"sequence.set": (p) => {
|
|
330
388
|
host.sequence = p.flags;
|
|
@@ -834,7 +834,7 @@ export declare class TestHost implements Transport {
|
|
|
834
834
|
* declare const host: TestHost;
|
|
835
835
|
* // ---cut---
|
|
836
836
|
* void plugin.appearance.language; // read once: the SDK then follows it
|
|
837
|
-
* plugin.appearance.
|
|
837
|
+
* plugin.player.on("appearance.changed", () => {}); // subscribes to appearance events
|
|
838
838
|
* host.setLanguage("fr");
|
|
839
839
|
* await host.settle();
|
|
840
840
|
* assert.equal(plugin.appearance.language, "fr");
|
|
@@ -1223,8 +1223,8 @@ export declare class TestHost implements Transport {
|
|
|
1223
1223
|
* import assert from "node:assert/strict";
|
|
1224
1224
|
* declare const host: TestHost;
|
|
1225
1225
|
* // ---cut---
|
|
1226
|
-
* const themes:
|
|
1227
|
-
* plugin.appearance.
|
|
1226
|
+
* const themes: string[] = [];
|
|
1227
|
+
* plugin.player.on("appearance.changed", ({ theme }) => themes.push(theme)); // subscribes (`events`)
|
|
1228
1228
|
* host.setAppearance("vestra-light");
|
|
1229
1229
|
* await host.settle();
|
|
1230
1230
|
* assert.deepEqual(themes, ["vestra-light"]);
|
|
@@ -1763,14 +1763,14 @@ export declare class TestHost implements Transport {
|
|
|
1763
1763
|
hosts?: string[];
|
|
1764
1764
|
}[];
|
|
1765
1765
|
/**
|
|
1766
|
-
*
|
|
1766
|
+
* The list `resolvers.fileTypes` carries: the extensions of this
|
|
1767
1767
|
* plugin's file resolvers and of {@link TestHost.otherResolvers}, sorted,
|
|
1768
1768
|
* each once.
|
|
1769
1769
|
*
|
|
1770
1770
|
* @capability None.
|
|
1771
1771
|
*
|
|
1772
1772
|
* @example Check the file types a resolver adds
|
|
1773
|
-
* The test checks the list the plugin will
|
|
1773
|
+
* The test checks the list the plugin will hear in
|
|
1774
1774
|
* `resolvers.fileTypes`: the extensions of its own file resolvers and of
|
|
1775
1775
|
* `otherResolvers`, sorted, each once.
|
|
1776
1776
|
* ```ts
|
|
@@ -1790,18 +1790,23 @@ export declare class TestHost implements Transport {
|
|
|
1790
1790
|
* or stopped).
|
|
1791
1791
|
*
|
|
1792
1792
|
* @example Let another plugin's file type appear while running
|
|
1793
|
-
* Another plugin starts and adds `.ch8`; the plugin under test
|
|
1794
|
-
*
|
|
1795
|
-
* nothing: `updateFileTypes` sends
|
|
1796
|
-
* a plugin starts or stops, and
|
|
1793
|
+
* Another plugin starts and adds `.ch8`; the plugin under test, which
|
|
1794
|
+
* listens with `player.on("resolvers.fileTypes")`, then hears it.
|
|
1795
|
+
* Changing `otherResolvers` alone pushes nothing: `updateFileTypes` sends
|
|
1796
|
+
* the new list as the player does when a plugin starts or stops, and
|
|
1797
|
+
* `settle()` lets the listener run.
|
|
1797
1798
|
* ```ts
|
|
1798
1799
|
* import assert from "node:assert/strict";
|
|
1799
1800
|
* declare const host: TestHost;
|
|
1800
1801
|
* // ---cut---
|
|
1802
|
+
* const heard: string[][] = [];
|
|
1803
|
+
* // A listener of the event (`events`): each list the player sends.
|
|
1804
|
+
* plugin.player.on("resolvers.fileTypes", ({ fileTypes }) => heard.push(fileTypes));
|
|
1805
|
+
* // Another plugin starts with a resolver for .ch8 files.
|
|
1801
1806
|
* host.otherResolvers.push({ owner: "example.emulator", extensions: ["ch8"] });
|
|
1802
1807
|
* host.updateFileTypes();
|
|
1803
1808
|
* await host.settle();
|
|
1804
|
-
* assert.deepEqual(
|
|
1809
|
+
* assert.deepEqual(heard, [["ch8"]]);
|
|
1805
1810
|
* ```
|
|
1806
1811
|
*
|
|
1807
1812
|
* @capability None.
|
|
@@ -2213,7 +2218,14 @@ export declare class TestHost implements Transport {
|
|
|
2213
2218
|
/** `Scrub.seek(seconds, { keyframes: true })`. */
|
|
2214
2219
|
keyframes: boolean;
|
|
2215
2220
|
}[];
|
|
2216
|
-
/**
|
|
2221
|
+
/**
|
|
2222
|
+
* Every `player.step` and core frame step, newest last. The position does
|
|
2223
|
+
* not move, except a step back after the end: like the player, a seek
|
|
2224
|
+
* that stays paused, one frame back (`stats` fps, else 30) for a frame,
|
|
2225
|
+
* to the last {@link TestHost.keyframes | keyframe} before the position
|
|
2226
|
+
* (none modelled: 1 ms back) for a keyframe. A keyframe step forward
|
|
2227
|
+
* after the end goes nowhere.
|
|
2228
|
+
*/
|
|
2217
2229
|
readonly steps: {
|
|
2218
2230
|
/** `"frame"` or `"keyframe"`. */
|
|
2219
2231
|
unit: string;
|
|
@@ -2349,6 +2361,11 @@ export declare class TestHost implements Transport {
|
|
|
2349
2361
|
* changed (the user paused, playback reached the end, a file finished
|
|
2350
2362
|
* loading). Any phase other than `empty` also turns on the source
|
|
2351
2363
|
* capabilities (pause, seek, rate, ...) unless the patch sets them.
|
|
2364
|
+
* After `phase: "ended"`, a seek (a plugin's, a core step seek) returns
|
|
2365
|
+
* to `ready` and plays on (`paused: false`), as in the player; it stays
|
|
2366
|
+
* paused when the end was reached while paused or by a frame step. A
|
|
2367
|
+
* seek at or past the end (the smaller of `position` and `duration`,
|
|
2368
|
+
* 0.5 ms slack) goes nowhere: accepted, still ended and paused.
|
|
2352
2369
|
* `phase: "loading"` makes a mounted backdrop effective, like the player.
|
|
2353
2370
|
*
|
|
2354
2371
|
* @param patch - Wire-level source fields, e.g. `phase`, `position`,
|
|
@@ -2932,7 +2949,10 @@ export declare class TestHost implements Transport {
|
|
|
2932
2949
|
settle(ms?: number): Promise<void>;
|
|
2933
2950
|
/**
|
|
2934
2951
|
* Close the fake stream servers and delete the host's temporary
|
|
2935
|
-
* directories. `stop()` from {@link startPlugin} calls it.
|
|
2952
|
+
* directories. `stop()` from {@link startPlugin} calls it. It never
|
|
2953
|
+
* throws: a directory that a closing file handle still holds (Windows:
|
|
2954
|
+
* `ENOTEMPTY`, `EBUSY`, `EPERM`) is retried for about 1.5 s, then left
|
|
2955
|
+
* for the system to clean, with a warning on the console.
|
|
2936
2956
|
*
|
|
2937
2957
|
* @capability None.
|
|
2938
2958
|
*
|
|
@@ -494,7 +494,7 @@ export class TestHost {
|
|
|
494
494
|
* declare const host: TestHost;
|
|
495
495
|
* // ---cut---
|
|
496
496
|
* void plugin.appearance.language; // read once: the SDK then follows it
|
|
497
|
-
* plugin.appearance.
|
|
497
|
+
* plugin.player.on("appearance.changed", () => {}); // subscribes to appearance events
|
|
498
498
|
* host.setLanguage("fr");
|
|
499
499
|
* await host.settle();
|
|
500
500
|
* assert.equal(plugin.appearance.language, "fr");
|
|
@@ -837,8 +837,8 @@ export class TestHost {
|
|
|
837
837
|
* import assert from "node:assert/strict";
|
|
838
838
|
* declare const host: TestHost;
|
|
839
839
|
* // ---cut---
|
|
840
|
-
* const themes:
|
|
841
|
-
* plugin.appearance.
|
|
840
|
+
* const themes: string[] = [];
|
|
841
|
+
* plugin.player.on("appearance.changed", ({ theme }) => themes.push(theme)); // subscribes (`events`)
|
|
842
842
|
* host.setAppearance("vestra-light");
|
|
843
843
|
* await host.settle();
|
|
844
844
|
* assert.deepEqual(themes, ["vestra-light"]);
|
|
@@ -1292,14 +1292,14 @@ export class TestHost {
|
|
|
1292
1292
|
*/
|
|
1293
1293
|
otherResolvers = [];
|
|
1294
1294
|
/**
|
|
1295
|
-
*
|
|
1295
|
+
* The list `resolvers.fileTypes` carries: the extensions of this
|
|
1296
1296
|
* plugin's file resolvers and of {@link TestHost.otherResolvers}, sorted,
|
|
1297
1297
|
* each once.
|
|
1298
1298
|
*
|
|
1299
1299
|
* @capability None.
|
|
1300
1300
|
*
|
|
1301
1301
|
* @example Check the file types a resolver adds
|
|
1302
|
-
* The test checks the list the plugin will
|
|
1302
|
+
* The test checks the list the plugin will hear in
|
|
1303
1303
|
* `resolvers.fileTypes`: the extensions of its own file resolvers and of
|
|
1304
1304
|
* `otherResolvers`, sorted, each once.
|
|
1305
1305
|
* ```ts
|
|
@@ -1328,18 +1328,23 @@ export class TestHost {
|
|
|
1328
1328
|
* or stopped).
|
|
1329
1329
|
*
|
|
1330
1330
|
* @example Let another plugin's file type appear while running
|
|
1331
|
-
* Another plugin starts and adds `.ch8`; the plugin under test
|
|
1332
|
-
*
|
|
1333
|
-
* nothing: `updateFileTypes` sends
|
|
1334
|
-
* a plugin starts or stops, and
|
|
1331
|
+
* Another plugin starts and adds `.ch8`; the plugin under test, which
|
|
1332
|
+
* listens with `player.on("resolvers.fileTypes")`, then hears it.
|
|
1333
|
+
* Changing `otherResolvers` alone pushes nothing: `updateFileTypes` sends
|
|
1334
|
+
* the new list as the player does when a plugin starts or stops, and
|
|
1335
|
+
* `settle()` lets the listener run.
|
|
1335
1336
|
* ```ts
|
|
1336
1337
|
* import assert from "node:assert/strict";
|
|
1337
1338
|
* declare const host: TestHost;
|
|
1338
1339
|
* // ---cut---
|
|
1340
|
+
* const heard: string[][] = [];
|
|
1341
|
+
* // A listener of the event (`events`): each list the player sends.
|
|
1342
|
+
* plugin.player.on("resolvers.fileTypes", ({ fileTypes }) => heard.push(fileTypes));
|
|
1343
|
+
* // Another plugin starts with a resolver for .ch8 files.
|
|
1339
1344
|
* host.otherResolvers.push({ owner: "example.emulator", extensions: ["ch8"] });
|
|
1340
1345
|
* host.updateFileTypes();
|
|
1341
1346
|
* await host.settle();
|
|
1342
|
-
* assert.deepEqual(
|
|
1347
|
+
* assert.deepEqual(heard, [["ch8"]]);
|
|
1343
1348
|
* ```
|
|
1344
1349
|
*
|
|
1345
1350
|
* @capability None.
|
|
@@ -1767,7 +1772,14 @@ export class TestHost {
|
|
|
1767
1772
|
* keyframe at or before it); the core's step seeks are in `coreSeeks`.
|
|
1768
1773
|
*/
|
|
1769
1774
|
seeks = [];
|
|
1770
|
-
/**
|
|
1775
|
+
/**
|
|
1776
|
+
* Every `player.step` and core frame step, newest last. The position does
|
|
1777
|
+
* not move, except a step back after the end: like the player, a seek
|
|
1778
|
+
* that stays paused, one frame back (`stats` fps, else 30) for a frame,
|
|
1779
|
+
* to the last {@link TestHost.keyframes | keyframe} before the position
|
|
1780
|
+
* (none modelled: 1 ms back) for a keyframe. A keyframe step forward
|
|
1781
|
+
* after the end goes nowhere.
|
|
1782
|
+
*/
|
|
1771
1783
|
steps = [];
|
|
1772
1784
|
/** Every core action run (`host.run`, a core command, a pressed core binding), newest last. */
|
|
1773
1785
|
coreRuns = [];
|
|
@@ -1941,6 +1953,11 @@ export class TestHost {
|
|
|
1941
1953
|
* changed (the user paused, playback reached the end, a file finished
|
|
1942
1954
|
* loading). Any phase other than `empty` also turns on the source
|
|
1943
1955
|
* capabilities (pause, seek, rate, ...) unless the patch sets them.
|
|
1956
|
+
* After `phase: "ended"`, a seek (a plugin's, a core step seek) returns
|
|
1957
|
+
* to `ready` and plays on (`paused: false`), as in the player; it stays
|
|
1958
|
+
* paused when the end was reached while paused or by a frame step. A
|
|
1959
|
+
* seek at or past the end (the smaller of `position` and `duration`,
|
|
1960
|
+
* 0.5 ms slack) goes nowhere: accepted, still ended and paused.
|
|
1944
1961
|
* `phase: "loading"` makes a mounted backdrop effective, like the player.
|
|
1945
1962
|
*
|
|
1946
1963
|
* @param patch - Wire-level source fields, e.g. `phase`, `position`,
|
|
@@ -2544,7 +2561,10 @@ export class TestHost {
|
|
|
2544
2561
|
}
|
|
2545
2562
|
/**
|
|
2546
2563
|
* Close the fake stream servers and delete the host's temporary
|
|
2547
|
-
* directories. `stop()` from {@link startPlugin} calls it.
|
|
2564
|
+
* directories. `stop()` from {@link startPlugin} calls it. It never
|
|
2565
|
+
* throws: a directory that a closing file handle still holds (Windows:
|
|
2566
|
+
* `ENOTEMPTY`, `EBUSY`, `EPERM`) is retried for about 1.5 s, then left
|
|
2567
|
+
* for the system to clean, with a warning on the console.
|
|
2548
2568
|
*
|
|
2549
2569
|
* @capability None.
|
|
2550
2570
|
*
|
|
@@ -71,6 +71,16 @@ export declare class Internals {
|
|
|
71
71
|
keysSent: string;
|
|
72
72
|
/** The binding table revision of `commands.keys` (a counter here). */
|
|
73
73
|
keysRevision: number;
|
|
74
|
+
/**
|
|
75
|
+
* Like the player (2026-11-09): a seek from the end plays on unless the
|
|
76
|
+
* end was reached while paused or by a frame step (set when the phase
|
|
77
|
+
* becomes `ended`).
|
|
78
|
+
*/
|
|
79
|
+
endKeepsPause: boolean;
|
|
80
|
+
/** A frame step since the last source intent (the player's `stepped`). */
|
|
81
|
+
stepped: boolean;
|
|
82
|
+
/** The next source intent is a frame step back from the end: it stays paused. */
|
|
83
|
+
holdPause: boolean;
|
|
74
84
|
/**
|
|
75
85
|
* The resources this plugin loaded into the current source (resource id →
|
|
76
86
|
* bytes), removed ones included: like the player, a removed track frees
|
|
@@ -58,6 +58,16 @@ export class Internals {
|
|
|
58
58
|
keysSent = "";
|
|
59
59
|
/** The binding table revision of `commands.keys` (a counter here). */
|
|
60
60
|
keysRevision = 0;
|
|
61
|
+
/**
|
|
62
|
+
* Like the player (2026-11-09): a seek from the end plays on unless the
|
|
63
|
+
* end was reached while paused or by a frame step (set when the phase
|
|
64
|
+
* becomes `ended`).
|
|
65
|
+
*/
|
|
66
|
+
endKeepsPause = false;
|
|
67
|
+
/** A frame step since the last source intent (the player's `stepped`). */
|
|
68
|
+
stepped = false;
|
|
69
|
+
/** The next source intent is a frame step back from the end: it stays paused. */
|
|
70
|
+
holdPause = false;
|
|
61
71
|
/**
|
|
62
72
|
* The resources this plugin loaded into the current source (resource id →
|
|
63
73
|
* bytes), removed ones included: like the player, a removed track frees
|
|
@@ -14,6 +14,12 @@ export declare const readyCapabilities: {
|
|
|
14
14
|
export declare function sourceIntent(host: TestHost, inner: Internals, intent: Record<string, Json>): {
|
|
15
15
|
ticket: Json;
|
|
16
16
|
};
|
|
17
|
+
/**
|
|
18
|
+
* Like the player: after the end, a seek at or past the end (the smaller of
|
|
19
|
+
* the position and the duration, 0.5 ms slack) goes nowhere. It is accepted;
|
|
20
|
+
* the source stays ended and paused.
|
|
21
|
+
*/
|
|
22
|
+
export declare function atEndAlready(host: TestHost, seconds: number): boolean;
|
|
17
23
|
/** The file resolver of this plugin that claims `source`, if any. */
|
|
18
24
|
export declare function fileResolver(host: TestHost, _inner: Internals, source: string): string | null;
|
|
19
25
|
/** Retire the producer that is the player's source, unless it is `keep`. */
|
|
@@ -50,6 +56,6 @@ export declare function loadedSubtitles(host: TestHost, inner: Internals): Map<s
|
|
|
50
56
|
export declare function subtitleRoom(host: TestHost, inner: Internals, resourceId: string): void;
|
|
51
57
|
export declare function subtitleChange(host: TestHost, inner: Internals, expected: Json): void;
|
|
52
58
|
/** Implements `TestHost.setSource`. */
|
|
53
|
-
export declare function setSource(host: TestHost,
|
|
59
|
+
export declare function setSource(host: TestHost, inner: Internals, patch: Partial<SourceState>): void;
|
|
54
60
|
/** The default handlers of this area's wire methods, by method name. */
|
|
55
61
|
export declare function mediaHandlers(host: TestHost, inner: Internals): Record<string, Handler>;
|
|
@@ -49,12 +49,20 @@ export const readyCapabilities = {
|
|
|
49
49
|
snapshotSource: true,
|
|
50
50
|
};
|
|
51
51
|
export function sourceIntent(host, inner, intent) {
|
|
52
|
+
// Both flags cover this intent only, whatever becomes of it (a stale
|
|
53
|
+
// one too, as in the player).
|
|
54
|
+
const hold = inner.holdPause;
|
|
55
|
+
inner.holdPause = false;
|
|
56
|
+
inner.stepped = false;
|
|
52
57
|
const expected = intent.expected;
|
|
53
58
|
const stamp = host.source.stamp;
|
|
54
59
|
if (expected &&
|
|
55
60
|
(expected.generation !== stamp.generation ||
|
|
56
61
|
expected.intentVersion !== stamp.intentVersion))
|
|
57
62
|
throw new HostError("stale", "stale");
|
|
63
|
+
// A new load, a restart or Close: the end that was kept is gone.
|
|
64
|
+
if (intent.kind !== "control")
|
|
65
|
+
inner.endKeepsPause = false;
|
|
58
66
|
const next = {
|
|
59
67
|
...host.source,
|
|
60
68
|
stamp: { ...stamp, intentVersion: stamp.intentVersion + 1 },
|
|
@@ -107,8 +115,25 @@ export function sourceIntent(host, inner, intent) {
|
|
|
107
115
|
const control = intent.control;
|
|
108
116
|
if (control.kind === "pause")
|
|
109
117
|
next.paused = control.paused === true;
|
|
110
|
-
if (control.kind === "seek")
|
|
111
|
-
|
|
118
|
+
if (control.kind === "seek") {
|
|
119
|
+
if (atEndAlready(host, Number(control.seconds))) {
|
|
120
|
+
// Goes nowhere; keep-open holds the end paused.
|
|
121
|
+
next.paused = true;
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
next.position = Number(control.seconds);
|
|
125
|
+
// Like the player (2026-11-09): a seek leaves the end and plays on,
|
|
126
|
+
// except a step back from the end, or after an end reached while
|
|
127
|
+
// paused or by frame stepping. Leaving the end starts a new cycle
|
|
128
|
+
// (session.rs `confirm_seek_from_end`), so the next end is new.
|
|
129
|
+
if (host.source.phase === "ended") {
|
|
130
|
+
next.cycle++;
|
|
131
|
+
next.phase = "ready";
|
|
132
|
+
next.terminalReason = null;
|
|
133
|
+
next.paused = hold || inner.endKeepsPause;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
112
137
|
if (control.kind === "rate")
|
|
113
138
|
next.rate = Number(control.rate);
|
|
114
139
|
}
|
|
@@ -129,6 +154,20 @@ export function sourceIntent(host, inner, intent) {
|
|
|
129
154
|
cancelResolutions(host, inner);
|
|
130
155
|
return { ticket: { stamp: next.stamp, cycle: next.cycle, owner: 1 } };
|
|
131
156
|
}
|
|
157
|
+
/**
|
|
158
|
+
* Like the player: after the end, a seek at or past the end (the smaller of
|
|
159
|
+
* the position and the duration, 0.5 ms slack) goes nowhere. It is accepted;
|
|
160
|
+
* the source stays ended and paused.
|
|
161
|
+
*/
|
|
162
|
+
export function atEndAlready(host, seconds) {
|
|
163
|
+
const s = host.source;
|
|
164
|
+
if (s.phase !== "ended")
|
|
165
|
+
return false;
|
|
166
|
+
const end = s.position !== null && s.duration !== null
|
|
167
|
+
? Math.min(s.position, s.duration)
|
|
168
|
+
: (s.position ?? s.duration);
|
|
169
|
+
return end !== null && seconds >= end - 0.0005;
|
|
170
|
+
}
|
|
132
171
|
/** The file resolver of this plugin that claims `source`, if any. */
|
|
133
172
|
export function fileResolver(host, _inner, source) {
|
|
134
173
|
if (source.includes("://") || !isAbsolute(source))
|
|
@@ -345,7 +384,11 @@ export function subtitleChange(host, inner, expected) {
|
|
|
345
384
|
};
|
|
346
385
|
}
|
|
347
386
|
/** Implements `TestHost.setSource`. */
|
|
348
|
-
export function setSource(host,
|
|
387
|
+
export function setSource(host, inner, patch) {
|
|
388
|
+
// The end keeps the pause when reached while paused or by a frame step
|
|
389
|
+
// (the player reads this as the end arrives).
|
|
390
|
+
if (patch.phase === "ended" && host.source.phase !== "ended")
|
|
391
|
+
inner.endKeepsPause = inner.stepped || host.source.paused;
|
|
349
392
|
host.source = {
|
|
350
393
|
...host.source,
|
|
351
394
|
...patch,
|
|
@@ -85,8 +85,9 @@ export function close(host, inner) {
|
|
|
85
85
|
retryDelay: 100,
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
|
-
catch {
|
|
89
|
-
// Left in the temporary directory.
|
|
88
|
+
catch (error) {
|
|
89
|
+
// Left in the temporary directory, and said so.
|
|
90
|
+
console.warn(`# TestHost: left ${inner.scratch} (${error.code ?? String(error)})`);
|
|
90
91
|
}
|
|
91
92
|
}
|
|
92
93
|
/** Implements `TestHost.keepsRunning`. */
|
|
@@ -40,7 +40,8 @@ export declare const TIMELINE_LIMITS: Readonly<{
|
|
|
40
40
|
}>;
|
|
41
41
|
/**
|
|
42
42
|
* One per plugin: read before activation (with `playback.read`), then kept
|
|
43
|
-
* current from `timeline.changed` (with `events`) once the plugin uses it
|
|
43
|
+
* current from `timeline.changed` (with `events`) once the plugin uses it
|
|
44
|
+
* (or listens to that event with `player.on`).
|
|
44
45
|
*/
|
|
45
46
|
export declare class TimelineService {
|
|
46
47
|
#private;
|
|
@@ -52,9 +53,6 @@ export declare class TimelineService {
|
|
|
52
53
|
start(): void;
|
|
53
54
|
accept(lists: WireTimeline): void;
|
|
54
55
|
read(): Promise<void>;
|
|
55
|
-
watch(listener: (marks: readonly TimelineMark[]) => void): {
|
|
56
|
-
dispose: () => Promise<void>;
|
|
57
|
-
};
|
|
58
56
|
}
|
|
59
57
|
export declare const timelineOf: (runtime: Runtime) => TimelineService;
|
|
60
58
|
export declare function timeline(scope: ScopeImpl): Timeline;
|
package/dist/plugin/timeline.js
CHANGED
|
@@ -52,13 +52,13 @@ const viewRanges = (ranges) => Object.freeze(ranges.map((range) => Object.freeze
|
|
|
52
52
|
})));
|
|
53
53
|
/**
|
|
54
54
|
* One per plugin: read before activation (with `playback.read`), then kept
|
|
55
|
-
* current from `timeline.changed` (with `events`) once the plugin uses it
|
|
55
|
+
* current from `timeline.changed` (with `events`) once the plugin uses it
|
|
56
|
+
* (or listens to that event with `player.on`).
|
|
56
57
|
*/
|
|
57
58
|
export class TimelineService {
|
|
58
59
|
#runtime;
|
|
59
60
|
marks = Object.freeze([]);
|
|
60
61
|
ranges = Object.freeze([]);
|
|
61
|
-
#listeners = new Set();
|
|
62
62
|
#started = false;
|
|
63
63
|
layer = false;
|
|
64
64
|
constructor(runtime) {
|
|
@@ -72,7 +72,8 @@ export class TimelineService {
|
|
|
72
72
|
if (this.#started)
|
|
73
73
|
return;
|
|
74
74
|
this.#started = true;
|
|
75
|
-
// A mirror:
|
|
75
|
+
// A mirror: bindings read it; it hears each event before the plugin's
|
|
76
|
+
// own listeners (`player.on`).
|
|
76
77
|
this.#runtime.on("timeline.changed", (data) => {
|
|
77
78
|
const lists = data;
|
|
78
79
|
if (lists && Array.isArray(lists.marks))
|
|
@@ -93,10 +94,6 @@ export class TimelineService {
|
|
|
93
94
|
this.marks = marks;
|
|
94
95
|
if (rangesChanged)
|
|
95
96
|
this.ranges = ranges;
|
|
96
|
-
// `onChange` follows the marks only, as before ranges existed.
|
|
97
|
-
if (marksChanged)
|
|
98
|
-
for (const listener of [...this.#listeners])
|
|
99
|
-
listener(marks);
|
|
100
97
|
this.#runtime.invalidate();
|
|
101
98
|
}
|
|
102
99
|
async read() {
|
|
@@ -104,16 +101,6 @@ export class TimelineService {
|
|
|
104
101
|
if (result)
|
|
105
102
|
this.accept(result);
|
|
106
103
|
}
|
|
107
|
-
watch(listener) {
|
|
108
|
-
this.#listeners.add(listener);
|
|
109
|
-
const held = this.#runtime.hold("timeline.changed");
|
|
110
|
-
return {
|
|
111
|
-
dispose: async () => {
|
|
112
|
-
this.#listeners.delete(listener);
|
|
113
|
-
await held.dispose();
|
|
114
|
-
},
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
104
|
}
|
|
118
105
|
export const timelineOf = (runtime) => runtime.service("timeline", () => new TimelineService(runtime));
|
|
119
106
|
export function timeline(scope) {
|
|
@@ -129,16 +116,6 @@ export function timeline(scope) {
|
|
|
129
116
|
scope.runtime.reading("timeline.changed");
|
|
130
117
|
return service().ranges;
|
|
131
118
|
},
|
|
132
|
-
onChange(listener) {
|
|
133
|
-
service().start();
|
|
134
|
-
const watch = service().watch((marks) => scope.run(listener, marks));
|
|
135
|
-
return scope.add({
|
|
136
|
-
dispose: async () => {
|
|
137
|
-
scope.forget(watch);
|
|
138
|
-
await watch.dispose();
|
|
139
|
-
},
|
|
140
|
-
});
|
|
141
|
-
},
|
|
142
119
|
layer() {
|
|
143
120
|
if (service().layer)
|
|
144
121
|
throw new Error("a plugin has one timeline layer; reuse it");
|
|
@@ -792,9 +792,14 @@ export interface Commands {
|
|
|
792
792
|
* For key hints beside a panel's controls (`KeyHint` and the `keys` of
|
|
793
793
|
* `ToolTipArea` in `@vestra/widgets.slint`). Read it in a
|
|
794
794
|
* {@link View.bind} function and the view follows every change; or
|
|
795
|
-
* listen with
|
|
795
|
+
* listen with `plugin.player.on("commands.keys", …)` and read it there
|
|
796
|
+
* (the SDK's copy already has the event's keys). The first read asks the
|
|
796
797
|
* player, and until its answer arrives (a few milliseconds) every
|
|
797
|
-
* command reads `[]`; a binding that read it runs again then.
|
|
798
|
+
* command reads `[]`; a binding that read it runs again then. That answer
|
|
799
|
+
* is not an event: a `player.on` listener hears only the player's later
|
|
800
|
+
* `commands.keys` events, so read the keys you start with in a `bind`
|
|
801
|
+
* function, which runs again when the answer arrives, not only in the
|
|
802
|
+
* listener.
|
|
798
803
|
*
|
|
799
804
|
* The plugin's own commands, and the player's own as `host/<id>`
|
|
800
805
|
* (`host/volume-up`, `host/mute`: the ids of
|
|
@@ -826,31 +831,6 @@ export interface Commands {
|
|
|
826
831
|
* @since 1.6.6
|
|
827
832
|
*/
|
|
828
833
|
keys(id: string): readonly string[];
|
|
829
|
-
/**
|
|
830
|
-
* Run `listener` after the keys of any of this plugin's commands changed
|
|
831
|
-
* (read them again with {@link Commands.keys}): the user changed or
|
|
832
|
-
* cleared a key, turned Ignore Default Shortcuts on or off, a command with
|
|
833
|
-
* keys was added or removed, or the player's first answer arrived. At most every
|
|
834
|
-
* 200 ms. A plugin in standby that listens is started for it, as for a
|
|
835
|
-
* key change in {@link Bindings.onChange}.
|
|
836
|
-
*
|
|
837
|
-
* @capability commands
|
|
838
|
-
*
|
|
839
|
-
* @example Name the current key in a status line
|
|
840
|
-
* The OSD tells the user the new key after they change it. The listener
|
|
841
|
-
* carries no data; it reads the labels with `keys`.
|
|
842
|
-
* ```ts
|
|
843
|
-
* plugin.commands.onKeysChange(() => {
|
|
844
|
-
* const [key] = plugin.commands.keys("toggle-blur");
|
|
845
|
-
* if (key) void plugin.osd.show("Blur: {}", [key]);
|
|
846
|
-
* else void plugin.osd.show("Blur has no key");
|
|
847
|
-
* });
|
|
848
|
-
* ```
|
|
849
|
-
*
|
|
850
|
-
* @player 0.7.6
|
|
851
|
-
* @since 1.6.6
|
|
852
|
-
*/
|
|
853
|
-
onKeysChange(listener: () => void): Disposable;
|
|
854
834
|
}
|
|
855
835
|
/**
|
|
856
836
|
* The core's basic playback actions (menu commands owned by the player),
|
|
@@ -862,7 +842,7 @@ export interface Commands {
|
|
|
862
842
|
* | `play-pause` | Space, a left click on the video | pause / resume, replay after the end |
|
|
863
843
|
* | `previous` / `next` | PageUp, Mouse:X2 / PageDown, Mouse:X1 | ask the sequence provider |
|
|
864
844
|
* | `frame-back` / `frame-forward` | D / F | `player.step("frame", …)` |
|
|
865
|
-
* | `seek-backward` / `seek-forward` | ← / → | relative seek by `setStepSeek` seconds (or `host.run`'s `seconds`), exact or to keyframes as `setStepSeek` says |
|
|
845
|
+
* | `seek-backward` / `seek-forward` | ← / → | relative seek by `setStepSeek` seconds (or `host.run`'s `seconds`), exact or to keyframes as `setStepSeek` says; after the end an exact seek that plays on |
|
|
866
846
|
* | `rate-normal`, `rate-down`, `rate-up` | Z, X, C | 1×, ±0.1 within 0.25–4 |
|
|
867
847
|
* | `volume-up` / `volume-down` | ↑ / ↓, wheel | ±5 (`volume-up` stops at 100) |
|
|
868
848
|
* | `mute` | M | toggle mute |
|