Repository navigation
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.
A plugin takes one of two forms:
-
Single file: a
.jsfile placed directly in thepluginsfolder. It can default-export a provider, a command, or an object withprovidersandcommandsarrays. -
Manifest folder: a folder in
plugins/that contains anupdainium.jsonmanifest and the JavaScript files it references.
plugins/
sourcehut/
updainium.json
index.js
provider.js
{
"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.
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 aURLobject and returnstrueif the provider handles it. -
reference(url)returns the repository details that the other functions use. -
repoApiUrlandreleaseApiUrlsreturn 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.
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");
},
},
],
};Plugins can read and write their own settings through window.updainium.config:
-
get(path)returns a value fromsettings.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.
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
repoApiUrlandreleaseApiUrls. - 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.
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.
Home · Discussions · Report a Bug · Contribute
Found something missing or outdated? Help improve this manual. Every contribution makes Updainium easier to use.
Made with ❤️ by the Updainium community.
Getting Started
User Guide
- Application Library
- Adding Applications
- Managing Applications
- Release Information
- Downloads and Verification
- Backups and Restore
- Settings and Preferences
Customization
Platform Guides
Developer Documentation
- Architecture Overview
- Supported Providers
- Plugin Development
- Configuration Reference
- Deep Links
- Security Model
- Contributing
Reference and Support