@clidey/dory 1.0.8 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -1
- package/bin/chat-server.ts +270 -0
- package/bin/dist/analytics-server.d.ts +11 -0
- package/bin/dist/analytics-server.d.ts.map +1 -0
- package/bin/dist/analytics-server.js +121 -0
- package/bin/dist/analytics-server.js.map +1 -0
- package/bin/dist/automation.d.ts +35 -0
- package/bin/dist/automation.d.ts.map +1 -0
- package/bin/dist/automation.js +259 -0
- package/bin/dist/automation.js.map +1 -0
- package/bin/dist/chat-server.d.ts +8 -0
- package/bin/dist/chat-server.d.ts.map +1 -0
- package/bin/dist/chat-server.js +322 -0
- package/bin/dist/chat-server.js.map +1 -0
- package/bin/dist/check.d.ts +16 -0
- package/bin/dist/check.d.ts.map +1 -0
- package/bin/dist/check.js +247 -0
- package/bin/dist/check.js.map +1 -0
- package/bin/dist/dory.js +252 -402
- package/bin/dist/dory.js.map +1 -1
- package/bin/dist/i18n-init.d.ts +6 -0
- package/bin/dist/i18n-init.d.ts.map +1 -0
- package/bin/dist/i18n-init.js +56 -0
- package/bin/dist/i18n-init.js.map +1 -0
- package/bin/dist/mcp-http.d.ts +8 -0
- package/bin/dist/mcp-http.d.ts.map +1 -0
- package/bin/dist/mcp-http.js +72 -0
- package/bin/dist/mcp-http.js.map +1 -0
- package/bin/dist/mcp.d.ts +2 -0
- package/bin/dist/mcp.d.ts.map +1 -0
- package/bin/dist/mcp.js +81 -0
- package/bin/dist/mcp.js.map +1 -0
- package/bin/dist/preview-entry.d.ts +2 -0
- package/bin/dist/preview-entry.d.ts.map +1 -0
- package/bin/dist/preview-entry.js +6 -0
- package/bin/dist/preview-entry.js.map +1 -0
- package/bin/dist/preview-server.d.ts +5 -0
- package/bin/dist/preview-server.d.ts.map +1 -0
- package/bin/dist/preview-server.js +159 -0
- package/bin/dist/preview-server.js.map +1 -0
- package/bin/dist/project-config.d.ts +22 -0
- package/bin/dist/project-config.d.ts.map +1 -0
- package/bin/dist/project-config.js +44 -0
- package/bin/dist/project-config.js.map +1 -0
- package/dist/index.html +57 -0
- package/dist/runtime/dory-runtime.css +2 -0
- package/dist/runtime/dory-runtime.html +14 -0
- package/dist/runtime/dory-runtime.js +5490 -0
- package/docs/api-playground-demo.mdx +119 -0
- package/docs/api-reference/asyncapi.json +324 -0
- package/docs/api-reference/openapi.json +366 -0
- package/docs/api-reference/operations/create.mdx +5 -0
- package/docs/api-reference/operations/delete.mdx +5 -0
- package/docs/api-reference/operations/get.mdx +5 -0
- package/docs/api-reference/operations/update.mdx +5 -0
- package/docs/api-reference/websocket-operations/receive-chat-message.mdx +5 -0
- package/docs/api-reference/websocket-operations/receive-notifications.mdx +5 -0
- package/docs/api-reference/websocket-operations/receive-presence-update.mdx +5 -0
- package/docs/api-reference/websocket-operations/send-chat-message.mdx +5 -0
- package/docs/api-reference/websocket-operations/send-presence-update.mdx +5 -0
- package/docs/assets/dory.jpeg +0 -0
- package/docs/components/accordion.mdx +145 -0
- package/docs/components/callouts.mdx +134 -0
- package/docs/components/cards.mdx +153 -0
- package/docs/components/code-blocks.mdx +281 -0
- package/docs/components/expandable.mdx +189 -0
- package/docs/components/icons.mdx +71 -0
- package/docs/components/images.mdx +82 -0
- package/docs/components/latex.mdx +148 -0
- package/docs/components/layout.mdx +175 -0
- package/docs/components/lists.mdx +134 -0
- package/docs/components/mermaid.mdx +149 -0
- package/docs/components/overview.mdx +81 -0
- package/docs/components/source.mdx +130 -0
- package/docs/components/steps.mdx +122 -0
- package/docs/components/tables.mdx +114 -0
- package/docs/components/tags.mdx +179 -0
- package/docs/components/typography.mdx +185 -0
- package/docs/configuration/analytics.mdx +45 -0
- package/docs/configuration/chat.mdx +59 -0
- package/docs/configuration/dory-json.mdx +278 -0
- package/docs/configuration/embed.mdx +73 -0
- package/docs/configuration/fonts.mdx +86 -0
- package/docs/configuration/internationalization.mdx +61 -0
- package/docs/configuration/navigation.mdx +217 -0
- package/docs/configuration/theming.mdx +166 -0
- package/docs/dory.json +129 -0
- package/docs/embed-example.html +176 -0
- package/docs/favicon.svg +18 -0
- package/docs/features.mdx +440 -0
- package/docs/getting-started/automation.mdx +76 -0
- package/docs/getting-started/configuration.mdx +95 -0
- package/docs/getting-started/installation.mdx +88 -0
- package/docs/getting-started/quick-start.mdx +53 -0
- package/docs/getting-started/whodb-ee-apps.mdx +122 -0
- package/docs/introduction.mdx +50 -0
- package/docs/logo/logo.svg +18 -0
- package/docs/playgrounds/api-playground.mdx +122 -0
- package/docs/playgrounds/websocket-playground.mdx +98 -0
- package/docs/social-card.png +0 -0
- package/docs/social-card.svg +17 -0
- package/docs/websocket-playground-demo.mdx +135 -0
- package/package.json +23 -17
- package/scripts/verify-runtime-parity.mjs +146 -0
- package/src/app.css +19 -1
- package/src/assets/fonts/HankenGrotesk.ttf +0 -0
- package/src/assets/fonts/OFL.txt +94 -0
- package/src/components/chat-assistant.tsx +229 -0
- package/src/components/dropdown.tsx +3 -3
- package/src/components/error-boundary.tsx +2 -2
- package/src/components/hooks.tsx +20 -1
- package/src/components/navigation.tsx +82 -51
- package/src/components/notification.tsx +2 -3
- package/src/components/routes.tsx +17 -19
- package/src/components/search-index.test.ts +15 -0
- package/src/components/search-index.ts +49 -48
- package/src/components/search.tsx +208 -104
- package/src/components/store.ts +27 -9
- package/src/config/mdx-common.ts +11 -0
- package/src/config/mdx.ts +10 -11
- package/src/embed/loader.ts +0 -3
- package/src/embed/types.ts +0 -2
- package/src/embed/widget-iframe.ts +19 -21
- package/src/embedded-runtime/config.ts +138 -0
- package/src/embedded-runtime/index.tsx +680 -0
- package/src/embedded-runtime/runtime.html +14 -0
- package/src/entry-server.tsx +46 -124
- package/src/main.tsx +16 -4
- package/src/mdx/accordion.tsx +3 -3
- package/src/mdx/api-playground.tsx +18 -16
- package/src/mdx/async-api.tsx +2 -2
- package/src/mdx/card.tsx +3 -2
- package/src/mdx/code.tsx +11 -9
- package/src/mdx/fence.tsx +6 -5
- package/src/mdx/icon-grid.tsx +4 -1
- package/src/mdx/icon-names.test.ts +15 -0
- package/src/mdx/icon-names.ts +60 -0
- package/src/mdx/icon-source-variants.ts +102 -0
- package/src/mdx/icon.tsx +12 -73
- package/src/mdx/latex.tsx +3 -2
- package/src/mdx/mdx.tsx +1 -1
- package/src/mdx/mermaid.tsx +12 -6
- package/src/mdx/open-api.tsx +130 -74
- package/src/mdx/preprocess.test.ts +16 -0
- package/src/mdx/preprocess.ts +61 -0
- package/src/mdx/processor.ts +4 -96
- package/src/mdx/source.tsx +5 -4
- package/src/mdx/specimen.tsx +38 -6
- package/src/mdx/tabs.tsx +29 -21
- package/src/mdx/text.tsx +9 -9
- package/src/mdx/try-it-panel.tsx +284 -0
- package/src/mdx/type-scale.tsx +4 -4
- package/src/mdx/websocket-playground.tsx +21 -14
- package/src/plugins/analytics-injector.ts +8 -0
- package/src/plugins/chat-dev-server.ts +32 -0
- package/src/plugins/docs-assets.test.ts +25 -0
- package/src/plugins/docs-assets.ts +6 -2
- package/src/plugins/frontmatter-dev-server.ts +2 -2
- package/src/plugins/frontmatter-generator.ts +1 -1
- package/src/plugins/html-files-middleware.test.ts +21 -1
- package/src/plugins/html-files-middleware.ts +26 -6
- package/src/plugins/html-metadata-injector.ts +24 -4
- package/src/plugins/llm-txt-dev-server.ts +2 -2
- package/src/plugins/llm-txt-generator.ts +21 -4
- package/src/plugins/prerender.ts +47 -20
- package/src/plugins/robots-generator.ts +1 -1
- package/src/plugins/sanitize.ts +1 -1
- package/src/plugins/shared.ts +6 -18
- package/src/plugins/sitemap-generator.ts +1 -1
- package/src/plugins/social-preview.test.ts +71 -0
- package/src/plugins/social-preview.ts +87 -0
- package/src/plugins/unified-mdx-plugin.ts +1 -1
- package/src/theme.scss +630 -207
- package/src/types/config.ts +53 -1
- package/src/ui/breadcrumb.tsx +17 -0
- package/src/ui/docs-header-view.tsx +32 -0
- package/src/ui/docs-navigation-view.tsx +69 -0
- package/src/ui/docs-page-frame.tsx +50 -0
- package/src/ui/dory-mark.tsx +9 -0
- package/src/ui/header.tsx +33 -90
- package/src/ui/layout.tsx +99 -153
- package/src/ui/mobile-navigation.tsx +10 -8
- package/src/ui/page-actions.tsx +67 -0
- package/src/ui/page-feedback.tsx +50 -0
- package/src/ui/page-footer.tsx +23 -0
- package/src/ui/prev-next-link.tsx +15 -69
- package/src/ui/prev-next-view.tsx +27 -0
- package/src/ui/table-of-content-view.tsx +167 -0
- package/src/ui/table-of-content.tsx +25 -183
- package/src/utils/analytics.test.ts +36 -0
- package/src/utils/analytics.ts +35 -0
- package/src/utils/colors.ts +7 -0
- package/src/utils/content-scope.test.ts +26 -0
- package/src/utils/content-scope.ts +39 -0
- package/src/utils/search-content.ts +12 -0
- package/src/utils/theme.ts +1 -7
- package/vite.config.ssr.ts +3 -3
- package/vite.config.ts +21 -15
|
@@ -13,6 +13,19 @@ export class DoryWidget {
|
|
|
13
13
|
private overlay: HTMLElement | null = null;
|
|
14
14
|
private isOpenState = false;
|
|
15
15
|
private eventHandlers: Map<string, Function[]> = new Map();
|
|
16
|
+
private readonly handleMessage = (event: MessageEvent) => {
|
|
17
|
+
if (event.source !== this.iframe?.contentWindow || event.origin !== new URL(this.config.baseUrl).origin) return;
|
|
18
|
+
const message = event.data;
|
|
19
|
+
if (!message || typeof message !== 'object' || message.source !== 'dory') return;
|
|
20
|
+
|
|
21
|
+
if (message.type === 'dory:ready') {
|
|
22
|
+
this.config.onReady?.();
|
|
23
|
+
this.emit('ready');
|
|
24
|
+
} else if (message.type === 'dory:navigate' && typeof message.path === 'string' && message.path.startsWith('/') && !message.path.startsWith('//')) {
|
|
25
|
+
this.config.onNavigate?.(message.path);
|
|
26
|
+
this.emit('navigate', message.path);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
16
29
|
|
|
17
30
|
constructor(config: DoryEmbedConfig) {
|
|
18
31
|
this.config = config;
|
|
@@ -74,11 +87,11 @@ export class DoryWidget {
|
|
|
74
87
|
|
|
75
88
|
// Add embedded mode flag
|
|
76
89
|
params.set('embedded', 'true');
|
|
90
|
+
params.set('parentOrigin', window.location.origin);
|
|
77
91
|
|
|
78
|
-
//
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
92
|
+
// Match the host on first open; setTheme can update it later.
|
|
93
|
+
const hostIsDark = document.documentElement.classList.contains('dark') || document.documentElement.getAttribute('data-theme') === 'dark';
|
|
94
|
+
params.set('theme', this.config.theme && this.config.theme !== 'inherit' ? this.config.theme : hostIsDark ? 'dark' : 'light');
|
|
82
95
|
|
|
83
96
|
const url = new URL(baseUrl);
|
|
84
97
|
url.pathname = this.resolveDocsPath(path);
|
|
@@ -95,23 +108,7 @@ export class DoryWidget {
|
|
|
95
108
|
}
|
|
96
109
|
|
|
97
110
|
private setupIframeMessaging() {
|
|
98
|
-
window.addEventListener('message',
|
|
99
|
-
// Verify origin
|
|
100
|
-
if (event.origin !== new URL(this.config.baseUrl).origin) {
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const message = event.data;
|
|
105
|
-
|
|
106
|
-
switch (message.type) {
|
|
107
|
-
case 'navigate':
|
|
108
|
-
this.emit('navigate', message.path);
|
|
109
|
-
break;
|
|
110
|
-
case 'ready':
|
|
111
|
-
this.emit('ready');
|
|
112
|
-
break;
|
|
113
|
-
}
|
|
114
|
-
});
|
|
111
|
+
window.addEventListener('message', this.handleMessage);
|
|
115
112
|
}
|
|
116
113
|
|
|
117
114
|
private getContainerStyles(): string {
|
|
@@ -286,6 +283,7 @@ export class DoryWidget {
|
|
|
286
283
|
}
|
|
287
284
|
|
|
288
285
|
destroy() {
|
|
286
|
+
window.removeEventListener('message', this.handleMessage);
|
|
289
287
|
// Cleanup event listeners
|
|
290
288
|
if (this.container && (this.container as any).__cleanup) {
|
|
291
289
|
(this.container as any).__cleanup();
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import type { DoryColors, DoryNavigation } from '../types/config';
|
|
2
|
+
|
|
3
|
+
export type EmbeddedConfig = {
|
|
4
|
+
name?: string;
|
|
5
|
+
title?: string;
|
|
6
|
+
version?: string;
|
|
7
|
+
copyright?: string;
|
|
8
|
+
repository?: { url: string; branch?: string; path?: string };
|
|
9
|
+
logo?: { light?: string; dark?: string };
|
|
10
|
+
colors?: Partial<DoryColors>;
|
|
11
|
+
fonts?: { family?: string; heading?: { family?: string }; mono?: { family?: string } };
|
|
12
|
+
theme?: { mode?: 'light' | 'dark' | 'system'; radius?: string };
|
|
13
|
+
navigation?: DoryNavigation;
|
|
14
|
+
i18n?: { defaultLocale?: string; locales?: Array<{ code: string; label?: string; navigation?: DoryNavigation }> };
|
|
15
|
+
chat?: { suggestedQuestions?: string[] };
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const safeText = (value: unknown, length = 100) =>
|
|
19
|
+
typeof value === 'string' && value.length <= length ? value.trim() || undefined : undefined;
|
|
20
|
+
const safeColor = (value: unknown) =>
|
|
21
|
+
typeof value === 'string' && /^#[0-9a-fA-F]{3}(?:[0-9a-fA-F]{3})?$/.test(value) ? value : undefined;
|
|
22
|
+
const safeFont = (value: unknown) => {
|
|
23
|
+
const family = safeText(value, 80);
|
|
24
|
+
return family && /^[\p{L}\p{N} ._-]+$/u.test(family) ? family : undefined;
|
|
25
|
+
};
|
|
26
|
+
const safeLogo = (value: unknown) => {
|
|
27
|
+
if (typeof value !== 'string' || value.length > 100_000) return undefined;
|
|
28
|
+
return /^(?:https:\/\/[^\s]+|data:image\/(?:svg\+xml|png|webp|jpeg);base64,[A-Za-z0-9+/=]+)$/.test(value) ? value : undefined;
|
|
29
|
+
};
|
|
30
|
+
const safeRepository = (value: unknown): EmbeddedConfig['repository'] => {
|
|
31
|
+
if (!value || typeof value !== 'object') return undefined;
|
|
32
|
+
const input = value as Record<string, unknown>;
|
|
33
|
+
if (typeof input.url !== 'string' || input.url.length > 300) return undefined;
|
|
34
|
+
try {
|
|
35
|
+
const url = new URL(input.url);
|
|
36
|
+
if (url.protocol !== 'https:' || url.username || url.password || url.search || url.hash) return undefined;
|
|
37
|
+
const branch = safeText(input.branch, 80);
|
|
38
|
+
const path = safeText(input.path, 160);
|
|
39
|
+
if (branch && !/^[a-zA-Z0-9._/-]+$/.test(branch)) return undefined;
|
|
40
|
+
if (path && !/^(?:[a-zA-Z0-9._-]+\/)*[a-zA-Z0-9._-]+$/.test(path)) return undefined;
|
|
41
|
+
return { url: url.href.replace(/\/$/, ''), branch, path };
|
|
42
|
+
} catch { return undefined; }
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
function safeNavigation(value: unknown): DoryNavigation | undefined {
|
|
46
|
+
if (!value || typeof value !== 'object' || !Array.isArray((value as DoryNavigation).tabs)) return undefined;
|
|
47
|
+
const tabs = (value as DoryNavigation).tabs.slice(0, 12).map(tab => ({
|
|
48
|
+
tab: safeText(tab?.tab, 80) ?? '',
|
|
49
|
+
groups: Array.isArray(tab?.groups) ? tab.groups.slice(0, 50).map(group => ({
|
|
50
|
+
group: safeText(group?.group, 80) ?? '',
|
|
51
|
+
pages: Array.isArray(group?.pages) ? group.pages.slice(0, 200).flatMap(entry => {
|
|
52
|
+
const raw = typeof entry === 'string' ? entry : entry?.page;
|
|
53
|
+
const page = safeText(raw, 200)?.replace(/^\/+|\/+$/g, '');
|
|
54
|
+
if (!page || !/^(?:[a-zA-Z0-9_-]+\/)*[a-zA-Z0-9_-]+$/.test(page)) return [];
|
|
55
|
+
return [typeof entry === 'string' ? page : { page, badge: safeText(entry.badge, 24) }];
|
|
56
|
+
}) : [],
|
|
57
|
+
})).filter(group => group.group && group.pages.length) : [],
|
|
58
|
+
})).filter(tab => tab.tab && tab.groups.length);
|
|
59
|
+
return tabs.length ? { tabs } : undefined;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function parseEmbeddedConfig(value: unknown): EmbeddedConfig {
|
|
63
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) return {};
|
|
64
|
+
try {
|
|
65
|
+
if (JSON.stringify(value).length > 200_000) return {};
|
|
66
|
+
} catch {
|
|
67
|
+
return {};
|
|
68
|
+
}
|
|
69
|
+
const input = value as EmbeddedConfig;
|
|
70
|
+
const colors: Partial<DoryColors> = {};
|
|
71
|
+
for (const key of ['primary', 'light', 'dark', 'background', 'surface', 'surfaceElevated', 'foreground', 'mutedForeground', 'border', 'accent'] as const) {
|
|
72
|
+
const safe = safeColor(input.colors?.[key]);
|
|
73
|
+
if (safe) colors[key] = safe;
|
|
74
|
+
}
|
|
75
|
+
const mode = input.theme?.mode;
|
|
76
|
+
const radius = typeof input.theme?.radius === 'string' && /^\d+(?:\.\d+)?(?:px|rem)$/.test(input.theme.radius) ? input.theme.radius : undefined;
|
|
77
|
+
const locales = Array.isArray(input.i18n?.locales) ? input.i18n.locales.slice(0, 24).flatMap(item => {
|
|
78
|
+
const code = safeText(item?.code, 16);
|
|
79
|
+
const navigation = safeNavigation(item?.navigation);
|
|
80
|
+
return code && /^[a-z]{2}(?:[-_][a-zA-Z]{2})?$/.test(code) ? [{ code, label: safeText(item.label, 80), navigation }] : [];
|
|
81
|
+
}) : [];
|
|
82
|
+
const suggestedQuestions = Array.isArray(input.chat?.suggestedQuestions)
|
|
83
|
+
? input.chat.suggestedQuestions.slice(0, 4).flatMap(question => {
|
|
84
|
+
const value = safeText(question, 120);
|
|
85
|
+
return value && value.length >= 3 ? [value] : [];
|
|
86
|
+
}) : [];
|
|
87
|
+
return {
|
|
88
|
+
name: safeText(input.name), title: safeText(input.title, 160), version: safeText(input.version, 80),
|
|
89
|
+
copyright: safeText(input.copyright, 120), repository: safeRepository(input.repository),
|
|
90
|
+
logo: { light: safeLogo(input.logo?.light), dark: safeLogo(input.logo?.dark) }, colors,
|
|
91
|
+
fonts: { family: safeFont(input.fonts?.family), heading: { family: safeFont(input.fonts?.heading?.family) }, mono: { family: safeFont(input.fonts?.mono?.family) } },
|
|
92
|
+
theme: { mode: mode === 'light' || mode === 'dark' || mode === 'system' ? mode : undefined, radius },
|
|
93
|
+
navigation: safeNavigation(input.navigation), i18n: { defaultLocale: /^[a-z]{2}(?:[-_][a-zA-Z]{2})?$/.test(input.i18n?.defaultLocale ?? '') ? input.i18n?.defaultLocale : undefined, locales },
|
|
94
|
+
chat: { suggestedQuestions },
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function toRgb(hex: string): string {
|
|
99
|
+
const expanded = hex.length === 4 ? `#${[...hex.slice(1)].map(char => char + char).join('')}` : hex;
|
|
100
|
+
return [1, 3, 5].map(index => Number.parseInt(expanded.slice(index, index + 2), 16)).join(' ');
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function applyEmbeddedConfig(config: EmbeddedConfig, theme: 'light' | 'dark') {
|
|
104
|
+
const root = document.documentElement;
|
|
105
|
+
for (const name of ['--brand-primary', '--brand-primary-rgb', '--brand-light', '--brand-light-rgb', '--brand-dark', '--brand-dark-rgb', '--brand-foreground', '--sidebar-primary', '--background', '--foreground', '--card-foreground', '--popover-foreground', '--secondary-foreground', '--card', '--popover', '--sidebar', '--muted', '--secondary', '--muted-foreground', '--border', '--input', '--sidebar-border', '--accent', '--ring', '--font-body', '--font-heading', '--font-mono', '--radius']) root.style.removeProperty(name);
|
|
106
|
+
root.removeAttribute('data-dory-colors');
|
|
107
|
+
const colors = config.colors;
|
|
108
|
+
if (colors) {
|
|
109
|
+
const light = colors.light ?? colors.primary;
|
|
110
|
+
const dark = colors.dark ?? colors.primary;
|
|
111
|
+
if (light || dark) {
|
|
112
|
+
root.setAttribute('data-dory-colors', 'true');
|
|
113
|
+
if (light) root.style.setProperty('--brand-light', light);
|
|
114
|
+
if (dark) root.style.setProperty('--brand-dark', dark);
|
|
115
|
+
if (light) root.style.setProperty('--brand-light-rgb', toRgb(light));
|
|
116
|
+
if (dark) root.style.setProperty('--brand-dark-rgb', toRgb(dark));
|
|
117
|
+
root.style.setProperty('--sidebar-primary', theme === 'dark' ? dark ?? light! : light ?? dark!);
|
|
118
|
+
}
|
|
119
|
+
if (colors.primary) {
|
|
120
|
+
root.style.setProperty('--brand-primary', colors.primary);
|
|
121
|
+
root.style.setProperty('--brand-primary-rgb', toRgb(colors.primary));
|
|
122
|
+
root.style.setProperty('--brand-foreground', colors.primary);
|
|
123
|
+
}
|
|
124
|
+
const mapped: Array<[keyof DoryColors, string[]]> = [
|
|
125
|
+
['background', ['--background']], ['foreground', ['--foreground', '--card-foreground', '--popover-foreground', '--secondary-foreground']],
|
|
126
|
+
['surface', ['--card', '--popover', '--sidebar']], ['surfaceElevated', ['--muted', '--secondary']],
|
|
127
|
+
['mutedForeground', ['--muted-foreground']], ['border', ['--border', '--input', '--sidebar-border']],
|
|
128
|
+
['accent', ['--accent', '--ring']],
|
|
129
|
+
];
|
|
130
|
+
for (const [key, names] of mapped) if (colors[key]) for (const name of names) root.style.setProperty(name, colors[key]!);
|
|
131
|
+
}
|
|
132
|
+
if (config.fonts?.family) root.style.setProperty('--font-body', `'${config.fonts.family}', sans-serif`);
|
|
133
|
+
if (config.fonts?.heading?.family) root.style.setProperty('--font-heading', `'${config.fonts.heading.family}', serif`);
|
|
134
|
+
if (config.fonts?.mono?.family) root.style.setProperty('--font-mono', `'${config.fonts.mono.family}', monospace`);
|
|
135
|
+
if (config.theme?.radius) root.style.setProperty('--radius', config.theme.radius);
|
|
136
|
+
root.classList.toggle('dark', theme === 'dark');
|
|
137
|
+
root.style.colorScheme = theme;
|
|
138
|
+
}
|