feat: load plugin frontends at runtime and remove plugin ids from the shell

This commit is contained in:
LukeGus committed 2026-09-22 20:15:52 -05:00
1 parent 49f0286a14
commit e88d5a52e3
721 files changed
+54265 -44416

No files matched your search

+40
View File
@@ -0,0 +1,40 @@
import type { ComponentType } from "react";
import type { Host } from "@/types/ui-types";
import { byOrderThenId, createRegistry } from "@/lib/registry";
import type { TabShellCallbacks } from "./tab-registry";
/** A command palette entry a plugin contributes. */
export interface PaletteEntryDef {
id: string;
pluginId?: string;
titleKey: string;
icon?: ComponentType<{ className?: string }>;
keywords?: string[];
scope: "global" | "host";
when?: (host?: Host) => boolean;
run: (shell: TabShellCallbacks, host?: Host) => void;
order?: number;
}
const registry = createRegistry<PaletteEntryDef>(byOrderThenId);
export const registerPaletteEntry = registry.register;
export const usePaletteEntries = registry.useList;
export const listPaletteEntries = registry.list;
export const resetPaletteEntries = registry.reset;
export function paletteEntriesFor(
all: PaletteEntryDef[],
scope: PaletteEntryDef["scope"],
host?: Host,
): PaletteEntryDef[] {
return all.filter((entry) => {
if (entry.scope !== scope) return false;
if (!entry.when) return true;
try {
return entry.when(host);
} catch {
return false;
}
});
}