@zenuml/core 4.4.1 → 4.6.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zenuml/core",
3
- "version": "4.4.1",
3
+ "version": "4.6.0",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -82,7 +82,8 @@
82
82
  "types": "./types/parser/index.d.ts",
83
83
  "default": "./dist/parser/index.cjs"
84
84
  }
85
- }
85
+ },
86
+ "./fonts/*": "./dist/fonts/*"
86
87
  },
87
88
  "engines": {
88
89
  "node": ">=20"
package/types/index.d.ts CHANGED
@@ -26,6 +26,50 @@ export declare function renderToSvg(
26
26
  options?: RenderOptions,
27
27
  ): RenderResult;
28
28
 
29
+ /**
30
+ * Make the diagram typefaces available to text measurement and rendering in a
31
+ * browser. `ZenUml.render()` awaits it; call it yourself before
32
+ * `renderToSvg()`. Never rejects: a refused font falls back to the font stack.
33
+ */
34
+ export declare function ensureDiagramFontsLoaded(): Promise<void>;
35
+
36
+ /**
37
+ * Load the participant icons `code` uses that `renderToSvg()` does not build
38
+ * in (e.g. `@VPC`, `@RDS` and the other cloud icons), so the next
39
+ * `renderToSvg(code)` draws them. Await it before `renderToSvg()`. Never
40
+ * rejects: an unknown or failing icon falls back to the text label.
41
+ */
42
+ export declare function ensureDiagramIconsLoaded(code: string): Promise<void>;
43
+
44
+ /** Font families whose file URL can be set with {@link setDiagramFontUrl}. */
45
+ export type DiagramFontFamily = "IBM Plex Sans" | "MS Sans Serif";
46
+
47
+ /**
48
+ * Set the URL the browser renderer loads a diagram font from, instead of its
49
+ * default. Call before rendering. Use it when the page's Content-Security-Policy
50
+ * refuses `data:` fonts, with the font file this package ships at
51
+ * `@zenuml/core/fonts/IBMPlexSans-Regular-Latin1.woff2`, served from an origin
52
+ * the policy allows.
53
+ *
54
+ * `family` defaults to "IBM Plex Sans", which otherwise loads from an embedded
55
+ * `data:` URI. "MS Sans Serif" (theme-neon, `@zenuml/core/fonts/MS-Sans-Serif.ttf`)
56
+ * is only loaded when set. `null` restores the default. Changing the URL makes
57
+ * the next render load the font again.
58
+ */
59
+ export declare function setDiagramFontUrl(
60
+ url: string | null,
61
+ family?: DiagramFontFamily,
62
+ ): void;
63
+
64
+ /**
65
+ * The IBM Plex Sans `@font-face` rule with the font embedded as a `data:` URI,
66
+ * for rasterising the rendered DOM — e.g. html-to-image's `fontEmbedCSS`
67
+ * option. SVG-as-image can only use embedded fonts, and html-to-image does not
68
+ * see faces registered with the FontFace API. Works on pages whose
69
+ * Content-Security-Policy refuses data: fonts for the document itself.
70
+ */
71
+ export declare function getDiagramFontFaceCss(): Promise<string | undefined>;
72
+
29
73
  export interface ParseResult {
30
74
  pass: boolean;
31
75
  errorDetails: ErrorDetail[];
@@ -62,6 +106,8 @@ interface IZenUml {
62
106
  declare class ZenUml implements IZenUml {
63
107
  static readonly version: string;
64
108
  static readonly default: typeof ZenUml;
109
+ /** Same as the named export {@link setDiagramFontUrl}. */
110
+ static readonly setDiagramFontUrl: typeof setDiagramFontUrl;
65
111
  constructor(el: HTMLElement | string, naked?: boolean);
66
112
  get code(): string | undefined;
67
113
  get theme(): string | undefined;