dynim-react 1.0.125 → 1.0.132

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.
@@ -1 +1 @@
1
- {"version":3,"file":"DynimProvider.d.ts","sourceRoot":"","sources":["../src/DynimProvider.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAc,EASZ,KAAK,SAAS,EAGf,MAAM,OAAO,CAAC;AAoBf;;;GAGG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAG9D;AA6ED,MAAM,WAAW,WAAW;IAC1B,kCAAkC;IAClC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,KAAK,IAAI,CAAC;IACzC,uFAAuF;IACvF,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,wCAAwC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,iBAAiB;IAChC,yCAAyC;IACzC,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,qBAAqB;IACrB,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,0CAA0C;IAC1C,SAAS,EAAE,OAAO,CAAC;IACnB,2CAA2C;IAC3C,cAAc,EAAE,OAAO,CAAC;IACxB,gCAAgC;IAChC,eAAe,EAAE,OAAO,CAAC;CAC1B;AAID,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,SAAS,CAAC;IACpB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,EAC5B,QAAQ,EACR,MAAW,GACZ,EAAE,kBAAkB,GAAG,GAAG,CAAC,OAAO,CAuZlC;AAED;;GAEG;AACH,wBAAgB,QAAQ,IAAI,iBAAiB,CAM5C"}
1
+ {"version":3,"file":"DynimProvider.d.ts","sourceRoot":"","sources":["../src/DynimProvider.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAc,EASZ,KAAK,SAAS,EAGf,MAAM,OAAO,CAAC;AAgDf;;;GAGG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAG9D;AA6ED,MAAM,WAAW,WAAW;IAC1B,kCAAkC;IAClC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,KAAK,IAAI,CAAC;IACzC,uFAAuF;IACvF,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,wCAAwC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,iBAAiB;IAChC,yCAAyC;IACzC,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,qBAAqB;IACrB,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,0CAA0C;IAC1C,SAAS,EAAE,OAAO,CAAC;IACnB,2CAA2C;IAC3C,cAAc,EAAE,OAAO,CAAC;IACxB,gCAAgC;IAChC,eAAe,EAAE,OAAO,CAAC;CAC1B;AAID,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,SAAS,CAAC;IACpB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,EAC5B,QAAQ,EACR,MAAW,GACZ,EAAE,kBAAkB,GAAG,GAAG,CAAC,OAAO,CAoblC;AAED;;GAEG;AACH,wBAAgB,QAAQ,IAAI,iBAAiB,CAM5C"}
@@ -9,9 +9,45 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
9
9
  */
10
10
  import React, { createContext, useContext, useEffect, useRef, useCallback, useMemo, useState, Component, } from 'react';
11
11
  import ReactDOM from 'react-dom';
12
- import { createCodeClient, createBundleLoader, createCSSLoader, BundleNotFoundError, BundleAuthError, } from 'dynim-core';
12
+ import { createCodeClient, createCSSLoader, createDataBridge, BundleNotFoundError, BundleAuthError, } from 'dynim-core';
13
13
  import { createSharedContext, updateSharedContext, isSharedContextReady } from './inference/sharedContext';
14
- import { generateThemeCSS } from './theme';
14
+ import { generateThemeCSS } from 'dynim-core';
15
+ // --- Bundle cache (sessionStorage) ---
16
+ const BUNDLE_CACHE_KEY = 'dynim_bundle_js';
17
+ function getCachedBundle() {
18
+ try {
19
+ return sessionStorage.getItem(BUNDLE_CACHE_KEY);
20
+ }
21
+ catch {
22
+ return null;
23
+ }
24
+ }
25
+ function setCachedBundle(code) {
26
+ try {
27
+ sessionStorage.setItem(BUNDLE_CACHE_KEY, code);
28
+ }
29
+ catch { /* quota / private browsing */ }
30
+ }
31
+ function clearCachedBundle() {
32
+ try {
33
+ sessionStorage.removeItem(BUNDLE_CACHE_KEY);
34
+ }
35
+ catch { }
36
+ }
37
+ async function importBundleText(code) {
38
+ const blob = new Blob([code], { type: 'application/javascript' });
39
+ const blobUrl = URL.createObjectURL(blob);
40
+ try {
41
+ const mod = await import(/* @vite-ignore */ blobUrl);
42
+ const App = mod.App || mod.default;
43
+ if (!App)
44
+ throw new Error('Bundle has no App export');
45
+ return App;
46
+ }
47
+ finally {
48
+ URL.revokeObjectURL(blobUrl);
49
+ }
50
+ }
15
51
  // Module-level token resolver — set by DynimProvider on mount.
16
52
  let _tokenResolver = null;
17
53
  /**
@@ -75,8 +111,8 @@ const DynimContext = createContext(null);
75
111
  */
76
112
  export function DynimProvider({ children, config = {}, }) {
77
113
  const codeClientRef = useRef(null);
78
- const bundleLoaderRef = useRef(null);
79
114
  const cssLoaderRef = useRef(null);
115
+ const dataBridgeRef = useRef(null);
80
116
  const hasAttemptedInitialLoadRef = useRef(false);
81
117
  // Delegate session management to the standalone SDK (window.dynim).
82
118
  // The standalone script owns auth via identify() → HMAC → session token.
@@ -211,10 +247,12 @@ export function DynimProvider({ children, config = {}, }) {
211
247
  useEffect(() => {
212
248
  const handlers = [
213
249
  ['dynim:bundle-ready', () => {
250
+ clearCachedBundle();
214
251
  const bundleUrl = `/api/code/bundle?temp=true&_t=${Date.now()}`;
215
252
  loadBundleRef.current?.(bundleUrl, true);
216
253
  }],
217
254
  ['dynim:bundle-saved', ((e) => {
255
+ clearCachedBundle();
218
256
  const detail = e.detail;
219
257
  if (detail?.cssVersion && codeClientRef.current) {
220
258
  codeClientRef.current.setCSSVersion(detail.cssVersion);
@@ -222,6 +260,7 @@ export function DynimProvider({ children, config = {}, }) {
222
260
  loadBundleRef.current?.('/api/code/bundle', true);
223
261
  })],
224
262
  ['dynim:bundle-abandoned', () => {
263
+ clearCachedBundle();
225
264
  loadBundleRef.current?.('/api/code/bundle', true);
226
265
  }],
227
266
  ['dynim:load-bundle', ((e) => {
@@ -246,20 +285,6 @@ export function DynimProvider({ children, config = {}, }) {
246
285
  }
247
286
  };
248
287
  }, []);
249
- // Get bundle loader
250
- const getBundleLoader = useCallback(() => {
251
- if (!bundleLoaderRef.current) {
252
- bundleLoaderRef.current = createBundleLoader({
253
- getAuthToken,
254
- includeCredentials: true,
255
- onError: (error) => {
256
- console.error('[DynimProvider] Bundle load failed:', error);
257
- configRef.current.onError?.(error);
258
- },
259
- });
260
- }
261
- return bundleLoaderRef.current;
262
- }, [getAuthToken]);
263
288
  // Get CSS loader
264
289
  const getCSSLoader = useCallback(() => {
265
290
  if (!cssLoaderRef.current) {
@@ -276,29 +301,49 @@ export function DynimProvider({ children, config = {}, }) {
276
301
  const buildCSSUrl = useCallback((temp = false) => {
277
302
  return codeClientRef.current?.getCSSUrl(temp) ?? null;
278
303
  }, []);
279
- // Load bundle (JS + CSS)
304
+ // Load bundle (JS + CSS) — with sessionStorage caching for saved bundles
280
305
  const loadBundle = useCallback(async (bundleUrl, loadCSS = true) => {
281
- const loader = getBundleLoader();
282
- if (loader.isLoading())
283
- return;
284
306
  setIsBundleLoading(true);
285
307
  setBundleError(null);
308
+ const isTemp = bundleUrl.includes('temp=true');
286
309
  try {
287
- const { App, cleanup } = await loader.load(bundleUrl);
310
+ let App;
311
+ // Try sessionStorage cache for saved (non-temp) bundles
312
+ const cached = !isTemp ? getCachedBundle() : null;
313
+ if (cached) {
314
+ App = await importBundleText(cached);
315
+ }
316
+ else {
317
+ // Fetch bundle with auth
318
+ const token = await getAuthToken();
319
+ const headers = { Accept: 'application/javascript' };
320
+ if (token)
321
+ headers['Authorization'] = `Bearer ${token}`;
322
+ const response = await fetch(bundleUrl, { headers, credentials: 'include' });
323
+ if (!response.ok) {
324
+ if (response.status === 404)
325
+ throw new BundleNotFoundError(bundleUrl);
326
+ if (response.status === 401)
327
+ throw new BundleAuthError();
328
+ throw new Error(`Failed to fetch bundle: ${response.status} ${response.statusText}`);
329
+ }
330
+ const code = await response.text();
331
+ App = await importBundleText(code);
332
+ // Cache saved bundles for next page load
333
+ if (!isTemp) {
334
+ setCachedBundle(code);
335
+ }
336
+ }
288
337
  setTenantApp(() => App);
289
338
  setIsBundleLoaded(true);
290
339
  setBundleResetKey(k => k + 1);
291
- cleanup();
292
340
  // Load CSS alongside JS bundle
293
341
  if (loadCSS) {
294
- const isTemp = bundleUrl.includes('temp=true');
295
342
  const cssUrl = buildCSSUrl(isTemp);
296
343
  if (cssUrl) {
297
- // Load CSS (temp has cache busting in URL, saved has version param)
298
344
  getCSSLoader().load(cssUrl);
299
345
  }
300
346
  else if (!isTemp) {
301
- // No saved CSS exists - unload any existing CSS
302
347
  getCSSLoader().unload();
303
348
  }
304
349
  }
@@ -308,7 +353,6 @@ export function DynimProvider({ children, config = {}, }) {
308
353
  if (error instanceof BundleNotFoundError || error instanceof BundleAuthError) {
309
354
  setTenantApp(null);
310
355
  setIsBundleLoaded(false);
311
- // Also unload any CSS
312
356
  getCSSLoader().unload();
313
357
  return;
314
358
  }
@@ -317,7 +361,7 @@ export function DynimProvider({ children, config = {}, }) {
317
361
  finally {
318
362
  setIsBundleLoading(false);
319
363
  }
320
- }, [getBundleLoader, getCSSLoader, buildCSSUrl]);
364
+ }, [getAuthToken, getCSSLoader, buildCSSUrl]);
321
365
  // Keep ref updated
322
366
  useEffect(() => {
323
367
  loadBundleRef.current = loadBundle;
@@ -362,6 +406,25 @@ export function DynimProvider({ children, config = {}, }) {
362
406
  catch (error) {
363
407
  console.log('[DynimProvider] Initial bundle load:', error.message);
364
408
  }
409
+ // Start data bridge if router was loaded with the bundle
410
+ if (window.__DATA_ROUTER__ && !dataBridgeRef.current) {
411
+ dataBridgeRef.current = createDataBridge({
412
+ apiBase: '',
413
+ getToken: getAuthToken,
414
+ authenticatedFetch: async (url, init) => {
415
+ const token = await getAuthToken();
416
+ const headers = {
417
+ ...init?.headers,
418
+ };
419
+ if (token) {
420
+ headers['Authorization'] = `Bearer ${token}`;
421
+ }
422
+ return fetch(url, { ...init, headers, credentials: 'include' });
423
+ },
424
+ onError: (err) => console.warn('[DynimProvider] Data bridge error:', err),
425
+ });
426
+ dataBridgeRef.current.start();
427
+ }
365
428
  // Prefetch theme after 3s delay (non-blocking)
366
429
  setTimeout(() => fetchTheme(), 3000);
367
430
  };
@@ -384,8 +447,10 @@ export function DynimProvider({ children, config = {}, }) {
384
447
  return () => {
385
448
  unmounted = true;
386
449
  window.removeEventListener('dynim:identified', onIdentified);
450
+ dataBridgeRef.current?.destroy();
451
+ dataBridgeRef.current = null;
387
452
  };
388
- }, [fetchTheme]);
453
+ }, [fetchTheme, getAuthToken]);
389
454
  // Public methods — always delegate to window.dynim (standalone script)
390
455
  const enterBuilder = useCallback(() => {
391
456
  window.dynim?.enterBuilder();
package/dist/index.d.ts CHANGED
@@ -12,7 +12,7 @@
12
12
  */
13
13
  export { DynimProvider, useDynim, getSessionToken } from './DynimProvider';
14
14
  export type { DynimConfig, DynimContextValue, DynimProviderProps } from './DynimProvider';
15
- export { defaultTheme } from './theme';
16
- export type { DynimTheme } from './theme';
15
+ export { defaultTheme } from 'dynim-core';
16
+ export type { DynimTheme } from 'dynim-core';
17
17
  export type { CodeMessage, CodeEdit, ConnectionRequest } from 'dynim-core';
18
18
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAC3E,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAG1F,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAG1C,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAC3E,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAG1F,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAG7C,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -13,4 +13,4 @@
13
13
  // Main exports
14
14
  export { DynimProvider, useDynim, getSessionToken } from './DynimProvider';
15
15
  // Theme customization
16
- export { defaultTheme } from './theme';
16
+ export { defaultTheme } from 'dynim-core';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dynim-react",
3
- "version": "1.0.125",
3
+ "version": "1.0.132",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -27,7 +27,7 @@
27
27
  "dev": "tsc --watch"
28
28
  },
29
29
  "dependencies": {
30
- "dynim-core": "^1.0.99"
30
+ "dynim-core": "^1.0.106"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "react": ">=17.0.0",
package/dist/theme.d.ts DELETED
@@ -1,58 +0,0 @@
1
- /**
2
- * Dynim Theme System
3
- *
4
- * Theme is automatically fetched from the API per project.
5
- * CSS variables are injected with defaults matching the original design.
6
- */
7
- export interface DynimTheme {
8
- accent?: string;
9
- accentHover?: string;
10
- builderBg?: string;
11
- builderText?: string;
12
- builderFont?: string;
13
- builderRadius?: string;
14
- builderOpacity?: string;
15
- chatAccent?: string;
16
- chatBg?: string;
17
- chatText?: string;
18
- chatFont?: string;
19
- chatRadius?: string;
20
- chatOpacity?: string;
21
- selectionColor?: string;
22
- hoverColor?: string;
23
- selectionRadius?: string;
24
- selectionOpacity?: string;
25
- hoverOpacity?: string;
26
- }
27
- /**
28
- * Default theme values - matches original SDK styling exactly
29
- */
30
- export declare const defaultTheme: Required<DynimTheme>;
31
- /**
32
- * Generates CSS variable declarations from a theme object
33
- */
34
- export declare function generateThemeCSS(theme?: DynimTheme): string;
35
- /**
36
- * CSS variable references for use in styles
37
- */
38
- export declare const themeVars: {
39
- readonly accent: "var(--dynim-accent)";
40
- readonly accentHover: "var(--dynim-accent-hover)";
41
- readonly builderBg: "var(--dynim-builder-bg)";
42
- readonly builderText: "var(--dynim-builder-text)";
43
- readonly builderFont: "var(--dynim-builder-font)";
44
- readonly builderRadius: "var(--dynim-builder-radius)";
45
- readonly builderOpacity: "var(--dynim-builder-opacity)";
46
- readonly chatAccent: "var(--dynim-chat-accent)";
47
- readonly chatBg: "var(--dynim-chat-bg)";
48
- readonly chatText: "var(--dynim-chat-text)";
49
- readonly chatFont: "var(--dynim-chat-font)";
50
- readonly chatRadius: "var(--dynim-chat-radius)";
51
- readonly chatOpacity: "var(--dynim-chat-opacity)";
52
- readonly selectionColor: "var(--dynim-selection-color)";
53
- readonly hoverColor: "var(--dynim-hover-color)";
54
- readonly selectionRadius: "var(--dynim-selection-radius)";
55
- readonly selectionOpacity: "var(--dynim-selection-opacity)";
56
- readonly hoverOpacity: "var(--dynim-hover-opacity)";
57
- };
58
- //# sourceMappingURL=theme.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../src/theme.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,UAAU;IAEzB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IAGxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IAGrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,UAAU,CAwB7C,CAAC;AA+BF;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,GAAE,UAAe,GAAG,MAAM,CAW/D;AAED;;GAEG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;CAwBZ,CAAC"}
package/dist/theme.js DELETED
@@ -1,97 +0,0 @@
1
- /**
2
- * Dynim Theme System
3
- *
4
- * Theme is automatically fetched from the API per project.
5
- * CSS variables are injected with defaults matching the original design.
6
- */
7
- /**
8
- * Default theme values - matches original SDK styling exactly
9
- */
10
- export const defaultTheme = {
11
- // Builder Bar - original values
12
- accent: '#3b82f6',
13
- accentHover: '#2563eb',
14
- builderBg: '#000000',
15
- builderText: '#ffffff',
16
- builderFont: 'system-ui, -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, sans-serif',
17
- builderRadius: '22px',
18
- builderOpacity: '0.08',
19
- // Chat Widget - original values
20
- chatAccent: '#3b82f6',
21
- chatBg: '#ffffff',
22
- chatText: '#1f2937',
23
- chatFont: 'system-ui, -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, sans-serif',
24
- chatRadius: '16px',
25
- chatOpacity: '0.08',
26
- // Selection - original values
27
- selectionColor: '#8b5cf6',
28
- hoverColor: '#0ea5e9',
29
- selectionRadius: '0',
30
- selectionOpacity: '0.1',
31
- hoverOpacity: '0.1',
32
- };
33
- /**
34
- * CSS variable names mapped to theme keys
35
- */
36
- const cssVarMap = {
37
- // Builder Bar
38
- accent: '--dynim-accent',
39
- accentHover: '--dynim-accent-hover',
40
- builderBg: '--dynim-builder-bg',
41
- builderText: '--dynim-builder-text',
42
- builderFont: '--dynim-builder-font',
43
- builderRadius: '--dynim-builder-radius',
44
- builderOpacity: '--dynim-builder-opacity',
45
- // Chat Widget
46
- chatAccent: '--dynim-chat-accent',
47
- chatBg: '--dynim-chat-bg',
48
- chatText: '--dynim-chat-text',
49
- chatFont: '--dynim-chat-font',
50
- chatRadius: '--dynim-chat-radius',
51
- chatOpacity: '--dynim-chat-opacity',
52
- // Selection
53
- selectionColor: '--dynim-selection-color',
54
- hoverColor: '--dynim-hover-color',
55
- selectionRadius: '--dynim-selection-radius',
56
- selectionOpacity: '--dynim-selection-opacity',
57
- hoverOpacity: '--dynim-hover-opacity',
58
- };
59
- /**
60
- * Generates CSS variable declarations from a theme object
61
- */
62
- export function generateThemeCSS(theme = {}) {
63
- const merged = { ...defaultTheme, ...theme };
64
- const vars = Object.entries(merged)
65
- .map(([key, value]) => {
66
- const cssVar = cssVarMap[key];
67
- return `${cssVar}: ${value};`;
68
- })
69
- .join('\n ');
70
- return `:root {\n ${vars}\n}`;
71
- }
72
- /**
73
- * CSS variable references for use in styles
74
- */
75
- export const themeVars = {
76
- // Builder Bar
77
- accent: 'var(--dynim-accent)',
78
- accentHover: 'var(--dynim-accent-hover)',
79
- builderBg: 'var(--dynim-builder-bg)',
80
- builderText: 'var(--dynim-builder-text)',
81
- builderFont: 'var(--dynim-builder-font)',
82
- builderRadius: 'var(--dynim-builder-radius)',
83
- builderOpacity: 'var(--dynim-builder-opacity)',
84
- // Chat Widget
85
- chatAccent: 'var(--dynim-chat-accent)',
86
- chatBg: 'var(--dynim-chat-bg)',
87
- chatText: 'var(--dynim-chat-text)',
88
- chatFont: 'var(--dynim-chat-font)',
89
- chatRadius: 'var(--dynim-chat-radius)',
90
- chatOpacity: 'var(--dynim-chat-opacity)',
91
- // Selection
92
- selectionColor: 'var(--dynim-selection-color)',
93
- hoverColor: 'var(--dynim-hover-color)',
94
- selectionRadius: 'var(--dynim-selection-radius)',
95
- selectionOpacity: 'var(--dynim-selection-opacity)',
96
- hoverOpacity: 'var(--dynim-hover-opacity)',
97
- };