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

    Interface WireExperimental

    Direct messages to the player (plugin.wire): requests by method name, raw events, property writes below the SDK's comparison and bare command registrations. Experimental: the wire protocol is not semver; this member changes with versions.

    The plugin API wraps the player's protocol (JSON requests and events over the plugin's standard input and output) in typed members that keep state, compare values and recover from lost replies. plugin.wire is the layer below them, for trying a player method the SDK does not wrap yet, or for a plugin that wants to send exactly what it chooses. Prefer the typed members: they are semver, plugin.wire is not. A method or event can change or disappear with a player version, and members of plugin.wire may change in any SDK release without a deprecation period.

    What the SDK still does at this level: on marks its subscription as a listener with where it was added (so the player keeps the plugin running and names the listener in its log), view(v) sends one write per property at a time and splits large ones, and commands.register waits during activation like commands.add. What it leaves to the plugin: the parameters' shape, the value limits, revisions of request, retries.

    The Tutorial shows bind() (the default), Player.on with View.set, and plugin.wire side by side, from examples/three-ways; the method and event names are in Messages and Events.

    A tab in the adjust column shows the playback speed, written by the plugin itself from the raw source.state event. The listener types the payload, which is unknown here, and view(panel).write sends the text as a property write; the SDK keeps no copy of the state and compares nothing.

    const panel = plugin.panels.mount("adjust", "ui/speed.slint", { title: "Speed" });
    const view = plugin.wire.view(panel);
    plugin.wire.on("source.state", (data) => {
    const s = data as { rate: number }; // the plugin types the payload
    void view.write("rate", { value: `${s.rate.toFixed(2)}×` });
    });

    1.7.0

    interface Wire {
        request<T = unknown>(method: string, params?: Json): Promise<T>;
        on(
            event: string & {} | HostEvent,
            listener: (data: unknown) => void,
        ): Disposable;
        view(view: View): WireView;
        commands: WireCommands;
    }
    Index
    • Experimental

      Send one request to the player by its method name and get its answer.

      Type Parameters

      • T = unknown

      Parameters

      • method: string

        The player's method name ("ui.setMount").

      • Optionalparams: Json

        Its parameters, a JSON object (omitted: none).

      Returns Promise<T>

      The player's result, once the player answered.

      Experimental: the wire protocol is not semver; this member changes with versions. method and params go to the player as given; the answer is the player's result, typed by the caller (T). The player's refusals arrive with their own codes (invalid, missing, stale…).

      Nothing of the SDK's sits between: no value limits, no seq or revision, no retry after a lost reply, no wait during activation. A request that changes something the SDK keeps (a window the SDK opened, a command added with Commands.add) leaves the SDK's copy out of date. The subscriptions are guarded. For the events the SDK knows (HostEvent) events.subscribe and events.unsubscribe are refused: the player keeps one subscription per event name, with one mark, and the SDK owns those (its copies of the state, Player.on); listen with Wire.on and stop by disposing what it returned. For any other event (a newer player's) events.subscribe must say why the plugin listens, why (a list of reasons for the player's log) or mirror: true (only a copy of the state), so the player's decision to keep the plugin running is never fooled; the SDK does not count such a subscription, the plugin unsubscribes it itself.

      invalid (throws) method is not a non-empty string, it is events.subscribe or events.unsubscribe of a HostEvent, or events.subscribe of another event without why (a non-empty list of strings) or mirror: true.

      unsupported (rejects) The player does not know the method.

      disabled (rejects) The plugin is stopping.

      The plugin's adjust tab shows "1.00×" in its rate property, written with the player's own request. The parameters are the protocol's (property, value); the player checks the value.

      const panel = plugin.panels.mount("adjust", "ui/speed.slint", { title: "Speed" });
      await panel.ready;
      await plugin.wire.request("ui.setMount", { property: "rate", value: "1.00×" });

      1.7.0

    • Experimental

      Listen to one event of the player by its name, with its data as the player sent it, untyped.

      Parameters

      • event: string & {} | HostEvent

        The event's name.

      • listener: (data: unknown) => void

        Receives each event's data.

      Returns Disposable

      A handle that stops listening; it is disposed with the scope.

      Experimental: the wire protocol is not semver; this member changes with versions. For one of the HostEvent names the SDK subscribes (events.subscribe) as for Player.on: once per name however many listeners, always marked as a listener with where it was added (why), never as a copy of the state (mirror), so the player keeps the plugin running while it listens (unless the player wakes a stopped plugin for that event). Any other name is listened to without a subscription: events the player sends unasked (commands.execute, ui.callback, ui.closed), or an event of a newer player that the plugin subscribed to itself with Wire.request.

      The listener gets a copy of the data, typed unknown: the plugin checks its shape (Player.on types it for the known events). As for Player.on, no update pass follows the listener, and its errors go to Scope.onError.

      invalid (throws) event is not a non-empty string, or listener is not a function.

      The listener hears the player's commands.execute event, which the player sends unasked when the user picks one of this plugin's commands. Its data names the command by its local id; the SDK still runs the command's own run too.

      plugin.wire.on("commands.execute", (data) => {
      const { id } = data as { id: string };
      console.log(`the player ran ${id}`);
      });

      1.7.0

    • Experimental

      Write a view's properties directly, below the SDK's comparison and row patches.

      Parameters

      • view: View

        A window, panel or settings page this plugin made.

      Returns WireView

      The view's direct writes.

      Experimental: the wire protocol is not semver; this member changes with versions. view is a Window, Panel or SettingsPage of this plugin; the writes go to it as ui.set, ui.setMount or settings.set. See WireView.

      invalid (throws) view is not a window, panel or settings page of this plugin.

      The sidebar shows a list the plugin keeps itself. The first write sends the whole list; later changes are row operations on what the player shows, sent as they are.

      const side = plugin.panels.mount("sidebar", "ui/list.slint");
      await side.ready;
      const rows = plugin.wire.view(side);
      await rows.write("items", { value: [{ id: "a", label: "First" }] });
      await rows.writeRows("items", [{ op: "insert", at: 1, rows: [{ id: "b", label: "Second" }] }]);

      1.7.0

    commands: WireCommands

    Bare command registrations, without state functions or update passes.