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

    Interface PaletteLead

    The palette's lead row, from Palette.lead. Disposing it removes the row.

    Holds the row while the scope lives. update changes what it shows (a status while a request runs, a note while it cannot run); onRun hears each activation; done ends the ticket of a finished request.

    While the plugin works on a request the row shows "Working… (Enter to stop)"; Enter on it stops the work. The status row replaces the lead while nothing is typed; its run event has status: true.

    const lead = plugin.palette.lead({ title: "Ask", icon: "search" });
    let stop = new AbortController();
    lead.onRun(async ({ query, ticket, status }) => {
    if (status) return stop.abort(); // Enter on the status row
    stop = new AbortController();
    await lead.update({ title: "Ask", icon: "search", status: { text: "Working… (Enter to stop)" } });
    try {
    await plugin.osd.show("Asked: {}", [query]);
    } finally {
    await lead.update({ title: "Ask", icon: "search" });
    await lead.done(ticket);
    }
    });

    0.7.6

    1.7.9

    interface PaletteLead {
        dispose(): Promise<void>;
        ready: Promise<void>;
        update(options: PaletteLeadOptions): Promise<void>;
        onRun(listener: (run: PaletteLeadRun) => void): Disposable;
        done(ticket: string): Promise<void>;
    }

    Hierarchy (View Summary)

    Index
    • Release the resource. Resolves once the player confirmed the release (or immediately for purely local resources). Never rejects.

      Returns Promise<void>

      Never.

      A "Turn feature off" item removes the feature's own menu item at once, before the plugin stops. dispose takes the command out of the menu and the binding table and resolves once the player confirmed it; the id can be added again later.

      const extra = plugin.commands.add({ id: "extra", path: ["Tools", "Extra"], run() {} });
      plugin.commands.add({
      id: "extra-off",
      path: ["Tools", "Turn extra off"],
      run: () => extra.dispose(), // never rejects
      });

      1.0.0

    • Listen to the user activating the row (Enter, Shift+Enter or a click). The player starts a stopped plugin for it.

      Parameters

      Returns Disposable

      A unit converter shows its answer and, after Shift+Enter, leaves the palette open for the next one. The listener gets the typed text and keep; the player closes the palette on Enter by itself.

      lead.onRun(async ({ query, keep, ticket }) => {
      const gigabytes = Number.parseFloat(query); // "3.5 GB in MB"
      await plugin.osd.show("{} MB", [gigabytes * 1024]);
      if (keep) await plugin.osd.show("Type the next value");
      await lead.done(ticket);
      });

      1.7.9

    • End a request's ticket: Commands.run refuses it from now on.

      Parameters

      • ticket: string

      Returns Promise<void>

      A macro plugin stops at the first command that fails and ends the ticket, so nothing more runs for this request. done ends the ticket at once; without it the ticket would end 120 s after its last run.

      lead.onRun(async ({ ticket }) => {
      try {
      await plugin.commands.run("host/mute", { ticket });
      } catch {
      await plugin.osd.show("Macro stopped"); // ticket, limit, disabled…
      } finally {
      await lead.done(ticket);
      }
      });

      builtin-only (rejects) The plugin is not built into the player.

      1.7.9

    ready: Promise<void>

    Settles when the player has the row.

    builtin-only (rejects) The plugin is not built into the player.

    conflict (rejects) Another plugin holds the lead.

    invalid (rejects) A text over its length.