Add completion, browser integration, and workspace improvements
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import type { PluginCommand, PluginView } from "./sdk.ts";
|
||||
|
||||
export type PluginTool = {
|
||||
owner: string; id: string; title: string; kind: "command" | "view";
|
||||
surface: "commands" | "open" | "settings";
|
||||
icon?: PluginView["icon"];
|
||||
};
|
||||
|
||||
export function pluginAccess(owner: string, commands: Iterable<PluginCommand>, views: Iterable<PluginView>): PluginTool[] {
|
||||
const result: PluginTool[] = [];
|
||||
for (const command of commands) {
|
||||
const legacyOpen = owner === "runestone.browser" && command.id === "new-tab";
|
||||
result.push({ owner, id: command.id, title: command.title, kind: "command", surface: command.category === "open" || (command.category === undefined && legacyOpen) ? "open" : "commands" });
|
||||
}
|
||||
for (const view of views) {
|
||||
const settings = view.settings ?? (owner === "runestone.local-autocomplete" && view.id === "settings");
|
||||
if (!settings && (view.launcher === false || (view.launcher === undefined && owner === "runestone.browser"))) continue;
|
||||
result.push({ owner, id: view.id, title: view.title, kind: "view", surface: settings ? "settings" : "open", icon: view.icon });
|
||||
}
|
||||
return result;
|
||||
}
|
||||
Reference in New Issue
Block a user