@zombie-mermaid/svg-renderer 3.1.0 → 3.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 +36 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +1328 -841
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/__tests__/c4-mermaid-reference.test.ts +85 -0
- package/src/__tests__/c4-svg.test.ts +337 -0
- package/src/__tests__/class-diamond-markers-1232.test.ts +59 -0
- package/src/__tests__/er-cardinality-markers-1233.test.ts +35 -0
- package/src/__tests__/fixtures/c4-mermaid-reference.json +626 -0
- package/src/__tests__/xychart-smooth-curve.test.ts +42 -0
- package/src/c4/layout.ts +490 -0
- package/src/c4/metrics.ts +235 -0
- package/src/c4/renderer.ts +366 -0
- package/src/class/renderer.ts +7 -6
- package/src/er/renderer.ts +14 -1
- package/src/layout-engine/elk-graph-builder.ts +4 -0
- package/src/registry.ts +60 -0
- package/src/xychart/layout.ts +27 -11
- package/src/xychart/renderer.ts +33 -42
package/dist/index.d.cts
CHANGED
|
@@ -168,6 +168,9 @@ export declare function directionToElk(dir: Direction | undefined, fallback: Elk
|
|
|
168
168
|
* single fixed orientation, matching Mermaid's own TB class rendering —
|
|
169
169
|
* which `../class/layout.ts` relies on to put a `note for X` above its
|
|
170
170
|
* class.
|
|
171
|
+
* - **C4** — `DOWN`. `C4Diagram.direction` is never set by the parser (C4
|
|
172
|
+
* sources have no direction statement), only by `RenderOptions.direction`,
|
|
173
|
+
* so an unset one is the top-down layout every C4 diagram is drawn in.
|
|
171
174
|
* - **ER** — `RIGHT`. An ER diagram's `direction` is optional
|
|
172
175
|
* (`ErDiagram.direction?`), left `undefined` when the source has no
|
|
173
176
|
* `direction` statement, and this renderer has always laid those out
|
|
@@ -186,6 +189,7 @@ export declare const ELK_DIRECTION_FALLBACK: {
|
|
|
186
189
|
readonly state: "DOWN";
|
|
187
190
|
readonly class: "DOWN";
|
|
188
191
|
readonly er: "RIGHT";
|
|
192
|
+
readonly c4: "DOWN";
|
|
189
193
|
};
|
|
190
194
|
|
|
191
195
|
/** The four values ELK's `elk.direction` option accepts in this codebase. */
|
|
@@ -304,6 +308,14 @@ export declare type FontSizes = {
|
|
|
304
308
|
[K in keyof typeof FONT_SIZES]: number;
|
|
305
309
|
};
|
|
306
310
|
|
|
311
|
+
/**
|
|
312
|
+
* Format a set of evenly-spaced tick values with enough decimal places to
|
|
313
|
+
* keep every label distinct. Precision comes from the tick step, not the
|
|
314
|
+
* magnitude of the value: a 0.5 step around 100 needs one decimal, or
|
|
315
|
+
* 99.5 and 100.5 both collapse into neighbouring whole numbers.
|
|
316
|
+
*/
|
|
317
|
+
export declare function formatTickLabels(ticks: number[]): string[];
|
|
318
|
+
|
|
307
319
|
/** Vertical gap between a subgraph header band and the content area below it (px).
|
|
308
320
|
* Without this, nested subgraph headers sit flush against their parent's header band.
|
|
309
321
|
* Increased from 8 to 12 to provide more clearance for edges routing near headers. */
|
|
@@ -351,6 +363,9 @@ export declare const MONO_FONT: "'JetBrains Mono'";
|
|
|
351
363
|
/** Full CSS fallback chain for monospace text */
|
|
352
364
|
export declare const MONO_FONT_STACK: "'JetBrains Mono', 'SF Mono', 'Fira Code', ui-monospace, monospace";
|
|
353
365
|
|
|
366
|
+
/** Generate "nice" tick values for a numeric range */
|
|
367
|
+
export declare function niceTickValues(min: number, max: number): number[];
|
|
368
|
+
|
|
354
369
|
/** Padding inside node shapes */
|
|
355
370
|
export declare const NODE_PADDING: {
|
|
356
371
|
/** Horizontal padding inside rectangles/rounded/stadium (increased from 16 for better label fit) */
|
|
@@ -552,6 +567,11 @@ export declare function resolveCssColors(svg: string, colors: DiagramColors): st
|
|
|
552
567
|
*/
|
|
553
568
|
export declare function resolveFontSizes(overrides?: FontSizeOptions): FontSizes;
|
|
554
569
|
|
|
570
|
+
export declare function smoothCurvePath(points: Array<{
|
|
571
|
+
x: number;
|
|
572
|
+
y: number;
|
|
573
|
+
}>): string;
|
|
574
|
+
|
|
555
575
|
/** Stroke widths per element type (in px) */
|
|
556
576
|
export declare const STROKE_WIDTHS: {
|
|
557
577
|
readonly outerBox: 1;
|
package/dist/index.d.ts
CHANGED
|
@@ -168,6 +168,9 @@ export declare function directionToElk(dir: Direction | undefined, fallback: Elk
|
|
|
168
168
|
* single fixed orientation, matching Mermaid's own TB class rendering —
|
|
169
169
|
* which `../class/layout.ts` relies on to put a `note for X` above its
|
|
170
170
|
* class.
|
|
171
|
+
* - **C4** — `DOWN`. `C4Diagram.direction` is never set by the parser (C4
|
|
172
|
+
* sources have no direction statement), only by `RenderOptions.direction`,
|
|
173
|
+
* so an unset one is the top-down layout every C4 diagram is drawn in.
|
|
171
174
|
* - **ER** — `RIGHT`. An ER diagram's `direction` is optional
|
|
172
175
|
* (`ErDiagram.direction?`), left `undefined` when the source has no
|
|
173
176
|
* `direction` statement, and this renderer has always laid those out
|
|
@@ -186,6 +189,7 @@ export declare const ELK_DIRECTION_FALLBACK: {
|
|
|
186
189
|
readonly state: "DOWN";
|
|
187
190
|
readonly class: "DOWN";
|
|
188
191
|
readonly er: "RIGHT";
|
|
192
|
+
readonly c4: "DOWN";
|
|
189
193
|
};
|
|
190
194
|
|
|
191
195
|
/** The four values ELK's `elk.direction` option accepts in this codebase. */
|
|
@@ -304,6 +308,14 @@ export declare type FontSizes = {
|
|
|
304
308
|
[K in keyof typeof FONT_SIZES]: number;
|
|
305
309
|
};
|
|
306
310
|
|
|
311
|
+
/**
|
|
312
|
+
* Format a set of evenly-spaced tick values with enough decimal places to
|
|
313
|
+
* keep every label distinct. Precision comes from the tick step, not the
|
|
314
|
+
* magnitude of the value: a 0.5 step around 100 needs one decimal, or
|
|
315
|
+
* 99.5 and 100.5 both collapse into neighbouring whole numbers.
|
|
316
|
+
*/
|
|
317
|
+
export declare function formatTickLabels(ticks: number[]): string[];
|
|
318
|
+
|
|
307
319
|
/** Vertical gap between a subgraph header band and the content area below it (px).
|
|
308
320
|
* Without this, nested subgraph headers sit flush against their parent's header band.
|
|
309
321
|
* Increased from 8 to 12 to provide more clearance for edges routing near headers. */
|
|
@@ -351,6 +363,9 @@ export declare const MONO_FONT: "'JetBrains Mono'";
|
|
|
351
363
|
/** Full CSS fallback chain for monospace text */
|
|
352
364
|
export declare const MONO_FONT_STACK: "'JetBrains Mono', 'SF Mono', 'Fira Code', ui-monospace, monospace";
|
|
353
365
|
|
|
366
|
+
/** Generate "nice" tick values for a numeric range */
|
|
367
|
+
export declare function niceTickValues(min: number, max: number): number[];
|
|
368
|
+
|
|
354
369
|
/** Padding inside node shapes */
|
|
355
370
|
export declare const NODE_PADDING: {
|
|
356
371
|
/** Horizontal padding inside rectangles/rounded/stadium (increased from 16 for better label fit) */
|
|
@@ -552,6 +567,11 @@ export declare function resolveCssColors(svg: string, colors: DiagramColors): st
|
|
|
552
567
|
*/
|
|
553
568
|
export declare function resolveFontSizes(overrides?: FontSizeOptions): FontSizes;
|
|
554
569
|
|
|
570
|
+
export declare function smoothCurvePath(points: Array<{
|
|
571
|
+
x: number;
|
|
572
|
+
y: number;
|
|
573
|
+
}>): string;
|
|
574
|
+
|
|
555
575
|
/** Stroke widths per element type (in px) */
|
|
556
576
|
export declare const STROKE_WIDTHS: {
|
|
557
577
|
readonly outerBox: 1;
|