@zombie-mermaid/core 4.0.0 → 4.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.
package/dist/index.d.cts CHANGED
@@ -63,22 +63,15 @@ export declare function applyInitConfig(options: RenderOptions, config: InitConf
63
63
  * Any other value is treated as a literal font name: sanitized and quoted
64
64
  * exactly as before.
65
65
  *
66
- * `hasMonoFont`'s `.mono` rule (class-diagram method signatures, ER-diagram
67
- * attribute types) never reaches out to Google Fonts at all — it used to
68
- * `@import` 'JetBrains Mono' from Google's CDN, a third-party network
69
- * dependency a published library's default SVG output had no business
70
- * making (#1061, filed as a follow-up from #1059's ASCII-side self-hosting
71
- * fix). It now embeds {@link SVG_MONO_FONT_FACE_CSS} — a small, subsetted
72
- * (Basic Latin + Latin-1 Supplement), self-hosted `@font-face` as a base64
73
- * `woff2` data URI, generated by scripts/build-mono-font-subset.ts into
74
- * ./generated/mono-font-subset.ts — directly in the SVG's own `<style>`
75
- * block. Unlike `font` above, this isn't caller-configurable: it's the same
76
- * embed for every consumer, on by default, with no network request either
77
- * way — a strict improvement over the dead-or-alive CDN fetch it replaces,
78
- * and the only way a *standalone* SVG (no surrounding host page providing
79
- * its own copy of the font) renders `.mono` text correctly out of the box.
66
+ * `mono`'s `.mono` rule (class-diagram method signatures, ER-diagram
67
+ * attribute types) never reaches out to Google Fonts at all. The caller
68
+ * supplies a self-hosted {@link MonoFontEmbed} (a base64 `woff2` `@font-face`
69
+ * plus its family name), which is inlined directly in the SVG's own `<style>`
70
+ * block (#1061). The font data itself lives in `@zombie-mermaid/svg-renderer`
71
+ * (see its `buildSvgStyleBlock`), not here, so ASCII-only consumers of
72
+ * `core` never carry it (#1319). Pass `false` to omit the `.mono` rule.
80
73
  */
81
- export declare function buildStyleBlock(font: string, hasMonoFont: boolean, nonce?: string): string;
74
+ export declare function buildStyleBlock(font: string, mono: MonoFontEmbed | false, nonce?: string): string;
82
75
 
83
76
  /**
84
77
  * Options applicable to class diagrams (`classDiagram`). Class diagrams use
@@ -292,6 +285,15 @@ export declare interface InitConfig {
292
285
  /** True when `value` is one of the five directions Mermaid recognizes. */
293
286
  export declare function isDirection(value: string): value is Direction;
294
287
 
288
+ /**
289
+ * True when one endpoint of `edge` is a subgraph id and the other is a node or
290
+ * subgraph nested inside it, at any depth.
291
+ */
292
+ export declare function isEdgeWithinOwnCluster(edge: {
293
+ source: string;
294
+ target: string;
295
+ }, subgraphById: Map<string, MermaidSubgraph>): boolean;
296
+
295
297
  /** True if `line` is an init directive. */
296
298
  export declare function isInitDirective(line: string): boolean;
297
299
 
@@ -451,6 +453,17 @@ export declare function mixHexColors(fg: string, bg: string, pct: number): strin
451
453
  */
452
454
  export declare function mixSrgb(c1: RgbaColor, c2: RgbaColor, p1?: number, p2?: number): RgbaColor | null;
453
455
 
456
+ /**
457
+ * A self-hosted monospace font a caller embeds in the SVG `<style>` block
458
+ * for the `.mono` rule. See `buildStyleBlock`.
459
+ */
460
+ export declare interface MonoFontEmbed {
461
+ /** Font family name, listed first in the `.mono` rule's font stack. */
462
+ family: string;
463
+ /** The complete `@font-face { ... }` rule (typically a base64 data URI). */
464
+ faceCss: string;
465
+ }
466
+
454
467
  /** Metrics for multi-line text measurement */
455
468
  export declare interface MultilineMetrics {
456
469
  /** Maximum line width in pixels */
@@ -1243,6 +1256,16 @@ export declare function withDirectionOverride<T extends {
1243
1256
  direction?: Direction;
1244
1257
  }>(diagram: T, override: Direction | undefined): T;
1245
1258
 
1259
+ /**
1260
+ * `graph` without its edges between a node and a subgraph that contains it.
1261
+ * The parser also registers a subgraph id used as an edge endpoint as a
1262
+ * placeholder entry in `graph.nodes`; one no remaining edge refers to is
1263
+ * removed too, so the result equals the graph parsed without those edges.
1264
+ * Returns `graph` itself (same reference) when it has none, and never mutates
1265
+ * its input.
1266
+ */
1267
+ export declare function withoutOwnClusterEdges(graph: MermaidGraph): MermaidGraph;
1268
+
1246
1269
  /**
1247
1270
  * Options applicable to XY charts (`xychart-beta`). XY charts have no
1248
1271
  * spacing/`direction`/`curve`/`fontSizes`/`layoutCache` concept (layout is
package/dist/index.d.ts CHANGED
@@ -63,22 +63,15 @@ export declare function applyInitConfig(options: RenderOptions, config: InitConf
63
63
  * Any other value is treated as a literal font name: sanitized and quoted
64
64
  * exactly as before.
65
65
  *
66
- * `hasMonoFont`'s `.mono` rule (class-diagram method signatures, ER-diagram
67
- * attribute types) never reaches out to Google Fonts at all — it used to
68
- * `@import` 'JetBrains Mono' from Google's CDN, a third-party network
69
- * dependency a published library's default SVG output had no business
70
- * making (#1061, filed as a follow-up from #1059's ASCII-side self-hosting
71
- * fix). It now embeds {@link SVG_MONO_FONT_FACE_CSS} — a small, subsetted
72
- * (Basic Latin + Latin-1 Supplement), self-hosted `@font-face` as a base64
73
- * `woff2` data URI, generated by scripts/build-mono-font-subset.ts into
74
- * ./generated/mono-font-subset.ts — directly in the SVG's own `<style>`
75
- * block. Unlike `font` above, this isn't caller-configurable: it's the same
76
- * embed for every consumer, on by default, with no network request either
77
- * way — a strict improvement over the dead-or-alive CDN fetch it replaces,
78
- * and the only way a *standalone* SVG (no surrounding host page providing
79
- * its own copy of the font) renders `.mono` text correctly out of the box.
66
+ * `mono`'s `.mono` rule (class-diagram method signatures, ER-diagram
67
+ * attribute types) never reaches out to Google Fonts at all. The caller
68
+ * supplies a self-hosted {@link MonoFontEmbed} (a base64 `woff2` `@font-face`
69
+ * plus its family name), which is inlined directly in the SVG's own `<style>`
70
+ * block (#1061). The font data itself lives in `@zombie-mermaid/svg-renderer`
71
+ * (see its `buildSvgStyleBlock`), not here, so ASCII-only consumers of
72
+ * `core` never carry it (#1319). Pass `false` to omit the `.mono` rule.
80
73
  */
81
- export declare function buildStyleBlock(font: string, hasMonoFont: boolean, nonce?: string): string;
74
+ export declare function buildStyleBlock(font: string, mono: MonoFontEmbed | false, nonce?: string): string;
82
75
 
83
76
  /**
84
77
  * Options applicable to class diagrams (`classDiagram`). Class diagrams use
@@ -292,6 +285,15 @@ export declare interface InitConfig {
292
285
  /** True when `value` is one of the five directions Mermaid recognizes. */
293
286
  export declare function isDirection(value: string): value is Direction;
294
287
 
288
+ /**
289
+ * True when one endpoint of `edge` is a subgraph id and the other is a node or
290
+ * subgraph nested inside it, at any depth.
291
+ */
292
+ export declare function isEdgeWithinOwnCluster(edge: {
293
+ source: string;
294
+ target: string;
295
+ }, subgraphById: Map<string, MermaidSubgraph>): boolean;
296
+
295
297
  /** True if `line` is an init directive. */
296
298
  export declare function isInitDirective(line: string): boolean;
297
299
 
@@ -451,6 +453,17 @@ export declare function mixHexColors(fg: string, bg: string, pct: number): strin
451
453
  */
452
454
  export declare function mixSrgb(c1: RgbaColor, c2: RgbaColor, p1?: number, p2?: number): RgbaColor | null;
453
455
 
456
+ /**
457
+ * A self-hosted monospace font a caller embeds in the SVG `<style>` block
458
+ * for the `.mono` rule. See `buildStyleBlock`.
459
+ */
460
+ export declare interface MonoFontEmbed {
461
+ /** Font family name, listed first in the `.mono` rule's font stack. */
462
+ family: string;
463
+ /** The complete `@font-face { ... }` rule (typically a base64 data URI). */
464
+ faceCss: string;
465
+ }
466
+
454
467
  /** Metrics for multi-line text measurement */
455
468
  export declare interface MultilineMetrics {
456
469
  /** Maximum line width in pixels */
@@ -1243,6 +1256,16 @@ export declare function withDirectionOverride<T extends {
1243
1256
  direction?: Direction;
1244
1257
  }>(diagram: T, override: Direction | undefined): T;
1245
1258
 
1259
+ /**
1260
+ * `graph` without its edges between a node and a subgraph that contains it.
1261
+ * The parser also registers a subgraph id used as an edge endpoint as a
1262
+ * placeholder entry in `graph.nodes`; one no remaining edge refers to is
1263
+ * removed too, so the result equals the graph parsed without those edges.
1264
+ * Returns `graph` itself (same reference) when it has none, and never mutates
1265
+ * its input.
1266
+ */
1267
+ export declare function withoutOwnClusterEdges(graph: MermaidGraph): MermaidGraph;
1268
+
1246
1269
  /**
1247
1270
  * Options applicable to XY charts (`xychart-beta`). XY charts have no
1248
1271
  * spacing/`direction`/`curve`/`fontSizes`/`layoutCache` concept (layout is