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

    Interface Packages

    plugin.packages: the plugins the player knows, and installing, enabling, reloading and uninstalling them.

    The plugin installs a package directory it downloaded and unpacked, and reports why when it does not work. validate asks the player to check the package and returns a candidate; install starts the change and done resolves with its final status: committed only once the new plugin reported that it is running, otherwise failed, cancelled, failedDegraded or tooLate.

    const candidate = await plugin.packages.validate(unpackedDirectory);
    const change = await candidate.install();
    // `message` says why a change did not commit.
    if ((await change.done) !== "committed") throw new Error(change.message ?? "install failed");

    The plugins the player knows: installed, built-in and this run's development loads. Installing, enabling, reloading and uninstalling act on other plugins, never on the calling one. Built-in plugins update with the player and cannot be installed, disabled or uninstalled.

    1.0.0

    interface Packages {
        validate(directory: string): Promise<PackageCandidate>;
        validateArchive(file: string): Promise<PackageCandidate>;
        list(): Promise<PluginInfo[]>;
        onChange(listener: (plugins: PluginInfo[]) => void): Disposable;
        setEnabled(id: string, enabled: boolean): Promise<void>;
        reload(id: string): Promise<void>;
        uninstall(
            id: string,
            options?: { removeData?: boolean },
        ): Promise<PackageChange>;
    }
    Index
    • Validate a package directory. A package whose id is reserved for the built-in plugins (vestra or vestra.*) fails with reserved.

      The player keeps the 32 most recent candidates of all plugins; an older one's install fails with stale (validate again).

      Parameters

      • directory: string

      Returns Promise<PackageCandidate>

      host (rejects) Not a package directory, or a manifest that breaks the rules (another apiVersion included); message says why.

      invalid (rejects) A bad request (a path that is not a string).

      javascript (rejects) The entry module does not parse.

      slint (rejects) A Slint file does not compile.

      reserved (rejects) A reserved id (vestra, vestra.*).

      versionMismatch (rejects) The package's minPlayerVersion is newer than the player.

      disabled (rejects) The calling plugin is stopping.

      The plugin checks a folder it unpacked and installs it if the player accepts it. validate runs the player's checks and resolves with a candidate; a package that fails them rejects with the reason.

      try {
      // Rejects with the reason when the package fails the checks.
      const candidate = await plugin.packages.validate(directory);
      await (await candidate.install()).done;
      } catch (error) {
      await plugin.osd.show("Not a valid plugin: {}", [(error as Error).message]);
      }

      1.0.0

    • Validate a .vxp package file: the same checks as Packages.validate after unpacking. Check the file's sha256 yourself before calling when you know it. A reserved id fails with reserved, as in Packages.validate.

      Parameters

      • file: string

      Returns Promise<PackageCandidate>

      invalid (rejects) The path does not end in .vxp, or the archive cannot be unpacked (over 64 MB, too many files, a damaged zip, an unsafe path).

      host (rejects) The unpacked package or its manifest breaks the rules; message says why.

      javascript (rejects) The entry module does not parse.

      slint (rejects) A Slint file does not compile.

      reserved (rejects) A reserved id.

      versionMismatch (rejects) The package's minPlayerVersion is newer than the player.

      disabled (rejects) The calling plugin is stopping.

      A .vxp the plugin downloaded is checked and installed. The player unpacks and checks it like a directory; checking the file's sha256 first, when the store publishes one, is up to the plugin.

      const candidate = await plugin.packages.validateArchive(file); // a .vxp path
      const change = await candidate.install();
      await plugin.osd.show("Install: {}", [await change.done]);

      1.1.0

    • Every plugin: running, installed, and this run's development loads.

      Returns Promise<PluginInfo[]>

      Error (rejects) Only when the player cannot be asked.

      The plugin lists the running plugins by name. list asks the player and resolves with every plugin it knows, with its state, origin and display texts in the interface language.

      const plugins = await plugin.packages.list();
      const running = plugins.filter((info) => info.state === "running");
      console.log(running.map((info) => info.display?.name ?? info.id));

      1.0.0

    • The new list after any start, stop, failure, install or uninstall.

      Parameters

      Returns Disposable

      A store window's list updates when a plugin starts, stops, fails, is installed or uninstalled. The listener receives the new list each time.

      plugin.packages.onChange((plugins) => console.log(plugins.length, "plugins"));
      

      1.0.0

    • Stop or start a plugin. An installed plugin stays disabled across launches; a development load only for this run. invalid to disable oneself, missing unknown. busy while it is being installed or reloaded. unsupported to disable a built-in (PluginInfo.builtin): users manage third-party plugins only.

      Parameters

      • id: string
      • enabled: boolean

      Returns Promise<void>

      invalid (rejects) Disabling the calling plugin itself.

      missing (rejects) An unknown id.

      busy (rejects) The plugin is being installed or reloaded.

      unsupported (rejects) A built-in plugin.

      unavailable (rejects) The player is a temporary window (AppInfo.temporary, player 0.10.3): it runs the main window's plugins as they are and enables or disables none.

      The plugin stops another plugin and keeps it disabled across launches until it is enabled again. Built-in plugins cannot be disabled (unsupported).

      await plugin.packages.setEnabled("someone.demo", false);
      

      1.0.0

    • Restart a plugin: stop it and start it again from the same package with the same data directory, for example to recover one that misbehaves. Built-ins included. A stopped or failed plugin is just started. The disabled flag is never written, so a reload never leaves a plugin disabled.

      Resolves once the plugin is stopped and its start is scheduled; the player starts it as soon as the old process is gone (at most 20 s). Follow it with Packages.onChange: starting, then running, or failed with the reason.

      invalid for oneself or a disabled plugin (enable it instead), missing unknown, busy while it is being installed or reloaded.

      Parameters

      • id: string

      Returns Promise<void>

      0.5.1

      1.5.19

      invalid (rejects) The calling plugin itself, or a disabled plugin.

      missing (rejects) An unknown id.

      busy (rejects) The plugin is being installed or reloaded.

      unsupported (rejects) A player before 0.5.1.

      The other plugin is stopped and started again from the same package and data. reload resolves once the old process is stopped and the start is scheduled; onChange then shows starting and running (or failed).

      await plugin.packages.reload("someone.demo");
      
    • Remove an installed plugin; removeData also deletes its data directory, otherwise reinstalling it from the same source reconnects to its data. Its user bindings stay (as orphans). unsupported for built-ins and development loads, missing unknown, invalid for oneself.

      Parameters

      • id: string
      • Optionaloptions: { removeData?: boolean }

      Returns Promise<PackageChange>

      unsupported (rejects) A built-in plugin or a development load.

      missing (rejects) An unknown id.

      invalid (rejects) The calling plugin itself.

      busy (rejects) The plugin library is being cleaned up, or that plugin is being installed or reloaded.

      revisionConflict (rejects) The installed revision of that plugin changed meanwhile; call uninstall again.

      unavailable (rejects) The player is a temporary window (AppInfo.temporary, player 0.10.3): it runs the main window's plugins as they are and removes none.

      The other plugin is removed and its data directory deleted, so a later reinstall starts fresh. Without removeData a reinstall from the same source finds its data again.

      const change = await plugin.packages.uninstall("someone.demo", { removeData: true });
      await change.done;

      1.0.0