@zenuml/core 4.4.0 → 4.5.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.0",
3
+ "version": "4.5.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,42 @@ 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
+ /** Font families whose file URL can be set with {@link setDiagramFontUrl}. */
37
+ export type DiagramFontFamily = "IBM Plex Sans" | "MS Sans Serif";
38
+
39
+ /**
40
+ * Set the URL the browser renderer loads a diagram font from, instead of its
41
+ * default. Call before rendering. Use it when the page's Content-Security-Policy
42
+ * refuses `data:` fonts, with the font file this package ships at
43
+ * `@zenuml/core/fonts/IBMPlexSans-Regular-Latin1.woff2`, served from an origin
44
+ * the policy allows.
45
+ *
46
+ * `family` defaults to "IBM Plex Sans", which otherwise loads from an embedded
47
+ * `data:` URI. "MS Sans Serif" (theme-neon, `@zenuml/core/fonts/MS-Sans-Serif.ttf`)
48
+ * is only loaded when set. `null` restores the default. Changing the URL makes
49
+ * the next render load the font again.
50
+ */
51
+ export declare function setDiagramFontUrl(
52
+ url: string | null,
53
+ family?: DiagramFontFamily,
54
+ ): void;
55
+
56
+ /**
57
+ * The IBM Plex Sans `@font-face` rule with the font embedded as a `data:` URI,
58
+ * for rasterising the rendered DOM — e.g. html-to-image's `fontEmbedCSS`
59
+ * option. SVG-as-image can only use embedded fonts, and html-to-image does not
60
+ * see faces registered with the FontFace API. Works on pages whose
61
+ * Content-Security-Policy refuses data: fonts for the document itself.
62
+ */
63
+ export declare function getDiagramFontFaceCss(): Promise<string | undefined>;
64
+
29
65
  export interface ParseResult {
30
66
  pass: boolean;
31
67
  errorDetails: ErrorDetail[];
@@ -62,6 +98,8 @@ interface IZenUml {
62
98
  declare class ZenUml implements IZenUml {
63
99
  static readonly version: string;
64
100
  static readonly default: typeof ZenUml;
101
+ /** Same as the named export {@link setDiagramFontUrl}. */
102
+ static readonly setDiagramFontUrl: typeof setDiagramFontUrl;
65
103
  constructor(el: HTMLElement | string, naked?: boolean);
66
104
  get code(): string | undefined;
67
105
  get theme(): string | undefined;