openclaw/scripts/lib/plugin-theme-assets.mts
Peter Steinberger c077d5f5f3
feat(themes): support plugin hats and critter artwork (#154935)
Let plugin themes declare bounded, self-contained SVG assets for avatar hats
and composer visitors. Capture artwork with each plugin generation, expose
content-hashed authenticated resource URLs, and rasterize images lazily in
the Control UI. Personal imports remain limited to built-in artwork IDs.

Package declared assets through the shared filesystem boundary while keeping
manifest declarations usable by native build and updater tooling. Preserve
existing pointer interactions, loaded-photo hats, palette notifications,
and transcript invalidation. Document validation and reload behavior.

Validation: focused protocol, manifest, Gateway, UI, packaging, native updater,
and extracted PR tooling tests; core/UI/scripts and affected test typechecks;
protocol generators, style lint, dead-code checks, assertion and line-cap
ratchets, formatting, docs links, and scoped-clean P1 review. Inspected
synthetic before/after captures are attached to the PR. Startup budget files
remain unchanged at 370300 B baseline and 370876 B enforcement.
2026-09-21 10:30:47 -07:00

23 lines
760 B
TypeScript

import { normalizeManifestThemes } from "../../src/plugins/manifest-themes.ts";
/** Packaging consumes the same declared paths as manifest discovery. */
export function collectPluginThemeAssetPaths(manifest: Record<string, unknown>): string[] {
if (typeof manifest.id !== "string") {
return [];
}
const normalized = normalizeManifestThemes(manifest.themes, manifest.id);
if (!normalized.ok) {
return [];
}
const paths = new Set<string>();
for (const theme of normalized.themes ?? []) {
paths.add(theme.source);
for (const source of Object.values(theme.hats ?? {})) {
paths.add(source);
}
for (const critter of Object.values(theme.critters ?? {})) {
paths.add(critter.source);
}
}
return [...paths];
}