@zombie-mermaid/svg-renderer 4.0.0 → 4.2.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/dist/index.cjs +59 -43
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +51 -1
- package/dist/index.d.ts +51 -1
- package/dist/index.js +1400 -1671
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/__tests__/flowchart-parallel-edge-lanes-1308.test.ts +168 -0
- package/src/__tests__/pie-layout.test.ts +215 -0
- package/src/__tests__/pie-svg.test.ts +194 -0
- package/src/__tests__/svg-edge-to-own-cluster-1310.test.ts +32 -0
- package/src/class/renderer.ts +2 -2
- package/src/er/renderer.ts +2 -2
- package/src/generated/mono-font-subset.ts +32 -0
- package/src/index.ts +2 -0
- package/src/layout-engine/edge-bundling.ts +79 -0
- package/src/layout-engine/to-elk.ts +15 -5
- package/src/layout-engine.ts +5 -1
- package/src/pie/layout.ts +234 -0
- package/src/pie/renderer.ts +161 -0
- package/src/registry.ts +31 -1
- package/src/styles.ts +28 -1
- package/src/title-gaps.ts +17 -2
package/dist/index.d.cts
CHANGED
|
@@ -12,11 +12,13 @@ import { FlowchartRenderOptions } from '@zombie-mermaid/core';
|
|
|
12
12
|
import { LayoutCache } from '@zombie-mermaid/core';
|
|
13
13
|
import { LayoutOptions } from 'elkjs';
|
|
14
14
|
import { MermaidGraph } from '@zombie-mermaid/core';
|
|
15
|
+
import { PieChart } from '@zombie-mermaid/mermaid-parser';
|
|
15
16
|
import { Point } from '@zombie-mermaid/core';
|
|
16
17
|
import { PositionedClassDiagram } from '@zombie-mermaid/mermaid-parser';
|
|
17
18
|
import { PositionedErDiagram } from '@zombie-mermaid/mermaid-parser';
|
|
18
19
|
import { PositionedGraph } from '@zombie-mermaid/core';
|
|
19
20
|
import { PositionedNode } from '@zombie-mermaid/core';
|
|
21
|
+
import { PositionedPieChart } from '@zombie-mermaid/mermaid-parser';
|
|
20
22
|
import { PositionedSequenceDiagram } from '@zombie-mermaid/mermaid-parser';
|
|
21
23
|
import { PositionedXYChart } from '@zombie-mermaid/mermaid-parser';
|
|
22
24
|
import { RenderOptions } from '@zombie-mermaid/core';
|
|
@@ -95,6 +97,14 @@ export declare function buildElkLeafNode(id: string, size: {
|
|
|
95
97
|
height: number;
|
|
96
98
|
}, label?: string): ElkNode;
|
|
97
99
|
|
|
100
|
+
/**
|
|
101
|
+
* SVG `<style>` block for a diagram: core's `buildStyleBlock` plus, when
|
|
102
|
+
* `hasMonoFont` is set, the self-hosted mono font subset for the `.mono`
|
|
103
|
+
* rule. The subset lives here rather than in `core` because only SVG output
|
|
104
|
+
* embeds it (#1319).
|
|
105
|
+
*/
|
|
106
|
+
export declare function buildSvgStyleBlock(font: string, hasMonoFont: boolean, nonce?: string): string;
|
|
107
|
+
|
|
98
108
|
/**
|
|
99
109
|
* Layout id for the i-th note. A class id is a run of non-whitespace
|
|
100
110
|
* (`\S+` in the parser), so an id containing a space can never collide
|
|
@@ -360,7 +370,7 @@ export declare function layoutErDiagramSync(diagram: ErDiagram, options?: ErRend
|
|
|
360
370
|
* drop-in for it wherever the graph is a flowchart. Other diagram types that
|
|
361
371
|
* share the engine (state, architecture) keep using `layoutGraphSync`.
|
|
362
372
|
*/
|
|
363
|
-
export declare function layoutFlowchartSync(
|
|
373
|
+
export declare function layoutFlowchartSync(rawGraph: MermaidGraph, options?: FlowchartRenderOptions): PositionedGraph;
|
|
364
374
|
|
|
365
375
|
/**
|
|
366
376
|
* Lay out a parsed MermaidGraph using ELK.js (synchronous).
|
|
@@ -368,6 +378,9 @@ export declare function layoutFlowchartSync(graph: MermaidGraph, options?: Flowc
|
|
|
368
378
|
*/
|
|
369
379
|
export declare function layoutGraphSync(graph: MermaidGraph, options?: FlowchartRenderOptions): PositionedGraph;
|
|
370
380
|
|
|
381
|
+
/** Lay out a parsed pie chart. Options are accepted for registry parity; none apply. */
|
|
382
|
+
export declare function layoutPieChart(chart: PieChart, _options?: unknown): PositionedPieChart;
|
|
383
|
+
|
|
371
384
|
/**
|
|
372
385
|
* Lay out a parsed sequence diagram.
|
|
373
386
|
* Returns a fully positioned diagram ready for SVG rendering.
|
|
@@ -398,6 +411,33 @@ export declare const NODE_PADDING: {
|
|
|
398
411
|
readonly diamondExtra: 24;
|
|
399
412
|
};
|
|
400
413
|
|
|
414
|
+
/** Mermaid pieRenderer.ts constants (default config and default theme). */
|
|
415
|
+
export declare const PIE: {
|
|
416
|
+
/** Frame height; the pie's own width equals it. */
|
|
417
|
+
readonly height: 450;
|
|
418
|
+
readonly margin: 40;
|
|
419
|
+
readonly legendRectSize: 18;
|
|
420
|
+
readonly legendSpacing: 4;
|
|
421
|
+
/** `pie.textPosition` default: label distance as a fraction of the radius. */
|
|
422
|
+
readonly textPosition: 0.75;
|
|
423
|
+
/** `pieOuterStrokeWidth`; the outline circle sits half of it outside the pie. */
|
|
424
|
+
readonly outerStrokeWidth: 2;
|
|
425
|
+
/** `pieTitleTextSize` */
|
|
426
|
+
readonly titleFontSize: 25;
|
|
427
|
+
/** `pieSectionTextSize` */
|
|
428
|
+
readonly sectionFontSize: 17;
|
|
429
|
+
/** `pieLegendTextSize` */
|
|
430
|
+
readonly legendFontSize: 17;
|
|
431
|
+
readonly fontWeight: 400;
|
|
432
|
+
/** Mermaid's `pie1`..`pie12` scale wraps after this many colours. */
|
|
433
|
+
readonly paletteSize: 12;
|
|
434
|
+
/** Slices below this percentage of the total are not drawn. */
|
|
435
|
+
readonly minPercent: 1;
|
|
436
|
+
};
|
|
437
|
+
|
|
438
|
+
/** CSS value for palette slot `index`: slot 0 follows `--accent` live. */
|
|
439
|
+
export declare function pieColorValue(index: number, accent: string | undefined, bg: string): string;
|
|
440
|
+
|
|
401
441
|
/**
|
|
402
442
|
* Build the `d` attribute for an edge's routed points under `curve`.
|
|
403
443
|
*
|
|
@@ -506,6 +546,16 @@ export declare function renderMermaidSVGAsync(text: string, options?: RenderOpti
|
|
|
506
546
|
/** @deprecated Use `renderMermaidSVG` */
|
|
507
547
|
export declare const renderMermaidSync: typeof renderMermaidSVG;
|
|
508
548
|
|
|
549
|
+
/**
|
|
550
|
+
* Render a positioned pie chart as an SVG string.
|
|
551
|
+
*
|
|
552
|
+
* The accessible name is `title` (from `options.title`) when given,
|
|
553
|
+
* otherwise the chart's own `accTitle`; `accDescr` becomes the root
|
|
554
|
+
* `<desc>`. Both are dropped when `decorative` is set — see svgOpenTag() in
|
|
555
|
+
* packages/core/src/theme.ts.
|
|
556
|
+
*/
|
|
557
|
+
export declare function renderPieSvg(chart: PositionedPieChart, colors: DiagramColors, font?: string, transparent?: boolean, embedSource?: string, title?: string, decorative?: boolean, emit?: SvgEmitOptions): string;
|
|
558
|
+
|
|
509
559
|
/**
|
|
510
560
|
* Render a positioned sequence diagram as an SVG string.
|
|
511
561
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -12,11 +12,13 @@ import { FlowchartRenderOptions } from '@zombie-mermaid/core';
|
|
|
12
12
|
import { LayoutCache } from '@zombie-mermaid/core';
|
|
13
13
|
import { LayoutOptions } from 'elkjs';
|
|
14
14
|
import { MermaidGraph } from '@zombie-mermaid/core';
|
|
15
|
+
import { PieChart } from '@zombie-mermaid/mermaid-parser';
|
|
15
16
|
import { Point } from '@zombie-mermaid/core';
|
|
16
17
|
import { PositionedClassDiagram } from '@zombie-mermaid/mermaid-parser';
|
|
17
18
|
import { PositionedErDiagram } from '@zombie-mermaid/mermaid-parser';
|
|
18
19
|
import { PositionedGraph } from '@zombie-mermaid/core';
|
|
19
20
|
import { PositionedNode } from '@zombie-mermaid/core';
|
|
21
|
+
import { PositionedPieChart } from '@zombie-mermaid/mermaid-parser';
|
|
20
22
|
import { PositionedSequenceDiagram } from '@zombie-mermaid/mermaid-parser';
|
|
21
23
|
import { PositionedXYChart } from '@zombie-mermaid/mermaid-parser';
|
|
22
24
|
import { RenderOptions } from '@zombie-mermaid/core';
|
|
@@ -95,6 +97,14 @@ export declare function buildElkLeafNode(id: string, size: {
|
|
|
95
97
|
height: number;
|
|
96
98
|
}, label?: string): ElkNode;
|
|
97
99
|
|
|
100
|
+
/**
|
|
101
|
+
* SVG `<style>` block for a diagram: core's `buildStyleBlock` plus, when
|
|
102
|
+
* `hasMonoFont` is set, the self-hosted mono font subset for the `.mono`
|
|
103
|
+
* rule. The subset lives here rather than in `core` because only SVG output
|
|
104
|
+
* embeds it (#1319).
|
|
105
|
+
*/
|
|
106
|
+
export declare function buildSvgStyleBlock(font: string, hasMonoFont: boolean, nonce?: string): string;
|
|
107
|
+
|
|
98
108
|
/**
|
|
99
109
|
* Layout id for the i-th note. A class id is a run of non-whitespace
|
|
100
110
|
* (`\S+` in the parser), so an id containing a space can never collide
|
|
@@ -360,7 +370,7 @@ export declare function layoutErDiagramSync(diagram: ErDiagram, options?: ErRend
|
|
|
360
370
|
* drop-in for it wherever the graph is a flowchart. Other diagram types that
|
|
361
371
|
* share the engine (state, architecture) keep using `layoutGraphSync`.
|
|
362
372
|
*/
|
|
363
|
-
export declare function layoutFlowchartSync(
|
|
373
|
+
export declare function layoutFlowchartSync(rawGraph: MermaidGraph, options?: FlowchartRenderOptions): PositionedGraph;
|
|
364
374
|
|
|
365
375
|
/**
|
|
366
376
|
* Lay out a parsed MermaidGraph using ELK.js (synchronous).
|
|
@@ -368,6 +378,9 @@ export declare function layoutFlowchartSync(graph: MermaidGraph, options?: Flowc
|
|
|
368
378
|
*/
|
|
369
379
|
export declare function layoutGraphSync(graph: MermaidGraph, options?: FlowchartRenderOptions): PositionedGraph;
|
|
370
380
|
|
|
381
|
+
/** Lay out a parsed pie chart. Options are accepted for registry parity; none apply. */
|
|
382
|
+
export declare function layoutPieChart(chart: PieChart, _options?: unknown): PositionedPieChart;
|
|
383
|
+
|
|
371
384
|
/**
|
|
372
385
|
* Lay out a parsed sequence diagram.
|
|
373
386
|
* Returns a fully positioned diagram ready for SVG rendering.
|
|
@@ -398,6 +411,33 @@ export declare const NODE_PADDING: {
|
|
|
398
411
|
readonly diamondExtra: 24;
|
|
399
412
|
};
|
|
400
413
|
|
|
414
|
+
/** Mermaid pieRenderer.ts constants (default config and default theme). */
|
|
415
|
+
export declare const PIE: {
|
|
416
|
+
/** Frame height; the pie's own width equals it. */
|
|
417
|
+
readonly height: 450;
|
|
418
|
+
readonly margin: 40;
|
|
419
|
+
readonly legendRectSize: 18;
|
|
420
|
+
readonly legendSpacing: 4;
|
|
421
|
+
/** `pie.textPosition` default: label distance as a fraction of the radius. */
|
|
422
|
+
readonly textPosition: 0.75;
|
|
423
|
+
/** `pieOuterStrokeWidth`; the outline circle sits half of it outside the pie. */
|
|
424
|
+
readonly outerStrokeWidth: 2;
|
|
425
|
+
/** `pieTitleTextSize` */
|
|
426
|
+
readonly titleFontSize: 25;
|
|
427
|
+
/** `pieSectionTextSize` */
|
|
428
|
+
readonly sectionFontSize: 17;
|
|
429
|
+
/** `pieLegendTextSize` */
|
|
430
|
+
readonly legendFontSize: 17;
|
|
431
|
+
readonly fontWeight: 400;
|
|
432
|
+
/** Mermaid's `pie1`..`pie12` scale wraps after this many colours. */
|
|
433
|
+
readonly paletteSize: 12;
|
|
434
|
+
/** Slices below this percentage of the total are not drawn. */
|
|
435
|
+
readonly minPercent: 1;
|
|
436
|
+
};
|
|
437
|
+
|
|
438
|
+
/** CSS value for palette slot `index`: slot 0 follows `--accent` live. */
|
|
439
|
+
export declare function pieColorValue(index: number, accent: string | undefined, bg: string): string;
|
|
440
|
+
|
|
401
441
|
/**
|
|
402
442
|
* Build the `d` attribute for an edge's routed points under `curve`.
|
|
403
443
|
*
|
|
@@ -506,6 +546,16 @@ export declare function renderMermaidSVGAsync(text: string, options?: RenderOpti
|
|
|
506
546
|
/** @deprecated Use `renderMermaidSVG` */
|
|
507
547
|
export declare const renderMermaidSync: typeof renderMermaidSVG;
|
|
508
548
|
|
|
549
|
+
/**
|
|
550
|
+
* Render a positioned pie chart as an SVG string.
|
|
551
|
+
*
|
|
552
|
+
* The accessible name is `title` (from `options.title`) when given,
|
|
553
|
+
* otherwise the chart's own `accTitle`; `accDescr` becomes the root
|
|
554
|
+
* `<desc>`. Both are dropped when `decorative` is set — see svgOpenTag() in
|
|
555
|
+
* packages/core/src/theme.ts.
|
|
556
|
+
*/
|
|
557
|
+
export declare function renderPieSvg(chart: PositionedPieChart, colors: DiagramColors, font?: string, transparent?: boolean, embedSource?: string, title?: string, decorative?: boolean, emit?: SvgEmitOptions): string;
|
|
558
|
+
|
|
509
559
|
/**
|
|
510
560
|
* Render a positioned sequence diagram as an SVG string.
|
|
511
561
|
*
|