haloforge-plugin-api 0.2.3

Plugin API for HaloForge — traits and types for building native HaloForge plugins
Documentation
import { invoke } from "@tauri-apps/api/core";
// ─── Plugin-scoped IPC ────────────────────────────────────────────────────────
let _currentPluginId = "";
/** @internal Called once by the plugin runtime to set the current plugin context. */
export function _setPluginId(id) {
    _currentPluginId = id;
}
/** @internal Exposed for SDK helpers that cannot rely on React context. */
export function _getPluginId() {
    return _currentPluginId;
}
/**
 * Call a Tauri command registered by this plugin's Rust backend.
 * The command name is automatically prefixed: `plugin_{id}_{command}`.
 *
 * @example
 * ```ts
 * const status = await invokePlugin<GitStatus>("git_status", { path: "/repo" });
 * ```
 */
export async function invokePlugin(command, args) {
    if (!_currentPluginId) {
        throw new Error("[plugin-sdk] invokePlugin: plugin ID not set. Did you call registerPlugin()?");
    }
    const wireName = `plugin_${_currentPluginId.replace(/[.\-]/g, "_")}_${command}`;
    return invoke("plugin_invoke", {
        args: { wire_name: wireName, args: args ?? {} },
    });
}
/**
 * Call a command registered by another plugin.
 * Use this to depend on services provided by another plugin.
 */
export async function invokeOtherPlugin(targetPluginId, command, args) {
    const wireName = `plugin_${targetPluginId.replace(/[.\-]/g, "_")}_${command}`;
    return invoke("plugin_invoke", {
        args: { wire_name: wireName, args: args ?? {} },
    });
}
/**
 * Call a built-in HaloForge host Tauri command directly.
 * Only available if declared in manifest permissions.
 */
export async function invokeHost(command, args) {
    return invoke(command, args);
}
//# sourceMappingURL=ipc.js.map