mirror of
https://github.com/getpaseo/paseo.git
synced 2026-10-25 10:42:45 +00:00
Adds plugin-contributed light and dark app themes, including persistence, host-aware coalescing, fallback behavior, documentation, examples, and browser/iOS QA.
39 lines
1.0 KiB
TypeScript
39 lines
1.0 KiB
TypeScript
import type { InstalledPlugin, PluginSidebarContribution } from "./types";
|
|
|
|
export interface PluginSidebarTarget {
|
|
plugin: InstalledPlugin;
|
|
item: PluginSidebarContribution;
|
|
}
|
|
|
|
export interface PluginSidebarGroup {
|
|
key: string;
|
|
pluginId: string;
|
|
contributionId: string;
|
|
title: string;
|
|
icon: string;
|
|
targets: PluginSidebarTarget[];
|
|
}
|
|
|
|
export function groupPluginSidebarContributions(plugins: InstalledPlugin[]): PluginSidebarGroup[] {
|
|
const groups = new Map<string, PluginSidebarGroup>();
|
|
for (const plugin of plugins) {
|
|
for (const item of plugin.sidebarItems) {
|
|
const key = `${plugin.id}/sidebar/${item.id}`;
|
|
const existing = groups.get(key);
|
|
if (existing) {
|
|
existing.targets.push({ plugin, item });
|
|
} else {
|
|
groups.set(key, {
|
|
key,
|
|
pluginId: plugin.id,
|
|
contributionId: item.id,
|
|
title: item.title,
|
|
icon: item.icon,
|
|
targets: [{ plugin, item }],
|
|
});
|
|
}
|
|
}
|
|
}
|
|
return [...groups.values()];
|
|
}
|