@elucim/dsl 0.10.0 → 0.12.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 +109 -46
  2. package/dist/index.js +458 -459
  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';
@@ -171,7 +186,11 @@ export declare interface DslRendererProps {
171
186
  dsl: ElucimDocument;
172
187
  className?: string;
173
188
  style?: default_2.CSSProperties;
174
- /** Inject theme colors as CSS custom properties (e.g. --elucim-foreground) */
189
+ /**
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.
193
+ */
175
194
  theme?: ElucimTheme;
176
195
  /**
177
196
  * Color scheme for semantic token resolution.
@@ -179,13 +198,28 @@ export declare interface DslRendererProps {
179
198
  * - `'light'` — inject light theme CSS variables
180
199
  * - `'auto'` — detect from `prefers-color-scheme` media query
181
200
  *
182
- * DSL documents using `$token` syntax (e.g. `$background`, `$foreground`)
183
- * will automatically adapt. Explicit `theme` values take priority over
184
- * colorScheme defaults.
201
+ * Explicit `theme` values take priority over colorScheme defaults.
185
202
  */
186
203
  colorScheme?: 'light' | 'dark' | 'auto';
187
204
  /** Render a static frame instead of interactive player. 'first' | 'last' | frame number */
188
205
  poster?: 'first' | 'last' | number;
206
+ /** Override the document's controls setting (Player root only). */
207
+ controls?: boolean;
208
+ /** Override the document's autoPlay setting (Player root only). */
209
+ autoPlay?: boolean;
210
+ /** Override the document's loop setting (Player root only). */
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;
217
+ /** Called whenever playback state changes (play/pause). */
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;
189
223
  /** Callback fired when DSL validation fails */
190
224
  onError?: (errors: Array<{
191
225
  path: string;
@@ -226,11 +260,52 @@ export declare interface ElucimDocument {
226
260
  root: RootNode;
227
261
  }
228
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
+ */
229
280
  export declare interface ElucimTheme {
281
+ /** Default text color. Maps to `$foreground` / `--elucim-foreground`. */
230
282
  foreground?: string;
283
+ /** Scene background. Maps to `$background` / `--elucim-background`. */
231
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`. */
232
302
  accent?: string;
233
- [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;
234
309
  }
235
310
 
236
311
  export declare interface FadeInNode {
@@ -362,7 +437,12 @@ export declare interface LaTeXNode {
362
437
  zIndex?: number;
363
438
  }
364
439
 
365
- 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;
366
446
 
367
447
  export declare interface LineNode {
368
448
  type: 'line';
@@ -579,6 +659,16 @@ export declare interface RenderRootOverrides {
579
659
  playerRef?: default_2.RefObject<PlayerRef | null>;
580
660
  /** CSS color-scheme to pass to Scene/Player. When set, overrides browser prefers-color-scheme. */
581
661
  colorScheme?: 'light' | 'dark' | 'light dark';
662
+ /** Override Player controls visibility. */
663
+ controls?: boolean;
664
+ /** Override Player autoPlay setting. */
665
+ autoPlay?: boolean;
666
+ /** Override Player loop setting. */
667
+ loop?: boolean;
668
+ /** When true, scene fills its parent container. */
669
+ fitToContainer?: boolean;
670
+ /** Callback fired when playback state changes. */
671
+ onPlayStateChange?: (playing: boolean) => void;
582
672
  }
583
673
 
584
674
  export declare function renderScene(node: SceneNode, overrides?: RenderRootOverrides): default_2.ReactNode;
@@ -633,14 +723,13 @@ export declare interface RenderToSvgStringOptions {
633
723
  }
634
724
 
635
725
  /**
636
- * Resolve a color value. If it starts with `$`, treat it as a semantic token
637
- * 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.
638
728
  *
639
729
  * @example
640
- * resolveColor('$foreground') // → 'var(--elucim-foreground, #e0e0e0)'
641
- * resolveColor('$accent') // → 'var(--elucim-accent, #4fc3f7)'
642
- * resolveColor('#ff0000') // → '#ff0000' (unchanged)
643
- * resolveColor(undefined) // → undefined (pass-through)
730
+ * resolveColor('$foreground') // → 'var(--elucim-foreground, #c8d6e5)'
731
+ * resolveColor('#ff0000') // → '#ff0000'
732
+ * resolveColor(undefined) // → undefined
644
733
  */
645
734
  export declare function resolveColor(value: string | undefined): string | undefined;
646
735
 
@@ -667,7 +756,7 @@ export declare interface SceneNode {
667
756
  /** Preset dimensions for common scene sizes */
668
757
  export declare type ScenePreset = 'card' | 'slide' | 'square';
669
758
 
670
- /** Standard semantic color tokens with their CSS variable and default fallback. */
759
+ /** Standard semantic color tokens with their CSS variable and dark-mode fallback. */
671
760
  export declare const SEMANTIC_TOKENS: Record<string, {
672
761
  cssVar: string;
673
762
  fallback: string;
@@ -963,40 +1052,14 @@ export declare interface TextNode {
963
1052
  }
964
1053
 
965
1054
  /**
966
- * Theme configuration for presentation builders.
967
- * Provides consistent colors across slides.
1055
+ * @deprecated Use `BuilderTheme` instead. Kept for backward compatibility.
968
1056
  */
969
- export declare interface Theme {
970
- background: string;
971
- /** Title text color */
972
- title: string;
973
- /** Subtitle / secondary text */
974
- subtitle: string;
975
- /** Primary accent (arrows, highlights) */
976
- primary: string;
977
- /** Secondary accent */
978
- secondary: string;
979
- /** Tertiary accent */
980
- tertiary: string;
981
- /** Muted text / annotations */
982
- muted: string;
983
- /** Default text color */
984
- text: string;
985
- /** Box fill colors for diagrams */
986
- boxFill: string;
987
- /** Box stroke color */
988
- boxStroke: string;
989
- /** Success / positive color */
990
- success: string;
991
- /** Warning / highlight color */
992
- warning: string;
993
- /** Error / negative color */
994
- error: string;
995
- /** Palette of 8 colors for sequential use */
996
- palette: string[];
997
- }
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>;
998
1061
 
999
- /** List of token names for documentation / autocomplete. */
1062
+ /** List of standard token names. */
1000
1063
  export declare const TOKEN_NAMES: ReadonlyArray<string>;
1001
1064
 
1002
1065
  export declare interface TransformNode {