@vestra-player/sdk 1.10.0 → 1.11.0-rc.1
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 +36 -0
- package/bin/vestra-plugin.mjs +1 -131
- package/dist/api-requests.d.ts +1 -1
- package/dist/api-requests.js +10 -2
- package/dist/commands.js +1 -0
- package/dist/docs-tree.json.gz +0 -0
- package/dist/manifest.d.ts +0 -5
- package/dist/manifest.js +1 -8
- package/dist/mpv.js +1 -1
- package/dist/plugin/appearance.d.ts +2 -2
- package/dist/plugin/appearance.js +3 -3
- package/dist/plugin/connection.d.ts +39 -29
- package/dist/plugin/connection.js +110 -101
- package/dist/plugin/index.js +8 -6
- package/dist/plugin/passes.js +1 -1
- package/dist/plugin/player/events.d.ts +18 -9
- package/dist/plugin/player/events.js +36 -11
- package/dist/plugin/player.d.ts +31 -28
- package/dist/plugin/player.js +42 -68
- package/dist/plugin/scope.d.ts +2 -9
- package/dist/plugin/scope.js +21 -27
- package/dist/plugin/subtitles.d.ts +6 -1
- package/dist/plugin/subtitles.js +18 -2
- package/dist/plugin/testing/commands.d.ts +5 -0
- package/dist/plugin/testing/commands.js +6 -3
- package/dist/plugin/testing/facts.d.ts +46 -0
- package/dist/plugin/testing/facts.js +106 -0
- package/dist/plugin/testing/index.d.ts +38 -13
- package/dist/plugin/testing/index.js +63 -17
- package/dist/plugin/testing/media.js +6 -0
- package/dist/plugin/testing/revoke.d.ts +15 -0
- package/dist/plugin/testing/revoke.js +13 -0
- package/dist/plugin/testing/services.js +50 -1
- package/dist/plugin/testing/transport.js +8 -0
- package/dist/plugin/timeline.d.ts +2 -2
- package/dist/plugin/timeline.js +3 -3
- package/dist/plugin/types/base.d.ts +91 -13
- package/dist/plugin/types/commands.d.ts +8 -8
- package/dist/plugin/types/packages.d.ts +10 -1
- package/dist/plugin/types/playback.d.ts +240 -116
- package/dist/plugin/types/plugin-wire.d.ts +2 -2
- package/dist/plugin/types/processing.d.ts +2 -3
- package/dist/plugin/types/services.d.ts +10 -4
- package/dist/plugin/types/subtitles.d.ts +9 -8
- package/dist/plugin/types/ui-layout.d.ts +32 -17
- package/dist/plugin/types/ui-locale.d.ts +9 -9
- package/dist/plugin/types/ui-shell.d.ts +7 -6
- package/dist/plugin/view/layout.d.ts +33 -1
- package/dist/plugin/view/layout.js +63 -34
- package/dist/plugin/window.d.ts +9 -1
- package/dist/plugin/window.js +14 -2
- package/dist/processing.d.ts +2 -2
- package/dist/request-queue.d.ts +7 -3
- package/dist/request-queue.js +19 -5
- package/dist/ts-plugin.d.ts +3 -4
- package/dist/ts-plugin.js +1 -1
- package/dist/wire.d.ts +4 -1
- package/dist/wire.js +2 -1
- package/llms.txt +3 -3
- package/package.json +3 -5
- package/capability-scan.json +0 -387
- package/dist/capability-scan.d.ts +0 -95
- package/dist/capability-scan.js +0 -249
- package/dist/member-uses.d.ts +0 -61
- package/dist/member-uses.js +0 -160
|
@@ -806,8 +806,8 @@ export declare class TestHost implements Transport {
|
|
|
806
806
|
*
|
|
807
807
|
* @example Simulate the user choosing French for the next start
|
|
808
808
|
* The plugin hears that the saved interface language changed. The host
|
|
809
|
-
* pushes `appearance.changed`, which a plugin
|
|
810
|
-
* `appearance.language
|
|
809
|
+
* pushes `appearance.changed`, which a plugin that listens to it sees in
|
|
810
|
+
* `appearance.language`; this run's
|
|
811
811
|
* language does not change.
|
|
812
812
|
* ```ts
|
|
813
813
|
* import assert from "node:assert/strict";
|
|
@@ -1070,8 +1070,8 @@ export declare class TestHost implements Transport {
|
|
|
1070
1070
|
* @example Let another plugin publish chapters
|
|
1071
1071
|
* The plugin under test sees two chapter marks another plugin put on the
|
|
1072
1072
|
* timeline. `setTimelineLayer` stores that plugin's whole layer and pushes
|
|
1073
|
-
* `timeline.changed`;
|
|
1074
|
-
* `
|
|
1073
|
+
* `timeline.changed`; while the plugin listens to it the SDK keeps
|
|
1074
|
+
* `marks` current from that event, and `settle()`
|
|
1075
1075
|
* lets it arrive.
|
|
1076
1076
|
* ```ts
|
|
1077
1077
|
* import assert from "node:assert/strict";
|
|
@@ -1192,7 +1192,7 @@ export declare class TestHost implements Transport {
|
|
|
1192
1192
|
*
|
|
1193
1193
|
* @example Simulate another plugin switching to the light palette
|
|
1194
1194
|
* The plugin hears the palette change. The host updates `appearance` and
|
|
1195
|
-
* pushes `appearance.changed` to a plugin that listens
|
|
1195
|
+
* pushes `appearance.changed` to a plugin that listens.
|
|
1196
1196
|
* ```ts
|
|
1197
1197
|
* import assert from "node:assert/strict";
|
|
1198
1198
|
* declare const host: TestHost;
|
|
@@ -2038,6 +2038,16 @@ export declare class TestHost implements Transport {
|
|
|
2038
2038
|
/** The Slint version. */
|
|
2039
2039
|
slint: string;
|
|
2040
2040
|
};
|
|
2041
|
+
/**
|
|
2042
|
+
* `true` to run as a temporary window
|
|
2043
|
+
* ({@link "@vestra-player/sdk"!AppInfo.temporary | AppInfo.temporary}):
|
|
2044
|
+
* the plugin sees it, and `secrets.set`, `secrets.delete`,
|
|
2045
|
+
* `packages.install`, `packages.uninstall` and `packages.setEnabled`
|
|
2046
|
+
* are refused with `unavailable`, as in the player.
|
|
2047
|
+
*
|
|
2048
|
+
* @since 1.10.1
|
|
2049
|
+
*/
|
|
2050
|
+
temporary?: boolean;
|
|
2041
2051
|
};
|
|
2042
2052
|
/**
|
|
2043
2053
|
* The player's rendering choice behind `plugin.rendering`. The mode drawing
|
|
@@ -2405,7 +2415,7 @@ export declare class TestHost implements Transport {
|
|
|
2405
2415
|
* The plugin is built into the player (`startPlugin`'s `builtin`). Only
|
|
2406
2416
|
* then does the host answer the built-in-only requests
|
|
2407
2417
|
* (`commands.list`, `commands.run`, `palette.lead.*`); otherwise they
|
|
2408
|
-
* fail with `
|
|
2418
|
+
* fail with `builtin-only`, as in the player.
|
|
2409
2419
|
*
|
|
2410
2420
|
* @since 1.7.9
|
|
2411
2421
|
*/
|
|
@@ -2417,6 +2427,23 @@ export declare class TestHost implements Transport {
|
|
|
2417
2427
|
* @since 1.7.9
|
|
2418
2428
|
*/
|
|
2419
2429
|
paletteLead: Record<string, Json> | null;
|
|
2430
|
+
/**
|
|
2431
|
+
* Every temporary window a built-in plugin opened with `app.openWindow`,
|
|
2432
|
+
* oldest first: the files and the process id answered
|
|
2433
|
+
* ({@link "@vestra-player/sdk"!App.openWindow | App.openWindow}). No
|
|
2434
|
+
* process starts. A
|
|
2435
|
+
* plugin that is not built in is refused with `builtin-only`, as in the
|
|
2436
|
+
* player; the files are checked as the player does (`invalid`,
|
|
2437
|
+
* `missing`).
|
|
2438
|
+
*
|
|
2439
|
+
* @since 1.10.1
|
|
2440
|
+
*/
|
|
2441
|
+
readonly openedWindows: {
|
|
2442
|
+
/** The files, as the plugin gave them. */
|
|
2443
|
+
paths: string[];
|
|
2444
|
+
/** The process id answered (made up: no process starts). */
|
|
2445
|
+
pid: number;
|
|
2446
|
+
}[];
|
|
2420
2447
|
/**
|
|
2421
2448
|
* Simulate the user activating the palette's lead row: Enter (`keep`:
|
|
2422
2449
|
* Shift+Enter) with `query` typed, or Enter on the status row
|
|
@@ -2563,7 +2590,7 @@ export declare class TestHost implements Transport {
|
|
|
2563
2590
|
* Deliver a host event to the plugin. Like the player, subscription-based
|
|
2564
2591
|
* events (`source.state`, `playback.backend`, `window.state`,
|
|
2565
2592
|
* `timeline.changed`, `appearance.changed`) are delivered only when the
|
|
2566
|
-
* plugin subscribed (
|
|
2593
|
+
* plugin subscribed (something of it listens). Most tests use the
|
|
2567
2594
|
* higher-level helpers (`setSource`, `setMainWindow`, ...) instead.
|
|
2568
2595
|
*
|
|
2569
2596
|
* @param event - The wire event name.
|
|
@@ -3318,13 +3345,11 @@ export declare class TestHost implements Transport {
|
|
|
3318
3345
|
* The manifest id comes from `directory/manifest.json` unless `id` is
|
|
3319
3346
|
* given; then no manifest is read (and without `directory` none is read
|
|
3320
3347
|
* either: the id is `"test.plugin"`). Nothing in the manifest changes how
|
|
3321
|
-
* the plugin runs:
|
|
3322
|
-
*
|
|
3323
|
-
* the player.
|
|
3348
|
+
* the plugin runs: the start-up read is the plugin's own call
|
|
3349
|
+
* (`plugin.player.read()`), and an event reaches it from its first
|
|
3350
|
+
* listener, as in the player.
|
|
3324
3351
|
*
|
|
3325
|
-
* Rejects when `manifest.json` cannot be read or parsed, when
|
|
3326
|
-
* `capabilities` (removed in 1.9.0; the message says what to call
|
|
3327
|
-
* instead), when `activate`
|
|
3352
|
+
* Rejects when `manifest.json` cannot be read or parsed, when `activate`
|
|
3328
3353
|
* throws, or when a registration made during activation fails (for example
|
|
3329
3354
|
* `limit`, `conflict`, `invalid`). Stricter than the player's runner for
|
|
3330
3355
|
* commands: there the SDK logs a command declaration the player refuses during
|
|
@@ -70,7 +70,6 @@ import { join } from "node:path";
|
|
|
70
70
|
import { fileURLToPath } from "node:url";
|
|
71
71
|
import { HostError } from "../../wire.js";
|
|
72
72
|
import { BAR_BUTTON_ICONS, BAR_BUTTON_LIMITS, BUILTIN_COMMANDS, BUILTIN_SUBMENUS, COMMAND_LIMITS, MENU_IDS, } from "../../commands.js";
|
|
73
|
-
import { CAPABILITIES_REMOVED } from "../../manifest.js";
|
|
74
73
|
import { MESSAGE_LIMIT } from "../../protocol.js";
|
|
75
74
|
import { OSD_LIMITS } from "../osd.js";
|
|
76
75
|
import { TIMELINE_LIMITS } from "../timeline.js";
|
|
@@ -86,6 +85,8 @@ import { createPlugin } from "../index.js";
|
|
|
86
85
|
import { PATCH_FEATURE } from "../patch.js";
|
|
87
86
|
import { LOCALES, LIST_SEPARATORS, loadPackageCatalog, TEXT_LIMITS, } from "../../i18n.js";
|
|
88
87
|
import { Internals } from "./internals.js";
|
|
88
|
+
import { sendFacts } from "./facts.js";
|
|
89
|
+
import { revokeRun, revokers } from "./revoke.js";
|
|
89
90
|
import { on, emit, settle, close, keepsRunning, transportHandlers, tick, takenErrors, tellResidency, } from "./transport.js";
|
|
90
91
|
import { bindingClaims, bindingKey, keysChanged, press, barButtons, commandsHandlers, builtinHandlers, runPaletteLead, } from "./commands.js";
|
|
91
92
|
import { registerCoreActions, windowFacts, coreActionsHandlers, } from "./core-actions.js";
|
|
@@ -484,8 +485,8 @@ export class TestHost {
|
|
|
484
485
|
*
|
|
485
486
|
* @example Simulate the user choosing French for the next start
|
|
486
487
|
* The plugin hears that the saved interface language changed. The host
|
|
487
|
-
* pushes `appearance.changed`, which a plugin
|
|
488
|
-
* `appearance.language
|
|
488
|
+
* pushes `appearance.changed`, which a plugin that listens to it sees in
|
|
489
|
+
* `appearance.language`; this run's
|
|
489
490
|
* language does not change.
|
|
490
491
|
* ```ts
|
|
491
492
|
* import assert from "node:assert/strict";
|
|
@@ -717,8 +718,8 @@ export class TestHost {
|
|
|
717
718
|
* @example Let another plugin publish chapters
|
|
718
719
|
* The plugin under test sees two chapter marks another plugin put on the
|
|
719
720
|
* timeline. `setTimelineLayer` stores that plugin's whole layer and pushes
|
|
720
|
-
* `timeline.changed`;
|
|
721
|
-
* `
|
|
721
|
+
* `timeline.changed`; while the plugin listens to it the SDK keeps
|
|
722
|
+
* `marks` current from that event, and `settle()`
|
|
722
723
|
* lets it arrive.
|
|
723
724
|
* ```ts
|
|
724
725
|
* import assert from "node:assert/strict";
|
|
@@ -824,7 +825,7 @@ export class TestHost {
|
|
|
824
825
|
*
|
|
825
826
|
* @example Simulate another plugin switching to the light palette
|
|
826
827
|
* The plugin hears the palette change. The host updates `appearance` and
|
|
827
|
-
* pushes `appearance.changed` to a plugin that listens
|
|
828
|
+
* pushes `appearance.changed` to a plugin that listens.
|
|
828
829
|
* ```ts
|
|
829
830
|
* import assert from "node:assert/strict";
|
|
830
831
|
* declare const host: TestHost;
|
|
@@ -1829,6 +1830,7 @@ export class TestHost {
|
|
|
1829
1830
|
* pass it to {@link startPlugin} as `host`.
|
|
1830
1831
|
*/
|
|
1831
1832
|
constructor() {
|
|
1833
|
+
revokers.set(this, () => this.#revoke());
|
|
1832
1834
|
this.subtitles = {
|
|
1833
1835
|
presentation: {
|
|
1834
1836
|
revision: 1,
|
|
@@ -1925,7 +1927,7 @@ export class TestHost {
|
|
|
1925
1927
|
* The plugin is built into the player (`startPlugin`'s `builtin`). Only
|
|
1926
1928
|
* then does the host answer the built-in-only requests
|
|
1927
1929
|
* (`commands.list`, `commands.run`, `palette.lead.*`); otherwise they
|
|
1928
|
-
* fail with `
|
|
1930
|
+
* fail with `builtin-only`, as in the player.
|
|
1929
1931
|
*
|
|
1930
1932
|
* @since 1.7.9
|
|
1931
1933
|
*/
|
|
@@ -1937,6 +1939,18 @@ export class TestHost {
|
|
|
1937
1939
|
* @since 1.7.9
|
|
1938
1940
|
*/
|
|
1939
1941
|
paletteLead = null;
|
|
1942
|
+
/**
|
|
1943
|
+
* Every temporary window a built-in plugin opened with `app.openWindow`,
|
|
1944
|
+
* oldest first: the files and the process id answered
|
|
1945
|
+
* ({@link "@vestra-player/sdk"!App.openWindow | App.openWindow}). No
|
|
1946
|
+
* process starts. A
|
|
1947
|
+
* plugin that is not built in is refused with `builtin-only`, as in the
|
|
1948
|
+
* player; the files are checked as the player does (`invalid`,
|
|
1949
|
+
* `missing`).
|
|
1950
|
+
*
|
|
1951
|
+
* @since 1.10.1
|
|
1952
|
+
*/
|
|
1953
|
+
openedWindows = [];
|
|
1940
1954
|
/**
|
|
1941
1955
|
* Simulate the user activating the palette's lead row: Enter (`keep`:
|
|
1942
1956
|
* Shift+Enter) with `query` typed, or Enter on the status row
|
|
@@ -2046,6 +2060,8 @@ export class TestHost {
|
|
|
2046
2060
|
const work = Promise.resolve(handler(record));
|
|
2047
2061
|
// `disconnect()` fails the requests still waiting, as the runner does.
|
|
2048
2062
|
work.catch(() => { });
|
|
2063
|
+
// The facts the request changed go out once it is handled (`facts.ts`).
|
|
2064
|
+
void work.then(() => sendFacts(this), () => { });
|
|
2049
2065
|
return (await Promise.race([work, this.#inner.gone]));
|
|
2050
2066
|
}
|
|
2051
2067
|
finally {
|
|
@@ -2123,7 +2139,7 @@ export class TestHost {
|
|
|
2123
2139
|
* Deliver a host event to the plugin. Like the player, subscription-based
|
|
2124
2140
|
* events (`source.state`, `playback.backend`, `window.state`,
|
|
2125
2141
|
* `timeline.changed`, `appearance.changed`) are delivered only when the
|
|
2126
|
-
* plugin subscribed (
|
|
2142
|
+
* plugin subscribed (something of it listens). Most tests use the
|
|
2127
2143
|
* higher-level helpers (`setSource`, `setMainWindow`, ...) instead.
|
|
2128
2144
|
*
|
|
2129
2145
|
* @param event - The wire event name.
|
|
@@ -2912,6 +2928,34 @@ export class TestHost {
|
|
|
2912
2928
|
upgrade(activate) {
|
|
2913
2929
|
return upgrade(this, this.#inner, activate);
|
|
2914
2930
|
}
|
|
2931
|
+
/** See {@link revokeRun}: each through the host's own handler. */
|
|
2932
|
+
#revoke() {
|
|
2933
|
+
const run = (method, params) => {
|
|
2934
|
+
try {
|
|
2935
|
+
void Promise.resolve(this.#defaults[method]?.(params)).catch(() => { });
|
|
2936
|
+
}
|
|
2937
|
+
catch {
|
|
2938
|
+
// Already gone.
|
|
2939
|
+
}
|
|
2940
|
+
};
|
|
2941
|
+
for (const id of [...this.windows.keys()])
|
|
2942
|
+
run("ui.close", { id });
|
|
2943
|
+
if (this.panels.size)
|
|
2944
|
+
run("ui.unmount", {});
|
|
2945
|
+
for (const id of [...this.commands.keys()])
|
|
2946
|
+
run("commands.unregister", { id });
|
|
2947
|
+
for (const id of [...this.settings.pages.keys()])
|
|
2948
|
+
run("settings.unregister", { id });
|
|
2949
|
+
for (const id of [...this.resolvers.keys()])
|
|
2950
|
+
run("sourceResolvers.unregister", { id });
|
|
2951
|
+
if (this.sequence !== null)
|
|
2952
|
+
run("sequence.set", { flags: null });
|
|
2953
|
+
for (const [producerId, producer] of this.producers)
|
|
2954
|
+
if (!producer.released)
|
|
2955
|
+
run("producer.release", { producerId });
|
|
2956
|
+
// Its processing chains (filters) are withdrawn.
|
|
2957
|
+
this.processing.resources.clear();
|
|
2958
|
+
}
|
|
2915
2959
|
#defaults = {
|
|
2916
2960
|
...triggersHandlers(this, this.#inner),
|
|
2917
2961
|
...transportHandlers(this, this.#inner),
|
|
@@ -2937,13 +2981,11 @@ export class TestHost {
|
|
|
2937
2981
|
* The manifest id comes from `directory/manifest.json` unless `id` is
|
|
2938
2982
|
* given; then no manifest is read (and without `directory` none is read
|
|
2939
2983
|
* either: the id is `"test.plugin"`). Nothing in the manifest changes how
|
|
2940
|
-
* the plugin runs:
|
|
2941
|
-
*
|
|
2942
|
-
* the player.
|
|
2984
|
+
* the plugin runs: the start-up read is the plugin's own call
|
|
2985
|
+
* (`plugin.player.read()`), and an event reaches it from its first
|
|
2986
|
+
* listener, as in the player.
|
|
2943
2987
|
*
|
|
2944
|
-
* Rejects when `manifest.json` cannot be read or parsed, when
|
|
2945
|
-
* `capabilities` (removed in 1.9.0; the message says what to call
|
|
2946
|
-
* instead), when `activate`
|
|
2988
|
+
* Rejects when `manifest.json` cannot be read or parsed, when `activate`
|
|
2947
2989
|
* throws, or when a registration made during activation fails (for example
|
|
2948
2990
|
* `limit`, `conflict`, `invalid`). Stricter than the player's runner for
|
|
2949
2991
|
* commands: there the SDK logs a command declaration the player refuses during
|
|
@@ -3019,9 +3061,6 @@ export async function startPlugin(activate, options = {}) {
|
|
|
3019
3061
|
let manifest = { id: options.id ?? "test.plugin" };
|
|
3020
3062
|
if (options.directory && options.id === undefined) {
|
|
3021
3063
|
const read = JSON.parse(readFileSync(join(directory, "manifest.json"), "utf8"));
|
|
3022
|
-
// As `vestra-plugin check` and the player: the field is gone.
|
|
3023
|
-
if (read && typeof read === "object" && "capabilities" in read)
|
|
3024
|
-
throw new Error(CAPABILITIES_REMOVED);
|
|
3025
3064
|
manifest = { id: read.id };
|
|
3026
3065
|
}
|
|
3027
3066
|
host.manifestId = manifest.id;
|
|
@@ -3072,6 +3111,9 @@ export async function startPlugin(activate, options = {}) {
|
|
|
3072
3111
|
triggers.stop = async (reason) => {
|
|
3073
3112
|
await instance.dispose({ reason });
|
|
3074
3113
|
await host.settle();
|
|
3114
|
+
// Standby and an upgrade stop the run: the player revokes what it held.
|
|
3115
|
+
revokeRun(host);
|
|
3116
|
+
await host.settle();
|
|
3075
3117
|
};
|
|
3076
3118
|
await host.settle();
|
|
3077
3119
|
tellResidency(host);
|
|
@@ -3094,6 +3136,8 @@ export async function startPlugin(activate, options = {}) {
|
|
|
3094
3136
|
if (!triggers.parked)
|
|
3095
3137
|
await instance.dispose({ reason });
|
|
3096
3138
|
await host.settle();
|
|
3139
|
+
revokeRun(host);
|
|
3140
|
+
await host.settle();
|
|
3097
3141
|
host.close();
|
|
3098
3142
|
};
|
|
3099
3143
|
return {
|
|
@@ -3120,6 +3164,8 @@ export async function startPlugin(activate, options = {}) {
|
|
|
3120
3164
|
host.loseConnection();
|
|
3121
3165
|
await instance.dispose({ reason: "host-lost" });
|
|
3122
3166
|
await host.settle();
|
|
3167
|
+
revokeRun(host);
|
|
3168
|
+
await host.settle();
|
|
3123
3169
|
host.close();
|
|
3124
3170
|
},
|
|
3125
3171
|
};
|
|
@@ -13,6 +13,7 @@ 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 { sendFacts, tracksChanged } from "./facts.js";
|
|
16
17
|
import { sourceEvents } from "./source-events.js";
|
|
17
18
|
/**
|
|
18
19
|
* Broadcast the source state `host.source` became from `previous`, then
|
|
@@ -23,6 +24,11 @@ export function emitSource(host, previous, reload = false) {
|
|
|
23
24
|
host.emit("source.state", host.source);
|
|
24
25
|
for (const [name, data] of sourceEvents(previous, host.source, reload))
|
|
25
26
|
host.emit(name, structuredClone(data));
|
|
27
|
+
const tracks = tracksChanged(previous, host.source);
|
|
28
|
+
if (tracks)
|
|
29
|
+
host.emit("audio.tracks.changed", structuredClone(tracks));
|
|
30
|
+
// The other facts after the source's events (`facts.ts`).
|
|
31
|
+
sendFacts(host);
|
|
26
32
|
}
|
|
27
33
|
export function initialSource() {
|
|
28
34
|
return {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal to the SDK; not exported from `@vestra-player/sdk/testing`.
|
|
3
|
+
*/
|
|
4
|
+
import type { TestHost } from "./index.ts";
|
|
5
|
+
/**
|
|
6
|
+
* What the player undoes by itself when a plugin's run stops (SDK 1.11.0):
|
|
7
|
+
* the plugin's own cleanup requests are not sent after `runtime.stop`
|
|
8
|
+
* (`RequestQueue.close`), so the test host revokes what the run held, as
|
|
9
|
+
* the player does (its stop revokes the run's windows, panels, commands,
|
|
10
|
+
* settings pages, resolvers, sequence provider, streams and filter
|
|
11
|
+
* chains). By host.
|
|
12
|
+
*/
|
|
13
|
+
export declare const revokers: WeakMap<TestHost, () => void>;
|
|
14
|
+
/** Revoke what the plugin's run held (`startPlugin`'s `stop`). */
|
|
15
|
+
export declare function revokeRun(host: TestHost): void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the player undoes by itself when a plugin's run stops (SDK 1.11.0):
|
|
3
|
+
* the plugin's own cleanup requests are not sent after `runtime.stop`
|
|
4
|
+
* (`RequestQueue.close`), so the test host revokes what the run held, as
|
|
5
|
+
* the player does (its stop revokes the run's windows, panels, commands,
|
|
6
|
+
* settings pages, resolvers, sequence provider, streams and filter
|
|
7
|
+
* chains). By host.
|
|
8
|
+
*/
|
|
9
|
+
export const revokers = new WeakMap();
|
|
10
|
+
/** Revoke what the plugin's run held (`startPlugin`'s `stop`). */
|
|
11
|
+
export function revokeRun(host) {
|
|
12
|
+
revokers.get(host)?.();
|
|
13
|
+
}
|
|
@@ -7,12 +7,46 @@
|
|
|
7
7
|
* Internal to the SDK; not exported from `@vestra-player/sdk/testing`.
|
|
8
8
|
*/
|
|
9
9
|
import { statSync } from "node:fs";
|
|
10
|
+
import { isAbsolute } from "node:path";
|
|
10
11
|
import { HostError } from "../../wire.js";
|
|
11
12
|
import { SESSION_STORAGE_LIMITS } from "../services.js";
|
|
12
13
|
import { validStep } from "../player/rules.js";
|
|
13
14
|
import { runCore, windowFacts } from "./core-actions.js";
|
|
15
|
+
import { builtinOnly } from "./commands.js";
|
|
14
16
|
import { shownText, declaredText, shownValues, hostText } from "./i18n.js";
|
|
15
17
|
import { resetWrites, writeProperty, initialValues, seeImages, kebab, typedView, checkType, inSetOrder, } from "./layout.js";
|
|
18
|
+
/** As the player in a temporary window (system.rs `GUEST_SECRETS`). */
|
|
19
|
+
const GUEST_SECRETS = "a temporary window cannot save or delete sign-in details; use the main window";
|
|
20
|
+
/** As the player in a temporary window (package_manager.rs `GUEST_PACKAGES`). */
|
|
21
|
+
const GUEST_PACKAGES = "a temporary window cannot install, update, remove, enable or disable plugins; use the main window";
|
|
22
|
+
/** The player's refusal of a change to the shared keychain or library in a temporary window. */
|
|
23
|
+
function guestRefuses(host, message) {
|
|
24
|
+
if (host.app.temporary === true)
|
|
25
|
+
throw new HostError("unavailable", message);
|
|
26
|
+
}
|
|
27
|
+
/** `app.openWindow`'s files, checked as the player does (capabilities/app_windows.rs). */
|
|
28
|
+
function windowPaths(paths) {
|
|
29
|
+
if (!Array.isArray(paths))
|
|
30
|
+
throw new HostError("invalid", "paths requires a list of file paths");
|
|
31
|
+
if (!paths.length || paths.length > 64)
|
|
32
|
+
throw new HostError("invalid", "paths takes 1 to 64 files");
|
|
33
|
+
return paths.map((path) => {
|
|
34
|
+
if (typeof path !== "string")
|
|
35
|
+
throw new HostError("invalid", "each path is a string");
|
|
36
|
+
if (!isAbsolute(path))
|
|
37
|
+
throw new HostError("invalid", `${path} is not an absolute path`);
|
|
38
|
+
let file = false;
|
|
39
|
+
try {
|
|
40
|
+
file = statSync(path).isFile();
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
// Not there: `missing` below, as the player.
|
|
44
|
+
}
|
|
45
|
+
if (!file)
|
|
46
|
+
throw new HostError("missing", `${path} is not a file`);
|
|
47
|
+
return path;
|
|
48
|
+
});
|
|
49
|
+
}
|
|
16
50
|
/** A `plugin.storage.session` key, checked as the player does. */
|
|
17
51
|
export function sessionKey(key) {
|
|
18
52
|
if (typeof key !== "string" ||
|
|
@@ -109,11 +143,15 @@ export function servicesHandlers(host, inner) {
|
|
|
109
143
|
"secrets.get": (p) => host.secrets.get(String(p.name)) ?? null,
|
|
110
144
|
"secrets.set": (p) => {
|
|
111
145
|
const name = String(p.name);
|
|
146
|
+
guestRefuses(host, GUEST_SECRETS);
|
|
112
147
|
if (!host.secrets.has(name) && host.secrets.size >= 256)
|
|
113
148
|
throw new HostError("limit", "a plugin stores at most 256 secret names");
|
|
114
149
|
host.secrets.set(name, String(p.value));
|
|
115
150
|
},
|
|
116
|
-
"secrets.delete": (p) =>
|
|
151
|
+
"secrets.delete": (p) => {
|
|
152
|
+
guestRefuses(host, GUEST_SECRETS);
|
|
153
|
+
host.secrets.delete(String(p.name));
|
|
154
|
+
},
|
|
117
155
|
// As the player (src/host/src/session_storage.rs).
|
|
118
156
|
"storage.session.get": (p) => {
|
|
119
157
|
const key = sessionKey(p.key);
|
|
@@ -140,6 +178,14 @@ export function servicesHandlers(host, inner) {
|
|
|
140
178
|
rendering: host.videoRender.gpu ? "gpu" : "software",
|
|
141
179
|
renderingReason: { ...host.rendering.reason },
|
|
142
180
|
}),
|
|
181
|
+
// Built-in only; no process starts: the call is recorded.
|
|
182
|
+
"app.openWindow": (p) => {
|
|
183
|
+
builtinOnly(host);
|
|
184
|
+
const paths = windowPaths(p.paths);
|
|
185
|
+
const pid = 40000 + host.openedWindows.length;
|
|
186
|
+
host.openedWindows.push({ paths, pid });
|
|
187
|
+
return { pid };
|
|
188
|
+
},
|
|
143
189
|
"clipboard.readText": () => host.clipboard.text,
|
|
144
190
|
"clipboard.writeText": (p) => {
|
|
145
191
|
if (typeof p.text !== "string")
|
|
@@ -352,6 +398,7 @@ export function servicesHandlers(host, inner) {
|
|
|
352
398
|
},
|
|
353
399
|
"packages.list": () => structuredClone(host.packages),
|
|
354
400
|
"packages.setEnabled": (p) => {
|
|
401
|
+
guestRefuses(host, GUEST_PACKAGES);
|
|
355
402
|
const id = String(p.id);
|
|
356
403
|
if (id === host.manifestId && p.enabled === false)
|
|
357
404
|
throw new HostError("invalid", "a plugin cannot disable itself");
|
|
@@ -394,6 +441,7 @@ export function servicesHandlers(host, inner) {
|
|
|
394
441
|
"packages.validate": (p) => validatePackage(host, inner, String(p.directory)),
|
|
395
442
|
"packages.validateArchive": (p) => validatePackage(host, inner, String(p.file)),
|
|
396
443
|
"packages.install": (p) => {
|
|
444
|
+
guestRefuses(host, GUEST_PACKAGES);
|
|
397
445
|
const manifest = host.candidates.get(String(p.token));
|
|
398
446
|
if (!manifest)
|
|
399
447
|
throw new HostError("stale", "unknown validation token");
|
|
@@ -448,6 +496,7 @@ export function servicesHandlers(host, inner) {
|
|
|
448
496
|
return { operationId: String(p.requestId), status: "committed" };
|
|
449
497
|
},
|
|
450
498
|
"packages.uninstall": (p) => {
|
|
499
|
+
guestRefuses(host, GUEST_PACKAGES);
|
|
451
500
|
const id = String(p.id);
|
|
452
501
|
const entry = host.packages.find((each) => each.id === id);
|
|
453
502
|
if (!entry)
|
|
@@ -10,6 +10,7 @@ import { rmSync } from "node:fs";
|
|
|
10
10
|
import { HostError } from "../../wire.js";
|
|
11
11
|
import { WAKE_EVENTS } from "../connection.js";
|
|
12
12
|
import { hearEvent } from "./triggers.js";
|
|
13
|
+
import { sendFacts } from "./facts.js";
|
|
13
14
|
export const tick = () => new Promise((resolve) => setImmediate(resolve));
|
|
14
15
|
/**
|
|
15
16
|
* Refusals for a position or resolver another plugin holds: not activation
|
|
@@ -50,6 +51,13 @@ export function on(_host, inner, event, listener) {
|
|
|
50
51
|
}
|
|
51
52
|
/** Implements `TestHost.emit`. */
|
|
52
53
|
export function emit(host, inner, event, data) {
|
|
54
|
+
deliver(host, inner, event, data);
|
|
55
|
+
// The window's and the layout's facts follow a `window.state`, whether
|
|
56
|
+
// the plugin hears it or not (`facts.ts`).
|
|
57
|
+
if (event === "window.state")
|
|
58
|
+
sendFacts(host, event);
|
|
59
|
+
}
|
|
60
|
+
function deliver(host, inner, event, data) {
|
|
53
61
|
// Trigger conditions first (the player evaluates them before it sends
|
|
54
62
|
// the state); a parked plugin hears nothing, a wake event wakes it.
|
|
55
63
|
if (hearEvent(host, inner, event, data))
|
|
@@ -40,8 +40,8 @@ export declare const TIMELINE_LIMITS: Readonly<{
|
|
|
40
40
|
}>;
|
|
41
41
|
/**
|
|
42
42
|
* One per plugin: read by `plugin.player.read()`, then kept
|
|
43
|
-
* current from `timeline.changed`
|
|
44
|
-
* (
|
|
43
|
+
* current from `timeline.changed` while the plugin listens to that event
|
|
44
|
+
* (`player.on`), and after this plugin's own changes.
|
|
45
45
|
*/
|
|
46
46
|
export declare class TimelineService {
|
|
47
47
|
#private;
|
package/dist/plugin/timeline.js
CHANGED
|
@@ -52,8 +52,8 @@ const viewRanges = (ranges) => Object.freeze(ranges.map((range) => Object.freeze
|
|
|
52
52
|
})));
|
|
53
53
|
/**
|
|
54
54
|
* One per plugin: read by `plugin.player.read()`, then kept
|
|
55
|
-
* current from `timeline.changed`
|
|
56
|
-
* (
|
|
55
|
+
* current from `timeline.changed` while the plugin listens to that event
|
|
56
|
+
* (`player.on`), and after this plugin's own changes.
|
|
57
57
|
*/
|
|
58
58
|
export class TimelineService {
|
|
59
59
|
#runtime;
|
|
@@ -78,7 +78,7 @@ export class TimelineService {
|
|
|
78
78
|
this.accept(lists);
|
|
79
79
|
else
|
|
80
80
|
void this.read();
|
|
81
|
-
}, "
|
|
81
|
+
}, "held", true);
|
|
82
82
|
}
|
|
83
83
|
accept(lists) {
|
|
84
84
|
const marks = view(lists.marks);
|