@elucim/dsl 0.11.0 → 0.13.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.
Files changed (3) hide show
  1. package/dist/index.d.ts +91 -48
  2. package/dist/index.js +395 -401
  3. package/package.json +2 -2
package/dist/index.d.ts CHANGED
@@ -106,6 +106,15 @@ export declare interface BezierCurveNode {
106
106
  zIndex?: number;
107
107
  }
108
108
 
109
+ export declare interface BuilderTheme extends ElucimTheme {
110
+ /** Box fill colors for diagrams */
111
+ boxFill: string;
112
+ /** Box stroke color */
113
+ boxStroke: string;
114
+ /** Palette of 8 colors for sequential use */
115
+ palette: string[];
116
+ }
117
+
109
118
  export declare interface CircleNode {
110
119
  type: 'circle';
111
120
  id?: string;
@@ -155,7 +164,13 @@ export declare interface CubicBezierEasing {
155
164
  y2: number;
156
165
  }
157
166
 
158
- export declare const darkTheme: Theme;
167
+ /** Dark theme preset — the default Elucim content theme. */
168
+ export declare const DARK_THEME: Required<Pick<ElucimTheme, 'foreground' | 'background' | 'title' | 'subtitle' | 'primary' | 'secondary' | 'tertiary' | 'muted' | 'surface' | 'border' | 'accent' | 'success' | 'warning' | 'error'>>;
169
+
170
+ /** Pre-computed CSS variable maps for colorScheme resolution. */
171
+ export declare const DARK_THEME_VARS: Record<string, string>;
172
+
173
+ export declare const darkTheme: BuilderTheme;
159
174
 
160
175
  export declare interface DrawNode {
161
176
  type: 'draw';
@@ -172,9 +187,9 @@ export declare interface DslRendererProps {
172
187
  className?: string;
173
188
  style?: default_2.CSSProperties;
174
189
  /**
175
- * Inject theme colors as CSS custom properties (e.g. --elucim-foreground).
176
- * Values can be hex colors, named colors, or CSS var() references
177
- * (e.g. `{ accent: "var(--my-app-accent)" }`).
190
+ * Theme for semantic token resolution.
191
+ * Keys map to `--elucim-{key}` CSS custom properties and `$token` DSL syntax.
192
+ * Values can be hex colors, named colors, or CSS `var()` references.
178
193
  */
179
194
  theme?: ElucimTheme;
180
195
  /**
@@ -183,9 +198,7 @@ export declare interface DslRendererProps {
183
198
  * - `'light'` — inject light theme CSS variables
184
199
  * - `'auto'` — detect from `prefers-color-scheme` media query
185
200
  *
186
- * DSL documents using `$token` syntax (e.g. `$background`, `$foreground`)
187
- * will automatically adapt. Explicit `theme` values take priority over
188
- * colorScheme defaults.
201
+ * Explicit `theme` values take priority over colorScheme defaults.
189
202
  */
190
203
  colorScheme?: 'light' | 'dark' | 'auto';
191
204
  /** Render a static frame instead of interactive player. 'first' | 'last' | frame number */
@@ -196,8 +209,17 @@ export declare interface DslRendererProps {
196
209
  autoPlay?: boolean;
197
210
  /** Override the document's loop setting (Player root only). */
198
211
  loop?: boolean;
212
+ /**
213
+ * When true, the rendered scene fills its parent container width and
214
+ * scales proportionally. Default: false.
215
+ */
216
+ fitToContainer?: boolean;
199
217
  /** Called whenever playback state changes (play/pause). */
200
218
  onPlayStateChange?: (playing: boolean) => void;
219
+ /** Called when a React render error occurs inside the scene tree. */
220
+ onRenderError?: (error: Error) => void;
221
+ /** Custom fallback UI shown when a render error occurs. */
222
+ fallback?: default_2.ReactNode;
201
223
  /** Callback fired when DSL validation fails */
202
224
  onError?: (errors: Array<{
203
225
  path: string;
@@ -238,11 +260,52 @@ export declare interface ElucimDocument {
238
260
  root: RootNode;
239
261
  }
240
262
 
263
+ /**
264
+ * Unified Elucim theme system.
265
+ *
266
+ * `ElucimTheme` is the single theme type used across the entire Elucim ecosystem:
267
+ * DslRenderer, ElucimEditor, and $token resolution all share this contract.
268
+ *
269
+ * Token names map 1:1 to the `$token` DSL syntax and `--elucim-*` CSS custom
270
+ * properties. For example, `{ primary: '#2563eb' }` sets `--elucim-primary`
271
+ * and is referenced in DSL documents as `$primary`.
272
+ *
273
+ * Values can be hex colors, named CSS colors, or CSS `var()` references
274
+ * (e.g. `{ accent: "var(--my-app-accent)" }`).
275
+ */
276
+ /**
277
+ * Canonical theme interface for Elucim content rendering and editor chrome.
278
+ * All fields are optional — unset fields fall back to the active colorScheme defaults.
279
+ */
241
280
  export declare interface ElucimTheme {
281
+ /** Default text color. Maps to `$foreground` / `--elucim-foreground`. */
242
282
  foreground?: string;
283
+ /** Scene background. Maps to `$background` / `--elucim-background`. */
243
284
  background?: string;
285
+ /** Title text color. Maps to `$title` / `--elucim-title`. */
286
+ title?: string;
287
+ /** Subtitle / secondary text. Maps to `$subtitle` / `--elucim-subtitle`. */
288
+ subtitle?: string;
289
+ /** Primary accent color. Maps to `$primary` / `--elucim-primary`. */
290
+ primary?: string;
291
+ /** Secondary accent. Maps to `$secondary` / `--elucim-secondary`. */
292
+ secondary?: string;
293
+ /** Tertiary accent. Maps to `$tertiary` / `--elucim-tertiary`. */
294
+ tertiary?: string;
295
+ /** Muted text / annotations. Maps to `$muted` / `--elucim-muted`. */
296
+ muted?: string;
297
+ /** Elevated surface color. Maps to `$surface` / `--elucim-surface`. */
298
+ surface?: string;
299
+ /** Border color. Maps to `$border` / `--elucim-border`. */
300
+ border?: string;
301
+ /** Alias for primary — `$accent` / `--elucim-accent`. */
244
302
  accent?: string;
245
- [key: string]: string | undefined;
303
+ /** Success / positive. Maps to `$success` / `--elucim-success`. */
304
+ success?: string;
305
+ /** Warning / highlight. Maps to `$warning` / `--elucim-warning`. */
306
+ warning?: string;
307
+ /** Error / negative. Maps to `$error` / `--elucim-error`. */
308
+ error?: string;
246
309
  }
247
310
 
248
311
  export declare interface FadeInNode {
@@ -374,7 +437,12 @@ export declare interface LaTeXNode {
374
437
  zIndex?: number;
375
438
  }
376
439
 
377
- export declare const lightTheme: Theme;
440
+ /** Light theme preset. */
441
+ export declare const LIGHT_THEME: Required<Pick<ElucimTheme, 'foreground' | 'background' | 'title' | 'subtitle' | 'primary' | 'secondary' | 'tertiary' | 'muted' | 'surface' | 'border' | 'accent' | 'success' | 'warning' | 'error'>>;
442
+
443
+ export declare const LIGHT_THEME_VARS: Record<string, string>;
444
+
445
+ export declare const lightTheme: BuilderTheme;
378
446
 
379
447
  export declare interface LineNode {
380
448
  type: 'line';
@@ -597,6 +665,8 @@ export declare interface RenderRootOverrides {
597
665
  autoPlay?: boolean;
598
666
  /** Override Player loop setting. */
599
667
  loop?: boolean;
668
+ /** When true, scene fills its parent container. */
669
+ fitToContainer?: boolean;
600
670
  /** Callback fired when playback state changes. */
601
671
  onPlayStateChange?: (playing: boolean) => void;
602
672
  }
@@ -653,14 +723,13 @@ export declare interface RenderToSvgStringOptions {
653
723
  }
654
724
 
655
725
  /**
656
- * Resolve a color value. If it starts with `$`, treat it as a semantic token
657
- * and return a CSS `var()` reference. Otherwise return the value unchanged.
726
+ * Resolve a color value. If it starts with `$`, treat it as a semantic token
727
+ * and return a CSS `var()` reference. Otherwise return the value unchanged.
658
728
  *
659
729
  * @example
660
- * resolveColor('$foreground') // → 'var(--elucim-foreground, #e0e0e0)'
661
- * resolveColor('$accent') // → 'var(--elucim-accent, #4fc3f7)'
662
- * resolveColor('#ff0000') // → '#ff0000' (unchanged)
663
- * resolveColor(undefined) // → undefined (pass-through)
730
+ * resolveColor('$foreground') // → 'var(--elucim-foreground, #c8d6e5)'
731
+ * resolveColor('#ff0000') // → '#ff0000'
732
+ * resolveColor(undefined) // → undefined
664
733
  */
665
734
  export declare function resolveColor(value: string | undefined): string | undefined;
666
735
 
@@ -687,7 +756,7 @@ export declare interface SceneNode {
687
756
  /** Preset dimensions for common scene sizes */
688
757
  export declare type ScenePreset = 'card' | 'slide' | 'square';
689
758
 
690
- /** Standard semantic color tokens with their CSS variable and default fallback. */
759
+ /** Standard semantic color tokens with their CSS variable and dark-mode fallback. */
691
760
  export declare const SEMANTIC_TOKENS: Record<string, {
692
761
  cssVar: string;
693
762
  fallback: string;
@@ -983,40 +1052,14 @@ export declare interface TextNode {
983
1052
  }
984
1053
 
985
1054
  /**
986
- * Theme configuration for presentation builders.
987
- * Provides consistent colors across slides.
1055
+ * @deprecated Use `BuilderTheme` instead. Kept for backward compatibility.
988
1056
  */
989
- export declare interface Theme {
990
- background: string;
991
- /** Title text color */
992
- title: string;
993
- /** Subtitle / secondary text */
994
- subtitle: string;
995
- /** Primary accent (arrows, highlights) */
996
- primary: string;
997
- /** Secondary accent */
998
- secondary: string;
999
- /** Tertiary accent */
1000
- tertiary: string;
1001
- /** Muted text / annotations */
1002
- muted: string;
1003
- /** Default text color */
1004
- text: string;
1005
- /** Box fill colors for diagrams */
1006
- boxFill: string;
1007
- /** Box stroke color */
1008
- boxStroke: string;
1009
- /** Success / positive color */
1010
- success: string;
1011
- /** Warning / highlight color */
1012
- warning: string;
1013
- /** Error / negative color */
1014
- error: string;
1015
- /** Palette of 8 colors for sequential use */
1016
- palette: string[];
1017
- }
1057
+ export declare type Theme = BuilderTheme;
1058
+
1059
+ /** Convert an ElucimTheme (or arbitrary token record) to CSS custom properties (`--elucim-*`). */
1060
+ export declare function themeToVars(theme?: ElucimTheme | Record<string, string | undefined>): Record<string, string>;
1018
1061
 
1019
- /** List of token names for documentation / autocomplete. */
1062
+ /** List of standard token names. */
1020
1063
  export declare const TOKEN_NAMES: ReadonlyArray<string>;
1021
1064
 
1022
1065
  export declare interface TransformNode {