feat(sdk): support for plugin icons

This commit is contained in:
jubnl
2026-07-13 15:48:01 +02:00
parent ebc98f0a3f
commit bae98d1144
18 changed files with 1709 additions and 30 deletions
+7 -2
View File
@@ -36,7 +36,7 @@ interface Version {
}
interface Entry {
id: string; name: string; author: string; description: string; repo: string;
homepage?: string; tags?: string[]; type: string; authorPublicKey?: string; versions: Version[];
homepage?: string; tags?: string[]; type: string; icon?: string; authorPublicKey?: string; versions: Version[];
}
/**
@@ -114,7 +114,11 @@ export function buildEntry(opts: {
throw new Error('this plugin was published signed — sign the update too (pass --sign) or TREK will refuse it.');
}
const versions = [version, ...existing.versions.filter((v) => v.version !== version.version)];
return { ...existing, authorPublicKey: authorPublicKey ?? existing.authorPublicKey, versions };
// Refresh the icon from the manifest when this release declares one (an author who adds
// or changes it should see it in the store), but never wipe an icon the entry already
// carries just because the manifest omits it.
const icon = typeof manifest.icon === 'string' && manifest.icon ? manifest.icon : existing.icon;
return { ...existing, icon, authorPublicKey: authorPublicKey ?? existing.authorPublicKey, versions };
}
const entry: Entry = {
@@ -126,6 +130,7 @@ export function buildEntry(opts: {
type: String(manifest.type),
versions: [version],
};
if (typeof manifest.icon === 'string' && manifest.icon) entry.icon = manifest.icon;
if (typeof manifest.homepage === 'string') entry.homepage = manifest.homepage;
if (Array.isArray(manifest.tags)) entry.tags = manifest.tags.map(String).slice(0, 8);
if (authorPublicKey) entry.authorPublicKey = authorPublicKey;
+9
View File
@@ -8,6 +8,7 @@
import fs from 'node:fs';
import path from 'node:path';
import { validateManifest, isUnboundedRange, KNOWN_ADDONS } from '../manifest.js';
import { LUCIDE_ICON_NAMES } from '../lucide-icon-names.js';
import { readJsonFile } from './json.js';
export interface ValidateReport {
@@ -45,6 +46,14 @@ export function validatePluginDir(dir: string): ValidateReport {
for (const a of res.manifest?.requiredAddons ?? []) {
if (!KNOWN_ADDONS.includes(a)) warnings.push(`requiredAddons: "${a}" is not a known TREK addon on this SDK version`);
}
// Same deal for `icon`: TREK resolves it against lucide at render time and falls
// back to Blocks on a name it can't find, so a typo is silent in the UI. Warn
// rather than error — the list is a snapshot, and a newer lucide may have names
// this SDK predates.
const icon = typeof raw.icon === 'string' ? raw.icon : '';
if (icon && !LUCIDE_ICON_NAMES.has(icon)) {
warnings.push(`icon: "${icon}" is not a known lucide icon name on this SDK version — TREK will fall back to Blocks`);
}
// TREK renders its UI with lucide icons only. It STRIPS emojis from the declarative
// text your hooks return (badges, columns, warnings, PDF sections, map/calendar/photo
// labels) and from notifications, so emojis in that text simply vanish at render.
File diff suppressed because it is too large Load Diff