merslim 0.1.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.
@@ -0,0 +1,654 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { RefObject, ComponentType } from 'react';
3
+
4
+ interface DbColumn {
5
+ name: string;
6
+ type: string;
7
+ isPK: boolean;
8
+ isFK: boolean;
9
+ isNullable: boolean;
10
+ isUnique: boolean;
11
+ }
12
+ interface DbRelation {
13
+ fromTable: string;
14
+ fromCol: string;
15
+ toTable: string;
16
+ toCol: string;
17
+ nullable: boolean;
18
+ }
19
+ interface DbTable {
20
+ name: string;
21
+ columns: DbColumn[];
22
+ }
23
+ interface ParsedSchema {
24
+ tables: DbTable[];
25
+ relations: DbRelation[];
26
+ inputFormat: 'sql' | 'prisma' | 'dbdiagram' | 'unknown';
27
+ }
28
+ /** Category of node, used for visual styling (color, icon, shape). */
29
+ type NodeKind = 'service' | 'database' | 'queue' | 'storage' | 'user' | 'client' | 'external' | 'process' | 'decision' | 'start' | 'end' | 'icon' | 'plain';
30
+ interface NodeIR {
31
+ /** Stable id used by edges to refer to this node. */
32
+ id: string;
33
+ /** Visible label. May contain markdown-ish bold/italic; renderers decide. */
34
+ label: string;
35
+ /** Visual category. Renderer maps this to shape/color/icon. */
36
+ kind: NodeKind;
37
+ /** Optional iconify-style ref (e.g. `logos:aws-rds`). When set, renderer
38
+ * shows the icon as the primary visual. */
39
+ icon?: string;
40
+ /** Optional subgraph this node belongs to. Maps to a cluster/group. */
41
+ subgraph?: string;
42
+ /** Free-form metadata for renderer-specific extensions. */
43
+ meta?: Record<string, unknown>;
44
+ }
45
+ type EdgeKind = 'solid' | 'dashed' | 'thick' | 'dotted' | 'invisible';
46
+ type EdgeArrow = 'none' | 'arrow' | 'open' | 'cross' | 'circle' | 'biarrow';
47
+ interface EdgeIR {
48
+ /** Source node id. */
49
+ source: string;
50
+ /** Target node id. */
51
+ target: string;
52
+ /** Optional label rendered along the edge. */
53
+ label?: string;
54
+ /** Visual style of the edge. */
55
+ kind?: EdgeKind;
56
+ /** Arrow head style on each end. Default: source=none, target=arrow. */
57
+ arrow?: {
58
+ source?: EdgeArrow;
59
+ target?: EdgeArrow;
60
+ };
61
+ }
62
+ type FlowDirection = 'TB' | 'BT' | 'LR' | 'RL';
63
+ interface SubgraphIR {
64
+ id: string;
65
+ label: string;
66
+ /** Optional nested subgraphs. */
67
+ subgraphs?: SubgraphIR[];
68
+ }
69
+ interface FlowchartIR {
70
+ type: 'flowchart';
71
+ direction: FlowDirection;
72
+ nodes: NodeIR[];
73
+ edges: EdgeIR[];
74
+ subgraphs?: SubgraphIR[];
75
+ }
76
+ /** ER diagrams reuse the existing ParsedSchema shape so DbSchemaFlow can
77
+ * consume the IR with zero conversion. */
78
+ interface ERDiagramIR {
79
+ type: 'er';
80
+ schema: ParsedSchema;
81
+ }
82
+ interface PieSlice {
83
+ label: string;
84
+ value: number;
85
+ }
86
+ interface PieChartIR {
87
+ type: 'pie';
88
+ title?: string;
89
+ slices: PieSlice[];
90
+ /** Whether the percentage label was opted-in via `pie showData`. */
91
+ showData?: boolean;
92
+ }
93
+ interface QuadrantPoint {
94
+ label: string;
95
+ /** Both in 0..1 range. */
96
+ x: number;
97
+ y: number;
98
+ }
99
+ interface QuadrantChartIR {
100
+ type: 'quadrant';
101
+ title?: string;
102
+ xAxisLabel?: {
103
+ low: string;
104
+ high: string;
105
+ };
106
+ yAxisLabel?: {
107
+ low: string;
108
+ high: string;
109
+ };
110
+ /** Quadrants in standard math order: 1=top-right, 2=top-left, 3=bottom-left, 4=bottom-right. */
111
+ quadrantLabels?: {
112
+ q1?: string;
113
+ q2?: string;
114
+ q3?: string;
115
+ q4?: string;
116
+ };
117
+ points: QuadrantPoint[];
118
+ }
119
+ interface JourneyTask {
120
+ label: string;
121
+ score: number;
122
+ actors: string[];
123
+ }
124
+ interface JourneySection {
125
+ title: string;
126
+ tasks: JourneyTask[];
127
+ }
128
+ interface JourneyIR {
129
+ type: 'journey';
130
+ title?: string;
131
+ sections: JourneySection[];
132
+ }
133
+ type SequenceArrow = 'sync' | 'reply' | 'async' | 'cross';
134
+ interface SequenceParticipant {
135
+ id: string;
136
+ label: string;
137
+ }
138
+ interface SequenceMessage {
139
+ kind: 'message';
140
+ from: string;
141
+ to: string;
142
+ arrow: SequenceArrow;
143
+ label: string;
144
+ }
145
+ interface SequenceNote {
146
+ kind: 'note';
147
+ /** Side relative to the participant(s) the note is anchored to. */
148
+ side: 'left' | 'right' | 'over';
149
+ participants: string[];
150
+ text: string;
151
+ }
152
+ type SequenceStep = SequenceMessage | SequenceNote;
153
+ interface SequenceIR {
154
+ type: 'sequence';
155
+ title?: string;
156
+ participants: SequenceParticipant[];
157
+ steps: SequenceStep[];
158
+ }
159
+ /** Discriminated union of every native IR type the renderer registry knows
160
+ * how to draw. Other diagram types still fall through to the mermaid
161
+ * fallback path until a renderer is registered for them. */
162
+ type ClassMemberKind = 'attribute' | 'method';
163
+ type ClassVisibility = 'public' | 'private' | 'protected' | 'package';
164
+ interface ClassMember {
165
+ kind: ClassMemberKind;
166
+ visibility?: ClassVisibility;
167
+ name: string;
168
+ /** Type for attributes; return-or-empty for methods. */
169
+ returnType?: string;
170
+ /** Comma-separated parameter list (string for now; we don't model them). */
171
+ parameters?: string;
172
+ }
173
+ interface ClassNode {
174
+ id: string;
175
+ label: string;
176
+ members: ClassMember[];
177
+ /** Stereotype like `<<interface>>` or `<<abstract>>`. */
178
+ stereotype?: string;
179
+ }
180
+ type ClassRelationKind = 'inheritance' | 'composition' | 'aggregation' | 'association' | 'dependency' | 'realization';
181
+ interface ClassRelation {
182
+ source: string;
183
+ target: string;
184
+ kind: ClassRelationKind;
185
+ label?: string;
186
+ }
187
+ interface ClassDiagramIR {
188
+ type: 'class';
189
+ classes: ClassNode[];
190
+ relations: ClassRelation[];
191
+ }
192
+ interface StateNode {
193
+ id: string;
194
+ label: string;
195
+ /** Special states: [*] start/end markers; `composite` wraps nested states. */
196
+ kind: 'state' | 'start' | 'end' | 'choice' | 'composite';
197
+ /** Parent composite-state id; top-level states have none. */
198
+ parent?: string;
199
+ }
200
+ interface StateTransition {
201
+ source: string;
202
+ target: string;
203
+ /** Optional guard / event label. */
204
+ label?: string;
205
+ /** The composite (if any) this transition lives inside. */
206
+ parent?: string;
207
+ }
208
+ interface StateDiagramIR {
209
+ type: 'state';
210
+ states: StateNode[];
211
+ transitions: StateTransition[];
212
+ }
213
+ type GanttItemStatus = 'default' | 'active' | 'done' | 'crit' | 'milestone';
214
+ interface GanttTask {
215
+ id: string;
216
+ label: string;
217
+ /** ISO date string (YYYY-MM-DD or full ISO). */
218
+ start: string;
219
+ /** ISO date string (exclusive end). For milestones equals start. */
220
+ end: string;
221
+ status: GanttItemStatus;
222
+ /** Group / section the task belongs to. */
223
+ section?: string;
224
+ }
225
+ interface GanttDiagramIR {
226
+ type: 'gantt';
227
+ title?: string;
228
+ /** Original `dateFormat` directive — informational, parser already
229
+ * normalizes start/end to ISO. */
230
+ dateFormat?: string;
231
+ /** Optional axis format passed to the timeline renderer. */
232
+ axisFormat?: string;
233
+ tasks: GanttTask[];
234
+ }
235
+ interface TimelineEvent {
236
+ id: string;
237
+ /** Period label, e.g. "2003" / "Q1 2026" / "Day 1". */
238
+ period: string;
239
+ /** Free text describing the event(s) at this period. */
240
+ text: string;
241
+ /** Section this event belongs to, if any. */
242
+ section?: string;
243
+ }
244
+ interface TimelineIR {
245
+ type: 'timeline';
246
+ title?: string;
247
+ events: TimelineEvent[];
248
+ }
249
+ type MindmapShape = 'default' | 'square' | 'rounded' | 'circle' | 'cloud' | 'bang' | 'hexagon';
250
+ interface MindmapNode {
251
+ id: string;
252
+ label: string;
253
+ shape: MindmapShape;
254
+ children: MindmapNode[];
255
+ /** Optional iconify-style ref. */
256
+ icon?: string;
257
+ }
258
+ interface MindmapIR {
259
+ type: 'mindmap';
260
+ root: MindmapNode;
261
+ }
262
+ type ArchSide = 'L' | 'R' | 'T' | 'B';
263
+ interface ArchitectureNode {
264
+ id: string;
265
+ label: string;
266
+ kind: 'group' | 'service';
267
+ /** Iconify-style ref (e.g. `logos:aws-rds`, `cloud`, `database`). */
268
+ icon?: string;
269
+ /** Parent group id when nested. */
270
+ parent?: string;
271
+ }
272
+ interface ArchitectureEdge {
273
+ source: string;
274
+ target: string;
275
+ sourceSide?: ArchSide;
276
+ targetSide?: ArchSide;
277
+ label?: string;
278
+ }
279
+ interface ArchitectureIR {
280
+ type: 'architecture';
281
+ nodes: ArchitectureNode[];
282
+ edges: ArchitectureEdge[];
283
+ }
284
+ type C4Variant = 'context' | 'container' | 'component' | 'deployment';
285
+ type C4ElementKind = 'person' | 'person-external' | 'system' | 'system-external' | 'system-db' | 'system-queue' | 'container' | 'container-external' | 'container-db' | 'container-queue' | 'component' | 'component-external' | 'component-db' | 'component-queue' | 'boundary' | 'system-boundary' | 'container-boundary' | 'enterprise-boundary' | 'node';
286
+ interface C4Element {
287
+ id: string;
288
+ kind: C4ElementKind;
289
+ label: string;
290
+ technology?: string;
291
+ description?: string;
292
+ parent?: string;
293
+ }
294
+ interface C4Relation {
295
+ source: string;
296
+ target: string;
297
+ label?: string;
298
+ technology?: string;
299
+ }
300
+ interface C4IR {
301
+ type: 'c4';
302
+ variant: C4Variant;
303
+ title?: string;
304
+ elements: C4Element[];
305
+ relations: C4Relation[];
306
+ }
307
+ type GitGraphOp = {
308
+ kind: 'commit';
309
+ id?: string;
310
+ type?: 'NORMAL' | 'REVERSE' | 'HIGHLIGHT';
311
+ tag?: string;
312
+ } | {
313
+ kind: 'branch';
314
+ name: string;
315
+ } | {
316
+ kind: 'checkout';
317
+ name: string;
318
+ } | {
319
+ kind: 'merge';
320
+ from: string;
321
+ tag?: string;
322
+ } | {
323
+ kind: 'cherry-pick';
324
+ commitId: string;
325
+ };
326
+ interface GitGraphIR {
327
+ type: 'gitgraph';
328
+ title?: string;
329
+ ops: GitGraphOp[];
330
+ }
331
+ type DiagramIR = FlowchartIR | ERDiagramIR | PieChartIR | QuadrantChartIR | JourneyIR | SequenceIR | ClassDiagramIR | StateDiagramIR | GanttDiagramIR | TimelineIR | MindmapIR | ArchitectureIR | C4IR | GitGraphIR;
332
+ type DiagramType = DiagramIR['type'];
333
+ /** Surface-level diagram-type label inferred from a mermaid source string.
334
+ * Includes types that have no native renderer yet (`'unsupported'`).
335
+ * Used by the registry to decide whether to dispatch native or fall back. */
336
+ type RecognizedDiagramType = DiagramType | 'sequence' | 'class' | 'state' | 'gantt' | 'pie' | 'quadrant' | 'mindmap' | 'gitgraph' | 'timeline' | 'journey' | 'c4' | 'architecture' | 'unsupported';
337
+ /** A successful parse: the inferred type plus its IR. Every recognized type
338
+ * has a native renderer, so `ir` is always populated when `ok === true`. */
339
+ interface ParseSuccess {
340
+ ok: true;
341
+ type: DiagramType;
342
+ ir: DiagramIR;
343
+ }
344
+ interface ParseFailure {
345
+ ok: false;
346
+ error: string;
347
+ /** Original source preserved so callers can show diagnostics. */
348
+ source: string;
349
+ }
350
+ type ParseResult = ParseSuccess | ParseFailure;
351
+
352
+ /** What every renderer exposes via a forwarded ref so the export pipeline
353
+ * can serialize the diagram to SVG/PNG without knowing the renderer's
354
+ * internals. */
355
+ interface RendererHandle {
356
+ /** Returns an SVG element representing the diagram. For renderers that
357
+ * produce a single inclusive <svg> (Sequence, Recharts, mermaid fallback)
358
+ * this is the live element; for renderers that mix HTML + SVG (ReactFlow,
359
+ * vis-timeline) it's a synthetic <svg> wrapping the HTML as foreignObject. */
360
+ getSvgElement(): SVGSVGElement | null;
361
+ /** Optional HTML container reference, used by the export pipeline as a
362
+ * more reliable source for PNG rasterization (canvas + foreignObject is
363
+ * unreliable across browsers). */
364
+ getHtmlContainer?(): HTMLElement | null;
365
+ }
366
+ /** Narrow DiagramIR to the IR variant a particular renderer accepts. */
367
+ type IRForType<T extends DiagramType> = T extends 'flowchart' ? FlowchartIR : T extends 'er' ? ERDiagramIR : T extends 'pie' ? PieChartIR : T extends 'quadrant' ? QuadrantChartIR : T extends 'journey' ? JourneyIR : T extends 'sequence' ? SequenceIR : T extends 'class' ? ClassDiagramIR : T extends 'state' ? StateDiagramIR : T extends 'gantt' ? GanttDiagramIR : T extends 'timeline' ? TimelineIR : T extends 'mindmap' ? MindmapIR : T extends 'architecture' ? ArchitectureIR : T extends 'c4' ? C4IR : T extends 'gitgraph' ? GitGraphIR : DiagramIR;
368
+ interface RendererProps<T extends DiagramType = DiagramType> {
369
+ ir: IRForType<T>;
370
+ /** Dark-mode flag; renderers honor it for color tokens. */
371
+ dark?: boolean;
372
+ /** Ref the renderer will populate with a RendererHandle on mount. */
373
+ handleRef?: RefObject<RendererHandle | null>;
374
+ }
375
+ interface RendererEntry<T extends DiagramType = DiagramType> {
376
+ type: T;
377
+ /** Lazy loader — only resolved when an IR of this type needs to render. */
378
+ loader: () => Promise<{
379
+ default: ComponentType<RendererProps<T>>;
380
+ }>;
381
+ }
382
+ declare function register<T extends DiagramType>(entry: RendererEntry<T>): void;
383
+ declare function getRenderer(type: DiagramType): RendererEntry | null;
384
+ declare function hasRenderer(type: DiagramType): boolean;
385
+ /** Reset the registry. Test-only. */
386
+ declare function _resetRegistry(): void;
387
+
388
+ interface DiagramRendererProps {
389
+ /** Mermaid-syntax source string. */
390
+ source: string;
391
+ /** Dark-mode flag; threaded through to the underlying renderer. */
392
+ dark?: boolean;
393
+ /** Ref to populate with a RendererHandle so the export toolbar can grab the SVG. */
394
+ handleRef?: RefObject<RendererHandle | null>;
395
+ /** Optional `onError` for parse / render failures. */
396
+ onError?: (message: string) => void;
397
+ }
398
+ /**
399
+ * Dispatch component. Parses the source to a DiagramIR, then delegates to
400
+ * the matching renderer in the registry.
401
+ *
402
+ * Every diagram type the registry knows about renders natively — there is
403
+ * no mermaid fallback. Unrecognized sources surface a clear error.
404
+ */
405
+ declare function DiagramRenderer({ source, dark, handleRef, onError }: DiagramRendererProps): react_jsx_runtime.JSX.Element;
406
+
407
+ type SvgSource = string | SVGSVGElement | (() => SVGSVGElement | null);
408
+ interface PngOptions {
409
+ /** Canvas resolution multiplier. Default: 2 (Retina-friendly). */
410
+ scale?: number;
411
+ /** Background color. Pass `null` for transparent. Default: `'#ffffff'`. */
412
+ background?: string | null;
413
+ }
414
+ interface SvgStringOptions {
415
+ /**
416
+ * When the source is a DOM element, copy `getComputedStyle()` values onto
417
+ * inline `style="…"` attributes so the standalone SVG carries its own
418
+ * presentation. Set to `false` if the source is already self-contained
419
+ * (e.g. SVG built by a custom renderer that emits inline attributes).
420
+ * Default: true.
421
+ */
422
+ inlineStyles?: boolean;
423
+ /**
424
+ * Strip <foreignObject> elements from the output. Required for canvas-based
425
+ * PNG conversion (browsers can't rasterize foreignObject). Default: true.
426
+ */
427
+ stripForeignObject?: boolean;
428
+ }
429
+ declare const INLINEABLE_STYLE_PROPS: readonly string[];
430
+ /**
431
+ * Convert any `SvgSource` to a self-contained SVG string.
432
+ *
433
+ * Pipeline for DOM sources:
434
+ * 1. Clone the element (no live-DOM mutation)
435
+ * 2. Ensure xmlns / xmlns:xlink namespace declarations are present
436
+ * 3. Walk live + clone in parallel and inline computed styles onto the clone
437
+ * 4. Strip <foreignObject> children (break canvas-based PNG conversion)
438
+ * 5. Serialize via XMLSerializer
439
+ */
440
+ declare function toSvgString(source: SvgSource, options?: SvgStringOptions): string;
441
+ /**
442
+ * Extracts intrinsic dimensions from an SVG string.
443
+ * Preference: viewBox → width/height attributes → fallback (800×600).
444
+ *
445
+ * Uses regex rather than DOMParser to stay bulletproof across XML namespace
446
+ * quirks (jsdom's DOMParser is fussier than browser DOMParser about
447
+ * `image/svg+xml` parse mode + querySelector).
448
+ */
449
+ declare function getSvgDimensions(svg: string): {
450
+ width: number;
451
+ height: number;
452
+ };
453
+ /** Convert an SVG string to a PNG `Blob` via an offscreen `<canvas>`. */
454
+ declare function svgToPngBlob(svg: string, options?: PngOptions): Promise<Blob>;
455
+ /** Download the SVG as a file. Preserves <foreignObject> so renderers that
456
+ * embed HTML (ReactFlow nodes, vis-timeline) export their full visual,
457
+ * not just the edges layer. */
458
+ declare function downloadSvg(source: SvgSource, filename: string): Promise<void>;
459
+ /** Download the diagram as PNG. */
460
+ declare function downloadPng(source: SvgSource, filename: string, options?: PngOptions): Promise<void>;
461
+ /** Copy the SVG markup to the clipboard as plain text. */
462
+ declare function copySvgToClipboard(source: SvgSource): Promise<void>;
463
+ /** Copy the diagram to the clipboard as a PNG image. */
464
+ declare function copyPngToClipboard(source: SvgSource, options?: PngOptions): Promise<void>;
465
+
466
+ interface DiagramExportToolbarProps {
467
+ source: SvgSource;
468
+ /** Filename prefix (no extension). Default: "diagram". */
469
+ filenameBase?: string;
470
+ /** PNG canvas resolution multiplier. Default: 2. */
471
+ pngScale?: number;
472
+ /** PNG background color. Pass `null` for transparent. Default: white. */
473
+ pngBackground?: string | null;
474
+ /** Outer container class (positioning, opacity, etc.). */
475
+ className?: string;
476
+ /** Called when an export operation throws. Default: silent. */
477
+ onError?: (error: Error) => void;
478
+ }
479
+ declare function DiagramExportToolbar({ source, filenameBase, pngScale, pngBackground, className, onError, }: DiagramExportToolbarProps): react_jsx_runtime.JSX.Element;
480
+
481
+ type FlowchartRendererProps = RendererProps<'flowchart'>;
482
+ declare function FlowchartRenderer({ ir, dark, handleRef }: FlowchartRendererProps): react_jsx_runtime.JSX.Element;
483
+
484
+ type ERRendererProps = RendererProps<'er'>;
485
+ declare function ERRenderer({ ir, dark, handleRef }: ERRendererProps): react_jsx_runtime.JSX.Element;
486
+
487
+ type PieRendererProps = RendererProps<'pie'>;
488
+ declare function PieRenderer({ ir, dark, handleRef }: PieRendererProps): react_jsx_runtime.JSX.Element;
489
+
490
+ type QuadrantRendererProps = RendererProps<'quadrant'>;
491
+ declare function QuadrantRenderer({ ir, dark, handleRef }: QuadrantRendererProps): react_jsx_runtime.JSX.Element;
492
+
493
+ type JourneyRendererProps = RendererProps<'journey'>;
494
+ declare function JourneyRenderer({ ir, dark, handleRef }: JourneyRendererProps): react_jsx_runtime.JSX.Element;
495
+
496
+ type SequenceRendererProps = RendererProps<'sequence'>;
497
+ declare function SequenceRenderer({ ir, dark, handleRef }: SequenceRendererProps): react_jsx_runtime.JSX.Element;
498
+
499
+ type ClassRendererProps = RendererProps<'class'>;
500
+ declare function ClassRenderer({ ir, dark, handleRef }: ClassRendererProps): react_jsx_runtime.JSX.Element;
501
+
502
+ type StateRendererProps = RendererProps<'state'>;
503
+ declare function StateRenderer({ ir, dark, handleRef }: StateRendererProps): react_jsx_runtime.JSX.Element;
504
+
505
+ type GanttRendererProps = RendererProps<'gantt'>;
506
+ declare function GanttRenderer({ ir, dark, handleRef }: GanttRendererProps): react_jsx_runtime.JSX.Element;
507
+
508
+ type TimelineRendererProps = RendererProps<'timeline'>;
509
+ declare function TimelineRenderer({ ir, dark, handleRef }: TimelineRendererProps): react_jsx_runtime.JSX.Element;
510
+
511
+ type MindmapRendererProps = RendererProps<'mindmap'>;
512
+ declare function MindmapRenderer({ ir, dark, handleRef }: MindmapRendererProps): react_jsx_runtime.JSX.Element;
513
+
514
+ type ArchitectureRendererProps = RendererProps<'architecture'>;
515
+ declare function ArchitectureRenderer({ ir, dark, handleRef }: ArchitectureRendererProps): react_jsx_runtime.JSX.Element;
516
+
517
+ type C4RendererProps = RendererProps<'c4'>;
518
+ declare function C4Renderer({ ir, dark, handleRef }: C4RendererProps): react_jsx_runtime.JSX.Element;
519
+
520
+ type GitGraphRendererProps = RendererProps<'gitgraph'>;
521
+ declare function GitGraphRenderer({ ir, dark, handleRef }: GitGraphRendererProps): react_jsx_runtime.JSX.Element;
522
+
523
+ declare function bootstrapDiagramRenderers(): void;
524
+
525
+ declare function detectDiagramType(source: string): Promise<RecognizedDiagramType | null>;
526
+ declare function parseToIR(source: string): Promise<ParseResult>;
527
+
528
+ interface BuildOptions$1 {
529
+ dark?: boolean;
530
+ padding?: number;
531
+ }
532
+ /** One-call flowchart → SVG. Internally runs dagre layout. */
533
+ declare function flowchartToSvg(ir: FlowchartIR, options?: BuildOptions$1): string;
534
+ /** One-call class diagram → SVG. */
535
+ declare function classToSvg(ir: ClassDiagramIR, options?: BuildOptions$1): string;
536
+ /** One-call ER diagram → SVG. */
537
+ declare function erToSvg(ir: ERDiagramIR, options?: BuildOptions$1): string;
538
+
539
+ interface BuildOptions {
540
+ dark?: boolean;
541
+ /** Outer canvas padding around the bounding box. Default: 32. */
542
+ padding?: number;
543
+ }
544
+ declare function buildFlowchartSvg(ir: FlowchartIR, positions: Map<string, {
545
+ x: number;
546
+ y: number;
547
+ }>, options?: BuildOptions): string;
548
+ interface StateBuildPositions {
549
+ /** Top-level nodes: absolute top-left. */
550
+ topLevel: Map<string, {
551
+ x: number;
552
+ y: number;
553
+ width: number;
554
+ height: number;
555
+ }>;
556
+ /** Children inside composites: position relative to composite top-left. */
557
+ children: Map<string, {
558
+ x: number;
559
+ y: number;
560
+ width: number;
561
+ height: number;
562
+ parent: string;
563
+ }>;
564
+ }
565
+ declare function buildStateSvg(ir: StateDiagramIR, positions: StateBuildPositions, options?: BuildOptions): string;
566
+ declare function buildClassSvg(ir: ClassDiagramIR, positions: Map<string, {
567
+ x: number;
568
+ y: number;
569
+ width: number;
570
+ height: number;
571
+ }>, options?: BuildOptions): string;
572
+ declare function buildErSvg(ir: ERDiagramIR, positions: Map<string, {
573
+ x: number;
574
+ y: number;
575
+ width: number;
576
+ height: number;
577
+ }>, options?: BuildOptions): string;
578
+ declare function buildMindmapSvg(ir: MindmapIR, positions: Map<string, {
579
+ x: number;
580
+ y: number;
581
+ width: number;
582
+ height: number;
583
+ depth: number;
584
+ }>, options?: BuildOptions): string;
585
+ declare function buildGanttSvg(ir: GanttDiagramIR, options?: BuildOptions): string;
586
+ declare function buildTimelineSvg(ir: TimelineIR, options?: BuildOptions): string;
587
+ declare function buildPieSvg(ir: PieChartIR, options?: BuildOptions): string;
588
+ declare function buildQuadrantSvg(ir: QuadrantChartIR, options?: BuildOptions): string;
589
+ declare function buildJourneySvg(ir: JourneyIR, options?: BuildOptions): string;
590
+ declare function buildArchitectureSvg(ir: ArchitectureIR, options?: BuildOptions): string;
591
+ declare function buildC4Svg(ir: C4IR, options?: BuildOptions): string;
592
+ declare function buildGitGraphSvg(ir: GitGraphIR, options?: BuildOptions): string;
593
+ /** Parse an SVG string to an SVGSVGElement so it can flow through the
594
+ * centralized export pipeline (which expects a DOM element). */
595
+ declare function svgStringToElement(svg: string): SVGSVGElement | null;
596
+
597
+ interface NodeSize {
598
+ width: number;
599
+ height: number;
600
+ }
601
+ interface LayoutResult {
602
+ /** Absolute top-left coordinates per node id. */
603
+ nodePositions: Map<string, {
604
+ x: number;
605
+ y: number;
606
+ }>;
607
+ /** Bounding box of the entire graph (post-padding). */
608
+ width: number;
609
+ height: number;
610
+ }
611
+ interface DagreLayoutOptions {
612
+ /** Default node size when not provided per-node. */
613
+ defaultNodeSize?: NodeSize;
614
+ /** Map of nodeId → { width, height }. Falls back to defaultNodeSize. */
615
+ nodeSizes?: Map<string, NodeSize>;
616
+ /** Spacing between sibling nodes in the same rank. Default: 60. */
617
+ nodeSeparation?: number;
618
+ /** Spacing between ranks. Default: 80. */
619
+ rankSeparation?: number;
620
+ /** Outer margin. Default: 24. */
621
+ margin?: number;
622
+ }
623
+ declare function layoutFlowchart(ir: FlowchartIR, options?: DagreLayoutOptions): LayoutResult;
624
+
625
+ /** Reads the current dark-mode flag from the `<html>` `.dark` class. */
626
+ declare function isDarkMode(): boolean;
627
+ /**
628
+ * Observes class changes on the `<html>` element and invokes the callback
629
+ * whenever the `.dark` class toggles. Returns a disposer.
630
+ */
631
+ declare function watchDarkMode(callback: (dark: boolean) => void): () => void;
632
+
633
+ interface KindStyle {
634
+ border: string;
635
+ headerBg: string;
636
+ accent: string;
637
+ bodyBg: string;
638
+ text: string;
639
+ iconColor: string;
640
+ }
641
+ interface ThemePalette {
642
+ canvasBg: string;
643
+ edgeColor: string;
644
+ edgeLabel: string;
645
+ edgeLabelBg: string;
646
+ subgraphBg: string;
647
+ subgraphBorder: string;
648
+ subgraphLabel: string;
649
+ nodeShadow: string;
650
+ byKind: Record<NodeKind, KindStyle>;
651
+ }
652
+ declare function getDiagramTheme(dark: boolean): ThemePalette;
653
+
654
+ export { type ArchSide, type ArchitectureEdge, type ArchitectureIR, type ArchitectureNode, ArchitectureRenderer, type C4Element, type C4ElementKind, type C4IR, type C4Relation, C4Renderer, type C4Variant, type ClassDiagramIR, type ClassMember, type ClassMemberKind, type ClassNode, type ClassRelation, type ClassRelationKind, ClassRenderer, type ClassVisibility, type DbColumn, type DbRelation, type DbTable, DiagramExportToolbar, type DiagramIR, DiagramRenderer, type DiagramType, type ERDiagramIR, ERRenderer, type EdgeArrow, type EdgeIR, type EdgeKind, type FlowDirection, type FlowchartIR, FlowchartRenderer, type GanttDiagramIR, type GanttItemStatus, GanttRenderer, type GanttTask, type GitGraphIR, type GitGraphOp, GitGraphRenderer, INLINEABLE_STYLE_PROPS, type IRForType, type JourneyIR, JourneyRenderer, type JourneySection, type JourneyTask, type MindmapIR, type MindmapNode, MindmapRenderer, type MindmapShape, type NodeIR, type NodeKind, type NodeSize, type ParseFailure, type ParseResult, type ParseSuccess, type ParsedSchema, type PieChartIR, PieRenderer, type PieSlice, type PngOptions, type QuadrantChartIR, type QuadrantPoint, QuadrantRenderer, type RecognizedDiagramType, type RendererEntry, type RendererHandle, type RendererProps, type SequenceArrow, type SequenceIR, type SequenceMessage, type SequenceNote, type SequenceParticipant, SequenceRenderer, type SequenceStep, type StateBuildPositions, type StateDiagramIR, type StateNode, StateRenderer, type StateTransition, type SubgraphIR, type SvgSource, type SvgStringOptions, type TimelineEvent, type TimelineIR, TimelineRenderer, _resetRegistry, bootstrapDiagramRenderers, buildArchitectureSvg, buildC4Svg, buildClassSvg, buildErSvg, buildFlowchartSvg, buildGanttSvg, buildGitGraphSvg, buildJourneySvg, buildMindmapSvg, buildPieSvg, buildQuadrantSvg, buildStateSvg, buildTimelineSvg, classToSvg, copyPngToClipboard, copySvgToClipboard, detectDiagramType, downloadPng, downloadSvg, erToSvg, flowchartToSvg, getDiagramTheme, getRenderer, getSvgDimensions, hasRenderer, isDarkMode, layoutFlowchart, parseToIR, register, svgStringToElement, svgToPngBlob, toSvgString, watchDarkMode };