@mermanjs/node-wasm 0.11.0 → 0.12.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/CHANGELOG.md +25 -1
- package/README.md +27 -41
- package/THIRD_PARTY_LICENSES/d3-hierarchy/LICENSE +13 -0
- package/THIRD_PARTY_LICENSES/d3-sankey/LICENSE +27 -0
- package/THIRD_PARTY_LICENSES/krilla/LICENSE-APACHE +202 -0
- package/THIRD_PARTY_LICENSES/krilla/LICENSE-ICC +116 -0
- package/THIRD_PARTY_LICENSES/{roxmltree-dom → krilla}/LICENSE-MIT +3 -3
- package/THIRD_PARTY_LICENSES/resvg-iir-blur/LICENSE +24 -0
- package/THIRD_PARTY_LICENSES/rust-cargo-dependencies.json +443 -508
- package/THIRD_PARTY_NOTICES.md +199 -71
- package/artifact/merman_node.cjs +26 -0
- package/artifact/merman_node_bg.wasm +0 -0
- package/dist/bounded-executor.mjs +8 -2
- package/dist/candidates/wasm.mjs +6 -9
- package/dist/candidates/wrap-engine.mjs +38 -2
- package/dist/engine.mjs +434 -132
- package/dist/errors.mjs +173 -70
- package/dist/generated/binding-contract.mjs +137 -122
- package/dist/generated/capability-surface.mjs +58 -56
- package/dist/generated/node-wire-contract.json +16 -4
- package/dist/index.d.ts +427 -158
- package/dist/index.mjs +11 -3
- package/dist/native-loader.mjs +83 -13
- package/dist/transport-contract.mjs +39 -1
- package/package.json +4 -2
- package/THIRD_PARTY_LICENSES/roxmltree-dom/LICENSE-APACHE +0 -201
- /package/THIRD_PARTY_LICENSES/{roxmltree-dom → roxmltree-ego-tree}/LICENSE-ISC +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,168 +1,395 @@
|
|
|
1
|
+
/// <reference lib="esnext.disposable" />
|
|
2
|
+
|
|
1
3
|
export type MermanResourceProfile =
|
|
2
4
|
| "interactive"
|
|
3
5
|
| "constrained"
|
|
4
6
|
| "trusted-native"
|
|
5
7
|
| "unbounded-for-trusted-input";
|
|
6
8
|
|
|
7
|
-
export type MermanAsciiGraphPresentation = "strict" | "adaptive";
|
|
8
|
-
|
|
9
|
-
/** Options for the canonical `ascii` operation, also accepted through optionsJson. */
|
|
10
|
-
export interface MermanAsciiRenderOptions {
|
|
11
|
-
/** Defaults to strict. Adaptive is Plain-only for Flowchart, Swimlane, and State. */
|
|
12
|
-
graph_presentation?: MermanAsciiGraphPresentation;
|
|
13
|
-
graphPresentation?: MermanAsciiGraphPresentation;
|
|
14
|
-
/** State supports Canonical only; Auto requires a maximum width. */
|
|
15
|
-
layout_profile?: "canonical" | "compact" | "auto";
|
|
16
|
-
layoutProfile?: "canonical" | "compact" | "auto";
|
|
17
|
-
charset?: "ascii" | "unicode";
|
|
18
|
-
max_width?: number;
|
|
19
|
-
maxWidth?: number;
|
|
20
|
-
overflow?: "allow" | "fallback" | "error";
|
|
21
|
-
color_mode?:
|
|
22
|
-
| "plain" | "none"
|
|
23
|
-
| "ansi16" | "ansi-16" | "ansi_16"
|
|
24
|
-
| "ansi256" | "ansi-256" | "ansi_256"
|
|
25
|
-
| "truecolor" | "true-color" | "true_color" | "html";
|
|
26
|
-
colorMode?: MermanAsciiRenderOptions["color_mode"];
|
|
27
|
-
[key: string]: unknown;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
9
|
export interface MermanBindingOptions {
|
|
31
|
-
version?:
|
|
10
|
+
version?: 4;
|
|
32
11
|
runtime_policy?: "deterministic";
|
|
33
12
|
fixed_today?: string | null;
|
|
34
13
|
/** Exact host-supplied Unix milliseconds; mutually exclusive with a non-null fixed_today. */
|
|
35
14
|
fixed_unix_millis?: number | null;
|
|
36
15
|
fixed_local_offset_minutes?: number | null;
|
|
16
|
+
site_config?: {
|
|
17
|
+
[key: string]: unknown;
|
|
18
|
+
themeCSS?: never;
|
|
19
|
+
theme_css?: never;
|
|
20
|
+
secure?: never;
|
|
21
|
+
securityLevel?: never;
|
|
22
|
+
security_level?: never;
|
|
23
|
+
dompurifyConfig?: never;
|
|
24
|
+
dompurify_config?: never;
|
|
25
|
+
maxEdges?: never;
|
|
26
|
+
max_edges?: never;
|
|
27
|
+
maxTextSize?: never;
|
|
28
|
+
max_text_size?: never;
|
|
29
|
+
};
|
|
30
|
+
parse?: { suppress_errors?: boolean };
|
|
31
|
+
/** DrawList v1 projection options. */
|
|
32
|
+
draw_list?: {
|
|
33
|
+
/** Bake endpoint markers and surface-contrast edge overlays into plain paths. */
|
|
34
|
+
expand_markers?: boolean;
|
|
35
|
+
};
|
|
36
|
+
/** Layout viewport, responsive adaptation, and incremental Shoal frame options. */
|
|
37
|
+
layout?: {
|
|
38
|
+
/**
|
|
39
|
+
* Explicit width-fitting adaptation for Kanban and Shoal-backed families
|
|
40
|
+
* (`flowchart`, `agentflow`, `swimlane`, `class`, `state`, `er`, `requirement`,
|
|
41
|
+
* `usecase`, `architecture`, and `c4`).
|
|
42
|
+
*/
|
|
43
|
+
adaptation?: "none" | "fit-width";
|
|
44
|
+
container_width?: number;
|
|
45
|
+
container_height?: number;
|
|
46
|
+
screen_available_width?: number;
|
|
47
|
+
/** Allow Shoal fit-width to fold wide leaf ranks. Defaults to `false`. */
|
|
48
|
+
fold_wide_ranks?: boolean;
|
|
49
|
+
/** Include a `shoal_layout_frame` snapshot in render metadata when rendering with Shoal. */
|
|
50
|
+
capture_shoal_frame?: boolean;
|
|
51
|
+
/** Replay the previous successful Shoal frame for this document and capture a new one. */
|
|
52
|
+
previous_shoal_frame?: Readonly<Record<string, unknown>>;
|
|
53
|
+
};
|
|
37
54
|
environment?: {
|
|
38
|
-
theme_portability?: "best-effort" | "require-portable";
|
|
39
55
|
text_measurement?: "deterministic" | null;
|
|
40
|
-
|
|
56
|
+
math_renderer?: "none" | "ratex";
|
|
41
57
|
};
|
|
42
58
|
resources?: {
|
|
43
59
|
profile?: MermanResourceProfile;
|
|
44
60
|
limits?: Record<string, number>;
|
|
45
61
|
};
|
|
46
|
-
/** A supplied selection replaces the
|
|
62
|
+
/** A supplied selection replaces the constructor theme. Use `null` or `"none"` to clear it. */
|
|
47
63
|
theme?: DiagramThemeSelection | null;
|
|
48
|
-
|
|
49
|
-
|
|
64
|
+
/** Overrides the SVG canvas base with a solid CSS color or `"transparent"`. */
|
|
65
|
+
background?: string;
|
|
66
|
+
svg?: {
|
|
67
|
+
diagram_id?: string;
|
|
68
|
+
/** Outline SVG text for font-independent display. Requires the native outlined-svg capability. */
|
|
69
|
+
outlines?: boolean;
|
|
70
|
+
pipeline?: "parity" | "static" | "readable" | "resvg-safe";
|
|
71
|
+
root_background_color?: string;
|
|
72
|
+
drop_native_duplicate_fallbacks?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Policy for math expressions when native math rendering is unavailable:
|
|
75
|
+
* `"strict"` rejects the render, `"source-text"` keeps raw math text, and
|
|
76
|
+
* `"drop"` omits the unavailable math payload.
|
|
77
|
+
*/
|
|
78
|
+
native_math_fallback?: "strict" | "source-text" | "drop";
|
|
79
|
+
viewbox_padding?: number;
|
|
80
|
+
viewBoxPadding?: number;
|
|
81
|
+
};
|
|
50
82
|
}
|
|
51
83
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
| string | number | boolean | null
|
|
55
|
-
| ThemeJsonValue[]
|
|
56
|
-
| { [key: string]: ThemeJsonValue };
|
|
57
|
-
export type ThemeJsonObject = { [key: string]: ThemeJsonValue };
|
|
58
|
-
|
|
59
|
-
/** Editable JSON sections are validated by the shared Rust theme compiler. */
|
|
60
|
-
export interface ThemeDesignV1 {
|
|
61
|
-
tokens?: Record<string, ThemeJsonValue>;
|
|
62
|
-
styles?: Record<string, ThemeJsonValue>;
|
|
63
|
-
rules?: ThemeJsonObject[];
|
|
64
|
-
palettes?: Record<string, ThemeJsonValue>;
|
|
65
|
-
canvas?: ThemeJsonObject;
|
|
66
|
-
typography?: ThemeJsonObject;
|
|
67
|
-
mermaid?: ThemeJsonObject;
|
|
68
|
-
assets?: ThemeJsonObject;
|
|
69
|
-
requirements?: ThemeJsonObject;
|
|
70
|
-
appearances?: Partial<Record<ThemeAppearance, ThemeAppearanceOverridesV1>>;
|
|
71
|
-
default_appearance?: ThemeAppearance;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export type ThemeAppearanceOverridesV1 =
|
|
75
|
-
Omit<ThemeDesignV1, "appearances" | "default_appearance" | "assets" | "requirements">;
|
|
76
|
-
|
|
77
|
-
export type ThemeRecipeV1 = {
|
|
78
|
-
schema_version: 1;
|
|
79
|
-
preset?: never;
|
|
80
|
-
spec?: never;
|
|
81
|
-
recipe?: never;
|
|
82
|
-
appearance?: never;
|
|
83
|
-
} & (
|
|
84
|
-
| { kind: "design"; design: ThemeDesignV1; complete_spec?: never }
|
|
85
|
-
| { kind: "complete_spec"; complete_spec: ThemeJsonObject; design?: never }
|
|
86
|
-
);
|
|
84
|
+
// BEGIN Theme v2 declarations
|
|
85
|
+
// @generated from crates/xtask/src/cmd/theme_contract/types.ts by `cargo run --locked -p xtask -- gen-theme-contract`.
|
|
87
86
|
|
|
87
|
+
/** A concrete appearance selected by the host. */
|
|
88
|
+
export type ThemeAppearance = "light" | "dark";
|
|
89
|
+
/** High-level grouping category used by theme pickers and catalogs. */
|
|
90
|
+
export type ThemeCategory = "reading" | "editor" | "art" | "custom";
|
|
91
|
+
/** Precedence policy when both the host and Mermaid source declare a theme. */
|
|
92
|
+
export type ThemePrecedence = "host" | "source";
|
|
93
|
+
|
|
94
|
+
/** Complete built-in theme catalog and per-family native capability bitmasks. */
|
|
95
|
+
export interface ThemeCatalog {
|
|
96
|
+
readonly schema_version: 2;
|
|
97
|
+
readonly presets: readonly ThemePresetCatalogEntry[];
|
|
98
|
+
readonly mermaid_themes: readonly string[];
|
|
99
|
+
/** Native theme capability bit masks by logical diagram family. */
|
|
100
|
+
readonly families: readonly { id: string; capabilities: number }[];
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** Metadata, supported appearances, and preview swatch for one built-in Theme v2 preset. */
|
|
104
|
+
export interface ThemePresetCatalogEntry {
|
|
105
|
+
readonly id: string;
|
|
106
|
+
readonly name: string;
|
|
107
|
+
readonly description: string;
|
|
108
|
+
readonly category: ThemeCategory;
|
|
109
|
+
readonly appearances: readonly ThemeAppearance[];
|
|
110
|
+
readonly default_appearance: ThemeAppearance;
|
|
111
|
+
/** Semantic colors for the preset's default appearance. */
|
|
112
|
+
readonly swatches: readonly [
|
|
113
|
+
canvas: string, node: string, container: string,
|
|
114
|
+
title: string, primaryText: string, firstDataFill: string,
|
|
115
|
+
];
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** Authorable Theme v2 document (schema version `2`) supporting `extends`, seeds, roles, typography, form, appearances, and per-family overrides. */
|
|
119
|
+
export interface ThemeDocument {
|
|
120
|
+
readonly $schema?: string;
|
|
121
|
+
readonly schema_version: 2;
|
|
122
|
+
readonly id?: string;
|
|
123
|
+
readonly name?: string;
|
|
124
|
+
readonly description?: string;
|
|
125
|
+
readonly category?: ThemeCategory;
|
|
126
|
+
readonly extends?: string;
|
|
127
|
+
readonly default_appearance?: ThemeAppearance;
|
|
128
|
+
readonly seed?: ThemeSeed;
|
|
129
|
+
readonly roles?: Partial<ThemeRoles>;
|
|
130
|
+
readonly typography?: Partial<ThemeTypography>;
|
|
131
|
+
readonly form?: ThemeFormPatch;
|
|
132
|
+
readonly appearances?: Readonly<Partial<Record<ThemeAppearance, ThemeAppearanceLayer>>>;
|
|
133
|
+
readonly overrides?: readonly ThemeFamilyOverride[];
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** A preset ID, `none` to clear the selection, or an editable v2 document. */
|
|
88
137
|
export type DiagramThemeSelection =
|
|
89
|
-
|
|
|
90
|
-
| (
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
138
|
+
| string
|
|
139
|
+
| (ThemeDocument & {
|
|
140
|
+
readonly preset?: never;
|
|
141
|
+
readonly document?: never;
|
|
142
|
+
readonly appearance?: never;
|
|
143
|
+
readonly precedence?: never;
|
|
144
|
+
})
|
|
145
|
+
| ({
|
|
146
|
+
readonly schema_version?: never;
|
|
147
|
+
readonly appearance?: ThemeAppearance;
|
|
148
|
+
readonly precedence?: ThemePrecedence;
|
|
149
|
+
} & (
|
|
150
|
+
| { readonly preset: string; readonly document?: never }
|
|
151
|
+
| { readonly document: ThemeDocument; readonly preset?: never }
|
|
94
152
|
));
|
|
95
153
|
|
|
96
|
-
export type
|
|
97
|
-
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
export
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export interface
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
154
|
+
export type ThemeSeed = Readonly<Partial<Record<
|
|
155
|
+
"canvas" | "ink" | "accent" | "surface" | "callout" | "info" | "success" | "warn" | "danger",
|
|
156
|
+
string
|
|
157
|
+
>>>;
|
|
158
|
+
|
|
159
|
+
export type ThemePaint = string | {
|
|
160
|
+
readonly kind: "linear_gradient";
|
|
161
|
+
readonly angle_deg?: number;
|
|
162
|
+
readonly stops: readonly { offset: number; color: string; opacity?: number }[];
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
export interface ThemeRoles {
|
|
166
|
+
readonly canvas: ThemePaint;
|
|
167
|
+
readonly "surface.node": string;
|
|
168
|
+
readonly "surface.container": string;
|
|
169
|
+
readonly "surface.callout": string;
|
|
170
|
+
readonly "surface.emphasis": string;
|
|
171
|
+
readonly "stroke.border": string;
|
|
172
|
+
readonly "stroke.connector": string;
|
|
173
|
+
readonly "stroke.guide": string;
|
|
174
|
+
readonly "text.primary": string;
|
|
175
|
+
readonly "text.muted": string;
|
|
176
|
+
readonly "text.title": string;
|
|
177
|
+
readonly "text.callout": string;
|
|
178
|
+
readonly "text.on_emphasis": string;
|
|
179
|
+
readonly "status.info": string;
|
|
180
|
+
readonly "status.success": string;
|
|
181
|
+
readonly "status.warn": string;
|
|
182
|
+
readonly "status.danger": string;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
type ThemeTextureColor = { readonly color?: string; readonly opacity?: number };
|
|
186
|
+
|
|
187
|
+
export type ThemeTexture =
|
|
188
|
+
| { readonly kind: "none" }
|
|
189
|
+
| (ThemeTextureColor & {
|
|
190
|
+
readonly kind: "grid";
|
|
191
|
+
readonly step_px: number;
|
|
192
|
+
readonly major_every?: number;
|
|
193
|
+
readonly major_opacity?: number;
|
|
194
|
+
})
|
|
195
|
+
| (ThemeTextureColor & { readonly kind: "dots"; readonly step_px: number; readonly radius_px?: number })
|
|
196
|
+
| (ThemeTextureColor & {
|
|
197
|
+
readonly kind: "ruled";
|
|
198
|
+
readonly line_height_px: number;
|
|
199
|
+
readonly margin_rule_color?: string;
|
|
200
|
+
readonly margin_rule_x_px?: number;
|
|
201
|
+
})
|
|
202
|
+
| (ThemeTextureColor & { readonly kind: "fibers"; readonly angle_deg?: number; readonly cross?: boolean })
|
|
203
|
+
| (ThemeTextureColor & { readonly kind: "scanlines"; readonly step_px: number })
|
|
204
|
+
| {
|
|
205
|
+
readonly kind: "radial_wash";
|
|
206
|
+
readonly color: string;
|
|
207
|
+
readonly opacity?: number;
|
|
208
|
+
readonly cx?: number;
|
|
209
|
+
readonly cy?: number;
|
|
210
|
+
readonly radius?: number;
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
interface ThemeShadowLayer {
|
|
214
|
+
readonly dx: number;
|
|
215
|
+
readonly dy: number;
|
|
216
|
+
readonly blur?: number;
|
|
217
|
+
readonly color: string;
|
|
218
|
+
readonly opacity?: number;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
interface ThemeGlow {
|
|
222
|
+
readonly kind: "glow";
|
|
223
|
+
readonly color: string;
|
|
224
|
+
readonly blur: number;
|
|
225
|
+
readonly opacity?: number;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export type ThemeElevationSpec =
|
|
229
|
+
| "flat" | "soft" | "crisp"
|
|
230
|
+
| { readonly kind: "layered_stack"; readonly layers: readonly ThemeShadowLayer[] }
|
|
231
|
+
| ThemeGlow;
|
|
232
|
+
|
|
233
|
+
export type ThemeElevation =
|
|
234
|
+
| { readonly kind: "flat" }
|
|
235
|
+
| { readonly kind: "shadows"; readonly layers: readonly Required<ThemeShadowLayer>[] }
|
|
236
|
+
| Required<ThemeGlow>;
|
|
237
|
+
|
|
238
|
+
type ThemeFontRole = "sans" | "serif" | "mono";
|
|
239
|
+
|
|
240
|
+
export interface ThemeTypography {
|
|
241
|
+
readonly sans: readonly string[];
|
|
242
|
+
readonly mono: readonly string[];
|
|
243
|
+
readonly serif: readonly string[];
|
|
244
|
+
readonly body_family: ThemeFontRole;
|
|
245
|
+
readonly title_family: ThemeFontRole;
|
|
246
|
+
readonly code_family: "mono" | "sans";
|
|
247
|
+
readonly base_size_px: number;
|
|
248
|
+
readonly title_weight: number;
|
|
249
|
+
readonly label_weight: number;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export interface ThemeForm {
|
|
253
|
+
readonly density: "compact" | "balanced" | "airy";
|
|
254
|
+
readonly radius: number;
|
|
255
|
+
readonly container_radius: number;
|
|
256
|
+
readonly stroke_width: number;
|
|
257
|
+
readonly connector_width: number;
|
|
258
|
+
readonly edge_style: "curved" | "orthogonal" | "straight" | "sketch";
|
|
259
|
+
readonly marker_style: "stealth" | "filled" | "open" | "classic";
|
|
260
|
+
readonly edge_label_bg: "auto" | "canvas" | "pill" | "transparent";
|
|
261
|
+
readonly chart: {
|
|
262
|
+
readonly gridlines: boolean;
|
|
263
|
+
readonly bar_radius: number;
|
|
264
|
+
readonly bar_wireframe: boolean;
|
|
265
|
+
readonly line_markers: boolean;
|
|
266
|
+
readonly pie_gap_px: number;
|
|
267
|
+
readonly pie_opacity: number;
|
|
268
|
+
};
|
|
156
269
|
}
|
|
157
270
|
|
|
158
|
-
export interface
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
271
|
+
export interface ThemeFormPatch extends Partial<Omit<ThemeForm, "chart">> {
|
|
272
|
+
readonly elevation?: ThemeElevationSpec;
|
|
273
|
+
readonly chart?: Partial<ThemeForm["chart"]>;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
interface ThemeCanvas {
|
|
277
|
+
readonly textures: readonly ThemeTexture[];
|
|
278
|
+
readonly padding_px: number;
|
|
164
279
|
}
|
|
165
280
|
|
|
281
|
+
interface ThemeDataPalette {
|
|
282
|
+
readonly ink: readonly string[];
|
|
283
|
+
readonly fill: readonly string[];
|
|
284
|
+
readonly fill_ink: readonly string[];
|
|
285
|
+
readonly pattern_encoding: boolean;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
type ThemeDataPatch = Partial<Omit<ThemeDataPalette, "fill_ink">> & { readonly fill_ink?: string };
|
|
289
|
+
|
|
290
|
+
export interface ThemeAppearanceLayer {
|
|
291
|
+
readonly seed?: ThemeSeed;
|
|
292
|
+
readonly roles?: Partial<ThemeRoles>;
|
|
293
|
+
readonly data?: ThemeDataPatch;
|
|
294
|
+
readonly canvas?: Partial<ThemeCanvas>;
|
|
295
|
+
readonly elevation?: ThemeElevationSpec;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
export interface ThemeFamilyOverride {
|
|
299
|
+
readonly families: readonly string[];
|
|
300
|
+
readonly appearance?: ThemeAppearance;
|
|
301
|
+
readonly roles?: Partial<ThemeRoles>;
|
|
302
|
+
readonly data?: ThemeDataPatch;
|
|
303
|
+
readonly form?: ThemeFormPatch;
|
|
304
|
+
readonly elevation?: ThemeElevationSpec;
|
|
305
|
+
readonly typography?: Partial<ThemeTypography>;
|
|
306
|
+
readonly node_ordinal_palette?: boolean;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
interface ResolvedFamilyTheme {
|
|
310
|
+
readonly roles: ThemeRoles;
|
|
311
|
+
readonly data: ThemeDataPalette;
|
|
312
|
+
readonly typography: ThemeTypography;
|
|
313
|
+
readonly form: ThemeForm;
|
|
314
|
+
readonly elevation: ThemeElevation;
|
|
315
|
+
readonly node_ordinal_palette: boolean;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/** Fully compiled Theme v2 token set for one concrete appearance, including resolved family overrides. */
|
|
319
|
+
export interface ResolvedTheme extends ResolvedFamilyTheme {
|
|
320
|
+
readonly id: string | null;
|
|
321
|
+
readonly appearance: ThemeAppearance;
|
|
322
|
+
readonly canvas: ThemeCanvas;
|
|
323
|
+
readonly family_overrides?: Readonly<Record<string, ResolvedFamilyTheme>>;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/** Structured diagnostic notice emitted while compiling or contrast-checking a Theme v2 document. */
|
|
327
|
+
export type ThemeNotice =
|
|
328
|
+
| {
|
|
329
|
+
readonly kind: "low_contrast";
|
|
330
|
+
readonly foreground: string;
|
|
331
|
+
readonly background: string;
|
|
332
|
+
readonly ratio: number;
|
|
333
|
+
readonly minimum: number;
|
|
334
|
+
}
|
|
335
|
+
| { readonly kind: "contrast_adjusted"; readonly foreground: string; readonly color: string }
|
|
336
|
+
| {
|
|
337
|
+
readonly kind: "appearance_polarity_mismatch";
|
|
338
|
+
readonly appearance: ThemeAppearance;
|
|
339
|
+
readonly family?: string;
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
/** Effective rendering theme mode, resolved preset/appearance, and notices recorded for a render operation. */
|
|
343
|
+
export interface ThemeOutcome {
|
|
344
|
+
readonly mode: "mermaid_parity" | "merman_native";
|
|
345
|
+
readonly preset_id?: string;
|
|
346
|
+
readonly appearance?: ThemeAppearance;
|
|
347
|
+
readonly notices: readonly (ThemeNotice | string)[];
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/** Aggregate WCAG contrast grade across checked foreground/background role pairs. */
|
|
351
|
+
export type ThemeContrastGrade = "warning" | "AA" | "AAA";
|
|
352
|
+
|
|
353
|
+
/** Measured WCAG contrast ratio for one semantic foreground/background pair. */
|
|
354
|
+
export interface ThemeContrastRow {
|
|
355
|
+
readonly foreground: string;
|
|
356
|
+
readonly background: string;
|
|
357
|
+
readonly ratio: number;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/** Options controlling `resolveTheme()` appearance selection, contrast auto-fix, and `extends` expansion. */
|
|
361
|
+
export interface ThemeResolveOptions extends Pick<RenderSvgOptions, "signal" | "timeoutMs"> {
|
|
362
|
+
readonly appearance?: ThemeAppearance;
|
|
363
|
+
/** Adjust foreground colors in the resolved preview and emit `fixed_document` when it fits. */
|
|
364
|
+
readonly auto_fix_contrast?: boolean;
|
|
365
|
+
/** Inline `extends` into a standalone authoring document in `expanded_document`. */
|
|
366
|
+
readonly expand?: boolean;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/** Structured syntax or validation failure returned when `resolveTheme()` rejects a document. */
|
|
370
|
+
export interface ThemeResolveError {
|
|
371
|
+
readonly ok: false;
|
|
372
|
+
/** One-based coordinates in the input document, when known. */
|
|
373
|
+
readonly line: number | null;
|
|
374
|
+
readonly column: number | null;
|
|
375
|
+
readonly path: string | null;
|
|
376
|
+
readonly message: string;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
/** Result of compiling and validating a Theme v2 document via `resolveTheme()`. */
|
|
380
|
+
export type ThemeResolution =
|
|
381
|
+
| {
|
|
382
|
+
readonly ok: true;
|
|
383
|
+
readonly resolved: ResolvedTheme;
|
|
384
|
+
readonly notices: readonly ThemeNotice[];
|
|
385
|
+
readonly contrast_grade?: ThemeContrastGrade;
|
|
386
|
+
readonly contrast_rows?: readonly ThemeContrastRow[];
|
|
387
|
+
readonly expanded_document?: ThemeDocument;
|
|
388
|
+
readonly fixed_document?: ThemeDocument;
|
|
389
|
+
}
|
|
390
|
+
| ThemeResolveError;
|
|
391
|
+
// END Theme v2 declarations
|
|
392
|
+
|
|
166
393
|
/** One host-loaded Iconify pack, admitted once into an immutable engine-local registry. */
|
|
167
394
|
export interface MermanIconPack {
|
|
168
395
|
json: string;
|
|
@@ -183,25 +410,29 @@ export interface RenderSvgOptions {
|
|
|
183
410
|
* carrying canonical cancellation details once transport admission or a renderer checkpoint
|
|
184
411
|
* observes the request.
|
|
185
412
|
*/
|
|
186
|
-
signal?: AbortSignal;
|
|
413
|
+
signal?: AbortSignal | null;
|
|
187
414
|
/**
|
|
188
415
|
* Relative monotonic deadline in milliseconds, starting when the Rust transport admits the
|
|
189
416
|
* operation. Values must be integers from 0 through 4,294,967,295.
|
|
190
417
|
*/
|
|
191
418
|
timeoutMs?: number;
|
|
192
|
-
/**
|
|
419
|
+
/** Request-local SVG ID. When supplying request options, set `svg.diagram_id` there. */
|
|
420
|
+
diagramId?: string;
|
|
421
|
+
/** Per-request options merged over the engine baseline. Supply either `options` or `optionsJson`. */
|
|
422
|
+
options?: MermanBindingOptions;
|
|
423
|
+
/** Raw per-request Options JSON. Supply either `optionsJson` or `options`. */
|
|
193
424
|
optionsJson?: string;
|
|
194
425
|
}
|
|
195
426
|
|
|
427
|
+
type DiagramOperationOptions = Omit<RenderSvgOptions, "diagramId"> & { diagramId?: never };
|
|
428
|
+
|
|
196
429
|
export interface MermanOperationRequest {
|
|
197
430
|
operationId: string;
|
|
198
431
|
source: string;
|
|
199
432
|
uri?: string | null;
|
|
200
|
-
/**
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
* satisfies MermanBindingOptions). Admission is advertised by metadataJson("ascii-capabilities").
|
|
204
|
-
*/
|
|
433
|
+
/** Per-request options merged over the engine baseline. Supply either `options` or `optionsJson`. */
|
|
434
|
+
options?: MermanBindingOptions;
|
|
435
|
+
/** Raw per-request Options JSON. Supply either `optionsJson` or `options`. */
|
|
205
436
|
optionsJson?: string;
|
|
206
437
|
}
|
|
207
438
|
|
|
@@ -209,10 +440,26 @@ export interface MermanOperationResult {
|
|
|
209
440
|
operation_id: string;
|
|
210
441
|
media_type: string;
|
|
211
442
|
data: string;
|
|
212
|
-
/** Canonical
|
|
443
|
+
/** Canonical JSON for `MermanOperationMetadata`. */
|
|
213
444
|
metadata_json: string;
|
|
214
445
|
}
|
|
215
446
|
|
|
447
|
+
export interface NativeMathFallbackObservation {
|
|
448
|
+
readonly policy: "source-text" | "drop";
|
|
449
|
+
readonly fallback_count: number;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
export interface MermanOperationMetadata {
|
|
453
|
+
readonly version: 1;
|
|
454
|
+
readonly operation_id: string;
|
|
455
|
+
readonly media_type: string;
|
|
456
|
+
readonly runtime_policy: "deterministic";
|
|
457
|
+
readonly byte_length: number;
|
|
458
|
+
readonly native_math_fallback?: NativeMathFallbackObservation;
|
|
459
|
+
readonly theme_outcome?: ThemeOutcome;
|
|
460
|
+
readonly [key: string]: unknown;
|
|
461
|
+
}
|
|
462
|
+
|
|
216
463
|
export interface MermanTextMeasurementCatalog {
|
|
217
464
|
protocol_version: number;
|
|
218
465
|
provider_ids: string[];
|
|
@@ -298,7 +545,7 @@ export interface MermanRuntimeConstructorServiceContract {
|
|
|
298
545
|
|
|
299
546
|
export interface MermanRuntimeCatalog {
|
|
300
547
|
schema_version: 1;
|
|
301
|
-
transport_api_version:
|
|
548
|
+
transport_api_version: 3;
|
|
302
549
|
package_version: string;
|
|
303
550
|
options_schema_versions: number[];
|
|
304
551
|
payload_schemas: MermanRuntimePayloadSchema[];
|
|
@@ -338,41 +585,61 @@ export interface MermanQueueState {
|
|
|
338
585
|
readonly state: "open" | "disposing" | "disposed";
|
|
339
586
|
}
|
|
340
587
|
|
|
588
|
+
/** Managed Node.js native rendering engine with bounded concurrency and cooperative cancellation. */
|
|
341
589
|
export declare class MermanEngine {
|
|
342
590
|
private constructor();
|
|
591
|
+
/** Snapshot of active, queued, and lifecycle state for this engine's worker queue. */
|
|
343
592
|
readonly queueState: MermanQueueState;
|
|
593
|
+
/** Immutable capability, output, registry, and resource catalog exposed by the loaded native addon. */
|
|
344
594
|
readonly runtimeCatalog: MermanRuntimeCatalog;
|
|
595
|
+
/** Renders Mermaid source to SVG asynchronously on the engine worker pool. */
|
|
345
596
|
renderSvg(source: string, options?: RenderSvgOptions): Promise<string>;
|
|
346
597
|
/** Synchronous rendering is intended only for explicit SSG build paths. */
|
|
347
598
|
renderSvgSync(source: string, options?: Omit<RenderSvgOptions, "signal">): string;
|
|
348
|
-
|
|
599
|
+
/** Computes the SVG capability plan JSON asynchronously without rendering. */
|
|
600
|
+
svgPlanJson(source: string, options?: DiagramOperationOptions): Promise<string>;
|
|
601
|
+
/** Computes the SVG capability plan JSON synchronously. */
|
|
349
602
|
svgPlanJsonSync(
|
|
350
603
|
source: string,
|
|
351
|
-
options?: Omit<
|
|
604
|
+
options?: Omit<DiagramOperationOptions, "signal">,
|
|
352
605
|
): string;
|
|
353
|
-
/**
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
606
|
+
/** Emits DrawList v1 JSON asynchronously for admitted compact diagrams (`flowchart`, `sequence`, `class`, `state`, `er`). */
|
|
607
|
+
drawListJson(source: string, options?: DiagramOperationOptions): Promise<string>;
|
|
608
|
+
/** Emits DrawList v1 JSON synchronously for admitted compact diagrams (`flowchart`, `sequence`, `class`, `state`, `er`). */
|
|
609
|
+
drawListJsonSync(source: string, options?: Omit<DiagramOperationOptions, "signal">): string;
|
|
610
|
+
/** Returns the compiled Theme v2 built-in preset and family capability catalog. */
|
|
611
|
+
themeCatalog(): ThemeCatalog;
|
|
612
|
+
/** Exports the editable v2 document, including every declared appearance. */
|
|
613
|
+
exportThemePreset(
|
|
614
|
+
presetId: string,
|
|
615
|
+
options?: Pick<RenderSvgOptions, "signal" | "timeoutMs">,
|
|
616
|
+
): Promise<ThemeDocument>;
|
|
617
|
+
/** Pass raw JSON text to preserve document-relative syntax and duplicate-key diagnostics. */
|
|
618
|
+
resolveTheme(
|
|
619
|
+
document: ThemeDocument | string,
|
|
620
|
+
options?: ThemeResolveOptions,
|
|
621
|
+
): Promise<ThemeResolution>;
|
|
622
|
+
/** Returns static JSON metadata for the requested contract metadata identifier. */
|
|
364
623
|
metadataJson(id: string): string;
|
|
624
|
+
/** Executes a generic binding operation asynchronously (for example `svg`, `png`, `pdf`, `ascii`, `draw-list`). */
|
|
365
625
|
executeOperation(
|
|
366
626
|
request: MermanOperationRequest,
|
|
367
627
|
options?: Pick<RenderSvgOptions, "signal" | "timeoutMs">,
|
|
368
628
|
): Promise<MermanOperationResult>;
|
|
629
|
+
/** Executes a generic binding operation synchronously. */
|
|
369
630
|
executeOperationSync(
|
|
370
631
|
request: MermanOperationRequest,
|
|
371
632
|
options?: Pick<RenderSvgOptions, "timeoutMs">,
|
|
372
633
|
): MermanOperationResult;
|
|
634
|
+
/** Drains in-flight operations and releases native resources. Idempotent. */
|
|
373
635
|
dispose(): Promise<void>;
|
|
636
|
+
/** Starts disposal immediately. Use async disposal to await in-flight operations and cleanup. */
|
|
637
|
+
[Symbol.dispose](): void;
|
|
638
|
+
/** Awaits in-flight operations and releases native resources (`await using engine = ...`). */
|
|
639
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
374
640
|
}
|
|
375
641
|
|
|
642
|
+
/** Creates and initializes a managed native {@link MermanEngine} for Node.js. */
|
|
376
643
|
export declare function createNodeEngine(
|
|
377
644
|
options?: CreateNodeEngineOptions,
|
|
378
645
|
): Promise<MermanEngine>;
|
|
@@ -397,7 +664,9 @@ export interface MermanResourceErrorDetails {
|
|
|
397
664
|
}
|
|
398
665
|
|
|
399
666
|
export interface MermanDiagnosticSpan {
|
|
667
|
+
/** Inclusive start, in UTF-8 bytes from the start of the diagnosed input. */
|
|
400
668
|
readonly start: number;
|
|
669
|
+
/** Exclusive end, in UTF-8 bytes from the start of the diagnosed input. */
|
|
401
670
|
readonly end: number;
|
|
402
671
|
readonly kind: "exact" | "insertion-point" | "fallback" | string;
|
|
403
672
|
}
|
|
@@ -431,7 +700,7 @@ export declare class MermanOperationError extends MermanError {
|
|
|
431
700
|
readonly codeName: string | null;
|
|
432
701
|
readonly kind: "generic" | "unknown-operation" | "missing-capability" | string;
|
|
433
702
|
readonly capabilityId: string | null;
|
|
434
|
-
/** Complete core-owned details
|
|
703
|
+
/** Complete core-owned details. */
|
|
435
704
|
readonly details: Readonly<Record<string, unknown>> | null;
|
|
436
705
|
readonly resourceDetails: MermanResourceErrorDetails | null;
|
|
437
706
|
readonly iconRegistryDetails: MermanIconRegistryErrorDetails | null;
|