mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-23 16:03:06 +00:00
Plugin API 1.4: grants for unencrypted HTTP, local sockets, IDE commands and owned database sources; window status items, output channels, content tabs, editor selections, decorations, search, Problems and VCS reads; runs, keyed terminals with exit events, plugin run targets, dynamic run configurations and test parsers; language features, injections, snippets and menu locations; plugin MCP tools on the built-in server; four official API examples. Released 1.3 plugins keep working.
25 lines
1.1 KiB
TypeScript
25 lines
1.1 KiB
TypeScript
/** Host-owned registrations shared by plugins, Run and Settings. */
|
|
import { create } from "zustand";
|
|
import { useMemo } from "react";
|
|
import type { RegisteredRunTarget } from "@/bindings";
|
|
import { DEFAULT_RUN_TARGET, type RunTargetValid } from "./remoteSettings";
|
|
import { useWorkflowSettings, workflowSettings } from "./workflowSettings";
|
|
|
|
export const usePluginRunTargets = create<{ targets: RegisteredRunTarget[] }>(() => ({ targets: [] }));
|
|
export type RuntimeRunTarget = Omit<RunTargetValid, "kind"> & { kind: RunTargetValid["kind"] | "plugin" };
|
|
const converted = (targets: RegisteredRunTarget[]): RuntimeRunTarget[] =>
|
|
targets.map((t) => ({
|
|
...DEFAULT_RUN_TARGET,
|
|
kind: "plugin",
|
|
id: t.id,
|
|
name: `${t.target.name} (${t.pluginName})`,
|
|
}));
|
|
export function runTargets(): RuntimeRunTarget[] {
|
|
return [...workflowSettings().runTargets, ...converted(usePluginRunTargets.getState().targets)];
|
|
}
|
|
export function useRunTargets(): RuntimeRunTarget[] {
|
|
const saved = useWorkflowSettings((s) => s.runTargets);
|
|
const plugins = usePluginRunTargets((s) => s.targets);
|
|
return useMemo(() => [...saved, ...converted(plugins)], [saved, plugins]);
|
|
}
|