feat(webui): add opt-in MaiBot appearance overlay
This commit is contained in:
29 files changed
+1424
-315
No files matched your search
@@ -0,0 +1,29 @@
|
||||
import type { WebuiPresentation, WebuiTarget } from '@snowluma/common/webui-target';
|
||||
import type { UiAppearance } from '@/types';
|
||||
|
||||
export interface TargetAppearance {
|
||||
css: string;
|
||||
licenseUrl?: string;
|
||||
resolve: (saved: UiAppearance, presentation: WebuiPresentation) => UiAppearance;
|
||||
}
|
||||
|
||||
export function resolveAppearance(
|
||||
saved: UiAppearance,
|
||||
presentation: WebuiPresentation | null,
|
||||
target: TargetAppearance | null,
|
||||
): UiAppearance {
|
||||
if (!presentation) {
|
||||
return saved;
|
||||
}
|
||||
|
||||
if (!target) {
|
||||
throw new Error('Target appearance must be prepared before mounting ThemeProvider');
|
||||
}
|
||||
|
||||
return target.resolve(saved, presentation);
|
||||
}
|
||||
|
||||
// Exhaustive: adding a shared target requires a frontend implementation here.
|
||||
export const targetLoaders = {
|
||||
maibot: () => import('./targets/maibot').then((module) => module.maibotAppearance),
|
||||
} satisfies Record<WebuiTarget, () => Promise<TargetAppearance>>;
|
||||
Reference in new issue
Block a user