Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active
TypeScript aianthropicartifactsawsazurechatgptchatgpt-cloneclaudeclonedeepseekgeminigooglegpt-5librechatmcpo1openairesponses-apivisionwebui
🎨 feat: Paint Inline Deployment Themes From the First Frame (#17203)
Marco Beretta1b7ab8a5230c
diff --git a/client/src/style.css b/client/src/style.cssindex 3a8c0c11e3..b3efd7a164 100644--- a/client/src/style.css+++ b/client/src/style.css@@ -124,7 +124,7 @@ html {/* High contrast appearance modes.** Every `IThemeRGB` token is delivered by the theme registry as an inline custom- * property on <html> (see packages/client/src/theme/themes/highContrast.ts), so+ * property on <html> (see packages/data-provider/src/themes/highContrast.ts), so* this block only covers what the token layer cannot reach: the CSS-only* variables and hard-coded literals elsewhere in this stylesheet. Every ratio* quoted below is measured against the mode's own canvas, pure white or purediff --git a/e2e/specs/mock/scenarios/badge-label.spec.ts b/e2e/specs/mock/scenarios/badge-label.spec.tsindex 932898b653..1ba55028a9 100644--- a/e2e/specs/mock/scenarios/badge-label.spec.ts+++ b/e2e/specs/mock/scenarios/badge-label.spec.ts@@ -1,6 +1,6 @@import { expect, test } from '@playwright/test';import type { Page } from '@playwright/test';-import type { ThemeDefinition } from '../../../../packages/client/src/theme/types';+import type { ThemeDefinition } from '../../../../packages/data-provider/src/themes/types';import { clickHouseTheme } from '../../../../packages/client/src/theme/themes/clickhouse';import { NEW_CHAT_PATH } from '../helpers';import { probeStyle } from './style.helpers';diff --git a/e2e/specs/mock/scenarios/button-roles.spec.ts b/e2e/specs/mock/scenarios/button-roles.spec.tsindex f9252463e4..79894f8d1d 100644--- a/e2e/specs/mock/scenarios/button-roles.spec.ts+++ b/e2e/specs/mock/scenarios/button-roles.spec.ts@@ -1,6 +1,6 @@import { expect, test } from '@playwright/test';import type { Locator, Page } from '@playwright/test';-import type { ThemeDefinition } from '../../../../packages/client/src/theme/types';+import type { ThemeDefinition } from '../../../../packages/data-provider/src/themes/types';import { clickHouseTheme } from '../../../../packages/client/src/theme/themes/clickhouse';import { NEW_CHAT_PATH } from '../helpers';import { probeStyle } from './style.helpers';diff --git a/e2e/specs/mock/scenarios/clickhouse-theme.spec.ts b/e2e/specs/mock/scenarios/clickhouse-theme.spec.tsindex 101dbd8ceb..4aa260d44b 100644--- a/e2e/specs/mock/scenarios/clickhouse-theme.spec.ts+++ b/e2e/specs/mock/scenarios/clickhouse-theme.spec.ts@@ -1,10 +1,10 @@import { randomUUID } from 'crypto';import { expect, test } from '@playwright/test';import type { Page } from '@playwright/test';-import type { IThemeRGB } from '../../../../packages/client/src/theme/types';+import type { IThemeRGB } from '../../../../packages/data-provider/src/themes/types';import { clickHouseTheme } from '../../../../packages/client/src/theme/themes/clickhouse';-import { defaultTheme } from '../../../../packages/client/src/theme/themes/default';-import { darkTheme } from '../../../../packages/client/src/theme/themes/dark';+import { defaultTheme } from '../../../../packages/data-provider/src/themes/default';+import { darkTheme } from '../../../../packages/data-provider/src/themes/dark';import { deleteConversations, seedConversations, seedMessages, withMongo } from '../db';import { getE2EUser } from '../../../setup/user';import { themeValue } from './style.helpers';diff --git a/e2e/specs/mock/scenarios/control-border.spec.ts b/e2e/specs/mock/scenarios/control-border.spec.tsindex df5ddcc62d..1219771bfa 100644--- a/e2e/specs/mock/scenarios/control-border.spec.ts+++ b/e2e/specs/mock/scenarios/control-border.spec.ts@@ -1,7 +1,7 @@import { expect, test } from '@playwright/test';import type { Page } from '@playwright/test';import { clickHouseTheme } from '../../../../packages/client/src/theme/themes/clickhouse';-import { darkTheme } from '../../../../packages/client/src/theme/themes/dark';+import { darkTheme } from '../../../../packages/data-provider/src/themes/dark';import { MOCK_ENDPOINTS, NEW_CHAT_PATH, selectMockEndpoint, sendMessage } from '../helpers';import { openAgentBuilder } from '../agents.helpers';import { themeValue } from './style.helpers';diff --git a/e2e/specs/mock/scenarios/control-spacing.spec.ts b/e2e/specs/mock/scenarios/control-spacing.spec.tsindex 6b03595c2f..640078c017 100644--- a/e2e/specs/mock/scenarios/control-spacing.spec.ts+++ b/e2e/specs/mock/scenarios/control-spacing.spec.ts@@ -1,6 +1,6 @@import { expect, test } from '@playwright/test';import type { Locator, Page } from '@playwright/test';-import type { ThemeDefinition } from '../../../../packages/client/src/theme/types';+import type { ThemeDefinition } from '../../../../packages/data-provider/src/themes/types';import { clickHouseTheme } from '../../../../packages/client/src/theme/themes/clickhouse';import { NEW_CHAT_PATH, messagesView, sendMessageAndWaitForCompletion } from '../helpers';import { probeStyle } from './style.helpers';diff --git a/e2e/specs/mock/scenarios/deployment-theme-first-paint.spec.ts b/e2e/specs/mock/scenarios/deployment-theme-first-paint.spec.tsindex fa2b069ae9..2da4b5ead7 100644--- a/e2e/specs/mock/scenarios/deployment-theme-first-paint.spec.ts+++ b/e2e/specs/mock/scenarios/deployment-theme-first-paint.spec.ts@@ -1,14 +1,14 @@import { resolve } from 'node:path';import { expect, test } from '@playwright/test';import { parseSessionHint, formatSessionHint, SESSION_HINT_COOKIE } from 'librechat-data-provider';-import type { SessionHint } from 'librechat-data-provider';+import type { SessionHint, ThemeDefinition } from 'librechat-data-provider';import type { Page } from '@playwright/test';import {readBundledThemeBoot,injectDeploymentThemeBoot,} from '../../../../packages/api/src/html/theme';import { clickHouseTheme } from '../../../../packages/client/src/theme/themes/clickhouse';-import { resolveTheme } from '../../../../packages/client/src/theme/registry';+import { resolveTheme } from '../../../../packages/data-provider/src/themes/registry';/*** `interface.theme` exists only in the `/api/config` answer, so before this@@ -28,6 +28,30 @@ import { resolveTheme } from '../../../../packages/client/src/theme/registry';type Mode = 'light' | 'dark';+/** An operator's own `interface.theme`, written inline in librechat.yaml rather than named. */+const inlineTheme = {+ version: 1 as const,+ name: 'acme',+ modes: {+ light: {+ colors: {+ 'rgb-surface-primary': '250 238 220',+ 'rgb-surface-primary-alt': '244 228 204',+ 'rgb-surface-canvas': '252 244 232',+ },+ },+ dark: {+ colors: {+ 'rgb-surface-primary': '28 36 52',+ 'rgb-surface-primary-alt': '20 26 40',+ 'rgb-surface-canvas': '16 22 34',+ },+ },+ },+} satisfies ThemeDefinition;++type ThemeSource = 'clickhouse' | typeof inlineTheme;+type Frame = {at: number;theme: string | null;@@ -54,7 +78,7 @@ const CACHE_KEY = 'deployment-theme';*/async function serveTheme(page: Page,- theme: () => string | null,+ theme: () => ThemeSource | null,held: () => boolean,signedInOnly = true,) {@@ -444,7 +468,7 @@ test('a session refresh keeps the readable session hint on the refresh session e* injection, with the `theme-boot.json` this build emitted, as a server configured with* `interface.theme: clickhouse` serves it.*/-async function serveThemedShell(page: Page) {+async function serveThemedShell(page: Page, source: ThemeSource) {const bundled = readBundledThemeBoot(resolve(__dirname, '../../../../client/dist'));expect(bundled.clickhouse).toBeDefined();await page.route(@@ -454,30 +478,35 @@ async function serveThemedShell(page: Page) {return route.fallback();}const response = await route.fetch();- const html = injectDeploymentThemeBoot(await response.text(), 'clickhouse', bundled);+ const html = injectDeploymentThemeBoot(await response.text(), source, bundled);await route.fulfill({ response, body: html });},);}/** Every `/api/config` answer, signed in or not, held until the app paints: the first one ends the window under test. */-function holdConfig(page: Page) {+function holdConfig(page: Page, source: ThemeSource) {return serveTheme(page,- () => 'clickhouse',+ () => source,() => true,false,);}/** Opens `path` in a browser that has never cached a deployment theme, throttled, and returns the frames before the config answers. */-async function firstVisitFrames(page: Page, path: string, ready: () => Promise<void>) {+async function firstVisitFrames(+ page: Page,+ path: string,+ ready: () => Promise<void>,+ source: ThemeSource = 'clickhouse',+) {await page.addInitScript((key) => {localStorage.removeItem(key);sessionStorage.clear();}, CACHE_KEY);- await serveThemedShell(page);- const answeredAt = await holdConfig(page);+ await serveThemedShell(page, source);+ const answeredAt = await holdConfig(page, source);await sampleFrames(page);await throttle(page);await page.goto(path);@@ -491,10 +520,14 @@ async function firstVisitFrames(page: Page, path: string, ready: () => Promise<v}/** A signed-in first visit: every frame before the answer, shell and app alike, wears the theme. */-async function expectFirstVisit(page: Page, mode: Mode) {- const { colors } = resolveTheme(clickHouseTheme, mode);- const frames = await firstVisitFrames(page, '/c/new', () =>- expect(page.getByTestId('composer-surface')).toBeVisible({ timeout: 60000 }),+async function expectFirstVisit(page: Page, mode: Mode, source: ThemeSource = 'clickhouse') {+ const definition = typeof source === 'string' ? clickHouseTheme : source;+ const { colors } = resolveTheme(definition, mode);+ const frames = await firstVisitFrames(+ page,+ '/c/new',+ () => expect(page.getByTestId('composer-surface')).toBeVisible({ timeout: 60000 }),+ source,);/** Frames of both the shell and the first render landed before the answer. */@@ -502,13 +535,13 @@ async function expectFirstVisit(page: Page, mode: Mode) {expect(frames[0].shell).not.toBeNull();expect(frames.some((frame) => frame.app)).toBe(true);for (const frame of frames) {- expect(frame.theme).toBe('clickhouse');+ expect(frame.theme).toBe(definition.name);expect(frame.surface).toBe(colors['rgb-surface-primary']);if (frame.shell !== null) {expect(frame.shell).toBe(rgb(colors['rgb-surface-canvas']));}}- await expect(page.locator('html')).toHaveAttribute('data-theme', 'clickhouse');+ await expect(page.locator('html')).toHaveAttribute('data-theme', definition.name);await expect(page.locator('html')).not.toHaveAttribute('data-theme-boot');}@@ -541,6 +574,13 @@ test.describe('deployment theme first-ever visit (light)', () => {await expectFirstVisit(page, 'light');});+ test('a first-ever signed-in visit paints an inline operator theme from the first frame in light @scenario:deployment-theme-first-visit-inline-light', async ({+ page,+ }) => {+ test.setTimeout(120000);+ await expectFirstVisit(page, 'light', inlineTheme);+ });+test.describe('signed out', () => {test.use({ storageState: { cookies: [], origins: [] } });@@ -563,6 +603,13 @@ test.describe('deployment theme first-ever visit (dark)', () => {await expectFirstVisit(page, 'dark');});+ test('a first-ever signed-in visit paints an inline operator theme from the first frame in dark @scenario:deployment-theme-first-visit-inline-dark', async ({+ page,+ }) => {+ test.setTimeout(120000);+ await expectFirstVisit(page, 'dark', inlineTheme);+ });+test.describe('signed out', () => {test.use({ storageState: { cookies: [], origins: [] } });diff --git a/e2e/specs/mock/scenarios/deployment-theme.spec.ts b/e2e/specs/mock/scenarios/deployment-theme.spec.tsindex 3a032588b1..eccaccd801 100644--- a/e2e/specs/mock/scenarios/deployment-theme.spec.ts+++ b/e2e/specs/mock/scenarios/deployment-theme.spec.ts@@ -1,8 +1,8 @@import { expect, test } from '@playwright/test';import type { Page } from '@playwright/test';import { clickHouseTheme } from '../../../../packages/client/src/theme/themes/clickhouse';-import { defaultTheme } from '../../../../packages/client/src/theme/themes/default';-import { darkTheme } from '../../../../packages/client/src/theme/themes/dark';+import { defaultTheme } from '../../../../packages/data-provider/src/themes/default';+import { darkTheme } from '../../../../packages/data-provider/src/themes/dark';import { getE2EUser } from '../../../setup/user';import { themeValue } from './style.helpers';diff --git a/e2e/specs/mock/scenarios/dialog-chrome.spec.ts b/e2e/specs/mock/scenarios/dialog-chrome.spec.tsindex b1f12b2db1..27a4c5022b 100644--- a/e2e/specs/mock/scenarios/dialog-chrome.spec.ts+++ b/e2e/specs/mock/scenarios/dialog-chrome.spec.ts@@ -1,6 +1,6 @@import { expect, test } from '@playwright/test';import type { Locator, Page } from '@playwright/test';-import type { ThemeDefinition } from '../../../../packages/client/src/theme/types';+import type { ThemeDefinition } from '../../../../packages/data-provider/src/themes/types';import { clickHouseTheme } from '../../../../packages/client/src/theme/themes/clickhouse';import { NEW_CHAT_PATH } from '../helpers';import { probeStyle } from './style.helpers';diff --git a/e2e/specs/mock/scenarios/field-focus.spec.ts b/e2e/specs/mock/scenarios/field-focus.spec.tsindex 957639fe5e..c679f8d93f 100644--- a/e2e/specs/mock/scenarios/field-focus.spec.ts+++ b/e2e/specs/mock/scenarios/field-focus.spec.ts@@ -1,6 +1,6 @@import { expect, test } from '@playwright/test';import type { Locator, Page } from '@playwright/test';-import type { ThemeDefinition } from '../../../../packages/client/src/theme/types';+import type { ThemeDefinition } from '../../../../packages/data-provider/src/themes/types';import { clickHouseTheme } from '../../../../packages/client/src/theme/themes/clickhouse';import { NEW_CHAT_PATH } from '../helpers';import { probeStyle } from './style.helpers';diff --git a/e2e/specs/mock/scenarios/prompt-category-icon.spec.ts b/e2e/specs/mock/scenarios/prompt-category-icon.spec.tsindex 554432ac2c..d3480809c2 100644--- a/e2e/specs/mock/scenarios/prompt-category-icon.spec.ts+++ b/e2e/specs/mock/scenarios/prompt-category-icon.spec.ts@@ -1,10 +1,13 @@import { randomUUID } from 'crypto';import { expect, test } from '@playwright/test';import type { Page } from '@playwright/test';-import type { IThemeRGB, ThemeDefinition } from '../../../../packages/client/src/theme/types';+import type {+ IThemeRGB,+ ThemeDefinition,+} from '../../../../packages/data-provider/src/themes/types';import { clickHouseTheme } from '../../../../packages/client/src/theme/themes/clickhouse';-import { defaultTheme } from '../../../../packages/client/src/theme/themes/default';-import { darkTheme } from '../../../../packages/client/src/theme/themes/dark';+import { defaultTheme } from '../../../../packages/data-provider/src/themes/default';+import { darkTheme } from '../../../../packages/data-provider/src/themes/dark';import { getAccessToken, requestJson } from '../helpers';import { openPanel } from './panels';diff --git a/e2e/specs/mock/scenarios/semantic-surfaces.spec.ts b/e2e/specs/mock/scenarios/semantic-surfaces.spec.tsindex 27c448ce3e..50167cee9e 100644--- a/e2e/specs/mock/scenarios/semantic-surfaces.spec.ts+++ b/e2e/specs/mock/scenarios/semantic-surfaces.spec.ts@@ -1,7 +1,7 @@import { randomUUID } from 'crypto';import { expect, test } from '@playwright/test';import type { Locator, Page } from '@playwright/test';-import type { IThemeRGB } from '../../../../packages/client/src/theme/types';+import type { IThemeRGB } from '../../../../packages/data-provider/src/themes/types';import {deleteConversations,deleteMessagesByConversation,@@ -9,8 +9,8 @@ import {withMongo,} from '../db';import { clickHouseTheme } from '../../../../packages/client/src/theme/themes/clickhouse';-import { defaultTheme } from '../../../../packages/client/src/theme/themes/default';-import { darkTheme } from '../../../../packages/client/src/theme/themes/dark';+import { defaultTheme } from '../../../../packages/data-provider/src/themes/default';+import { darkTheme } from '../../../../packages/data-provider/src/themes/dark';import { openAgentBuilder, uniqueAgentName, cleanupAgent } from '../agents.helpers';import { MOCK_ENDPOINTS, getAccessToken, requestJson } from '../helpers';import { getE2EUser } from '../../../setup/user';diff --git a/e2e/specs/mock/scenarios/share-deployment-theme.spec.ts b/e2e/specs/mock/scenarios/share-deployment-theme.spec.tsindex 6eede75dad..2b71c9d94f 100644--- a/e2e/specs/mock/scenarios/share-deployment-theme.spec.ts+++ b/e2e/specs/mock/scenarios/share-deployment-theme.spec.ts@@ -1,8 +1,8 @@import { expect, test } from '@playwright/test';import type { Page } from '@playwright/test';import { clickHouseTheme } from '../../../../packages/client/src/theme/themes/clickhouse';-import { defaultTheme } from '../../../../packages/client/src/theme/themes/default';-import { darkTheme } from '../../../../packages/client/src/theme/themes/dark';+import { defaultTheme } from '../../../../packages/data-provider/src/themes/default';+import { darkTheme } from '../../../../packages/data-provider/src/themes/dark';import {sendMessageAndWaitForCompletion,selectMockEndpoint,diff --git a/e2e/specs/mock/scenarios/theme-cache-pin.spec.ts b/e2e/specs/mock/scenarios/theme-cache-pin.spec.tsindex 5ea3ef98b1..f88fae5f97 100644--- a/e2e/specs/mock/scenarios/theme-cache-pin.spec.ts+++ b/e2e/specs/mock/scenarios/theme-cache-pin.spec.ts@@ -87,7 +87,7 @@ test.describe('the theme cache resolver output pin', () => {test('a fallback that acts only beside another source asks for an epoch bump @scenario:theme-pin-joint-fallback', () => {const result = runPin([{- bundle: 'client',+ bundle: 'provider',from: '"rgb-series-8": customColors?.["rgb-text-secondary"] ?? baseColors["rgb-text-secondary"]',to: '"rgb-series-8": baseColors["rgb-text-secondary"]',},@@ -99,7 +99,7 @@ test.describe('the theme cache resolver output pin', () => {test('a fallback that acts only when two sources meet asks for an epoch bump @scenario:theme-pin-conjunctive-fallback', () => {const result = runPin([{- bundle: 'client',+ bundle: 'provider',from: '...customColors,\n\t\t\t...codeSurfaceFallback,',to: '...customColors,\n\t\t\t...(customColors?.["rgb-status-error"] !== void 0 && customColors?.["rgb-status-warning"] !== void 0 && customColors?.["rgb-border-light"] === void 0 ? { "rgb-border-light": customColors["rgb-status-error"] } : {}),\n\t\t\t...codeSurfaceFallback,',},@@ -111,7 +111,7 @@ test.describe('the theme cache resolver output pin', () => {test('swapping precedence between sources that share a validator asks for an epoch bump @scenario:theme-pin-shared-validator-precedence', () => {const result = runPin([{- bundle: 'client',+ bundle: 'provider',from: '["dialogTitleFontFamily", "displayFontFamily"],',to: '["dialogTitleFontFamily", "fontFamily"],\n\t["dialogTitleFontFamily", "displayFontFamily"],',},@@ -123,7 +123,7 @@ test.describe('the theme cache resolver output pin', () => {test('a shadow role that stops canonicalizing None asks for an epoch bump @scenario:theme-pin-shadow-none-case', () => {const result = runPin([{- bundle: 'client',+ bundle: 'provider',from: 'result[key].trim().toLowerCase() === "none"',to: 'result[key] === "none"',},@@ -135,7 +135,7 @@ test.describe('the theme cache resolver output pin', () => {test('a shadow role that stops trimming None asks for an epoch bump @scenario:theme-pin-shadow-none-padding', () => {const result = runPin([{- bundle: 'client',+ bundle: 'provider',from: 'result[key].trim().toLowerCase() === "none"',to: 'result[key].toLowerCase() === "none"',},diff --git a/e2e/specs/mock/scenarios/theme-paint.spec.ts b/e2e/specs/mock/scenarios/theme-paint.spec.tsindex b498b0b6cd..150ad5faed 100644--- a/e2e/specs/mock/scenarios/theme-paint.spec.ts+++ b/e2e/specs/mock/scenarios/theme-paint.spec.ts@@ -1,9 +1,9 @@import { expect, test } from '@playwright/test';import type { Page } from '@playwright/test';-import type { IThemeRGB } from '../../../../packages/client/src/theme/types';+import type { IThemeRGB } from '../../../../packages/data-provider/src/themes/types';import { clickHouseTheme } from '../../../../packages/client/src/theme/themes/clickhouse';-import { defaultTheme } from '../../../../packages/client/src/theme/themes/default';-import { darkTheme } from '../../../../packages/client/src/theme/themes/dark';+import { defaultTheme } from '../../../../packages/data-provider/src/themes/default';+import { darkTheme } from '../../../../packages/data-provider/src/themes/dark';import {sendMessageAndWaitForCompletion,selectMockEndpoint,diff --git a/e2e/specs/mock/scenarios/theme-surfaces.spec.ts b/e2e/specs/mock/scenarios/theme-surfaces.spec.tsindex 437a2b69cb..15e48f5a20 100644--- a/e2e/specs/mock/scenarios/theme-surfaces.spec.ts+++ b/e2e/specs/mock/scenarios/theme-surfaces.spec.ts@@ -1,7 +1,7 @@import { randomUUID } from 'crypto';import { expect, test } from '@playwright/test';import type { Locator, Page } from '@playwright/test';-import type { IThemeRGB } from '../../../../packages/client/src/theme/types';+import type { IThemeRGB } from '../../../../packages/data-provider/src/themes/types';import { clickHouseTheme } from '../../../../packages/client/src/theme/themes/clickhouse';import { deleteConversations, seedConversations, seedMessages } from '../db';import { probeStyle } from './style.helpers';diff --git a/packages/api/src/html/theme.spec.ts b/packages/api/src/html/theme.spec.tsindex cd5041758f..36f278cf0a 100644--- a/packages/api/src/html/theme.spec.ts+++ b/packages/api/src/html/theme.spec.ts@@ -2,8 +2,16 @@ import fs from 'fs';import os from 'os';import path from 'path';import { logger } from '@librechat/data-schemas';-import { THEME_BOOT_FILE, DEPLOYMENT_THEME_BOOT_ID } from 'librechat-data-provider';-import type { BundledThemeBoot, DeploymentThemeBoot } from 'librechat-data-provider';+import {+ THEME_BOOT_FILE,+ describeThemeModes,+ DEPLOYMENT_THEME_BOOT_ID,+} from 'librechat-data-provider';+import type {+ ThemeDefinition,+ BundledThemeBoot,+ DeploymentThemeBoot,+} from 'librechat-data-provider';import type { Request, Response } from 'express';import {readBundledThemeBoot,@@ -51,8 +59,25 @@ describe('injectDeploymentThemeBoot', () => {expect(html.indexOf(DEPLOYMENT_THEME_BOOT_ID)).toBeLessThan(html.indexOf('boot()'));});- it('embeds only the source of an inline definition, which the bundle resolves', () => {- const inline = { version: 1 as const, name: 'acme', modes: { light: {}, dark: {} } };+ it('resolves both modes of an inline definition as the client does', () => {+ const inline = {+ version: 1 as const,+ name: 'acme',+ modes: { light: { colors: { 'rgb-surface-primary': '10 20 30' } }, dark: {} },+ } satisfies ThemeDefinition;+ const boot = bootOf(injectDeploymentThemeBoot(SHELL, inline, bundled));++ expect(boot).toEqual({ source: inline, modes: describeThemeModes(inline) });+ expect(boot?.modes?.light.properties).toContainEqual(['--surface-primary', '10 20 30']);+ expect(boot?.modes?.dark.attributes).toEqual(expect.objectContaining({ 'data-theme': 'acme' }));+ });++ it('embeds only the source of an inline definition the client would reject', () => {+ const inline = {+ version: 1 as const,+ name: 'acme',+ modes: { light: { colors: { 'rgb-x': 'red' } } },+ };expect(bootOf(injectDeploymentThemeBoot(SHELL, inline, bundled))).toEqual({ source: inline });});diff --git a/packages/api/src/html/theme.ts b/packages/api/src/html/theme.tsindex 13da41eb9e..bd1ebc6f26 100644--- a/packages/api/src/html/theme.ts+++ b/packages/api/src/html/theme.ts@@ -4,9 +4,16 @@ import { logger } from '@librechat/data-schemas';import {THEME_BOOT_FILE,isBundledThemeName,+ describeThemeModes,+ validateThemeDefinition,DEPLOYMENT_THEME_BOOT_ID,} from 'librechat-data-provider';-import type { BundledThemeBoot, DeploymentThemeBoot } from 'librechat-data-provider';+import type {+ ThemeBootModes,+ ThemeDefinition,+ BundledThemeBoot,+ DeploymentThemeBoot,+} from 'librechat-data-provider';import type { Request, Response } from 'express';import { rejectTenantHeader } from '../middleware/tenantHeader';import { isEnabled } from '../utils/common';@@ -34,11 +41,27 @@ export function readBundledThemeBoot(distPath: string): BundledThemeBoot {return {};}+/**+ * Both modes of the deployment theme as the boot script replays them: a bundled name from the+ * build's file, an inline definition resolved here by the resolver the client runs. A definition+ * the client would reject has none, so the shell keeps the stock palette the bundle falls back to.+ */+function resolveBootModes(+ source: DeploymentThemeBoot['source'],+ bundled: BundledThemeBoot,+): ThemeBootModes | undefined {+ if (typeof source === 'string') {+ return isBundledThemeName(source) ? bundled[source] : undefined;+ }+ const definition = source as ThemeDefinition;+ return validateThemeDefinition(definition).length === 0+ ? describeThemeModes(definition)+ : undefined;+}+/*** Embeds the deployment's `interface.theme` ahead of the shell's boot script, so a first-ever- * visit paints it before `/api/config` answers. A bundled name carries both resolved modes for- * the boot script; an inline definition carries only its source, which the bundle resolves at- * its first render.+ * visit paints it before `/api/config` answers, with both resolved modes for the boot script.*/export function injectDeploymentThemeBoot(html: string,@@ -48,8 +71,7 @@ export function injectDeploymentThemeBoot(if (source == null || html.includes(`id="${DEPLOYMENT_THEME_BOOT_ID}"`)) {return html;}- const modes =- typeof source === 'string' && isBundledThemeName(source) ? bundled[source] : undefined;+ const modes = resolveBootModes(source, bundled);const boot: DeploymentThemeBoot = { source, ...(modes && { modes }) };/** A `<` in the payload could close the block; it never has to be raw. */const payload = JSON.stringify(boot).replace(/</g, '\\u003c');diff --git a/packages/client/src/components/Progress.spec.tsx b/packages/client/src/components/Progress.spec.tsxindex eba0e20e5d..fd0c915d29 100644--- a/packages/client/src/components/Progress.spec.tsx+++ b/packages/client/src/components/Progress.spec.tsx@@ -2,8 +2,8 @@ import '@testing-library/jest-dom';import { join } from 'node:path';import { readFileSync } from 'node:fs';import { render, screen } from '@testing-library/react';-import type { ThemeDefinition } from '../theme/types';-import { resolveTheme, validateThemeDefinition, THEME_VERSION } from '../theme/registry';+import { resolveTheme, validateThemeDefinition, THEME_VERSION } from 'librechat-data-provider';+import type { ThemeDefinition } from 'librechat-data-provider';import { applyResolvedTheme, clearAppliedTheme } from '../theme/utils/applyTheme';import { Progress } from './Progress';diff --git a/packages/client/src/components/SegmentedMeter.spec.tsx b/packages/client/src/components/SegmentedMeter.spec.tsxindex 9e9c0ae9ed..0b745848ea 100644--- a/packages/client/src/components/SegmentedMeter.spec.tsx+++ b/packages/client/src/components/SegmentedMeter.spec.tsx@@ -2,9 +2,9 @@ import '@testing-library/jest-dom';import { join } from 'node:path';import { readFileSync } from 'node:fs';import { render, screen } from '@testing-library/react';-import type { ThemeDefinition } from '../theme/types';+import { resolveTheme, validateThemeDefinition, THEME_VERSION } from 'librechat-data-provider';+import type { ThemeDefinition } from 'librechat-data-provider';import type { MeterSegment } from './SegmentedMeter';-import { resolveTheme, validateThemeDefinition, THEME_VERSION } from '../theme/registry';import { applyResolvedTheme, clearAppliedTheme } from '../theme/utils/applyTheme';import { SegmentedMeter, MeterSwatch, SERIES_SLOT_COUNT } from './SegmentedMeter';diff --git a/packages/client/src/theme/README.md b/packages/client/src/theme/README.mdindex 717d4c6b1d..80d8308e3a 100644--- a/packages/client/src/theme/README.md+++ b/packages/client/src/theme/README.md@@ -611,7 +611,7 @@ function ThemeToggle() {- `'high-contrast-dark'` - Accessibility mode: white on black, WCAG AAAHigh contrast applies the built-in `highContrastTheme` definition-(`themes/highContrast.ts`), which outranks a deployment's custom theme, and adds+(`packages/data-provider/src/themes/highContrast.ts`), which outranks a deployment's custom theme, and addsa `high-contrast` class to `<html>` for the CSS-only variables the token layercannot reach.@@ -679,11 +679,8 @@ const { theme, setTheme } = useContext(ThemeContext);packages/client/src/theme/├── context/│ └── ThemeProvider.tsx # Main theme provider-├── types/-│ └── index.ts # TypeScript interfaces├── themes/-│ ├── default.ts # Light theme colors-│ ├── dark.ts # Dark theme colors+│ ├── clickhouse.ts # The bundled ClickHouse theme│ └── index.ts # Theme exports├── utils/│ ├── applyTheme.ts # Apply CSS variables@@ -693,6 +690,11 @@ packages/client/src/theme/└── index.ts # Main exports```+The theme types, the resolver (`registry.ts`), the default, dark and high contrast palettes and+`describeResolvedTheme` live in `packages/data-provider/src/themes`, so the server resolves a+deployment's inline `interface.theme` for the shell's first paint with the same code the client+runs. This package re-exports them.+### CSS Variable FormatThe theme system uses RGB values in CSS variables:diff --git a/packages/client/src/theme/allowlist.md b/packages/client/src/theme/allowlist.mdindex 47444c0593..e6b44cc450 100644--- a/packages/client/src/theme/allowlist.md+++ b/packages/client/src/theme/allowlist.md@@ -18,7 +18,7 @@ does not fit an entry below is a sign it should be a role.| # | Entry | Files | Why || --- | ------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |-| 1 | Theme definitions | `packages/client/src/theme/themes/*.ts`, `themes/clickui.json`, `packages/client/src/theme/registry.ts`, `packages/client/src/theme/defaults.css`, `packages/client/src/theme/tokens.css` | The palettes and appearance values themselves: these are the values roles resolve to. |+| 1 | Theme definitions | `packages/client/src/theme/themes/*.ts`, `themes/clickui.json`, `packages/data-provider/src/themes/*.ts`, `packages/client/src/theme/defaults.css`, `packages/client/src/theme/tokens.css` | The palettes and appearance values themselves: these are the values roles resolve to. || 2 | Third-party brand marks | `packages/client/src/svgs/GoogleIcon.tsx`, `FacebookIcon.tsx`, `DiscordIcon.tsx`, `GeminiIcon.tsx`, `PaLMIcon.tsx`; `client/src/mobile.css` (`.azure-bg-color`); `client/src/components/Chat/Input/Files/SourceIcon.tsx` (the OpenAI chip) | Fixed by each company's brand guidelines: the Google, Facebook, Discord, Gemini and PaLM marks, the Azure file-source chip's blue gradient, and the OpenAI file-source chip (white/75, black/65 in dark) behind OpenAI's mark. || 3 | Provider brand colours | `packages/client/src/icons/provider/registry.ts`, `icons/provider/Avatar.tsx` | Each provider colour is already behind a `--provider-*` variable a deployment can override; the literal is only its fallback. || 4 | Opt-in decorative palettes | `packages/client/src/svgs/BirthdayIcon.tsx`, `packages/client/src/components/PixelCard.tsx`, `client/src/components/Lia/engine/*.ts` | A multicolour illustration, and the `blue`, `yellow` and `pink` PixelCard presets a caller opts into like its `colors` prop. The app renders only PixelCard's default, which reads theme roles. The Lia mascot's sprite palette is artwork, not UI chrome. |diff --git a/packages/client/src/theme/atoms/themeAtoms.ts b/packages/client/src/theme/atoms/themeAtoms.tsindex 5923b18183..12b6ca039d 100644--- a/packages/client/src/theme/atoms/themeAtoms.ts+++ b/packages/client/src/theme/atoms/themeAtoms.ts@@ -2,8 +2,8 @@// Theme state is now managed via React useState + localStorage in ThemeProvider.import { WritableAtom } from 'jotai';+import { IThemeRGB } from 'librechat-data-provider';import { atomWithStorage, RESET } from 'jotai/utils';-import { IThemeRGB } from '../types';/*** @deprecated Use ThemeContext instead. This atom is no longer used internally.diff --git a/packages/client/src/theme/context/ThemeProvider.spec.tsx b/packages/client/src/theme/context/ThemeProvider.spec.tsxindex 97106e3b82..01d4c74203 100644--- a/packages/client/src/theme/context/ThemeProvider.spec.tsx+++ b/packages/client/src/theme/context/ThemeProvider.spec.tsx@@ -1,6 +1,7 @@import '@testing-library/jest-dom';import { useLayoutEffect } from 'react';import { act, render, screen, waitFor } from '@testing-library/react';+import { darkTheme, highContrastDarkTheme, highContrastLightTheme } from 'librechat-data-provider';import {ThemeProvider,isDark,@@ -8,8 +9,6 @@ import {resolvesToHighContrast,useTheme,} from './ThemeProvider';-import { highContrastDarkTheme, highContrastLightTheme } from '../themes/highContrast';-import { darkTheme } from '../themes/dark';const matchMedia = (matches: boolean): MediaQueryList =>({diff --git a/packages/client/src/theme/context/ThemeProvider.tsx b/packages/client/src/theme/context/ThemeProvider.tsxindex 18ccef1c4f..a8726e8c94 100644--- a/packages/client/src/theme/context/ThemeProvider.tsx+++ b/packages/client/src/theme/context/ThemeProvider.tsx@@ -9,7 +9,16 @@ import React, {useState,} from 'react';import { JSX } from 'react/jsx-runtime';-import type { IThemeRGB, ThemeDefinition, ThemeMode } from '../types';+import {+ darkTheme,+ defaultTheme,+ fromLegacyTheme,+ highContrastTheme,+ collectThemeWarnings,+ resolveTheme,+ validateThemeDefinition,+} from 'librechat-data-provider';+import type { IThemeRGB, ThemeDefinition, ThemeMode } from 'librechat-data-provider';import applyTheme, {applyResolvedTheme,clearAppliedTheme,@@ -18,15 +27,6 @@ import applyTheme, {THEME_DISABLED_ATTRIBUTE,THEME_FIELD_FOCUS_ATTRIBUTE,} from '../utils/applyTheme';-import {- fromLegacyTheme,- highContrastTheme,- collectThemeWarnings,- resolveTheme,- validateThemeDefinition,-} from '../registry';-import { defaultTheme } from '../themes/default';-import { darkTheme } from '../themes/dark';import '../highContrast.css';import '../preflight.css';diff --git a/packages/client/src/theme/defaults.css b/packages/client/src/theme/defaults.cssindex 1d48c8e239..650da5355e 100644--- a/packages/client/src/theme/defaults.css+++ b/packages/client/src/theme/defaults.css@@ -8,8 +8,9 @@* here; these cover the page before and without a theme definition.** The roles are written against the primitive scales under `:root`, so a host that redefines a- * step after this import retints every role that reads it. `themes/default.ts`, `themes/dark.ts`- * and `registry.ts` carry the same values for the runtime, and `defaults.spec.ts` holds them equal.+ * step after this import retints every role that reads it. `default.ts`, `dark.ts` and+ * `registry.ts` under `packages/data-provider/src/themes` carry the same values for the runtime,+ * and `defaults.spec.ts` holds them equal.*/:root {--white: 255 255 255;diff --git a/packages/client/src/theme/defaults.spec.ts b/packages/client/src/theme/defaults.spec.tsindex 0c870365fb..16fdb996a2 100644--- a/packages/client/src/theme/defaults.spec.ts+++ b/packages/client/src/theme/defaults.spec.ts@@ -1,14 +1,14 @@import fs from 'fs';import path from 'path';-import type { IThemeRGB } from './types';import {+ darkTheme,+ defaultTheme,defaultBrands,defaultAppearance,darkAppearanceDefaults,themeAppearanceProperties,-} from './registry';-import { defaultTheme } from './themes/default';-import { darkTheme } from './themes/dark';+} from 'librechat-data-provider';+import type { IThemeRGB } from 'librechat-data-provider';const stylesheet = fs.readFileSync(path.resolve(__dirname, 'defaults.css'), 'utf8');diff --git a/packages/client/src/theme/highContrast.css b/packages/client/src/theme/highContrast.cssindex 2b4a49eb67..ed651bd61b 100644--- a/packages/client/src/theme/highContrast.css+++ b/packages/client/src/theme/highContrast.css@@ -4,7 +4,7 @@* palettes they complete.** `ThemeProvider` puts `high-contrast` on <html> and paints the palette as- * inline custom properties (see `themes/highContrast.ts`). Two of those tokens+ * inline custom properties (see `packages/data-provider/src/themes/highContrast.ts`). Two of those tokens* are not self-sufficient, and the rules below are what make them correct:* the selected fills are deliberately light so their label clears AAA, which* only works because selection is marked by a perimeter; and `::placeholder`@@ -22,7 +22,7 @@/*** Selection and navigation are conveyed by a fill alone almost everywhere, and* these palettes keep fills light on purpose so the label on them can clear AAA- * (see the `surface-active` note in `themes/highContrast.ts`). The cue is+ * (see the `surface-active` note in `packages/data-provider/src/themes/highContrast.ts`). The cue is* therefore a perimeter: `text-primary` is 21:1 against either canvas, and it* is what discharges WCAG 1.4.11 for the fill.*diff --git a/packages/client/src/theme/index.ts b/packages/client/src/theme/index.tsindex 67b58cf5bc..9f2779bd05 100644--- a/packages/client/src/theme/index.ts+++ b/packages/client/src/theme/index.ts@@ -1,5 +1,16 @@// Export types-export * from './types';+export type {+ Theme,+ IThemeRGB,+ ThemeMode,+ IThemeBrands,+ IThemeColors,+ IThemeVariables,+ ThemeDefinition,+ IThemeAppearance,+ ThemeModeDefinition,+ ResolvedThemeDefinition,+} from 'librechat-data-provider';// Export ThemeProvider, ThemeContext, useTheme hook, and the mode predicatesexport {@@ -39,7 +50,7 @@ export {themeColorTokens,renamedColorTokens,validateThemeDefinition,-} from './registry';+} from 'librechat-data-provider';// Export theme atoms for persistenceexport { themeModeAtom, themeColorsAtom, themeNameAtom } from './atoms/themeAtoms';diff --git a/packages/client/src/theme/registry.spec.ts b/packages/client/src/theme/registry.spec.tsindex f0dd6d11b7..cfc796fc73 100644--- a/packages/client/src/theme/registry.spec.ts+++ b/packages/client/src/theme/registry.spec.ts@@ -1,7 +1,8 @@import { join } from 'node:path';import { readFileSync } from 'node:fs';-import type { IThemeAppearance, IThemeRGB, ThemeDefinition } from './types';import {+ darkTheme,+ defaultTheme,collectThemeWarnings,darkAppearanceDefaults,defaultAppearanceFor,@@ -13,11 +14,10 @@ import {layerRoleSources,themeColorTokens,validateThemeDefinition,-} from './registry';+} from 'librechat-data-provider';+import type { IThemeAppearance, IThemeRGB, ThemeDefinition } from 'librechat-data-provider';import { describeResolvedTheme } from './utils/applyTheme';import { clickHouseTheme } from './themes/clickhouse';-import { defaultTheme } from './themes/default';-import { darkTheme } from './themes/dark';import * as themeEntry from './index';const compactTheme: ThemeDefinition = {diff --git a/packages/client/src/theme/semanticTokens.spec.ts b/packages/client/src/theme/semanticTokens.spec.tsindex ed2d07ffa5..e80a85e8c5 100644--- a/packages/client/src/theme/semanticTokens.spec.ts+++ b/packages/client/src/theme/semanticTokens.spec.ts@@ -1,12 +1,15 @@import { join } from 'node:path';import { readFileSync } from 'node:fs';-import type { IThemeAppearance, IThemeRGB } from './types';+import {+ darkTheme,+ defaultTheme,+ defaultAppearance,+ highContrastDarkTheme,+ highContrastLightTheme,+} from 'librechat-data-provider';+import type { IThemeAppearance, IThemeRGB } from 'librechat-data-provider';import { clickHouseDarkTheme, clickHouseLightTheme, clickHouseTheme } from './themes/clickhouse';-import { highContrastDarkTheme, highContrastLightTheme } from './themes/highContrast';import { fieldControl } from '../components/Field';-import { defaultTheme } from './themes/default';-import { defaultAppearance } from './registry';-import { darkTheme } from './themes/dark';const sharedComponents = ['AnimatedSearchInput.tsx',diff --git a/packages/client/src/theme/tailwind.spec.js b/packages/client/src/theme/tailwind.spec.jsindex 67cf362c90..b5bcc74d5a 100644--- a/packages/client/src/theme/tailwind.spec.js+++ b/packages/client/src/theme/tailwind.spec.js@@ -11,7 +11,7 @@ const { compile } = require('tailwindcss');const tailwindPreset = require('../../tailwind.preset.cjs');const packageConfig = require('../../tailwind.config.js');const packageJson = require('../../package.json');-const { defaultAppearance, themeAppearanceProperties } = require('./registry');+const { defaultAppearance, themeAppearanceProperties } = require('librechat-data-provider');const packageRoot = path.resolve(__dirname, '../..');diff --git a/packages/client/src/theme/themes/clickhouse.spec.tsx b/packages/client/src/theme/themes/clickhouse.spec.tsxindex dbd756835d..4dac789999 100644--- a/packages/client/src/theme/themes/clickhouse.spec.tsx+++ b/packages/client/src/theme/themes/clickhouse.spec.tsx@@ -2,14 +2,14 @@ import fs from 'fs';import path from 'path';import '@testing-library/jest-dom';import { render, waitFor } from '@testing-library/react';-import type { ThemeMode, IThemeRGB } from '../types';import {defaultAppearance,libreChatTheme,resolveTheme,themeColorTokens,validateThemeDefinition,-} from '../registry';+} from 'librechat-data-provider';+import type { ThemeMode, IThemeRGB } from 'librechat-data-provider';import { clickHouseDarkTheme, clickHouseLightTheme, clickHouseTheme } from './clickhouse';import { ThemeProvider } from '../context/ThemeProvider';diff --git a/packages/client/src/theme/themes/clickhouse.ts b/packages/client/src/theme/themes/clickhouse.tsindex 12ee105bdc..8f306f4402 100644--- a/packages/client/src/theme/themes/clickhouse.ts+++ b/packages/client/src/theme/themes/clickhouse.ts@@ -1,4 +1,4 @@-import type { IThemeAppearance, ThemeDefinition, IThemeRGB } from '../types';+import type { IThemeAppearance, ThemeDefinition, IThemeRGB } from 'librechat-data-provider';/*** ClickHouse reference theme, built from Click UI's design tokensdiff --git a/packages/client/src/theme/themes/clickui.spec.ts b/packages/client/src/theme/themes/clickui.spec.tsindex ed65179edf..d3e0bcb990 100644--- a/packages/client/src/theme/themes/clickui.spec.ts+++ b/packages/client/src/theme/themes/clickui.spec.ts@@ -2,8 +2,9 @@ import { createElement } from 'react';import { join } from 'path';import { readFileSync } from 'fs';import { cleanup, fireEvent, render } from '@testing-library/react';+import { resolveTheme, themeAppearanceProperties } from 'librechat-data-provider';+import type { IThemeAppearance, IThemeRGB, ThemeMode } from 'librechat-data-provider';import type { ReactElement } from 'react';-import type { IThemeAppearance, IThemeRGB, ThemeMode } from '../types';import {Table,TableBody,@@ -13,7 +14,6 @@ import {TableRow,} from '../../components/Table';import { OGDialog, OGDialogContent, OGDialogTitle } from '../../components/OriginalDialog';-import { resolveTheme, themeAppearanceProperties } from '../registry';import { Tabs, TabsList, TabsTrigger } from '../../components/Tabs';import { Checkbox } from '../../components/Checkbox';import { Button } from '../../components/Button';diff --git a/packages/client/src/theme/themes/highContrast.spec.ts b/packages/client/src/theme/themes/highContrast.spec.tsindex 031cab17aa..197d5020ce 100644--- a/packages/client/src/theme/themes/highContrast.spec.ts+++ b/packages/client/src/theme/themes/highContrast.spec.ts@@ -1,5 +1,6 @@-import type { IThemeRGB } from '../types';import {+ highContrastDarkTheme,+ highContrastLightTheme,HIGH_CONTRAST_THEME_NAME,defaultBrands,highContrastTheme,@@ -7,8 +8,8 @@ import {themeBrandTokens,themeColorTokens,validateThemeDefinition,-} from '../registry';-import { highContrastDarkTheme, highContrastLightTheme } from './highContrast';+} from 'librechat-data-provider';+import type { IThemeRGB } from 'librechat-data-provider';type Rgb = [number, number, number];diff --git a/packages/client/src/theme/themes/index.ts b/packages/client/src/theme/themes/index.tsindex 3b8c13fc21..9534ff96b8 100644--- a/packages/client/src/theme/themes/index.ts+++ b/packages/client/src/theme/themes/index.ts@@ -1,4 +1,7 @@-export { defaultTheme } from './default';-export { darkTheme } from './dark';-export { highContrastDarkTheme, highContrastLightTheme } from './highContrast';+export {+ darkTheme,+ defaultTheme,+ highContrastDarkTheme,+ highContrastLightTheme,+} from 'librechat-data-provider';export { clickHouseDarkTheme, clickHouseLightTheme, clickHouseTheme } from './clickhouse';diff --git a/packages/client/src/theme/tokens.spec.ts b/packages/client/src/theme/tokens.spec.tsindex fb296e0797..1d9639c10f 100644--- a/packages/client/src/theme/tokens.spec.ts+++ b/packages/client/src/theme/tokens.spec.ts@@ -3,8 +3,7 @@ import path from 'path';import fsp from 'fs/promises';import { compile } from 'tailwindcss';import { deserialize, serialize } from 'v8';-import { themeColorTokens, themeDerivedColorTokens } from 'librechat-data-provider';-import { defaultTheme } from './themes/default';+import { defaultTheme, themeColorTokens, themeDerivedColorTokens } from 'librechat-data-provider';/** Tailwind's compiler clones its theme with `structuredClone`, which jsdom does not provide.* V8 serialization is the same structured-clone algorithm Node's global uses. */diff --git a/packages/client/src/theme/utils/applyTheme.spec.ts b/packages/client/src/theme/utils/applyTheme.spec.tsindex dd8da12340..cba85e7917 100644--- a/packages/client/src/theme/utils/applyTheme.spec.ts+++ b/packages/client/src/theme/utils/applyTheme.spec.ts@@ -1,4 +1,10 @@-import type { IThemeRGB, ThemeDefinition } from '../types';+import {+ defaultTheme,+ defaultAppearance,+ highContrastTheme,+ resolveTheme,+} from 'librechat-data-provider';+import type { IThemeRGB, ThemeDefinition } from 'librechat-data-provider';import applyTheme, {applyResolvedTheme,clearAppliedTheme,@@ -7,8 +13,6 @@ import applyTheme, {THEME_SCOPE_ATTRIBUTE,THEME_FIELD_FOCUS_ATTRIBUTE,} from './applyTheme';-import { defaultAppearance, highContrastTheme, resolveTheme } from '../registry';-import { defaultTheme } from '../themes/default';const semanticProperties = ['--link',diff --git a/packages/client/src/theme/utils/applyTheme.ts b/packages/client/src/theme/utils/applyTheme.tsindex af66da33b0..0cf8118789 100644--- a/packages/client/src/theme/utils/applyTheme.ts+++ b/packages/client/src/theme/utils/applyTheme.ts@@ -1,29 +1,19 @@-import type { ThemeBootStyle } from 'librechat-data-provider';-import type { IThemeAppearance, IThemeBrands, IThemeRGB, ResolvedThemeDefinition } from '../types';-import type { RenamedThemeRGB } from '../registry';import {- controlBorderFallback,- focusFallbacks,- overlayFallbacks,- pressedFallbacks,- primaryButtonFallbacks,- primaryInkFallbacks,- primaryInkRoles,- MARK_NEIGHBOURHOOD,- themeAppearanceProperties,- themeBrandTokens,- themeColorTokens,- withRenamedColors,-} from '../registry';--const colorProperty = (token: keyof IThemeRGB): `--${string}` => `--${token.slice(4)}`;-const brandProperty = (token: keyof IThemeBrands): `--${string}` => `--${token}`;--export const themeOwnedProperties: readonly string[] = Object.freeze([- ...themeColorTokens.map(colorProperty),- ...Object.values(themeAppearanceProperties),- ...themeBrandTokens.map(brandProperty),-]);+ describeThemeColors,+ describeResolvedTheme,+ THEME_DISABLED_ATTRIBUTE,+ THEME_FIELD_FOCUS_ATTRIBUTE,+ themeOwnedProperties,+} from 'librechat-data-provider';+import type { IThemeRGB, ResolvedThemeDefinition } from 'librechat-data-provider';++export {+ describeResolvedTheme,+ themeOwnedProperties,+ THEME_DISABLED_ATTRIBUTE,+ THEME_FIELD_FOCUS_ATTRIBUTE,+} from 'librechat-data-provider';+export type { ResolvedThemeStyle } from 'librechat-data-provider';const rgbPattern = /^(\d{1,3})\s+(\d{1,3})\s+(\d{1,3})$/;@@ -32,187 +22,6 @@ function validateRGB(rgb: string): boolean {return match !== null && match.slice(1).every((channel) => Number(channel) <= 255);}-/** `base` is the bundled palette for the mode being applied. The adapter writes- * only the keys a theme names, so a derivation whose source the theme inherits- * rather than restates has nothing to read without it. */-function mapColors(input: RenamedThemeRGB, base?: IThemeRGB): Array<[string, string]> {- const colors = withRenamedColors(input);- const variables = themeColorTokens.reduce<Array<[string, string]>>((result, token) => {- const value = colors[token];- if (value !== undefined) {- result.push([colorProperty(token), value]);- }- return result;- }, []);-- if (- colors['rgb-surface-composer-hover'] === undefined &&- colors['rgb-surface-hover'] !== undefined- ) {- variables.push(['--surface-composer-hover', colors['rgb-surface-hover']]);- }-- /**- * Stored and environment themes predate the shimmer stops, and this adapter- * applies only the keys a theme names — so without this they would keep the- * stock sweep while every other color moved, and in dark mode the CSS cannot- * recover: `.dark` declares a base outright, so the `--text-primary` fallback- * never runs. The bright stop follows the theme's primary text color, which- * is what it already resolves to in light. The dip has no legacy counterpart- * and stays at its default: it is the faded half of the sweep, carried at low- * alpha, so it reads as dimmed against any base.- */- if (colors['rgb-shimmer-base'] === undefined && colors['rgb-text-primary'] !== undefined) {- variables.push(['--shimmer-base', colors['rgb-text-primary']]);- }-- /** The dark page was `surface-primary-alt` before it had a role, as in `resolveTheme`. */- if (colors['rgb-page-canvas'] === undefined && colors['rgb-surface-primary-alt'] !== undefined) {- variables.push(['--page-canvas', colors['rgb-surface-primary-alt']]);- }-- if (colors['rgb-text-muted'] === undefined && colors['rgb-text-tertiary'] !== undefined) {- variables.push(['--text-muted', colors['rgb-text-tertiary']]);- }-- if (- colors['rgb-chart-widget-surface'] === undefined &&- colors['rgb-surface-primary'] !== undefined- ) {- variables.push(['--chart-widget-surface', colors['rgb-surface-primary']]);- }-- /** The switch knob was painted `surface-primary` before it had a role, as in `resolveTheme`. */- if (colors['rgb-switch-thumb'] === undefined && colors['rgb-surface-primary'] !== undefined) {- variables.push(['--switch-thumb', colors['rgb-surface-primary']]);- }-- /** The field fill follows the canvas, as in `resolveTheme`. */- if (colors['rgb-field-fill'] === undefined && colors['rgb-surface-primary'] !== undefined) {- variables.push(['--field-fill', colors['rgb-surface-primary']]);- }-- /** The checkbox fill follows the canvas, as in `resolveTheme`. */- if (colors['rgb-checkbox-fill'] === undefined && colors['rgb-surface-primary'] !== undefined) {- variables.push(['--checkbox-fill', colors['rgb-surface-primary']]);- }-- Object.entries(overlayFallbacks(colors)).forEach(([role, value]) => {- variables.push([colorProperty(role as keyof IThemeRGB), value]);- });-- if (colors['rgb-table-header-text'] === undefined && colors['rgb-text-secondary'] !== undefined) {- variables.push(['--table-header-text', colors['rgb-text-secondary']]);- }-- if (colors['rgb-table-header-fill'] === undefined && colors['rgb-surface-dialog'] !== undefined) {- variables.push(['--table-header-fill', colors['rgb-surface-dialog']]);- }-- if (colors['rgb-chart-widget-stroke'] === undefined && colors['rgb-border-light'] !== undefined) {- variables.push(['--chart-widget-stroke', colors['rgb-border-light']]);- }-- if (colors['rgb-focus-subtle'] === undefined && colors['rgb-border-heavy'] !== undefined) {- variables.push(['--focus-subtle', colors['rgb-border-heavy']]);- }-- const legacyControlBorder = controlBorderFallback(colors);- if (legacyControlBorder !== undefined) {- variables.push(['--border-control', legacyControlBorder]);- }-- const focus = focusFallbacks(colors);- if (colors['rgb-focus-outline'] === undefined && focus['rgb-focus-outline'] !== undefined) {- variables.push(['--focus-outline', focus['rgb-focus-outline']]);- }- if (colors['rgb-focus-control'] === undefined && focus['rgb-focus-control'] !== undefined) {- variables.push(['--focus-control', focus['rgb-focus-control']]);- }- if (- colors['rgb-border-field-focus'] === undefined &&- focus['rgb-border-field-focus'] !== undefined- ) {- variables.push(['--border-field-focus', focus['rgb-border-field-focus']]);- }-- const pressed = pressedFallbacks(colors);- if (colors['rgb-surface-pressed'] === undefined && pressed['rgb-surface-pressed'] !== undefined) {- variables.push(['--surface-pressed', pressed['rgb-surface-pressed']]);- }- if (- colors['rgb-surface-inverted-pressed'] === undefined &&- pressed['rgb-surface-inverted-pressed'] !== undefined- ) {- variables.push(['--surface-inverted-pressed', pressed['rgb-surface-inverted-pressed']]);- }-- const primary = primaryButtonFallbacks(colors);- if (colors['rgb-button-primary'] === undefined && primary['rgb-button-primary'] !== undefined) {- variables.push(['--button-primary', primary['rgb-button-primary']]);- }- if (- colors['rgb-button-primary-hover'] === undefined &&- primary['rgb-button-primary-hover'] !== undefined- ) {- variables.push(['--button-primary-hover', primary['rgb-button-primary-hover']]);- }-- const inks = primaryInkFallbacks(colors);- primaryInkRoles.forEach((role) => {- const ink = inks[role];- if (colors[role] === undefined && ink !== undefined) {- variables.push([`--${role.slice(4)}`, ink]);- }- });-- /**- * Same rule as `resolveTheme`: a theme that paints what the mark is measured- * against coordinated the `status-success-strong` the mark wore before it had- * a token, so it keeps that fill rather than taking LibreChat's stock blue.- * This adapter writes only the keys a theme names, so the inherited value- * arrives through `base`, the bundled palette for the mode being applied.- */- const ownsMarkSurroundings = MARK_NEIGHBOURHOOD.some((token) => colors[token] !== undefined);- const inheritedSuccess =- colors['rgb-status-success-strong'] ?? base?.['rgb-status-success-strong'];- if (- ownsMarkSurroundings &&- colors['rgb-status-verified'] === undefined &&- inheritedSuccess !== undefined- ) {- variables.push(['--status-verified', inheritedSuccess]);- }-- return variables;-}--/**- * The `theme-chrome-quiet:` variant matches the literal `0`, so every spelling of zero is written as- * it. A `none` list height is written as the viewport's, which the list's available-height cap- * always undercuts; `none` itself would void the `min()` that applies that cap.- */-function canonicalAppearance(key: keyof IThemeAppearance, value: string): string {- if (key === 'listMaxHeight' && value === 'none') {- return '100dvh';- }- return key === 'chromeBorderAlpha' && Number(value) === 0 ? '0' : value;-}--function mapAppearance(appearance: IThemeAppearance): Array<[string, string]> {- return Object.entries(themeAppearanceProperties).map(([key, property]) => [- property,- canonicalAppearance(key as keyof IThemeAppearance, appearance[key as keyof IThemeAppearance]),- ]);-}--/**- * Mirrors the applied theme's `disabledStyle` on the root for host stylesheets and tests. Absent- * means the default `dim` style. The `theme-disabled:` variants read the inherited- * `--theme-disabled-style` property instead, so the nearest themed root decides.- */-export const THEME_DISABLED_ATTRIBUTE = 'data-theme-disabled';-/*** Marks a root other than the document one that a legacy palette themes. The stylesheet points* the avatar backdrop at that root's own secondary surface, or its tertiary one under a `.dark`@@ -220,13 +29,6 @@ export const THEME_DISABLED_ATTRIBUTE = 'data-theme-disabled';*/export const THEME_SCOPE_ATTRIBUTE = 'data-theme-scope';-/**- * Mirrors the applied theme's `fieldFocusStyle` on the root, like `THEME_DISABLED_ATTRIBUTE`.- * The `theme-field-border:` variant and `Field.css` read the inherited- * `--theme-field-focus-style` property instead, so the nearest themed root decides.- */-export const THEME_FIELD_FOCUS_ATTRIBUTE = 'data-theme-field-focus';-/*** Marks a root that `client/index.html` painted from the cached deployment theme before the* bundle ran. The provider drops that copy before it snapshots the root, so a later restore@@ -243,28 +45,6 @@ export function clearAppliedTheme(root: HTMLElement = document.documentElement):root.removeAttribute(THEME_BOOT_ATTRIBUTE);}-/** What `applyResolvedTheme` writes on the root, as plain data a boot script can replay. */-export type ResolvedThemeStyle = ThemeBootStyle;--export function describeResolvedTheme(theme: ResolvedThemeDefinition): ResolvedThemeStyle {- return {- properties: [- ...mapColors(theme.colors),- ...mapAppearance(theme.appearance),- ...themeBrandTokens.map(- (token) => [brandProperty(token), theme.brands[token]] as [string, string],- ),- ],- attributes: {- 'data-theme': theme.name,- ...(theme.appearance.disabledStyle === 'fill' && { [THEME_DISABLED_ATTRIBUTE]: 'fill' }),- ...(theme.appearance.fieldFocusStyle === 'border' && {- [THEME_FIELD_FOCUS_ATTRIBUTE]: 'border',- }),- },- };-}-export function applyResolvedTheme(theme: ResolvedThemeDefinition,root: HTMLElement = document.documentElement,@@ -292,7 +72,7 @@ export default function applyTheme(if (root !== root.ownerDocument.documentElement) {root.setAttribute(THEME_SCOPE_ATTRIBUTE, '');}- mapColors(themeRGB, base).forEach(([property, value]) => {+ describeThemeColors(themeRGB, base).forEach(([property, value]) => {if (!validateRGB(value)) {console.error(`Invalid RGB value for ${property}: ${value}`);return;diff --git a/packages/data-provider/src/index.ts b/packages/data-provider/src/index.tsindex 1c9dc09f08..77679cbb2c 100644--- a/packages/data-provider/src/index.ts+++ b/packages/data-provider/src/index.ts@@ -5,6 +5,7 @@ export * from './balance';export * from './config';export * from './footer';export * from './theme';+export * from './themes';export * from './langchain';export * from './filters';export * from './file-config';diff --git a/packages/client/src/theme/themes/dark.ts b/packages/data-provider/src/themes/dark.tssimilarity index 99%rename from packages/client/src/theme/themes/dark.tsrename to packages/data-provider/src/themes/dark.tsindex 5ffda1b4c7..16b45e3d9b 100644--- a/packages/client/src/theme/themes/dark.ts+++ b/packages/data-provider/src/themes/dark.ts@@ -1,4 +1,4 @@-import { IThemeRGB } from '../types';+import type { IThemeRGB } from './types';/*** Dark themediff --git a/packages/client/src/theme/themes/default.ts b/packages/data-provider/src/themes/default.tssimilarity index 99%rename from packages/client/src/theme/themes/default.tsrename to packages/data-provider/src/themes/default.tsindex d7a13b9272..54ca246c3c 100644--- a/packages/client/src/theme/themes/default.ts+++ b/packages/data-provider/src/themes/default.ts@@ -1,4 +1,4 @@-import { IThemeRGB } from '../types';+import type { IThemeRGB } from './types';/*** Default light themediff --git a/packages/data-provider/src/themes/describe.ts b/packages/data-provider/src/themes/describe.tsnew file mode 100644index 0000000000..2e3297b3e3--- /dev/null+++ b/packages/data-provider/src/themes/describe.ts@@ -0,0 +1,253 @@+import type {+ IThemeAppearance,+ IThemeBrands,+ IThemeRGB,+ ResolvedThemeDefinition,+ ThemeDefinition,+} from './types';+import type { ThemeBootModes, ThemeBootStyle } from '../config';+import type { RenamedThemeRGB } from './registry';+import {+ focusFallbacks,+ resolveTheme,+ overlayFallbacks,+ pressedFallbacks,+ primaryInkRoles,+ withRenamedColors,+ MARK_NEIGHBOURHOOD,+ primaryInkFallbacks,+ controlBorderFallback,+ primaryButtonFallbacks,+ themeAppearanceProperties,+} from './registry';+import { themeBrandTokens, themeColorTokens } from '../theme';++const colorProperty = (token: keyof IThemeRGB): `--${string}` => `--${token.slice(4)}`;+const brandProperty = (token: keyof IThemeBrands): `--${string}` => `--${token}`;++export const themeOwnedProperties: readonly string[] = Object.freeze([+ ...themeColorTokens.map(colorProperty),+ ...Object.values(themeAppearanceProperties),+ ...themeBrandTokens.map(brandProperty),+]);++/** `base` is the bundled palette for the mode being applied. The adapter writes+ * only the keys a theme names, so a derivation whose source the theme inherits+ * rather than restates has nothing to read without it. */+export function describeThemeColors(+ input: RenamedThemeRGB,+ base?: IThemeRGB,+): Array<[string, string]> {+ const colors = withRenamedColors(input);+ const variables = themeColorTokens.reduce<Array<[string, string]>>((result, token) => {+ const value = colors[token];+ if (value !== undefined) {+ result.push([colorProperty(token), value]);+ }+ return result;+ }, []);++ if (+ colors['rgb-surface-composer-hover'] === undefined &&+ colors['rgb-surface-hover'] !== undefined+ ) {+ variables.push(['--surface-composer-hover', colors['rgb-surface-hover']]);+ }++ /**+ * Stored and environment themes predate the shimmer stops, and this adapter+ * applies only the keys a theme names, so without this they would keep the+ * stock sweep while every other color moved, and in dark mode the CSS cannot+ * recover: `.dark` declares a base outright, so the `--text-primary` fallback+ * never runs. The bright stop follows the theme's primary text color, which+ * is what it already resolves to in light. The dip has no legacy counterpart+ * and stays at its default: it is the faded half of the sweep, carried at low+ * alpha, so it reads as dimmed against any base.+ */+ if (colors['rgb-shimmer-base'] === undefined && colors['rgb-text-primary'] !== undefined) {+ variables.push(['--shimmer-base', colors['rgb-text-primary']]);+ }++ /** The dark page was `surface-primary-alt` before it had a role, as in `resolveTheme`. */+ if (colors['rgb-page-canvas'] === undefined && colors['rgb-surface-primary-alt'] !== undefined) {+ variables.push(['--page-canvas', colors['rgb-surface-primary-alt']]);+ }++ if (colors['rgb-text-muted'] === undefined && colors['rgb-text-tertiary'] !== undefined) {+ variables.push(['--text-muted', colors['rgb-text-tertiary']]);+ }++ if (+ colors['rgb-chart-widget-surface'] === undefined &&+ colors['rgb-surface-primary'] !== undefined+ ) {+ variables.push(['--chart-widget-surface', colors['rgb-surface-primary']]);+ }++ /** The switch knob was painted `surface-primary` before it had a role, as in `resolveTheme`. */+ if (colors['rgb-switch-thumb'] === undefined && colors['rgb-surface-primary'] !== undefined) {+ variables.push(['--switch-thumb', colors['rgb-surface-primary']]);+ }++ /** The field fill follows the canvas, as in `resolveTheme`. */+ if (colors['rgb-field-fill'] === undefined && colors['rgb-surface-primary'] !== undefined) {+ variables.push(['--field-fill', colors['rgb-surface-primary']]);+ }++ /** The checkbox fill follows the canvas, as in `resolveTheme`. */+ if (colors['rgb-checkbox-fill'] === undefined && colors['rgb-surface-primary'] !== undefined) {+ variables.push(['--checkbox-fill', colors['rgb-surface-primary']]);+ }++ Object.entries(overlayFallbacks(colors)).forEach(([role, value]) => {+ variables.push([colorProperty(role as keyof IThemeRGB), value]);+ });++ if (colors['rgb-table-header-text'] === undefined && colors['rgb-text-secondary'] !== undefined) {+ variables.push(['--table-header-text', colors['rgb-text-secondary']]);+ }++ if (colors['rgb-table-header-fill'] === undefined && colors['rgb-surface-dialog'] !== undefined) {+ variables.push(['--table-header-fill', colors['rgb-surface-dialog']]);+ }++ if (colors['rgb-chart-widget-stroke'] === undefined && colors['rgb-border-light'] !== undefined) {+ variables.push(['--chart-widget-stroke', colors['rgb-border-light']]);+ }++ if (colors['rgb-focus-subtle'] === undefined && colors['rgb-border-heavy'] !== undefined) {+ variables.push(['--focus-subtle', colors['rgb-border-heavy']]);+ }++ const legacyControlBorder = controlBorderFallback(colors);+ if (legacyControlBorder !== undefined) {+ variables.push(['--border-control', legacyControlBorder]);+ }++ const focus = focusFallbacks(colors);+ if (colors['rgb-focus-outline'] === undefined && focus['rgb-focus-outline'] !== undefined) {+ variables.push(['--focus-outline', focus['rgb-focus-outline']]);+ }+ if (colors['rgb-focus-control'] === undefined && focus['rgb-focus-control'] !== undefined) {+ variables.push(['--focus-control', focus['rgb-focus-control']]);+ }+ if (+ colors['rgb-border-field-focus'] === undefined &&+ focus['rgb-border-field-focus'] !== undefined+ ) {+ variables.push(['--border-field-focus', focus['rgb-border-field-focus']]);+ }++ const pressed = pressedFallbacks(colors);+ if (colors['rgb-surface-pressed'] === undefined && pressed['rgb-surface-pressed'] !== undefined) {+ variables.push(['--surface-pressed', pressed['rgb-surface-pressed']]);+ }+ if (+ colors['rgb-surface-inverted-pressed'] === undefined &&+ pressed['rgb-surface-inverted-pressed'] !== undefined+ ) {+ variables.push(['--surface-inverted-pressed', pressed['rgb-surface-inverted-pressed']]);+ }++ const primary = primaryButtonFallbacks(colors);+ if (colors['rgb-button-primary'] === undefined && primary['rgb-button-primary'] !== undefined) {+ variables.push(['--button-primary', primary['rgb-button-primary']]);+ }+ if (+ colors['rgb-button-primary-hover'] === undefined &&+ primary['rgb-button-primary-hover'] !== undefined+ ) {+ variables.push(['--button-primary-hover', primary['rgb-button-primary-hover']]);+ }++ const inks = primaryInkFallbacks(colors);+ primaryInkRoles.forEach((role) => {+ const ink = inks[role];+ if (colors[role] === undefined && ink !== undefined) {+ variables.push([`--${role.slice(4)}`, ink]);+ }+ });++ /**+ * Same rule as `resolveTheme`: a theme that paints what the mark is measured+ * against coordinated the `status-success-strong` the mark wore before it had+ * a token, so it keeps that fill rather than taking LibreChat's stock blue.+ * This adapter writes only the keys a theme names, so the inherited value+ * arrives through `base`, the bundled palette for the mode being applied.+ */+ const ownsMarkSurroundings = MARK_NEIGHBOURHOOD.some((token) => colors[token] !== undefined);+ const inheritedSuccess =+ colors['rgb-status-success-strong'] ?? base?.['rgb-status-success-strong'];+ if (+ ownsMarkSurroundings &&+ colors['rgb-status-verified'] === undefined &&+ inheritedSuccess !== undefined+ ) {+ variables.push(['--status-verified', inheritedSuccess]);+ }++ return variables;+}++/**+ * The `theme-chrome-quiet:` variant matches the literal `0`, so every spelling of zero is written as+ * it. A `none` list height is written as the viewport's, which the list's available-height cap+ * always undercuts; `none` itself would void the `min()` that applies that cap.+ */+function canonicalAppearance(key: keyof IThemeAppearance, value: string): string {+ if (key === 'listMaxHeight' && value === 'none') {+ return '100dvh';+ }+ return key === 'chromeBorderAlpha' && Number(value) === 0 ? '0' : value;+}++function mapAppearance(appearance: IThemeAppearance): Array<[string, string]> {+ return Object.entries(themeAppearanceProperties).map(([key, property]) => [+ property,+ canonicalAppearance(key as keyof IThemeAppearance, appearance[key as keyof IThemeAppearance]),+ ]);+}++/**+ * Mirrors the applied theme's `disabledStyle` on the root for host stylesheets and tests. Absent+ * means the default `dim` style. The `theme-disabled:` variants read the inherited+ * `--theme-disabled-style` property instead, so the nearest themed root decides.+ */+export const THEME_DISABLED_ATTRIBUTE = 'data-theme-disabled';++/**+ * Mirrors the applied theme's `fieldFocusStyle` on the root, like `THEME_DISABLED_ATTRIBUTE`.+ * The `theme-field-border:` variant and `Field.css` read the inherited+ * `--theme-field-focus-style` property instead, so the nearest themed root decides.+ */+export const THEME_FIELD_FOCUS_ATTRIBUTE = 'data-theme-field-focus';++/** What `applyResolvedTheme` writes on the root, as plain data a boot script can replay. */+export type ResolvedThemeStyle = ThemeBootStyle;++export function describeResolvedTheme(theme: ResolvedThemeDefinition): ResolvedThemeStyle {+ return {+ properties: [+ ...describeThemeColors(theme.colors),+ ...mapAppearance(theme.appearance),+ ...themeBrandTokens.map(+ (token) => [brandProperty(token), theme.brands[token]] as [string, string],+ ),+ ],+ attributes: {+ 'data-theme': theme.name,+ ...(theme.appearance.disabledStyle === 'fill' && { [THEME_DISABLED_ATTRIBUTE]: 'fill' }),+ ...(theme.appearance.fieldFocusStyle === 'border' && {+ [THEME_FIELD_FOCUS_ATTRIBUTE]: 'border',+ }),+ },+ };+}++/** Both modes of a definition as the shell's boot script replays them. */+export function describeThemeModes(theme: ThemeDefinition): ThemeBootModes {+ return {+ light: describeResolvedTheme(resolveTheme(theme, 'light')),+ dark: describeResolvedTheme(resolveTheme(theme, 'dark')),+ };+}diff --git a/packages/client/src/theme/themes/highContrast.ts b/packages/data-provider/src/themes/highContrast.tssimilarity index 99%rename from packages/client/src/theme/themes/highContrast.tsrename to packages/data-provider/src/themes/highContrast.tsindex 50dbb2eeb8..918728e09d 100644--- a/packages/client/src/theme/themes/highContrast.ts+++ b/packages/data-provider/src/themes/highContrast.ts@@ -1,4 +1,4 @@-import { IThemeRGB } from '../types';+import type { IThemeRGB } from './types';/*** High contrast accessibility themes.diff --git a/packages/data-provider/src/themes/index.ts b/packages/data-provider/src/themes/index.tsnew file mode 100644index 0000000000..ac8f219f43--- /dev/null+++ b/packages/data-provider/src/themes/index.ts@@ -0,0 +1,6 @@+export * from './types';+export * from './registry';+export * from './describe';+export { defaultTheme } from './default';+export { darkTheme } from './dark';+export { highContrastDarkTheme, highContrastLightTheme } from './highContrast';diff --git a/packages/client/src/theme/registry.ts b/packages/data-provider/src/themes/registry.tssimilarity index 98%rename from packages/client/src/theme/registry.tsrename to packages/data-provider/src/themes/registry.tsindex e2cc68e9c4..3d263221d6 100644--- a/packages/client/src/theme/registry.ts+++ b/packages/data-provider/src/themes/registry.ts@@ -1,20 +1,3 @@-import {- THEME_VERSION,- isThemeRGB,- collectThemeIssues,- isThemeAppearanceToken,- collectThemeWarningIssues,- defaultSwitchSize,- themeColorTokens as sharedColorTokens,- renamedThemeColorTokens,- themeBrandTokens as sharedBrandTokens,-} from 'librechat-data-provider';-import type {- ThemeColorToken,- ThemeBrandToken,- ThemeAppearanceToken,- RenamedThemeColorToken,-} from 'librechat-data-provider';import type {IThemeAppearance,IThemeBrands,@@ -25,11 +8,25 @@ import type {ThemeDefinition,ThemeMode,} from './types';-import { highContrastDarkTheme, highContrastLightTheme } from './themes/highContrast';-import { defaultTheme } from './themes/default';-import { darkTheme } from './themes/dark';--export { THEME_VERSION };+import type {+ ThemeColorToken,+ ThemeBrandToken,+ ThemeAppearanceToken,+ RenamedThemeColorToken,+} from '../theme';+import {+ THEME_VERSION,+ isThemeRGB,+ collectThemeIssues,+ isThemeAppearanceToken,+ collectThemeWarningIssues,+ defaultSwitchSize,+ themeColorTokens as sharedColorTokens,+ renamedThemeColorTokens,+} from '../theme';+import { highContrastDarkTheme, highContrastLightTheme } from './highContrast';+import { defaultTheme } from './default';+import { darkTheme } from './dark';/*** Compile-time guard: the categorical series scale is declared across three@@ -60,7 +57,7 @@ export type SharedTokensMatchTypes = [Assert<SameKeys<ThemeBrandToken, keyof IThemeBrands>>,];-export const themeColorTokens: readonly (keyof IThemeRGB)[] = sharedColorTokens;+const themeColorTokens: readonly (keyof IThemeRGB)[] = sharedColorTokens;const colorTokenSet: ReadonlySet<string> = new Set<string>(themeColorTokens);@@ -462,8 +459,6 @@ export function defaultAppearanceFor(mode: ThemeMode): IThemeAppearance {return mode === 'dark' ? { ...defaultAppearance, ...darkAppearanceDefaults } : defaultAppearance;}-export const themeBrandTokens: readonly (keyof IThemeBrands)[] = sharedBrandTokens;-export const defaultBrands: IThemeBrands = Object.freeze({'provider-openai': '#19C37D','provider-openai-gpt4': '#AB68FF',@@ -545,7 +540,7 @@ export function validateThemeDefinition(theme: ThemeDefinition): string[] {* A partial theme promises that an omitted value falls back, and `Partial<T>` lets a key be* present with `undefined`. Spreading that would overwrite the inherited value with nothing:* every brand and appearance token is written to the DOM unconditionally, so an avatar would- * lose its fill and a shadow or radius step its value, unlike colors, which `mapColors` skips.+ * lose its fill and a shadow or radius step its value, unlike colors, which `describeThemeColors` skips.*/function definedEntries<T extends object>(values?: Partial<T>): Partial<T> {if (!values) {diff --git a/packages/client/src/theme/types/index.ts b/packages/data-provider/src/themes/types.tssimilarity index 100%rename from packages/client/src/theme/types/index.tsrename to packages/data-provider/src/themes/types.ts