@vestra-player/sdk - v1.11.3
    Preparing search index...

    An in-memory fake Vestra Player for plugin tests.

    The plugin under test talks to it over the real wire protocol (the host is the plugin's transport), so everything the SDK does runs unchanged. The host answers each request with simplified player behaviour, records what the plugin did, and lets the test act as the user or another plugin.

    Members fall into a few groups:

    Usually created by startPlugin. Create one yourself only to preset data that the plugin reads during activation (app, appearance, secrets, ...), then pass it as startPlugin(activate, { host }).

    Fields that mirror player state at the wire level (source, subtitles, processing, snapshots, jobs, producers, uploads, resolvers, calls) use the protocol's shapes. They are fine for assertions but are not part of the plugin API: their shape may change in minor versions.

    The test starts the plugin in a player with the dark theme, opens a file the way another plugin would, and checks the plugin's panel title. A host created first can be preset with data the plugin reads during activation; startPlugin then uses it. openElsewhere changes the source and broadcasts it, the plugin's listener updates its panel, and settle() waits for those requests before the assertion.

    import assert from "node:assert/strict";
    import test from "node:test";
    import { startPlugin, TestHost } from "@vestra-player/sdk/testing";
    import activate from "../main.ts";

    test("shows the playing file in the panel", async () => {
    const host = new TestHost();
    host.appearance = "vestra"; // read during activation
    const { stop } = await startPlugin(activate, {
    directory: new URL("..", import.meta.url),
    host,
    });
    host.openElsewhere("/media/clip.mp4"); // another plugin opened a file
    await host.settle();
    assert.equal(host.mounted().props["title"], "clip.mp4");
    await stop();
    });

    An in-memory player that speaks the real wire protocol, so the SDK's own logic runs as it does in the player; only the player side is simulated (no decoding, no Slint, no windows). Make one per test, preset it if the plugin reads something during activation, start the plugin with startPlugin, drive it, settle(), and assert on what it recorded.

    1.0.0

    Implements

    • Transport
    Index
    • get locale(): Locale

      The interface language the test host plays (plugin.i18n.locale), "en" by default. Set it before startPlugin (or pass its locale option): the plugin's catalog for it is read from the package's locales/ then, and the menus (FakeCommand.display), OSD messages, dialog texts, settings page and panel titles show its translations, the way the player shows them.

      The player's own texts (core actions' messages and menus, its refusals) are English, or the player's Simplified Chinese for "zh-Hans". While locale was never set they stay in Chinese; set locale to test what a user sees now.

      Returns Locale

      The test starts the plugin with a Chinese interface and checks the menu path its Blur item shows. The locale option sets host.locale before activation, so the plugin's locales/zh-Hans.po is loaded; the built-in menu @video shows in the player's own words (视频), the item's title in the plugin's translation.

      const { host, stop } = await startPlugin(activate, { directory, locale: "zh-Hans" });
      assert.deepEqual(host.command("blur").display.path, ["视频", "模糊…"]);
      await stop();

      1.5.9

    • set locale(locale: Locale): void

      The interface language of this run (plugin.i18n.locale): the runner passes the player's VESTRA_LOCALE, the test host its locale.

      Parameters

      Returns void

    • get conflicts(): string[][]

      Bindings declared by more than one command, each as [binding, winner, ...ignored] (command ids; core actions as host/<id>). Empty when there are none.

      Returns string[][]

      The test fails when two commands, the player's or the plugin's, declare the same binding. Each entry is [binding, winner, ...ignored], so an empty list means every key does what its command says.

      assert.deepEqual(host.conflicts, []);
      
    • get barButtons(): readonly FakeBarButton[]

      The plugin's bottom-bar buttons (CommandOptions.button) as the player shows them: at most one, the first declared (BAR_BUTTON_LIMITS; a later one stays a menu item only). Empty once the command is disposed. Whether one is in the strip or its » menu is the player's business (the room and the other plugins' buttons).

      Returns readonly FakeBarButton[]

      The test finds the plugin's Store button, clicks it and checks that the Store window opened. barButtons lists the buttons of the plugin's commands declared with button, as the bar shows them; click() runs the command like its menu item and waits until the host is idle, and rejects while the command is disabled or busy.

      const [button] = host.barButtons; // one button per plugin
      assert.equal(button?.icon, "store");
      await button?.click();
      assert.equal(host.window("store").visible, true);

      1.5.29

    • get loggedErrors(): readonly HostError[]

      Every host error the plugin logged (expected or not), oldest first: errors with a code that nothing in the plugin handled.

      Returns readonly HostError[]

      The test asserts that the plugin left no refusal to its log. The list keeps every host error the plugin did not handle, also those the test expected with expectError, so it is empty only when none came.

      assert.deepEqual(host.loggedErrors.map((error) => error.code), []);
      

      1.11.2

    • get keepsRunning(): string[]

      Why the player would keep this plugin running while nothing uses it (lazy activation), one line per reason: an event it listens to that is not one the player wakes it for (with what listens and where it was added), its panel in the bottom bar or the backdrop, its open windows (these as the player's log says them), and its sidebar tab while that is the current tab. The player counts the current tab as busy work, not as something live: it keeps the plugin running only while the tab is shown, and a sidebar panel in a background tab is no reason at all (the plugin may go to standby; showing the tab starts it again). Empty: the player may stop it while idle and start it again on its next use. A state stream (player.stream) shows as a listener of source.state; filter chains, producer streams, jobs and the like (which also keep a plugin running) are not listed.

      Returns string[]

      1.5.40

      The test fails if the plugin keeps running for no reason after it starts, and names the reason (a stream opened in activate, say: open it only while something shows the state). The player stops such a plugin while nothing uses it and starts it again on its next use, so it costs no process meanwhile.

      assert.deepEqual(host.keepsRunning, []);
      
    • get now(): number

      The test host's wall clock (Unix milliseconds), which when.time conditions read. It starts at the real time; it moves only with TestHost.advance, or when a test sets it.

      Returns number

      1.10.0

    • set now(value: number): void

      Set the clock to value (Unix milliseconds). Only the clock moves: the kept conditions see the new time at their next evaluation, on TestHost.advance or a state the test pushes.

      Parameters

      • value: number

      Returns void

    • Press button index of the newest OSD message, as the user does: its command runs as if picked from a menu, and settles. A disabled or busy command does nothing, as in the player.

      Parameters

      • index: number

        0 or 1.

      Returns Promise<void>

      Error (rejects) The newest message has no button index.

      The test checks the button the plugin put on its newest message, then presses it as the user would: the plugin's reveal command runs.

      assert.deepEqual(host.osdActions.at(-1), [
      { title: "Show in Folder", command: "reveal" },
      ]);
      await host.pressOsdAction(0); // runs the plugin's `reveal` command

      1.6.9

    • Read the plugin's translations for TestHost.locale from a package directory, as the player would (locales/<locale>.json of a built package, else the source locales/<locale>.po); startPlugin does this. None for English; a missing file means none; a broken .po throws.

      Parameters

      • directory: string

        The package directory (holding locales/).

      Returns void

      1.5.9

      The test switches the host to German before starting the plugin and loads that catalog itself (startPlugin does the same). Texts are then shown in German.

      host.locale = "de";
      host.loadCatalog(directory); // locales/de.po (or de.json)
    • A text of the plugin as the player shows it: translated with the plugin's catalog (TestHost.loadCatalog), then formatted with args when given.

      Parameters

      • text: TextValue

        English source text or template.

      • Optionalargs: TemplateArgs

        Values for its placeholders.

      Returns string

      The shown text.

      The test expects the text a Chinese user sees for a template the plugin shows. translate looks the English source up in the plugin's catalog for host.locale and fills in the arguments, the way the player does.

      assert.equal(host.translate("Speed {}×", [2]), "倍速 2×");
      

      1.5.9

    • Simulate another plugin (or the user) saving the interface language: pushes appearance.changed.

      Parameters

      Returns void

      1.5.9

      The plugin hears that the saved interface language changed. The host pushes appearance.changed, which a plugin that listens to it sees in appearance.language; this run's language does not change.

      void plugin.appearance.language; // read once: the SDK then follows it
      plugin.player.on("appearance.changed", () => {}); // subscribes to appearance events
      host.setLanguage("fr");
      await host.settle();
      assert.equal(plugin.appearance.language, "fr");
    • Simulate another plugin publishing its timeline ranges (or clearing them with []); pushes timeline.changed when the plugin subscribed.

      Parameters

      • pluginId: string

        The other plugin's manifest id.

      • ranges: { start: number; end: number; style: string; title?: string | null }[]

        All its ranges.

      Returns void

      The plugin under test sees a range another plugin put on the seek bar: setTimelineRanges stores that plugin's ranges and pushes timeline.changed, and settle() lets it arrive.

      host.setTimelineRanges("community.clips", [
      { start: 40, end: 52.5, style: "selection", title: "Clip" },
      ]);
      await host.settle();
      assert.equal(plugin.timeline.ranges[0]?.plugin, "community.clips");

      1.6.9

    • Simulate another plugin publishing its timeline layer (or clearing it with []); pushes timeline.changed when the plugin subscribed.

      Parameters

      • pluginId: string

        The other plugin's manifest id.

      • marks: { time: number; kind: string; title?: string | null }[]

        Its whole layer.

      Returns void

      The plugin under test sees two chapter marks another plugin put on the timeline. setTimelineLayer stores that plugin's whole layer and pushes timeline.changed; while the plugin listens to it the SDK keeps marks current from that event, and settle() lets it arrive.

      host.setTimelineLayer("community.chapters", [
      { time: 0, kind: "chapter", title: "Intro" },
      { time: 95, kind: "chapter", title: "Part 1" },
      ]); // replaces that plugin's whole layer; [] would clear it
      await host.settle();
      assert.equal(plugin.timeline.marks.length, 2);

      1.0.0

    • The file an image property shows, or null when the value is not a runtime image. View properties hold images in their wire form; this reads the path back.

      Parameters

      • value: Json | undefined

      Returns string | null

      The test checks that the Cover window's image comes from the plugin's data directory. An image property holds the SDK's wire form of plugin.ui.image(path), not a path; imagePath reads the path back.

      assert.equal(
      host.imagePath(host.window("cover").props["cover"]),
      join(plugin.dataDirectory, "cover.png"),
      );

      1.0.0

    • Drop files like the player: on a panel with an onDrop listener the whole list goes there; otherwise (and on the video area) each path goes to the first provider of its extension (folder for existing directories), one call per provider with all of its paths. Files nobody takes are ignored. Resolves once the host is idle again.

      Parameters

      • paths: string[]

        The dropped paths, in the order the file manager gives.

      • options: {
            target?: "video" | "panel";
            at?: { x: number; y: number };
            modifiers?: Partial<{ alt: boolean; shift: boolean; cmd: boolean }>;
        } = {}

        target: "video" (default) or "panel"; at: the drop point in panel coordinates (default { x: 0, y: 0 }); modifiers: keys held (default all false).

      Returns Promise<void>

      The first drop lands on the video area: each extension belongs to the provider that registered it first, and each provider gets one call with all of its paths. The second lands on the panel at a point, with Alt held, and the panel's onDrop gets the whole list. drop resolves once the host is idle.

      await host.drop(["/media/a.srt", "/media/b.mkv"]); // on the video area
      // On the panel, 10 px from its left and 48 px from its top, Alt held.
      await host.drop(["/media/list.m3u"], {
      target: "panel",
      at: { x: 10, y: 48 },
      modifiers: { alt: true },
      });

      Never: files nobody takes are ignored, as in the player.

      1.0.0

    • Simulate another plugin switching the palette: updates TestHost.appearance and pushes appearance.changed.

      Parameters

      Returns void

      The plugin hears the palette change. The host updates appearance and pushes appearance.changed to a plugin that listens.

      const themes: string[] = [];
      plugin.player.on("appearance.changed", ({ theme }) => themes.push(theme)); // subscribes
      host.setAppearance("vestra-light");
      await host.settle();
      assert.deepEqual(themes, ["vestra-light"]);

      1.0.0

    • One settings page by id. Throws when it was never registered.

      Parameters

      • id: string

      Returns {
          category: string;
          title: string;
          order: number;
          file: string;
          component: string;
          global: string;
          props: Record<string, Json>;
          emit(callback: string, ...args: Json[]): void;
      }

      • category: string

        The page's settings category.

      • title: string

        The page title.

      • order: number

        The page order within its category.

      • file: string

        The .slint file (package-relative).

      • component: string

        The exported component the SDK found.

      • global: string

        The exported global (the page's bridge) the SDK found.

      • props: Record<string, Json>

        The page's properties by Slint (kebab-case) name.

      • emit: function

      The test sets the step on the General page and checks the page shows it. emit fires the page's callback as the user's input would; the plugin's handler stores the value and its bind function sends it back as a property, which settle() waits for.

      const page = host.settingsPage("general");
      page.emit("setStep", 10);
      await host.settle();
      assert.equal(page.props["step"], 10);

      1.0.0

    • Simulate the backdrop's effective changing (false: a video frame appeared; true: there is none again); pushed to the plugin.

      Parameters

      • effective: boolean

      Returns void

      The plugin's backdrop hears that a video frame now covers it. false means a picture appeared; the change is pushed like the player's window.state.

      host.setBackdropEffective(false);
      await host.settle();
      assert.equal(plugin.panels.backdrop.state?.effective, false);

      1.0.0

    • Simulate another plugin mounting a panel, before or after the plugin under test, as the player handles it: in the sidebar it is another tab (after the existing ones; the first panel's tab is current); the bottom bar and the backdrop take one panel, so the plugin's own mount there then rejects with conflict (not an activation failure, as in the player). Pushed as a window.state change.

      Parameters

      • slot: "bottom" | "sidebar" | "adjust" | "backdrop"

        The position.

      • plugin: string

        The other plugin's manifest id.

      • options: { title?: string } = {}

        title: its tab label (default: plugin).

      Returns void

      The sidebar ends up with two tabs: the playlist, mounted first, and the plugin's own panel after it. mountOther before startPlugin mounts another plugin's panel as the player would, so the plugin's mount during activation becomes the second tab (in the bottom bar or the backdrop it would be refused with conflict instead).

      const host = new TestHost();
      host.mountOther("sidebar", "vestra.playlist", { title: "播放列表" });
      await startPlugin(activate, { host, directory });
      assert.equal(host.layout.sidebar?.panels?.length, 2);

      1.5.2

    • Simulate another plugin's panel going away (TestHost.mountOther): when its tab was current, the next tab (else the previous one) is.

      Parameters

      • plugin: string

      Returns void

      1.5.2

      The other plugin's sidebar tab disappears and the plugin's own tab becomes current. When the removed tab was current, the next tab (else the previous one) becomes current, as in the player.

      host.unmountOther("vestra.playlist");
      await host.settle();
      assert.equal(host.layout.sidebar?.panels?.length, 1);
    • Simulate the user clicking a sidebar tab: plugin's panel (the plugin under test's manifestId, or one of TestHost.mountOther) becomes the current tab. Pushed as a window.state change.

      Parameters

      • plugin: string

      Returns void

      1.5.2

      The user switches the sidebar to the playlist; the plugin's panel is in a background tab now. The change is pushed as window.state.

      host.selectTab("vestra.playlist");
      await host.settle();
      assert.notEqual(host.layout.sidebar?.owner, 1); // the plugin under test is owner 1
    • Simulate another plugin taking the display layer first (the plugin's video.view() then fails with conflict), or, with null, releasing it (values reset to the defaults).

      Parameters

      • pluginId: string | null

      Returns void

      The plugin's video.view() fails with conflict because another plugin took the display layer first. null releases it again.

      host.setVideoViewOwner("someone.zoom");
      const view = plugin.video.view();
      view.set({ zoom: 2 });
      await host.settle();
      assert.equal(view.status.state, "failed");

      1.0.0

    • Simulate another plugin owning the render options (the plugin's video.render() then fails with conflict), or, with null, releasing them (values reset to the defaults).

      Parameters

      • pluginId: string | null

      Returns void

      The plugin's render options report conflict while another plugin owns them; null releases them and resets the values to the defaults.

      host.setVideoRenderOwner("someone.hdr");
      const render = plugin.video.render();
      render.set({ toneMapping: "bt.2390" });
      await host.settle();
      assert.equal(render.status.state, "failed");

      1.0.0

    • What the player pushes when mpv cannot compile a shader (code failed) or switches to software rendering (unsupported, which also sets videoRender.gpu to false and rendering.reason to window-fallback with message). Pushed only when this plugin is the owner. previous-crash is a shortcut that only sets the handle's status and reaches onError: the real player never pushes it, it refuses the set request itself. To test that, set TestHost.previousCrash.

      Parameters

      • code: "failed" | "previous-crash" | "unsupported"
      • message: string

      Returns void

      The plugin's render options report failed, as when mpv rejects a shader. The host pushes the failure only while this plugin owns the render options, which its first accepted set made it; the SDK updates the handle's status when the push arrives, so the test settles first.

      const render = plugin.video.render();
      render.set({ toneMapping: "bt.2390" }); // makes the plugin the owner
      await host.settle();
      host.failVideoRender("failed", "shader compile failed: ERROR: 0:39: ...");
      await host.settle();
      assert.equal(render.status.state, "failed");

      1.0.0

    • What the player pushes to a shader handle when mpv cannot compile a shader (code failed; the player cannot tell whose shader failed, so every handle with shaders hears it) or the player switches to software rendering (unsupported; use TestHost.failVideoRender, which also tells the handles). Pushed only to a handle that holds shaders.

      code (default failed) is the error code pushed. previous-crash is a shortcut that only sets the handle's status and reaches onError: the real player never pushes it, it refuses the set request itself after an abnormal end. To test that, set TestHost.previousCrash.

      Parameters

      • id: string
      • message: string
      • code: "failed" | "previous-crash" = "failed"

      Returns void

      The plugin's shader handle reports failed, as when mpv rejects a shader. The host pushes the failure only to a handle that holds shaders, which its accepted set made it; the SDK updates the handle's status when the push arrives, so the test settles first.

      const file = join(plugin.dataDirectory, "sharpen.glsl");
      writeFileSync(file, "//!HOOK MAIN\n");
      const shaders = plugin.video.shaders("sharpen");
      shaders.set([file]); // the handle now holds a shader
      await host.settle();
      host.failVideoShaders("sharpen", "shader compile failed: ERROR: 0:3: ...");
      await host.settle();
      assert.equal(shaders.status.state, "failed");

      1.5.39

    • The list resolvers.fileTypes carries: the extensions of this plugin's file resolvers and of TestHost.otherResolvers, sorted, each once.

      Returns string[]

      The test checks the list the plugin will hear in resolvers.fileTypes: the extensions of its own file resolvers and of otherResolvers, sorted, each once.

      assert.deepEqual(host.fileTypes(), ["ch8"]);
      

      1.5.8

    • Push resolvers.fileTypes when TestHost.fileTypes changed: called after this plugin's resolvers come and go; call it yourself after changing TestHost.otherResolvers (another plugin started or stopped).

      Returns void

      Another plugin starts and adds .ch8; the plugin under test, which listens with player.on("resolvers.fileTypes"), then hears it. Changing otherResolvers alone pushes nothing: updateFileTypes sends the new list as the player does when a plugin starts or stops, and settle() lets the listener run.

      const heard: string[][] = [];
      // A listener of the event: each list the player sends.
      plugin.player.on("resolvers.fileTypes", ({ fileTypes }) => heard.push(fileTypes));
      // Another plugin starts with a resolver for .ch8 files.
      host.otherResolvers.push({ owner: "example.emulator", extensions: ["ch8"] });
      host.updateFileTypes();
      await host.settle();
      assert.deepEqual(heard, [["ch8"]]);

      1.5.8

    • Simulate mpv changing a property: store the value and send it to the plugin if it observes the property (plugin.mpv.observe).

      Parameters

      • name: string

        The property, as mpv names it.

      • value: Json

        Its new value.

      Returns void

      The plugin's listener hears the value the test gives the property. setMpvProperty stores it and sends the mpv.property event that the player sends to an observer; settle lets it arrive.

      const seen: unknown[] = [];
      plugin.mpv.observe("estimated-vf-fps", (fps) => seen.push(fps));
      await host.settle();
      host.setMpvProperty("estimated-vf-fps", 59.94);
      await host.settle();
      assert.deepEqual(seen, [null, 59.94]); // no value at first, then the change

      1.8.0

    • Make the upscaler's reason decoding with cause, with the player's message, and set upscaling.hwdecCurrent to match (d3d11va-copy, no, nvdec). plugins are named for copy-back only, as the player does. Returns the reason; call TestHost.upscalingChanged to tell a listening plugin.

      Parameters

      Returns UpscalingReason

      The plugin's window explains why upscaling waits. The test fakes the copy-back cause that Picture Adjustments' filters cause and checks that the window names the plugin.

      host.upscalingDecoding("copy-back", [{ id: "vestra.video", name: "Picture Adjustments" }]);
      host.upscalingChanged();
      await host.settle();
      assert.match(String(host.window("upscale").props.blocker), /Picture Adjustments/);

      1.5.43

    • Send video.upscaling.changed with the state TestHost.upscaling describes now (without enabled), as the player does when it changes; a plugin listening with plugin.video.upscaling.onChange receives it. Nothing reaches a plugin that does not listen.

      Returns void

      The window resized: the test changes the area and the factor, sends the change, and checks that the plugin's window shows the new factor.

      host.upscaling.area = { width: 2560, height: 1440 };
      host.upscaling.factor = 1.33; // 1080p in a 1440p area
      host.upscalingChanged(); // as the player after the resize settled
      await host.settle();
      assert.equal(host.window("upscale").props.factor, "×1.33");

      1.5.43

    • Send video.motion.changed with the state TestHost.motion describes now (without mode), and then the one of TestHost.nvidiaMotion, as the player does when they change; a plugin listening with plugin.video.motion(engine).onChange receives its engine's. Nothing reaches a plugin that does not listen.

      Returns void

      The player turned the converter off for this video; the plugin's panel shows the reason.

      host.motion.double = { code: "overload", message: "the GPU could not keep up with this video" };
      host.motionChanged();
      await host.settle();

      1.7.19

    • Simulate the user activating the palette's lead row: Enter (keep: Shift+Enter) with query typed, or Enter on the status row (status). Mints a ticket, sends the palette.lead event, waits until the host is idle and returns the ticket.

      Like the player, commands.run takes the ticket until PaletteLead.done or 120 s after its last run, at most 30 runs, 4 a second, and 120 runs a minute per plugin (limit). A command declared destructive (and the player's host/stop and host/quit, and the Settings and Reset menus) is confirmed first: the answer comes from TestHost.dialogAnswers ({ confirmed: false, checked: false } is Don't Run, confirmed: true Run, with checked: true Run and "Don't ask again", which runs like Run since every command a test host lists is built in). A run with then (since 1.7.16) takes one answer for its whole plan and remembers an approved plan for the ticket, as the player does ("@vestra-player/sdk"!CommandRunOptions.then). Each run adds the command's title (and · step/of) to TestHost.osd.

      Parameters

      • query: string

        What the user typed.

      • options: { keep?: boolean; status?: boolean } = {}

        keep: Shift+Enter; status: the status row.

      Returns Promise<string>

      The ticket of this user action.

      The user asks the plugin to stop playback and declines the confirmation. builtin lets the plugin hold the lead; the ticket minted here is what its listener passes to commands.run, and the queued answer declines the player's alert for host/stop. One answer covers a request whose first run names the rest of its plan in then.

      import assert from "node:assert/strict";
      import { startPlugin } from "@vestra-player/sdk/testing";
      import activate from "../main.ts";

      const { host, stop } = await startPlugin(activate, {
      directory: new URL("..", import.meta.url),
      builtin: true, // as a plugin built into the player
      });
      host.dialogAnswers.push({ confirmed: false, checked: false }); // Don't Run
      await host.runPaletteLead("stop playback");
      assert.deepEqual(host.coreRuns, []); // declined: nothing ran
      await stop();

      Error without a code (rejects) The plugin has no lead row.

      1.7.9

    • One of the 14 core actions (play-pause, stop, seek-forward, ...) that the test host registers like the player, as host/<id>. Throws for an unknown id. run() executes it like its menu item: a disabled action rejects with command, as in the player (plugin.host.run rejects with unavailable instead); otherwise it runs with the player's checks and writes its on-screen text to TestHost.osd.

      Parameters

      • id: string

      Returns FakeCommand

      The test pauses playback the way the Space key does and checks that the host recorded it. Core actions belong to the player (host/<id>); run() applies the player's checks, so a source must be ready first, and every run is appended to coreRuns.

      host.setSource({ phase: "ready", duration: 100, position: 10 });
      await host.coreAction("play-pause").run();
      assert.equal(host.source.paused, true);
      assert.deepEqual(host.coreRuns, ["play-pause"]);

      1.0.0

    • Replace the host's behaviour for one wire method until TestHost.reset. The handler receives the request parameters and returns the reply (or a promise of it).

      Throw a HostError to simulate a definite refusal (the plugin's call rejects with that code); throw a plain Error to simulate a lost reply (the SDK then runs its recovery path). Method names are protocol names, e.g. "clipboard.writeText", "secrets.get", "system.openPath", "audio.addTrack"; see TestHost.sent to find the one a call uses.

      Parameters

      • method: string

        The wire method name.

      • handler: Handler

        Produces the reply from the request parameters.

      Returns void

      The plugin's Open Folder command meets a missing folder and must tell the user. handle replaces the host's answer to one wire method; the HostError it throws reaches the plugin as a rejection with code missing, like the player's refusal. reset restores the default behaviour for the rest of the test.

      host.handle("system.openPath", () => {
      throw new HostError("missing", "no such file");
      });
      await host.command("open-folder").run(); // the plugin catches `missing`
      assert.deepEqual(host.osd, ["Folder not found"]);
      host.reset("system.openPath");

      1.0.0

    • Restore the default behaviour of a method replaced with TestHost.handle.

      Parameters

      • method: string

      Returns void

      The first write fails, the second succeeds. reset removes the handler that handle installed, so the method is answered by the test host again.

      host.handle("clipboard.writeText", () => {
      throw new HostError("failed", "denied");
      });
      await assert.rejects(plugin.clipboard.writeText("x"));
      host.reset("clipboard.writeText");
      await plugin.clipboard.writeText("x"); // the default handler again

      1.0.0

    • Deliver a host event to the plugin. Like the player, subscription-based events (source.state, playback.backend, window.state, timeline.changed, appearance.changed) are delivered only when the plugin subscribed (something of it listens). Most tests use the higher-level helpers (setSource, setMainWindow, ...) instead.

      Parameters

      • event: string

        The wire event name.

      • data: unknown

        The event payload (wire-level shape).

      Returns void

      The test pushes a window.state event after changing layout by hand. Like the player, the host delivers it only when the plugin subscribed; most tests use setSource, setMainWindow and the other helpers instead.

      host.emit("window.state", {}); // no facts: the SDK reads window.state again
      await host.settle();

      1.0.0

    • Change the source facts and broadcast them, as if the player's state changed (the user paused, playback reached the end, a file finished loading). Any phase other than empty also turns on the source capabilities (pause, seek, rate, ...) unless the patch sets them. After phase: "ended", a seek (a plugin's, a core step seek) returns to ready and plays on (paused: false), as in the player; it stays paused when the end was reached while paused or by a frame step. A seek at or past the end (the smaller of position and duration, 0.5 ms slack) goes nowhere: accepted, still ended and paused. phase: "loading" makes a mounted backdrop effective, like the player.

      Parameters

      • patch: Partial<SourceState>

        Wire-level source fields, e.g. phase, position, duration, paused, audioTracks.

      Returns void

      The plugin sees a one-minute source become ready, then end on its own. setSource changes the host's source facts and broadcasts them like the player's events; the SDK updates player.state when the event arrives, so the test settles before reading it.

      host.setSource({ phase: "ready", duration: 60, position: 0 });
      await host.settle();
      assert.equal(plugin.player.state.phase, "ready");
      host.setSource({ phase: "ended", terminalReason: "natural" });
      await host.settle();

      1.0.0

    • Simulate the user changing the main window (resizing, maximizing or restoring it, entering or leaving fullscreen, closing the picture-in-picture window) and broadcast it. maximized reads false while fullscreen. Like the player, entering fullscreen collapses an attached, visible sidebar (effective: false, reason: "fullscreen") and leaving fullscreen docks it again.

      Parameters

      • patch: Partial<
            {
                fullscreen: boolean;
                maximized: boolean;
                videoArea: { width: number; height: number };
                pictureInPicture: { supported: boolean; active: boolean };
            },
        >

      Returns void

      The plugin sees the main window fullscreen at 1920×1080, then learns that picture-in-picture is available, then sees the window leave fullscreen maximized. setMainWindow changes the host's window facts and broadcasts them as the player does when the user resizes or toggles fullscreen; entering fullscreen also collapses an attached sidebar.

      host.setMainWindow({ fullscreen: true, videoArea: { width: 1920, height: 1080 } });
      await host.settle();
      assert.equal(plugin.window.state.fullscreen, true);
      host.setMainWindow({ pictureInPicture: { supported: true, active: false } });
      // Leaving fullscreen into a maximized window: `maximized` reads true again.
      host.setMainWindow({ fullscreen: false, maximized: true });
      await host.settle();
      assert.equal(plugin.window.state.maximized, true);

      1.0.0

    • The pointer reached the right edge in fullscreen (true) or left the popped-out columns (false): the attached sidebar and the adjust column, those switched on, pop out or collapse (reference §6.3). No effect outside fullscreen, or on a column switched off or floating.

      Parameters

      • popped: boolean

      Returns void

      The pointer reaches the right edge in fullscreen and the attached sidebar pops out over the video. Outside fullscreen, or with the sidebar hidden or floating, nothing happens.

      host.setMainWindow({ fullscreen: true });
      host.popSidebar(true);
      await host.settle();

      1.0.0

    • Simulate another plugin (or the user) opening a source: a new sourceId, then the given phase. Calls the plugin made against the old state now fail with stale.

      The source stamp advances exactly as in the player: a new generation and a new intent, also when source is the path already open (the user opened the same file again). Call it after startPlugin to test what the user does while the plugin runs: a file opened after activation, another file, the same one again. A control the plugin then makes with the state it read before (player.setRate, seek, step, …) is refused with stale, as in the player. The user's own pause, seek or speed change is a core action (coreAction("play-pause").run()): a new intent, which makes an older state stale too. setSource changes the facts only.

      Parameters

      • source: string

        The path or URL.

      • phase: "empty" | "loading" | "ready" | "ended" | "error" = "ready"

        The phase to end in (default "ready").

      Returns void

      A state the plugin captured before stops being current once another file opens. openElsewhere gives the source a new sourceId, so isCurrent turns false. Promise-returning calls made with ifCurrent: before then reject with stale; calls that return nothing drop the write silently instead (TimelineLayer.set with ifCurrent).

      const before = plugin.player.state;
      host.openElsewhere("/media/other.mp4");
      await host.settle();
      assert.equal(plugin.player.isCurrent(before), false);

      1.0.0

    • Simulate a generated stream failing in the player (its audio device lost, its frame connection broken), like the player: the source fails with message (phase: "error") and the producer is retired at once. The stream's onStop listeners get a stream error with message.

      Parameters

      • producerId: number

        The producer, from TestHost.producers.

      • message: string

        The player's failure text.

      Returns void

      The plugin's stream stops with an error, as when the player loses its audio device. failStream puts the source into error with the message and retires the producer at once; the stream's onStop listeners get a stream error carrying the message.

      const [producer] = host.producers.values();
      host.failStream(producer!.id, "producer transport closed");

      1.5.7

    • Press a binding like the host's table would: panel-focus bindings first when panel is true, then global ones; within a scope the earliest registration first (the player's own commands before the plugin's), as the conflict rule orders them. A disabled command lets the key pass to the next command bound to it: the one it shadowed, then the global scope. The first enabled one runs; press resolves after it ran ("ran"). When only disabled commands hold the key, the first of them decides, as in the player: with a reason it shows the reason on the OSD and eats the key ("reason", see host.osd); without one the key goes on to the focused control ("passed", nothing runs). Unlike the player, which only logs a key that reaches a busy command, press then rejects, so a test notices. Rejects when nothing is bound. Bindings use the reference syntax ("Space", "Ctrl+O", "Mouse:WheelUp"), and user overrides in bindings.overlay apply.

      Parameters

      • binding: string
      • options: { panel?: boolean } = {}

      Returns Promise<"reason" | "ran" | "passed">

      What the key did: "ran", "reason" or "passed".

      Ctrl+B runs whatever is bound globally; Delete is pressed while the plugin's panel has focus, so panel bindings are tried first. press follows the player's binding table and resolves with what happened: "ran", "reason" (a disabled command showed why) or "passed".

      await host.press("Ctrl+B"); // a global binding
      await host.press("Delete", { panel: true }); // while the panel has focus

      command (rejects) A HostError: the command that would run is busy (the player only logs this).

      Error (rejects) Nothing is bound to the key.

      1.0.0

    • Change the keys of one of the plugin's commands, or of one of the player's core commands by its host/<id>, as the user does in Keyboard Shortcuts: inputs replaces its keys ([] clears them, as Ignore Default Shortcuts does for every default), null gives it its own defaults back. It writes bindings.overlay, and the plugin hears it as from the player: bindings.changed and, when what plugin.commands.keys reads changed, commands.keys.

      Parameters

      • command: string
      • inputs: readonly string[] | null

      Returns void

      The view showed W for Brightness −; after the user moves it to Shift+W, it shows the new key. rebind changes the overlay and pushes the new labels, and settle lets the binding run again. The test host is a Mac unless systemInfo.os says otherwise, hence ⇧W.

      host.rebind("brightness.down", ["Shift+W"]);
      await host.settle();
      assert.equal(host.window("picture").props["brightness-down"], "⇧W");

      Error command is neither a command of the plugin nor a core command.

      1.6.6

    • The Markdown document a value holds (its wire form read back), or null when the value is not one. images maps each remote address to the downloaded file. Pass a whole property value or a field of one: a document nested in rows is read the same way.

      Parameters

      • value: Json | undefined

      Returns MarkdownWire | null

      The test checks the Markdown source of the first chat message. Rows hold the document in its wire form, as plugin.ui.markdown produced it; markdown reads it back, nested in a row or not.

      const rows = host.window("chat").props["messages"] as { body: Json }[];
      assert.equal(host.markdown(rows[0]!.body)?.text, "**Hello**");

      1.1.0

    • Replace the plugin list and push packages.changed (another plugin started, stopped, was installed or removed).

      Parameters

      • list: {
            id: string;
            version: string | null;
            origin: "installed" | "development";
            state: "failed" | "starting" | "running" | "disabled" | "stopped";
            error: string | null;
            directory: string;
            builtin?: boolean;
            source?: PackageSource | null;
            dataDirectory?: string | null;
        }[]
        • id: string

          The plugin's manifest id.

        • version: string | null

          Its version, null when unknown.

        • origin: "installed" | "development"

          Where it was loaded from.

        • state: "failed" | "starting" | "running" | "disabled" | "stopped"

          Its run state.

        • error: string | null

          Why it failed (state: "failed").

        • directory: string

          The package directory.

        • Optionalbuiltin?: boolean

          Shipped with the player: uninstall and install are unsupported.

        • Optionalsource?: PackageSource | null

          Where it was installed from.

        • OptionaldataDirectory?: string | null

          Its data directory.

      Returns void

      The plugin's store window hears that a plugin is running now. The list replaces packages and is pushed as packages.changed, which the plugin's packages.onChange listeners receive.

      host.setPackages([...host.packages]); // edit a copy, then push it
      await host.settle();

      1.0.0

    • Simulate another plugin calling player.next() / previous(): the host asks this plugin's sequence provider. Rejects with unavailable when there is no provider or its flag is false.

      Parameters

      • direction: "next" | "previous"

      Returns Promise<unknown>

      unavailable (rejects) A HostError: there is no sequence provider, or its flag is false.

      Another plugin calls player.next(); the host asks the plugin under test, which is the sequence provider, and the test checks what it opened.

      await host.step("next");
      await host.settle();
      assert.equal(host.source.source, "/media/b.mp4");

      1.0.0

    • The plugin's command with this local id. Throws when it is not registered (never added, or disposed).

      Parameters

      • id: string

      Returns FakeCommand

      The test checks that Export becomes enabled once a file is ready. The record is updated as the plugin sends new state; read it after settle().

      host.setSource({ phase: "ready", duration: 60 });
      await host.settle();
      assert.equal(host.command("export").state.enabled, true); // throws if not registered

      1.0.0

    • The plugin's tool window with this id (by default the file name without extension: ui/picture.slint → picture). Throws when it was never opened with show().

      Parameters

      • id: string

      Returns FakeWindow

      The Picture window's Reset callback runs and the brightness returns to 0. The window is found by its id (the .slint file name by default); emit fires the callback the plugin bound, and settle() waits for the property the handler wrote.

      host.window("picture").emit("reset");
      await host.settle();
      assert.equal(host.window("picture").props["brightness"], 0);

      1.0.0

    • The plugin's mounted panel (bottom bar, sidebar, adjust column or backdrop): the one in slot, or without it the only one (a plugin mounts one panel per slot; with several, name the slot). Throws when there is none. Its props use Slint (kebab-case) names; emit fires a callback on the panel's global.

      Parameters

      • Optionalslot: "bottom" | "sidebar" | "adjust" | "backdrop"

      Returns FakePanel

      The test checks the panel sits in the sidebar and selects its third row. emit fires a callback on the panel's global as a click would; the plugin's handler runs, and settle() waits for what it sent.

      const panel = host.mounted();
      assert.equal(panel.slot, "sidebar");
      panel.emit("select", 2);
      await host.settle();

      1.0.0

    • The parameters of every request of one wire method, oldest first.

      Parameters

      • method: string

      Returns Record<string, Json>[]

      The test checks the last OSD request the plugin sent, before translation. sent lists the parameters of every request of one wire method, oldest first; host.osd holds the texts as shown instead.

      assert.deepEqual(host.sent("osd.show").at(-1), { text: "Saved" });
      

      1.0.0

    • Wait until no request is in flight (and the SDK's follow-up passes ran), and at least ms milliseconds have passed so that timers due by then fired. Call it after every action that makes the plugin talk to the host, before asserting.

      It only waits for host calls. Work the plugin does on its own (reading or parsing a file, a child process, a network request) is not waited for: on a loaded machine it can finish after settle() returns. Poll the result you assert on instead (second example).

      settle() does not wait for the SDK's once-a-second full update pass. After setSource (or another player state change) only the bindings that read a changed field of plugin.player.state run again; state the plugin changed outside a handler without plugin.update() shows only in the next full pass. Have the plugin call plugin.update() after such a change, or wait settle(1000).

      Parameters

      • ms: number = 0

        Extra time to wait, for debounces and timers (default 0).

      Returns Promise<void>

      The plugin's store writes its file 300 ms after the last save, so the test waits 400 ms before it checks what the plugin did next. settle(ms) returns when no request is in flight and at least ms have passed, so the store's timer has fired. The file write itself is the plugin's own work, which settle does not wait for: a test that reads the file calls await store.flush() instead.

      const store = plugin.storage.json("prefs", { defaults: { step: 5 } });
      store.save({ step: 10 });
      await host.settle(400); // past storage.json's 300 ms debounce

      The plugin reads and parses a file before it shows a status; settle does not wait for that (it only waits for host requests), so the test polls the property it asserts on, 20 ms at a time, for up to 2 seconds.

      const importWindow = host.window("import");
      importWindow.emit("load-file"); // the plugin reads and parses the file itself
      for (let i = 0; i < 100 && importWindow.props["status-text"] !== expected; i++)
      await host.settle(20);
      assert.equal(importWindow.props["status-text"], expected);

      Error (rejects) The plugin logged a host error the test did not expect (TestHost.strictErrors, SDK 1.11.2); the message names it and says how to expect it (TestHost.expectError).

      1.0.0

    • Expect the plugin to log one host error with code (each call expects one more). An expected error does not fail the test; one that never comes fails stop() (under TestHost.strictErrors).

      Parameters

      • code: string

        The error's code, e.g. "stale".

      Returns void

      The plugin read the state once and sets the speed with its old copy; after the user opened another file the player refuses the control.

      host.openElsewhere("/media/other.mp4");
      host.expectError("stale");
      await host.command("rate-2").run();
      assert.equal(host.loggedErrors.at(-1)?.code, "stale");

      1.11.2

    • Close the fake stream servers and delete the host's temporary directories. stop() from startPlugin calls it. It never throws: a directory that a closing file handle still holds (Windows: ENOTEMPTY, EBUSY, EPERM) is retried for about 1.5 s, then left for the system to clean, with a warning on the console.

      Returns void

      A test that made a host but failed before startPlugin removes the host's temporary directories itself. stop() from startPlugin calls close for you otherwise.

      const host = new TestHost();
      try {
      // … preset the host; the test fails here …
      } finally {
      host.close(); // deletes the host's temporary data
      }

      1.0.0

    • Move the clock by ms milliseconds and, while the source plays (phase ready, not paused), the position by rate × ms. Each position boundary and time bound a kept condition waits for is passed in its order: an enter or leave runs with the clock and the position where the player would call it, and the test does not wait. The new position is then pushed as source.state.

      Parameters

      • ms: number

      Returns Promise<void>

      The source plays from 0, and the plugin's position condition has a lead of 2 s before a range at 10 s. Advancing 8 s of clock plays 8 s of media, so the trigger's enter runs on the way, at 8 s.

      host.setSource({ phase: "ready", duration: 60, position: 0 });
      // … the plugin gave when.position.in([{ start: 10, end: 12 }], { lead: 2 })
      await host.advance(8_000); // its enter ran at 8 s

      TypeError (rejects) ms is not a number of 0 or more.

      1.10.0

    • The player puts the plugin in standby: it is stopped (reason idle); its trigger conditions and the wake events it listens to are kept. A condition that flips, or a wake event, starts it again (activate() runs anew) and delivers what waited, in order; the conditions given again by activate() change nothing.

      Returns Promise<void>

      Error without a code (rejects) The plugin was not started with startPlugin.

      The test puts a plugin that armed one trigger in standby, as the player does when nothing uses it, and checks that the player still keeps the condition that will start the plugin again.

      await host.park(); // stopped with reason "idle"
      assert.equal(host.parked, true);
      assert.equal(host.triggers.length, 1);

      1.10.0

    • Another version replaces the plugin: it is stopped (reason upgrade), the conditions of its unnamed triggers are cleared, the named ones kept, and it starts again with activate (the new version's code; default: the same). A name the new version does not declare is dropped when it starts.

      Parameters

      • Optionalactivate: (plugin: Plugin) => unknown

      Returns Promise<void>

      Error without a code (rejects) The plugin was not started with startPlugin.

      The test arms the plugin's sleep timer from its command, replaces the plugin with the same code as a new version, and checks that the player still keeps the condition of the trigger named sleep.

      await host.command("in45").run();
      await host.upgrade(); // the same activate, as the new version
      assert.ok(host.triggers.some((kept) => kept.trigger === "sleep"));

      1.10.0

    calls: Call[] = []

    Every request the plugin sent, in order: { method, params }. Wire-level; prefer TestHost.sent for one method.

    subscriptions: Set<string> = ...

    The host events the plugin subscribed to.

    listening: Set<string> = ...

    The subscribed events the plugin really listens to: a listener (player.on, an onChange and the like) or a stream. The SDK's own copies of the state are left out, and a binding that reads a state subscribes nothing. Empty means the player may stop the plugin while nothing uses it (unless it holds something else: a window, a panel, a filter…).

    1.5.38

    listeningWhy: Map<string, string[]> = ...

    Why the plugin listens to each event of TestHost.listening: every listener and stream, as the player's log says them (a listener added at main.ts:12, a stream opened at main.ts:20), in the order they came. A binding's or command field's read of the event's state is listed beside them (with "— use plugin.when" where a condition exists); it is never a reason on its own.

    1.5.40

    source: SourceState = ...

    The player's source facts (phase, position, duration, paused, rate, audio tracks, loop, ...). Wire-level shape; change it with TestHost.setSource, which also broadcasts it.

    windows: Map<string, FakeWindow> = ...

    Tool windows by id (see TestHost.window).

    panels: Map<string, FakePanel> = ...

    The plugin's mounted panels by slot, in mount order (one panel per slot). See TestHost.mounted.

    commands: Map<string, FakeCommand> = ...

    The plugin's commands by local id (see TestHost.command).

    coreCommands: Map<string, FakeCommand> = ...

    The player's 14 core actions (host/<id>), kept apart from the plugin's commands.

    layout: {
        bottom: LayoutSlot | null;
        sidebar: LayoutSlot | null;
        adjust: LayoutSlot | null;
    } = ...

    Both panel positions as the player reports them (null while no panel is mounted there). You may change a slot directly and then call host.emit("window.state", {}) to simulate a change made elsewhere.

    Type Declaration

    • bottom: LayoutSlot | null

      The bottom bar position: preferred, effective, reason, detached, owner and panels (its one panel).

    • sidebar: LayoutSlot | null

      The sidebar position: preferred, effective, reason, detached; panels are its tabs in order ({ owner, plugin, title }), owner the current tab's (the plugin under test is owner 1).

    • adjust: LayoutSlot | null

      The adjust column, like the sidebar but never detached. It starts hidden (preferred: false, reason: "userHidden"), as the player's does until the user opens it.

    With the plugin's panel in the sidebar, toggling the sidebar records that the user prefers it hidden. toggle() reads the slot from the player, asks for the opposite of its preferred flag and resolves once the player answered, so the host's layout already shows the new value.

    assert.equal(host.layout.sidebar?.preferred, true);
    await plugin.panels.sidebar.toggle();
    assert.equal(host.layout.sidebar?.preferred, false);
    osd: string[] = []

    Every osd.show text as the player shows it (translated with the plugin's catalog and formatted with its args), newest last. The template and args the plugin sent are in host.sent("osd.show").

    osdActions: { title: string; command: string }[][] = []

    The action buttons of each osd.show message, in step with osd (index for index): each button's title as shown and its command; [] for a message without actions.

    Type Declaration

    • title: string

      The button title as shown, in the plugin's locale.

    • command: string

      The local id of the plugin's command the button runs.

    osdPanel: string | null = null

    The text of this plugin's osd panel as shown, null when hidden.

    language: LanguagePreference = "system"

    The saved interface language (plugin.appearance.language), changed by appearance.setLanguage or TestHost.setLanguage.

    1.5.9

    confirmTexts: {
        message: string;
        detail?: string;
        confirm: string;
        cancel: string;
        checkbox?: string;
    }[] = []

    Every dialogs.confirm as the player shows it: its texts translated (message and detail formatted with args), newest last. The options the plugin sent are in TestHost.confirms.

    Type Declaration

    • message: string

      The question.

    • Optionaldetail?: string

      The text under it, if any.

    • confirm: string

      The confirm button.

    • cancel: string

      The cancel button (the player's "Cancel" by default).

    • Optionalcheckbox?: string

      The checkbox, if any.

    1.5.9

    fileDialogs: FileDialogText[] = []

    Every file dialog (openFile, openFiles, openDirectory, saveFile) as the player shows it: the title translated, a text file name translated, newest last. The options the plugin sent are in host.sent("dialogs.open").

    1.5.11

    sequence: { canNext: boolean; canPrevious: boolean } | null = null

    The sequence provider's flags, null without a provider.

    Type Declaration

    • { canNext: boolean; canPrevious: boolean }
      • canNext: boolean

        The provider's canNext, as last evaluated.

      • canPrevious: boolean

        The provider's canPrevious, as last evaluated.

    • null
    stats: PlaybackStats = ...

    What player.stats() returns. Fields added in later rounds may be left out; the SDK fills them with null.

    The plugin's player.stats() now reports a 1920×1080 H.264 stream at 24 fps. The host answers stats() with this object as it stands, so a test sets it before the plugin asks; fields it leaves out come back as null from the SDK.

    host.stats = {
    ...host.stats, // keep the other fields
    video: { codec: "h264", width: 1920, height: 1080, fps: 24 },
    } as typeof host.stats;
    subtitleLoads: {
        format: "srt" | "ass";
        title: string | null;
        select: "primary" | "secondary" | "none";
        bytes: Buffer;
    }[] = []

    Every subtitles.load: its options and bytes, newest last.

    Type Declaration

    • format: "srt" | "ass"

      The format option ("srt" by default).

    • title: string | null

      The title option, null when omitted.

    • select: "primary" | "secondary" | "none"

      The select option ("primary" by default).

    • bytes: Buffer

      The uploaded file bytes.

    clipboard: { text: string | null; images: string[] } = ...

    The fake system clipboard. Preset text to test readText; writeText replaces it and writeImage appends the image path.

    Type Declaration

    • text: string | null

      The clipboard's text, null when it holds none.

    • images: string[]

      Paths given to clipboard.writeImage, newest last.

    power: "off" | "playing" = "off"

    The effective power.preventSleep mode.

    tools: {
        calls: { tool: string; args: string[] }[];
        handle(
            tool: "ffmpeg" | "ffprobe",
            handler: (
                args: string[],
            ) =>
                | { stdout?: string
                | Uint8Array<ArrayBufferLike>; stderr?: string }
                | Promise<
                    { stdout?: string
                    | Uint8Array<ArrayBufferLike>; stderr?: string },
                >,
        ): void;
    } = ...

    The fake ffmpeg / ffprobe behind plugin.tools. A tool without a handler is not found (available() is false, run() rejects with unavailable).

    Type Declaration

    • calls: { tool: string; args: string[] }[]

      Every run: the tool name and its arguments, newest last.

    • handle: function
      • Make tool available and answer each run with handler(args). Return { stdout?, stderr? } (a string stdout is UTF-8 encoded), or throw a HostError to fail the run with that code. A later call replaces the handler.

        Parameters

        • tool: "ffmpeg" | "ffprobe"
        • handler: (
              args: string[],
          ) =>
              | { stdout?: string
              | Uint8Array<ArrayBufferLike>; stderr?: string }
              | Promise<
                  { stdout?: string
                  | Uint8Array<ArrayBufferLike>; stderr?: string },
              >

        Returns void

    The plugin's Probe command gets an empty stream list from ffprobe, and any ffmpeg run fails as it would on a broken file. handle makes the tool available and answers each tools.run with the handler's result; a thrown HostError makes the run reject with that code. calls records every run with its arguments.

    host.tools.handle("ffprobe", (args) => {
    assert.ok(args.includes("-show_streams")); // what the plugin asked for
    return { stdout: JSON.stringify({ streams: [] }) }; // a file with no streams
    });
    // Every ffmpeg run rejects with code `failed`.
    host.tools.handle("ffmpeg", () => {
    throw new HostError("failed", "Invalid data found when processing input");
    });
    await host.command("probe").run();
    assert.equal(host.tools.calls[0]?.tool, "ffprobe");
    system: { revealed: string[]; opened: string[]; urls: string[] } = ...

    Paths given to system.reveal / system.openPath, newest last; inject failures with host.handle("system.openPath", …).

    Type Declaration

    • revealed: string[]

      Paths given to system.reveal, newest last.

    • opened: string[]

      Paths given to system.openPath, newest last.

    • urls: string[]

      system.openUrl addresses, newest last.

    menus: { items: (string | null)[]; x: number; y: number }[] = []

    Every panel.showMenu, newest last.

    Type Declaration

    • items: (string | null)[]

      Command ids, null for a separator.

    • x: number

      at.x, in window coordinates.

    • y: number

      at.y, in window coordinates.

    timeline: {
        layers: Map<
            string,
            { time: number; kind: string; title: string
            | null }[],
        >;
        get marks(): {
            time: number;
            kind: string;
            title: string
            | null;
            plugin: string;
        }[];
        rangeLayers: Map<
            string,
            { start: number; end: number; style: string; title: string
            | null }[],
        >;
        get ranges(): {
            start: number;
            end: number;
            style: string;
            title: string
            | null;
            plugin: string;
        }[];
    } = ...

    Timeline layers by plugin id (this plugin's is manifestId) and the merged list plugin.timeline.marks reads. A new source clears them.

    Type Declaration

    • layers: Map<string, { time: number; kind: string; title: string | null }[]>

      Each plugin's layer by plugin id; layers with no marks are absent.

    • get marks(): { time: number; kind: string; title: string | null; plugin: string }[]

      Every layer merged, sorted by time, with the publishing plugin's id.

    • rangeLayers: Map<
          string,
          { start: number; end: number; style: string; title: string
          | null }[],
      >

      Each plugin's ranges by plugin id; layers without ranges are absent.

    • get ranges(): {
          start: number;
          end: number;
          style: string;
          title: string | null;
          plugin: string;
      }[]

      Every layer's ranges merged, sorted by start, with the plugin's id.

    images: { path: string; ref: number; maxSide?: number }[] = []

    Runtime images written to views (plugin.ui.image, plugin.ui.remoteImage), whole values and images nested in rows, newest last. The SDK refuses images of released scopes before anything is sent. The test host does not read the files, so it does not check the player's per-view budget (IMAGE_LIMITS.viewBytes).

    Type Declaration

    • path: string

      The image file's path, as given to ui.image.

    • ref: number

      The SDK's reference number for that ImageRef.

    • OptionalmaxSide?: number

      Its maxSide option, when given.

    dropProviders: { id: string; extensions: string[] }[] = []

    drops.provide registrations of this plugin, in order (id is the SDK's).

    Type Declaration

    • id: string

      The SDK's provider id.

    • extensions: string[]

      The extensions it takes (lower case, "folder" for directories).

    panelDrops: boolean = false

    The panel has an onDrop listener.

    appearance: ThemeId = "vestra"

    The palette (plugin.appearance.theme); setAppearance changes it elsewhere.

    settings: {
        pages: Map<
            string,
            {
                category: string;
                title: string;
                order: number;
                file: string;
                component: string;
                global: string;
                props: Record<string, Json>;
                emit(callback: string, ...args: Json[]): void;
            },
        >;
        shows: (string | null)[];
        current: string | null;
        open: boolean;
    } = ...

    Settings pages by id (plugin.settings.page), every show (page id or null), and the page the options window shows.

    Type Declaration

    • pages: Map<
          string,
          {
              category: string;
              title: string;
              order: number;
              file: string;
              component: string;
              global: string;
              props: Record<string, Json>;
              emit(callback: string, ...args: Json[]): void;
          },
      >

      Registered pages by page id.

    • shows: (string | null)[]

      Every settings.show(pageId): the page id, null when omitted.

    • current: string | null

      The page the options window shows, null before any show.

    • open: boolean

      Whether the options window is open.

    backdrop: { owner: string; effective: boolean } | null = null

    The backdrop: who mounted it and whether it shows (panels.backdrop.state).

    Type Declaration

    • { owner: string; effective: boolean }
      • owner: string

        The manifest id of the plugin that mounted it.

      • effective: boolean

        Whether it shows now (no video frame). true when mounted.

    • null
    videoView: { owner: string | null; values: ViewSettings } = ...

    The display layer (plugin.video.view()): who owns it (this plugin is manifestId) and the values the player holds.

    Type Declaration

    • owner: string | null

      The owning plugin's manifest id, null while nobody owns it.

    • values: ViewSettings

      The values the player holds.

    videoRender: { owner: string | null; values: RenderSettings; gpu: boolean } = ...

    The render options (plugin.video.render()): who owns them, the values the player holds, and whether it renders on the GPU (gpu: false is software rendering, where every set fails with unsupported).

    Type Declaration

    • owner: string | null

      The owning plugin's manifest id, null while nobody owns them.

    • values: RenderSettings

      The values the player holds.

    • gpu: boolean

      true: GPU rendering; false: software rendering (unsupported). plugin.app.system() reports it as rendering.

    videoShaders: { handles: Map<string, string[]>; others: number } = ...

    The shader channel (plugin.video.shaders(id)): the lists the player holds for this plugin's handles by id (the real paths, after following links), and how many shaders other plugins hold, which count against VIDEO_PROCESSING_LIMITS.shaders (limit). Files must be under TestHost.fileRoots; under software rendering (videoRender.gpu = false) a non-empty list fails with unsupported.

    Type Declaration

    • handles: Map<string, string[]>

      This plugin's lists by handle id; a cleared handle has none.

    • others: number

      Shaders other plugins hold (0–16).

    1.5.39

    fileRoots: string[] = []

    Where the plugin's own files may be: its package directory and its data directory (startPlugin sets both when the list is still empty). lut3d files and shader-channel files outside them fail with invalid, as in the player.

    1.5.39

    previousCrash: string | null = null

    Play a run after an abnormal end with plugin shaders on: while set, a non-empty video.shaders list and a render options set with a non-empty shaders list are refused with previous-crash and this message; clearing still works. null (default): shaders apply.

    The plugin's shader handle turns failed with previous-crash, as in the player after a crash while plugin shaders were drawing. The player refuses the list itself (and shows its own OSD line), so the plugin should report it once and not set the list again.

    host.previousCrash = "plugin shaders are off for this start";
    const file = join(plugin.dataDirectory, "sharpen.glsl");
    writeFileSync(file, "//!HOOK MAIN\n");
    const shaders = plugin.video.shaders("sharpen");
    shaders.set([file]); // refused: the previous run ended abnormally
    await host.settle();
    assert.equal(shaders.status.state, "failed");

    1.5.54

    processing: {
        configurationRevision: number;
        backendUncertain: Partial<Record<"video" | "audio", string>>;
        resources: Map<
            string,
            { stage: string; revision: number; nodes: Json; offsetMs?: number },
        >;
        book: Map<
            string,
            {
                status: "completed"
                | "failed";
                result?: Json;
                error?: { code: string; message: string };
            },
        >;
    } = ...

    The player's processing (filter) state. Wire-level; may change in minor versions. resources holds each video.filter / audio.filter chain the plugin applied, keyed by the SDK's resource id.

    Type Declaration

    • configurationRevision: number

      Increases with every accepted change.

    • backendUncertain: Partial<Record<"video" | "audio", string>>

      Set a stage here to simulate a blocked backend (backend-uncertain).

    • resources: Map<string, { stage: string; revision: number; nodes: Json; offsetMs?: number }>

      Applied chains by resource id; an empty chain removes its entry, as in the player.

    • book: Map<
          string,
          {
              status: "completed"
              | "failed";
              result?: Json;
              error?: { code: string; message: string };
          },
      >

      Outcomes of processing operations, for the SDK's recovery queries.

    After the plugin set its picture chain, the test reads the one chain the host holds and compares its nodes. resources keeps each applied video.filter / audio.filter chain by the SDK's resource id, after the host validated it with the player's value ranges.

    const [chain] = [...host.processing.resources.values()];
    assert.deepEqual(chain?.nodes, [{ kind: "hue", degrees: 30 }]);
    subtitles: SubtitleState

    The player's subtitle state: tracks, selection, style layers, fonts and loaded resources. Wire-level shape (may change in minor versions); add tracks to subtitles.tracks (entries may carry codec, text, streamIndex) to simulate a source's subtitles.

    uploads: Map<
        number,
        { bytes: Buffer<ArrayBufferLike>[]; expected: number; generation?: number },
    > = ...

    Subtitle uploads in progress, by upload id. Wire-level.

    snapshots: Map<number, Json> = ...

    Snapshots taken with media.capture, by snapshot id. Wire-level.

    exports: Record<string, Json>[] = []

    Every jobs.start request (kind, destination, quality, …), newest last: a snapshot's (snapshotId) or, since 1.7.8, an export of remembered files' parts (parts), whose job runs half way through its middle part (progress.part), then completes (a copy's destination gets the extension of its container).

    mediaFiles: Map<
        string,
        {
            duration?: number;
            status?: "ok"
            | "missing"
            | "changed";
            version?: number;
            video?:
                | {
                    codec: string;
                    width: number;
                    height: number;
                    fps: number;
                    pixelFormat: string
                    | null;
                }
                | null;
            audio?: { codec: string; sampleRate: number; channels: number }
            | null;
        },
    > = ...

    Local files as the fake player knows them, by path, for plugin.media.sources and exports of their parts. A file not listed is a 1080p 30 fps H.264 file with AAC stereo 48 kHz sound, as long as the current source. Set status to missing or changed to stand for a moved or rewritten file; video: null or audio: null for a file without one.

    The plugin's list gets a part of a 4K file, then one of a 1080p file: the check then says size and the job has to re-encode.

    host.mediaFiles.set("/media/b.mp4", {
    duration: 30,
    video: { codec: "h264", width: 1920, height: 818, fps: 30, pixelFormat: "yuv420p" },
    });
    host.setSource({ phase: "ready", source: "/media/b.mp4", duration: 30 });

    1.7.8

    sourceOpens: { token: string; start: number }[] = []

    Every plugin.media.sources.open the plugin made (its token and start, 0 for the beginning), newest last. Each opens the token's path as an ordinary open: source becomes that path, position the start.

    Type Declaration

    • token: string

      The token opened.

    • start: number

      Seconds it started at.

    1.7.8

    sourceReferences: Map<string, { path: string; version?: number }> = ...

    The plugin's source references (plugin.media.sources) by token: the path each stands for. locate takes its answer from TestHost.dialogAnswers. Wire-level.

    1.7.8

    jobs: Map<number, MediaJob> = ...

    Export jobs by job id. Each state query advances a job one step (queued → running → completed; cancelling → cancelled). A running clip reports half its progress; a finished clip's outcome has start and end (a stream copy starts 1 s before the snapshot time, as if snapped to a keyframe, and its destination gets the extension of its container: .mkv for container: "mkv", else .mp4). Wire-level.

    exportFailure: { code: string; message: string } | null = null

    Set it to make every running export end failed with this error on its next state query, as the player reports one (unsupported for a stream copy it cannot make, export-failed otherwise); null (the default) completes them.

    Type Declaration

    • { code: string; message: string }
      • code: string

        The outcome.error.code.

      • message: string

        The outcome.error.message.

    • null

    1.6.10

    producerTransport: "unix" | "tcp" = "unix"

    openStream's transport: a local stream (a Unix socket on macOS and Linux, a named pipe on Windows) or, with "tcp", loopback TCP where the plugin must send the token first, as the player on Windows answers. Set it before the plugin calls openStream.

    producers: Map<
        number,
        FakeProducer & {
            server: Server;
            path: string;
            admitted: boolean;
            epoch: number;
            pending: Json;
            acknowledged: boolean;
            active: boolean;
        },
    > = ...

    Generated streams (player.openStream) by producer id: the fake player end of each frame connection. Wire-level beyond the FakeProducer fields.

    resolvers: Map<string, Json> = ...

    Registered source resolvers (resolvers.add) by id: their declarations.

    otherResolvers: {
        owner: string;
        extensions?: string[];
        schemes?: string[];
        hosts?: string[];
    }[] = []

    Resolvers other plugins hold, as resolvers.add declares them plus the holder's id: a registration of this plugin that claims one of their extensions (or scheme + host pairs) is refused with conflict, which does not fail activation, like the player.

    Type Declaration

    • owner: string

      The manifest id of the plugin holding them (shown in the refusal).

    • Optionalextensions?: string[]

      File extensions it resolves (a file resolver), lower case, no dot.

    • Optionalschemes?: string[]

      URL schemes it resolves (a web resolver), with hosts.

    • Optionalhosts?: string[]

      Exact host names it resolves (a web resolver), with schemes.

    The plugin starts in a player where another plugin already resolves .ch8 files. Pushed before startPlugin, the entry makes the plugin's own resolver for .ch8 fail with conflict during activation, which (as in the player) does not fail the activation.

    const host = new TestHost();
    host.otherResolvers.push({ owner: "example.emulator", extensions: ["ch8"] });
    resolutions: Map<
        number,
        { resolverId: string; source: string; paused: boolean },
    > = ...

    File opens waiting for this plugin's file resolver (extensions), by request id: the path and how it was opened. Opening a matching path (player.open, TestHost.openElsewhere) sends source.resolveRequest; the answer selects the stream, fails the open or, once the source changed, is stale. Any later source change cancels it (source.resolveCancel). Web resolvers are not simulated: emit source.resolveRequest yourself.

    dialogAnswers: (string[] | { confirmed: boolean; checked: boolean } | null)[] = []

    Answers for dialogs.open (paths, null = cancelled) and dialogs.confirm ({ confirmed, checked }), consumed in order. A dialog with no queued answer, or with the wrong kind, fails the request (as a lost reply).

    For openFile / openDirectory / saveFile queue a one-path array; for openFiles any number of paths.

    Type Declaration

    • string[]
    • { confirmed: boolean; checked: boolean }
      • confirmed: boolean

        The user clicked the confirm button.

      • checked: boolean

        The checkbox state.

    • null

    The plugin's Open command gets a picked file, then a cancelled file dialog, then a confirmed question. All answers share one queue, taken from the front in the order the plugin opens dialogs of any kind: if the next queued answer is missing or of the wrong kind, the dialog fails like a lost reply, so queue them in the order the plugin asks.

    host.dialogAnswers.push(["/media/movie.mkv"]); // openFile picks it
    host.dialogAnswers.push(null); // the next file dialog is cancelled
    host.dialogAnswers.push({ confirmed: true, checked: false }); // confirm
    await host.command("open").run();
    confirms: Record<string, Json>[] = []

    Every dialogs.confirm request (its options), newest last.

    mainWindow: {
        fullscreen: boolean;
        maximized: boolean;
        videoArea: { width: number; height: number };
        onTop: boolean;
        cursorAutoHide: "playing" | "fullscreen";
        pictureInPicture: { supported: boolean; active: boolean };
    } = ...

    The main window as the player would show it. Change it with setMainWindow (the user resized or maximized it, entered fullscreen, closed the picture-in-picture window); onTop, cursorAutoHide and pictureInPicture.active record the plugin's window.set… calls. pictureInPicture.supported: false stands for Windows and Linux.

    Type Declaration

    • fullscreen: boolean

      Whether the main window is fullscreen.

    • maximized: boolean

      Whether the main window is maximized (default false). Like the player, window.state reports false while fullscreen and this value again after leaving it.

      1.5.52

    • videoArea: { width: number; height: number }

      The video area in logical points (default 780×609).

      • width: number

        Width in logical points.

      • height: number

        Height in logical points.

    • onTop: boolean

      The effective window.setAlwaysOnTop value.

    • cursorAutoHide: "playing" | "fullscreen"

      The effective window.setCursorAutoHide mode.

    • pictureInPicture: { supported: boolean; active: boolean }

      Picture-in-picture: supported (preset) and active.

      • supported: boolean

        Set to false to simulate Windows or Linux.

      • active: boolean

        Whether the picture-in-picture window shows the video.

    mpv: {
        commands: (string | number | boolean)[][];
        properties: Map<string, Json>;
        labels: Map<string, string>;
        observed: Set<string>;
    } = ...

    The mpv pass-through (plugin.mpv), without an mpv: commands are the commands the plugin sent, in order (they do nothing else); properties is what get answers and set writes (a property not in it fails backend, "mpv: property not found"); labels are the owners of filter labels by "vf/<label>" or "af/<label>" (preset another plugin's id to test conflict); observed are the properties the plugin observes. The player's refusals apply (refused, invalid, the limit of 64 observed properties), from the same table as the player's.

    Type Declaration

    • commands: (string | number | boolean)[][]

      The commands the plugin sent, in order, as their arrays.

    • properties: Map<string, Json>

      Property values by name: what get answers and set writes.

    • labels: Map<string, string>

      The owner (a plugin id) of each filter label, by "vf/<label>" or "af/<label>".

    • observed: Set<string>

      The properties the plugin observes now.

    1.8.0

    secrets: Map<string, string> = ...

    The player's secret store for this plugin: name → value. Preset entries to simulate stored secrets; inject failures with host.handle("secrets.get", ...). Like the player, secrets.set of a new name fails limit once 256 names are stored.

    sessionStorage: Map<string, Json> = ...

    plugin.storage.session: key → value, as the player keeps them. Preset entries to simulate values an earlier run of the plugin stored in the same player session, or pass startPlugin(..., { sessionStorage }). Like the player, a key is 1–1024 bytes, a set that would make the entries larger than 1 MiB (keys, values as compact JSON and SESSION_STORAGE_LIMITS.entryBytes per key) fails limit, and an object's properties are stored sorted, as the player hands them back.

    1.5.25

    systemInfo: Omit<WireSystemInfo, "rendering" | "renderingReason"> = ...

    What plugin.app.system() reports. Its rendering follows videoRender.gpu ("gpu" or "software"), so one switch covers the render options and the fact; its renderingReason is rendering.reason.

    app: {
        version: string;
        build: string | null;
        components: {
            mpv: string | null;
            libav: Record<string, string>;
            slint: string;
        };
        temporary?: boolean;
    } = ...

    What plugin.app reports. Set it before startPlugin: the plugin receives it once at start-up.

    Type Declaration

    • version: string

      The player version.

    • build: string | null

      The short git hash of the build, null when unknown.

    • components: { mpv: string | null; libav: Record<string, string>; slint: string }

      Component versions.

      • mpv: string | null

        libmpv's mpv-version.

      • libav: Record<string, string>

        { ffmpeg: <version> }.

      • slint: string

        The Slint version.

    • Optionaltemporary?: boolean

      true to run as a temporary window (AppInfo.temporary): the plugin sees it, and secrets.set, secrets.delete, packages.install, packages.uninstall and packages.setEnabled are refused with unavailable, as in the player.

      1.10.1

    rendering: {
        reason: RenderingReason;
        preference: RenderingPreference;
        startedWith: RenderingMode;
        gpu: { available: boolean; reason: RenderingReason | null };
        restarts: number;
    } = ...

    The player's rendering choice behind plugin.rendering. The mode drawing now is videoRender.gpu, as for plugin.app.system(); the rest is preset here and changed by the plugin's calls, as the player would:

    • setPreference saves preference and never changes the mode. It refuses "gpu" while gpu.available is false: with unsupported when gpu.reason.code is no-gpu-backend or headless, otherwise with unavailable, the reason's message in both cases.
    • The next start uses "software" for the "software" choice, else software with gpu.reason while the GPU is not available, else the GPU (code preference for a "gpu" choice, default for "auto"). restartPending compares that with startedWith.
    • restartPlayer counts in restarts and leaves the plugin running (call stop() yourself); a second one rejects with busy, as a restart is then under way.

    Inject other refusals (failed for an unwritable settings file or a new process that could not start) with host.handle("rendering.setPreference", …) or host.handle("rendering.restart", …). The defaults are a macOS player on the GPU: "auto", available, started on the GPU.

    Type Declaration

    • reason: RenderingReason

      Why the mode drawing now is what it is (RenderingState.reason, SystemInfo.renderingReason).

    • preference: RenderingPreference

      The saved choice: "auto", "gpu" or "software".

    • startedWith: RenderingMode

      The mode this run started with; restartPending compares the next start's mode with it.

    • gpu: { available: boolean; reason: RenderingReason | null }

      Whether the plugin may choose "gpu", and why not (null while available).

      • available: boolean

        false: setPreference("gpu") is refused.

      • reason: RenderingReason | null

        Why the GPU cannot be chosen; null while it can.

    • restarts: number

      Accepted restartPlayer calls.

    The plugin's GPU menu item is greyed out with the player's reason when the GPU cannot be chosen. The host is preset before the plugin starts, because the plugin reads the state while activating; software rendering is videoRender.gpu = false, and gpu says why the GPU cannot be chosen.

    import assert from "node:assert/strict";
    import { startPlugin, TestHost } from "@vestra-player/sdk/testing";
    import activate from "../main.ts";

    const host = new TestHost();
    host.videoRender.gpu = false; // software draws now (Linux)
    host.rendering.startedWith = "software";
    host.rendering.reason = { code: "no-gpu-backend", message: "this player has no GPU renderer on Linux yet" };
    host.rendering.gpu = { available: false, reason: host.rendering.reason };
    const { stop } = await startPlugin(activate, {
    directory: new URL("..", import.meta.url),
    host,
    });
    const item = host.command("gpu-rendering");
    assert.equal(item.state.enabled, false);
    assert.equal(item.state.reason, "this player has no GPU renderer on Linux yet");
    await stop();

    1.5.35

    upscaling: {
        reason: UpscalingReason | null;
        enabled: boolean;
        factor: number | null;
        checked: boolean;
        renderingStarting: boolean;
        video: UpscalingVideoSize | null;
        area: { width: number; height: number } | null;
        gpu: string | null;
        hwdecCurrent: string | null;
    } = ...

    The GPU's video upscaler behind plugin.video.upscaling, answered as the player would:

    • state() and set(true) set checked (the player's one GPU check; a plugin that should not wake the GPU while it starts can assert it is still false) and report available from reason (null: it works), this plugin's enabled, and requested with factor while enabled, available and factor is above 1.
    • set(true) refuses with unsupported and the reason's message while reason is set, unless its code is decoding, or rendering with renderingStarting (GPU rendering still starting): those can pass during the run, so the player keeps the request. Nothing changes when it refuses.
    • set(false) always succeeds and does not check the GPU: before any check it reports available: false with the reason unchecked.

    Inject other answers with host.handle("video.upscaling.set", …). The defaults are a player where upscaling works and a 1080p video shown full screen on a 4K display (factor 2), whatever systemInfo says.

    Type Declaration

    • reason: UpscalingReason | null

      Why upscaling does not work; null while it does.

    • enabled: boolean

      Whether this plugin has upscaling on (set); a test may preset it.

    • factor: number | null

      The factor the player would request; null or at most 1: the video needs no upscaling.

    • checked: boolean

      Whether the plugin made the player check the GPU (state, set(true)).

    • renderingStarting: boolean

      GPU rendering is still starting: a rendering reason then lets set(true) keep the request.

    • video: UpscalingVideoSize | null

      The video's size the state reports; null: no video.

    • area: { width: number; height: number } | null

      The video area the state reports; null: none.

    • gpu: string | null

      The rendering GPU's name the state reports.

    • hwdecCurrent: string | null

      mpv's decoder the state reports; null: no video.

    The plugin's upscaling item is greyed out with the player's reason after the user first picks it. Starting the plugin checks nothing (checked stays false, so no GPU wakes up); the first pick reads the state, and set(true) would reject with unsupported, as in the player.

    import assert from "node:assert/strict";
    import { startPlugin, TestHost } from "@vestra-player/sdk/testing";
    import activate from "../main.ts";

    const host = new TestHost();
    host.upscaling.reason = { code: "no-gpu", message: "no NVIDIA GPU" };
    const { stop } = await startPlugin(activate, {
    directory: new URL("..", import.meta.url),
    host,
    });
    assert.equal(host.upscaling.checked, false); // starting woke no GPU
    const item = host.command("upscaling");
    await item.run(); // the first pick checks the GPU
    assert.equal(item.state.enabled, false); // greyed out
    assert.equal(item.state.reason, "no NVIDIA GPU"); // the player's message
    await stop();

    1.5.37

    motion: {
        mode: MotionMode;
        double: MotionReason | null;
        display: MotionReason | null;
        renderingStarting: boolean;
        sourceFps: number | null;
        outputFps: number | null;
        performance: boolean;
        displayFps: number;
        gpu: string | null;
    } = ...

    Motion smoothing behind plugin.video.motion, answered as the player would:

    • state() and set() report this plugin's mode, the reasons double and display (null: that mode works) and active: the mode while its reason is null and sourceFps is known, else off; while active, searchMode (performance with performance) and outputFps (outputFps, or twice sourceFps).
    • set(mode) refuses with unsupported and the reason's message while that mode's reason is platform, no-gpu, runtime, filter or rendering (unless renderingStarting): those hold for the run. The others can pass, so the player keeps the request. off always succeeds; an unknown mode is invalid.

    Inject other answers with host.handle("video.motion.set", …). The defaults are a player where both modes work on a 24 fps video and a 60 Hz display.

    Type Declaration

    • mode: MotionMode

      This plugin's mode (set); a test may preset it.

    • double: MotionReason | null

      Why Double Frame Rate does not work; null while it does.

    • display: MotionReason | null

      Why Match Display does not work; null while it does.

    • renderingStarting: boolean

      GPU rendering is still starting: a rendering reason then lets set keep the request.

    • sourceFps: number | null

      The converter's input rate (MotionState.sourceFps); null: not known yet (nothing is active).

    • outputFps: number | null

      The measured output rate while active; null: twice sourceFps.

    • performance: boolean

      The faster motion search (the player's first fallback step).

    • displayFps: number

      The display's refresh rate.

    • gpu: string | null

      The converting GPU's name; null: none.

    Match Display needs GPU rendering: the plugin greys it with the player's reason, and Double waits for a rate that fits.

    host.motion.display = { code: "rendering", message: "Match Display needs GPU rendering" };
    host.motion.double = { code: "rate", message: "24 fps doubled is 48 fps on a 60 Hz display" };
    host.motionChanged();
    await host.settle();
    assert.equal(host.motion.mode, "off");

    1.7.19

    nvidiaMotion: {
        mode: MotionMode;
        double: MotionReason | null;
        display: MotionReason | null;
        renderingStarting: boolean;
        sourceFps: number | null;
        outputFps: number | null;
        performance: boolean;
        displayFps: number;
        gpu: string | null;
    } = ...

    NVIDIA's engine behind plugin.video.motion("nvidia"): the same model as TestHost.motion (AMD's), its own state, answered the same way. The defaults are a player where both modes work on a 24 fps video and a 60 Hz display, converting on an RTX 4070 Laptop GPU. One converter at a time, as the player: the first engine set to a mode (or preset to one, amd first) holds it while its mode is not off, and the other engine's modes report other-engine, in the player's order: a model's own run-long, renderer, upscaling or doubling reason comes first, its failed, overload, rate, format or size after. A test of "another plugin holds AMD's converter" sets host.motion.mode.

    Type Declaration

    • mode: MotionMode

      This plugin's mode (set); a test may preset it.

    • double: MotionReason | null

      Why Double Frame Rate does not work; null while it does.

    • display: MotionReason | null

      Why Match Display does not work; null while it does.

    • renderingStarting: boolean

      GPU rendering is still starting: a rendering reason then lets set keep the request.

    • sourceFps: number | null

      The converter's input rate (MotionState.sourceFps); null: not known yet (nothing is active).

    • outputFps: number | null

      The measured output rate while active; null: twice sourceFps.

    • performance: boolean

      The faster motion search (the player's first fallback step).

    • displayFps: number

      The display's refresh rate.

    • gpu: string | null

      The converting GPU's name; null: none.

    The same reason on both modes is what the player answers there: the plugin shows it and keeps the mode off, since no-gpu holds for the run.

    const reason = { code: "no-gpu", message: "no NVIDIA GPU" };
    host.nvidiaMotion.double = reason;
    host.nvidiaMotion.display = reason;

    1.11.1

    chapters: { title: string | null; start: number }[] = []

    What player.chapters() lists while media is ready.

    Type Declaration

    • title: string | null

      The chapter title, null without one.

    • start: number

      Start time in seconds.

    dataDirectory: string = ...

    plugin.dataDirectory: a fresh empty temporary directory, removed with the host on stop(). plugin.storage.json reads and writes real files here. Pass startPlugin(..., { dataDirectory }) to use another one.

    manifestId: string = "test.plugin"

    The manifest id of the plugin under test (set by startPlugin; "test.plugin" by default).

    stepSeek: number = 5

    The player.setStepSeek value in effect (default 5).

    stepSeekKeyframes: boolean = false

    The player.setStepSeek keyframes in effect (default false).

    keyframes: number[] | null = null

    Test data: the keyframe times (seconds, ascending) of the current source, for keyframe step seeks. null (the default): none modelled, and step seeks are exact even with stepSeekKeyframes.

    With keyframe step seeks on, Forward from 0:12 lands on the keyframe at 0:20, not at 0:17, and the OSD says so. keyframes gives the source's keyframe times; setStepSeek turns on keyframe steps of 5 s, and the core action seek-forward seeks to the first keyframe at or after the target, as the player does.

    host.setSource({ phase: "ready", duration: 45, position: 12 });
    host.keyframes = [0, 10, 20, 30, 40];
    await plugin.player.setStepSeek({ seconds: 5, keyframes: true });
    await plugin.host.run("seek-forward"); // target 17 s, next keyframe 20 s
    assert.equal(host.source.position, 20);
    assert.equal(host.osd.at(-1), "Forward 5 s: 00:20 / 00:45");
    coreSeeks: {
        action: string;
        seconds: number;
        keyframes: boolean;
        landed: number;
    }[] = []

    Every step seek the core ran (seek-backward / seek-forward, from a key, the menu or host.run), newest last: the step, whether it went to a keyframe, and where it landed.

    Type Declaration

    • action: string

      seek-backward or seek-forward.

    • seconds: number

      The step: host.run's seconds, else setStepSeek's.

    • keyframes: boolean

      It landed on a keyframe (stepSeekKeyframes and keyframes modelled).

    • landed: number

      The new position.

    seeks: { seconds: number; keyframes: boolean }[] = []

    Every seek a plugin submitted (player.seek, Scrub.seek), newest last, with the mode it asked for. The test host lands on the exact target either way (the player lands a keyframes seek on the last keyframe at or before it); the core's step seeks are in coreSeeks.

    Type Declaration

    • seconds: number

      The target.

    • keyframes: boolean

      Scrub.seek(seconds, { keyframes: true }).

    steps: { unit: string; direction: string }[] = []

    Every player.step and core frame step, newest last. The position does not move, except a step back after the end: like the player, a seek that stays paused, one frame back (stats fps, else 30) for a frame, to the last keyframe before the position (none modelled: 1 ms back) for a keyframe. A keyframe step forward after the end goes nowhere.

    Type Declaration

    • unit: string

      "frame" or "keyframe".

    • direction: string

      "backward" or "forward".

    coreRuns: string[] = []

    Every core action run (host.run, a core command, a pressed core binding), newest last.

    builtin: boolean = false

    The plugin is built into the player (startPlugin's builtin). Only then does the host answer the built-in-only requests (commands.list, commands.run, palette.lead.*); otherwise they fail with builtin-only, as in the player.

    1.7.9

    paletteLead: Record<string, Json> | null = null

    The palette's lead row as the plugin last set it (palette.lead.set, wire form), null without one. Wire-level.

    1.7.9

    openedWindows: { paths: string[]; pid: number }[] = []

    Every temporary window a built-in plugin opened with app.openWindow, oldest first: the files and the process id answered (App.openWindow). No process starts. A plugin that is not built in is refused with builtin-only, as in the player; the files are checked as the player does (invalid, missing).

    Type Declaration

    • paths: string[]

      The files, as the plugin gave them.

    • pid: number

      The process id answered (made up: no process starts).

    1.10.1

    bindings: { overlay: Map<string, string[]> } = ...

    The binding overlay plugin.bindings.set writes ("<plugin>/<command>" to inputs; preset it to simulate saved overrides). press honours it.

    Type Declaration

    • overlay: Map<string, string[]>

      "<plugin>/<command>" → the user's inputs for it.

    packages: {
        id: string;
        version: string | null;
        origin: "installed" | "development";
        state: "failed" | "starting" | "running" | "disabled" | "stopped";
        error: string | null;
        directory: string;
        builtin?: boolean;
        source?: PackageSource | null;
        dataDirectory?: string | null;
    }[] = []

    What packages.list reports; setEnabled, uninstall and install update it. builtin, source and dataDirectory are optional here (default false, null, null).

    Type Declaration

    • id: string

      The plugin's manifest id.

    • version: string | null

      Its version, null when unknown.

    • origin: "installed" | "development"

      Where it was loaded from.

    • state: "failed" | "starting" | "running" | "disabled" | "stopped"

      Its run state.

    • error: string | null

      Why it failed (state: "failed").

    • directory: string

      The package directory.

    • Optionalbuiltin?: boolean

      Shipped with the player: uninstall and install are unsupported.

    • Optionalsource?: PackageSource | null

      Where it was installed from.

    • OptionaldataDirectory?: string | null

      Its data directory.

    packageCalls: {
        method: "uninstall" | "reload" | "setEnabled" | "install";
        id: string;
        enabled?: boolean;
        removeData?: boolean;
        source?: PackageSource;
        replace?: boolean;
    }[] = []

    Every packages.setEnabled / uninstall / install, newest last.

    Type Declaration

    • method: "uninstall" | "reload" | "setEnabled" | "install"

      Which call.

    • id: string

      The target plugin id.

    • Optionalenabled?: boolean

      setEnabled's value, or install's enabled option when given.

    • OptionalremoveData?: boolean

      uninstall's removeData option.

    • Optionalsource?: PackageSource

      install's source ({ kind: "file" } when not given).

    • Optionalreplace?: boolean

      install's replace option.

    candidates: Map<string, PackageManifest> = ...

    Packages validate and validateArchive accept: path (directory or .vxp file) → its manifest. Other paths fail with missing. install adds or upgrades the entry in TestHost.packages following the player's source rules: the same source upgrades, another source needs replace (conflict otherwise), a built-in id is unsupported. The installed entry's state follows "@vestra-player/sdk"!InstallOptions.enabled: a first install runs, an update of a disabled entry stays disabled unless enabled is true, and enabled: false installs it disabled.

    The plugin can validate and install /downloads/someone.demo-1.0.0.vxp as if the file existed. The host accepts only paths listed here (others fail with missing) and returns this manifest from validate; an install then follows the player's source rules.

    host.candidates.set("/downloads/someone.demo-1.0.0.vxp", {
    id: "someone.demo", version: "1.0.0", apiVersion: "vestra/1",
    entry: "main.js",
    });
    installKeepsDisabled: boolean = true

    Which install rule packages.install plays. true (default): an update or reinstall keeps a disabled plugin disabled unless the plugin passes "@vestra-player/sdk"!InstallOptions.enabled. false: every install runs the plugin and enabled is ignored (it is still checked and recorded in TestHost.packageCalls).

    The plugin under test installs an update over a plugin the user disabled and expects it to run afterwards. With false the host plays that rule; the default keeps the update disabled.

    host.installKeepsDisabled = false; // every install runs
    

    1.5.55

    remoteImages: Map<string, string | null> = ...

    Remote images (plugin.ui.markdown, plugin.ui.remoteImage): address → a local PNG or JPEG file served for it, or null for a failing download. Nothing is fetched from the network in tests; unknown addresses fail.

    audioDevices: { id: string; name: string }[] = []

    What player.audioDevices() lists. setAudioDevice updates host.source.audioOutput.

    Type Declaration

    • id: string

      The device id, e.g. coreaudio/<UID>.

    • name: string

      The system's name for it.

    strictErrors: boolean = true

    Whether a host error the plugin logged fails the test (default true). A host error is a refusal or failure with a code (stale, invalid, disabled, …) that nothing in the plugin handled: no try/catch around the call and no plugin.onError listener, so the player would only write it to its log. The next TestHost.settle (so also command(…).run()) rejects with it, or else stop(); the message names the error and how to expect it. A test that means it calls TestHost.expectError first. Set false to only log host errors, as before SDK 1.11.2. TestHost.loggedErrors lists them either way.

    The user opens another file, then runs a command that controls the old one with a state the plugin read before: the player refuses it with stale, and the plugin leaves the refusal to its log. The test says so before it runs the command; without expectError the run rejects.

    host.openElsewhere("/media/other.mp4");
    host.expectError("stale");
    await host.command("rate-2").run();

    1.11.2