feat: add Theme API v2 with token compiler, skin slot

This commit is contained in:
Linus Rath
2026-04-28 15:39:13 +02:00
parent dafc8ace3c
commit 1b84547211
10 changed files with 1015 additions and 36 deletions
+18 -1
View File
@@ -1,9 +1,11 @@
// IndexedDB storage for plugin/theme binary blobs (JS bundles, CSS, previews)
const DB_NAME = 'bulwark-plugins';
const DB_VERSION = 1;
// Bumped to 2 to add the theme-skin store; existing stores are preserved.
const DB_VERSION = 2;
const STORE_PLUGINS = 'plugin-code';
const STORE_THEMES = 'theme-css';
const STORE_THEME_SKINS = 'theme-skin';
const STORE_PREVIEWS = 'previews';
function openDB(): Promise<IDBDatabase> {
@@ -18,6 +20,9 @@ function openDB(): Promise<IDBDatabase> {
if (!db.objectStoreNames.contains(STORE_THEMES)) {
db.createObjectStore(STORE_THEMES);
}
if (!db.objectStoreNames.contains(STORE_THEME_SKINS)) {
db.createObjectStore(STORE_THEME_SKINS);
}
if (!db.objectStoreNames.contains(STORE_PREVIEWS)) {
db.createObjectStore(STORE_PREVIEWS);
}
@@ -83,6 +88,18 @@ export const pluginStorage = {
await deleteItem(STORE_THEMES, themeId);
},
// Theme skin CSS — separate store so it can be present/absent independently
// of the colour-token CSS (e.g. some v2 themes ship colours only).
async saveThemeSkin(themeId: string, skin: string): Promise<void> {
await putItem(STORE_THEME_SKINS, themeId, skin);
},
async getThemeSkin(themeId: string): Promise<string | null> {
return getItem<string>(STORE_THEME_SKINS, themeId);
},
async deleteThemeSkin(themeId: string): Promise<void> {
await deleteItem(STORE_THEME_SKINS, themeId);
},
// Preview images (stored as data URIs)
async savePreview(id: string, dataUri: string): Promise<void> {
await putItem(STORE_PREVIEWS, id, dataUri);