Skip to content
livrasand edited this page Nov 28, 2026 · 1 revision

Plugin Development

This page describes how to write an Updainium plugin: the two plugin formats, the manifest, the provider and command shapes, and how to test. For installing and managing plugins as a user, see Plugins.

Plugin formats

A plugin takes one of two forms:

  • Single file: a .js file placed directly in the plugins folder. It can default-export a provider, a command, or an object with providers and commands arrays.
  • Manifest folder: a folder in plugins/ that contains an updainium.json manifest and the JavaScript files it references.
plugins/
  sourcehut/
    updainium.json
    index.js
    provider.js

Manifest: updainium.json

{
  "id": "sourcehut-provider",
  "version": "0.1.0",
  "engines": {
    "updainium": "^1.4"
  },
  "main": "index.js",
  "contributes": {
    "providers": ["provider.js"],
    "commands": ["commands.js"],
    "keybindings": [
      { "command": "sourcehut.sync", "key": "mod+shift+s" }
    ]
  }
}
Field Required Meaning
id yes Unique plugin identifier
version no Plugin version
engines.updainium no Semver range for the app version, such as ^1.4. Incompatible plugins are skipped.
main no Entry file, relative to the plugin folder. Defaults to index.js.
contributes.providers no Provider files or provider objects
contributes.commands no Command files or command definitions
contributes.keybindings no Shortcuts, as an array of { command, key } objects or a { "command": "combo" } map

Use mod in a keybinding for Cmd on macOS and Ctrl on Windows and Linux. File paths in main and contributes are relative to the plugin folder.

Providers

A provider converts a repository URL into release API calls and normalizes the response. A provider object has these members:

export default {
  id: "sourcehut",
  match(url) {
    return url.hostname === "git.sr.ht";
  },
  reference(url) {
    const parts = url.pathname.split("/").filter(Boolean);
    const repositoryPath = parts.slice(0, 2).join("/");
    return {
      repo: `git.sr.ht/${repositoryPath}`,
      url: `https://git.sr.ht/${repositoryPath}`,
      repositoryPath,
      provider: "sourcehut",
    };
  },
  repoApiUrl(reference) {
    return `https://git.sr.ht/api/${reference.repositoryPath}`;
  },
  releaseApiUrls(reference) {
    return [`https://git.sr.ht/api/${reference.repositoryPath}/releases`];
  },
  normalize(payload) {
    const release = Array.isArray(payload) ? payload[0] : payload;
    return {
      tag_name: release?.tag_name,
      name: release?.name,
      published_at: release?.published_at,
      body: release?.body,
      assets: [],
    };
  },
};
  • match(url) receives a URL object and returns true if the provider handles it.
  • reference(url) returns the repository details that the other functions use.
  • repoApiUrl and releaseApiUrls return the API URLs that Updainium will request.
  • normalize(payload) converts the API response into Updainium's release shape.

A provider with the same id as a built-in provider replaces it. Plugin providers are tried before the built-in ones.

Commands

A command has this shape:

type Command = {
  id: string;
  title: string;
  category?: string;
  keywords?: string[];
  when?: () => boolean;
  run: () => void | Promise<void>;
};

A command appears in the Command Palette under its category. Commands with the same id replace earlier ones. In a manifest plugin, a command defined in updainium.json can have its run function exported from main, matching the command id. A command defined in a contributed JavaScript file exports the full command object.

export default {
  commands: [
    {
      id: "sourcehut.open",
      title: "Open SourceHut",
      category: "SourceHut",
      run() {
        window.open("https://sr.ht", "_blank");
      },
    },
  ],
};

Reading and writing settings

Plugins can read and write their own settings through window.updainium.config:

  • get(path) returns a value from settings.json.
  • set(path, value) saves a value and returns a promise.

Writes are limited to the plugins.* namespace. Writing anywhere else throws an error. Use a namespace of your own, such as plugins.yourPlugin.option, so your values do not collide with other plugins.

Security boundaries

Plugins are not sandboxed. They run in the WebView with the same resources as the app's interface: fetch, local storage, the clipboard, and the Tauri commands that the app's capability files allow. The following limits still apply:

  • Release checks only call the URLs returned by repoApiUrl and releaseApiUrls.
  • Release downloads are verified with a sha256 checksum when the provider supplies one.
  • GitHub and other tokens are stored in the operating system's credential store and are not available to plugins.
  • A plugin cannot change the Rust backend, the Tauri capability set, or the installed application files.

Testing a plugin

Run npm run tauri dev and place your plugin in the plugins/ folder of the project root. Development builds read plugins from that folder, so you can test changes without copying them into the configuration folder. Set VITE_DEV_PLUGINS_DIR to use a different folder. Then open the command palette with Cmd+Shift+P or Ctrl+Shift+P and confirm that your command appears.

Clone this wiki locally