@mermanjs/node-wasm 0.10.0-alpha.2 → 0.10.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 CHANGED
@@ -2,6 +2,35 @@
2
2
 
3
3
  All notable changes to the `@mermanjs/node` package group will be documented in this file.
4
4
 
5
+ ## [0.10.0] - 2026-11-12
6
+
7
+ Cumulative changes since the latest stable Node package group, `0.9.3`. The package remains experimental; see the [stable upgrade guide](../../docs/release/V093_TO_V0100_UPGRADE_GUIDE.md) for the complete migration.
8
+
9
+ | Upgrading from | Next step |
10
+ | --- | --- |
11
+ | `0.9.3` | Apply the breaking changes below and refresh SVG snapshots. |
12
+ | `0.10.0-alpha.1` or `alpha.2` | Review the guide's remaining contract and theme-catalog changes. |
13
+
14
+ ### Breaking changes
15
+
16
+ - Keep the nine-package group on one exact release: `@mermanjs/node`, its seven native platform packages, and explicit `@mermanjs/node-wasm`. Custom facades and native/WASM artifacts must come from the same source revision. Node binding API remains `1`; browser Web packages are a separate product.
17
+ - Migrate Options JSON from schema `2` to `3`: replace `presentation` styling with top-level `theme` and remove retired presentation-profile and host-owned CSS/security fields. Replace `metadataJson("presentation-catalog")` with `metadataJson("theme-catalog")`.
18
+ - Update custom render-metadata decoders for `theme_execution_evidence.version: 2` and required nullable `materialized_theme`. Keep unknown evidence versions opaque and inspect output-target admission separately from theme application. [#277](https://github.com/Latias94/merman/pull/277)
19
+ - Handle formula rejection under `constrained`, or choose `interactive` or an appropriate trusted policy with host execution and memory limits. Installing a math-capable transport does not relax resource admission.
20
+
21
+ ### Added
22
+
23
+ - Apply optional themes from 11 design groups with 14 concrete presets, including `paper-cut`, `carbon-copy`, and `pop-art`, or import editable JSON. Core colors and fonts reach all 34 diagram families, respecting source-owned styles and the typography used to measure labels. Presets retain alpha maturity; effects and output support depend on the family, shape, look, and target. See the [theme guide](../../docs/rendering/custom-diagram-themes.md) and [coverage limits](../../docs/rendering/diagram-theme-coverage.md). [#178](https://github.com/Latias94/merman/pull/178), [#277](https://github.com/Latias94/merman/pull/277), [#299](https://github.com/Latias94/merman/pull/299)
24
+ - Keep light and dark appearances in one schema-1 recipe. Editor, Gruvbox, and Ayu are paired designs; catalog consumers read `appearances` and each `concrete_preset_id`. Export the complete recipe with `export-theme-preset-json`, inspect or materialize it with `materialize-theme-json`, and resolve Follow-app policy to a declared appearance in the host. Whole-recipe validation includes inactive appearances. [#284](https://github.com/Latias94/merman/pull/284)
25
+ - Use native GNU or musl Linux ARM64 alongside the existing targets; GNU Linux requires glibc `2.31+`. Both native Node and explicit Node-WASM include SVG math, Cytoscape, and ELK. Binary export, analysis, ASCII, and text-measurement callbacks remain outside this SVG product. See the [package guide](README.md). [#265](https://github.com/Latias94/merman/pull/265), [#266](https://github.com/Latias94/merman/pull/266)
26
+
27
+ ### Changed and fixed
28
+
29
+ - Refine Cyberpunk with clear neutral text and restrained neon contours, and Ghibli with warm paper, sage surfaces and independent chart inks. Both add dedicated Flowchart, Sequence and XY Chart styling while retaining editable recipe export. [#302](https://github.com/Latias94/merman/pull/302)
30
+ - Advance from Mermaid `12.1.0` to `12.3.0`, including timed Flowchart Step edges, numbered badges, nine `bpmn-*` shapes, and updated Swimlane and Usecase behavior. Static SVG retains Step edges and badges without browser animation. Review snapshots for ELK `0.12.1` routing, label clearance, containers, and packing; see the [Mermaid migration](../../docs/migrations/mermaid-12-3.md). [#277](https://github.com/Latias94/merman/pull/277)
31
+ - Correct Class, Sequence, and State source handling and label geometry, including rich Class relationship labels and Sequence frames. Review affected SVG snapshots. [#282](https://github.com/Latias94/merman/pull/282), [#286](https://github.com/Latias94/merman/pull/286), [#294](https://github.com/Latias94/merman/pull/294), [#297](https://github.com/Latias94/merman/pull/297)
32
+ - Enforce JSON byte, member, token, and string limits consistently in native and Node-WASM engine construction, including defaults and shared values, without mutating caller input or invoking getters or `toJSON`. [#277](https://github.com/Latias94/merman/pull/277)
33
+
5
34
  ## [0.10.0-alpha.2] - 2026-11-06
6
35
 
7
36
  Changes since `0.10.0-alpha.1`. See the [host installation guide](../../docs/release/PREBUILT_PRODUCTS.md) for independently verified package availability.
package/README.md CHANGED
@@ -4,14 +4,14 @@ Explicit Node-targeted WebAssembly rendering for Node.js 22+ and static-site bui
4
4
  This is a separate opt-in package; `@mermanjs/node` remains the native N-API package and never
5
5
  silently falls back to browser or Node WASM.
6
6
 
7
- Version `0.10.0-alpha.2` targets Mermaid `12.3.0` and uses Node binding API `1`, Options JSON schema `3`, and theme execution evidence schema `2`. Keep the facade, generated glue, and WASM at the same exact version and source revision. Check the [host installation guide](https://github.com/Latias94/merman/blob/main/docs/release/PREBUILT_PRODUCTS.md#published-versions) for verified versions and channel availability.
7
+ Version `0.10.0` targets Mermaid `12.3.0` and uses Node binding API `1`, Options JSON schema `3`, and theme execution evidence schema `2`. Keep the facade, generated glue, and WASM at the same exact version and source revision. Check the [host installation guide](https://github.com/Latias94/merman/blob/main/docs/release/PREBUILT_PRODUCTS.md#published-versions) for verified versions and channel availability, and the [stable upgrade guide](https://github.com/Latias94/merman/blob/main/docs/release/V093_TO_V0100_UPGRADE_GUIDE.md) for migration. The package remains experimental.
8
8
 
9
9
  Version `0.10.0-alpha.1` retains Mermaid `12.2.0` and theme execution evidence schema `1`; Node binding API `1` and Options JSON schema `3` are unchanged. Upgrade all package assets together and update evidence consumers for the [render-evidence changes](https://github.com/Latias94/merman/blob/main/docs/release/UNRELEASED_CONTRACT_VERSIONS.md#source-appearance-and-render-evidence-follow-up).
10
10
 
11
11
  ## Quick start
12
12
 
13
13
  ```sh
14
- npm install --save-exact @mermanjs/node-wasm@0.10.0-alpha.2
14
+ npm install --save-exact @mermanjs/node-wasm@0.10.0
15
15
  ```
16
16
 
17
17
  ```js
@@ -62,27 +62,41 @@ Node.js 22.0.0 is the minimum runtime.
62
62
 
63
63
  ## Compiled themes
64
64
 
65
+ The catalog groups 11 designs with 14 concrete presets, including `paper-cut`, `carbon-copy`, and
66
+ `pop-art`. Editor, Gruvbox, and Ayu provide both Light and Dark; other designs declare their own modes.
67
+
65
68
  Select a preset through the top-level `theme` group in Options JSON schema `3`. Discover preset
66
69
  IDs through the initialized engine's theme catalog:
67
70
 
68
71
  ```js
69
72
  const catalog = JSON.parse(engine.metadataJson("theme-catalog"));
70
73
  const themedSvg = await engine.renderSvg("flowchart LR\nA --> B", {
71
- optionsJson: JSON.stringify({ version: 3, theme: { preset: "spotless" } }),
74
+ optionsJson: JSON.stringify({ version: 3, theme: { preset: "editor", appearance: "dark" } }),
72
75
  });
73
76
  ```
74
77
 
75
- Catalog `available` means that the recipe can compile under the current resource policy. All
76
- built-in presets remain `alpha` with empty `qualified_cells`; availability and unknown
77
- profile/admission IDs never establish portable output. Flowchart glow and shadow effects require
78
- the Classic look and supported shapes. SVG fonts resolve on the viewing host; exported recipes
78
+ The catalog groups one design's `supported_appearances`, `default_appearance`, and appearance-specific
79
+ discovery details. `available` means that every declared appearance can compile under the current
80
+ resource policy. All built-in presets remain `alpha` with empty appearance-specific `qualified_cells`; availability and unknown
81
+ profile/admission IDs never establish portable output. Flowchart glow and shadow effects support
82
+ documented shapes in Classic and Neo; other families retain their own look and output restrictions.
83
+ SVG fonts resolve on the viewing host; exported recipes
79
84
  do not embed them.
80
85
 
81
- Use `executeOperation()` or `executeOperationSync()` with operation IDs
82
- `materialize-theme-json`, `describe-theme-support-json`, or `export-theme-preset-json` for
83
- shared definition JSON, support queries and preset export. Materialization returns a complete
84
- spec that can be passed as `theme: { spec }`; no intermediate file is required. Replace old
85
- `presentation.theme` inputs and `presentation-catalog` metadata calls when upgrading. See the
86
+ `engine.exportThemePreset("editor")` returns a complete editable V1 recipe with
87
+ `design.appearances` and `design.default_appearance`. Serialize it with `JSON.stringify(recipe, null, 2)`,
88
+ save and edit the JSON, then reload it with `JSON.parse(...)`, retaining `schema_version`, `kind`,
89
+ and the complete `design`. Pass that recipe with a concrete appearance
90
+ through `theme: { recipe, appearance: "dark" }`; omitted appearance uses its declared default.
91
+ `engine.materializeTheme({ schema_version: 1, action: "inspect", recipe })` validates all modes,
92
+ while `action: "materialize"` with an optional `appearance` returns a concrete specification.
93
+ Keep the authored recipe when saving or sharing a theme. Resolve Follow-app/editor in the host.
94
+
95
+ Both transports share the same async authoring helpers, generic `executeOperation()` and synchronous
96
+ `executeOperationSync()` routes. The original `materialize-theme-json`,
97
+ `describe-theme-support-json`, and `export-theme-preset-json` operation IDs remain unchanged.
98
+ See the [native package examples](https://github.com/Latias94/merman/blob/main/platforms/node/packages/node/README.md#compiled-themes)
99
+ and the
86
100
  [theme guide](https://github.com/Latias94/merman/blob/main/docs/rendering/custom-diagram-themes.md)
87
101
  for authoring and portability, and the
88
102
  [current Node changelog](https://github.com/Latias94/merman/blob/main/platforms/node/CHANGELOG.md)
@@ -5,7 +5,7 @@
5
5
  "version": "0.9.3",
6
6
  "command_profile": "workspace-all-features-runtime",
7
7
  "offline": true,
8
- "cargo_lock_sha256": "fea9469fc52b00b62f0552d73b7268a120fbe122f74855d72ae619f38150eb00",
8
+ "cargo_lock_sha256": "7ba53b1cc29c197389c49542df3055fabfd083b2c3f0850a5ca283d923a5a09d",
9
9
  "configuration_sha256": "50ee414d81334fe54e34465a8441d8ee5ec237518b06b3759c794056aa3e26a4"
10
10
  },
11
11
  "licenses": [
Binary file
package/dist/engine.mjs CHANGED
@@ -88,6 +88,16 @@ const COMPILED_PREREQUISITES_BY_OPERATION_ID = new Map(
88
88
  const KNOWN_OUTPUT_CONTRACT_BY_ID = new Map(
89
89
  NODE_WIRE_CONTRACT.artifact.output_contracts.map((contract) => [contract.id, contract]),
90
90
  );
91
+ const THEME_AUTHORING_INPUT_LIMITS = Object.freeze({
92
+ ...NODE_TRANSPORT_LIMITS.metadata,
93
+ max_utf8_bytes: NODE_TRANSPORT_FIELD_LIMITS.source_utf8_bytes,
94
+ max_string_utf8_bytes: NODE_TRANSPORT_FIELD_LIMITS.source_utf8_bytes,
95
+ });
96
+ const THEME_AUTHORING_RESULT_LIMITS = Object.freeze({
97
+ ...NODE_TRANSPORT_LIMITS.metadata,
98
+ max_utf8_bytes: NODE_TRANSPORT_FIELD_LIMITS.data_utf8_bytes,
99
+ max_string_utf8_bytes: NODE_TRANSPORT_FIELD_LIMITS.data_utf8_bytes,
100
+ });
91
101
  const MAX_OPERATION_TIMEOUT_MS = 0xffff_ffff;
92
102
  const MERMAN_ENGINE_CONSTRUCTION_TOKEN = Symbol("MermanEngine construction");
93
103
 
@@ -259,6 +269,33 @@ export class MermanEngine {
259
269
  );
260
270
  }
261
271
 
272
+ materializeTheme(input, options = {}) {
273
+ return this.#themeAuthoring("materialize-theme-json", input, options);
274
+ }
275
+
276
+ describeThemeSupport(query, options = {}) {
277
+ return this.#themeAuthoring("describe-theme-support-json", query, options);
278
+ }
279
+
280
+ exportThemePreset(presetId, options = {}) {
281
+ if (typeof presetId !== "string") {
282
+ return Promise.reject(new TypeError("theme preset ID must be a string."));
283
+ }
284
+ return this.#themeAuthoring("export-theme-preset-json", presetId, options);
285
+ }
286
+
287
+ async #themeAuthoring(operationId, input, options) {
288
+ const source = typeof input === "string"
289
+ ? input
290
+ : encodeTransportJson(input, "theme authoring input", THEME_AUTHORING_INPUT_LIMITS);
291
+ const json = await this.#execute(
292
+ { operationId, source, optionsJson: options.optionsJson },
293
+ { signal: options.signal, timeoutMs: options.timeoutMs },
294
+ false,
295
+ );
296
+ return parseTransportJsonText(json, "theme authoring result", THEME_AUTHORING_RESULT_LIMITS);
297
+ }
298
+
262
299
  metadataJson(id) {
263
300
  this.#executor.assertOpen();
264
301
  if (typeof id !== "string" || id.length === 0) {
package/dist/index.d.ts CHANGED
@@ -16,9 +16,125 @@ export interface MermanBindingOptions {
16
16
  profile?: MermanResourceProfile;
17
17
  limits?: Record<string, number>;
18
18
  };
19
+ /** A supplied selection replaces the complete constructor theme; null clears it. */
20
+ theme?: DiagramThemeSelection | null;
19
21
  [key: string]: unknown;
20
22
  }
21
23
 
24
+ export type ThemeAppearance = "light" | "dark";
25
+ export type ThemeJsonValue =
26
+ | string | number | boolean | null
27
+ | ThemeJsonValue[]
28
+ | { [key: string]: ThemeJsonValue };
29
+ export type ThemeJsonObject = { [key: string]: ThemeJsonValue };
30
+
31
+ /** Editable JSON sections are validated by the shared Rust theme compiler. */
32
+ export interface ThemeDesignV1 {
33
+ tokens?: Record<string, ThemeJsonValue>;
34
+ styles?: Record<string, ThemeJsonValue>;
35
+ rules?: ThemeJsonObject[];
36
+ palettes?: Record<string, ThemeJsonValue>;
37
+ canvas?: ThemeJsonObject;
38
+ typography?: ThemeJsonObject;
39
+ mermaid?: ThemeJsonObject;
40
+ assets?: ThemeJsonObject;
41
+ requirements?: ThemeJsonObject;
42
+ appearances?: Partial<Record<ThemeAppearance, ThemeAppearanceOverridesV1>>;
43
+ default_appearance?: ThemeAppearance;
44
+ }
45
+
46
+ export type ThemeAppearanceOverridesV1 =
47
+ Omit<ThemeDesignV1, "appearances" | "default_appearance" | "assets" | "requirements">;
48
+
49
+ export type ThemeRecipeV1 = {
50
+ schema_version: 1;
51
+ preset?: never;
52
+ spec?: never;
53
+ recipe?: never;
54
+ appearance?: never;
55
+ } & (
56
+ | { kind: "design"; design: ThemeDesignV1; complete_spec?: never }
57
+ | { kind: "complete_spec"; complete_spec: ThemeJsonObject; design?: never }
58
+ );
59
+
60
+ export type DiagramThemeSelection =
61
+ | ThemeRecipeV1
62
+ | ({ kind?: never; schema_version?: never; design?: never; complete_spec?: never } & (
63
+ | { preset: string; appearance?: ThemeAppearance; recipe?: never; spec?: never }
64
+ | { recipe: ThemeRecipeV1; appearance?: ThemeAppearance; preset?: never; spec?: never }
65
+ | { spec: ThemeJsonObject; preset?: never; recipe?: never; appearance?: never }
66
+ ));
67
+
68
+ export type ThemeAuthoringRequestV1 =
69
+ | { schema_version: 1; action: "inspect"; recipe: ThemeRecipeV1; appearance?: never }
70
+ | { schema_version: 1; action: "materialize"; recipe: ThemeRecipeV1; appearance?: ThemeAppearance };
71
+ export type ThemeAuthoringInput = ThemeDesignV1 | ThemeAuthoringRequestV1 | string;
72
+
73
+ export interface ThemeDesignReferenceUse {
74
+ token: string;
75
+ path: string;
76
+ domain: ThemeJsonObject;
77
+ }
78
+
79
+ export interface ThemeRecipeReferenceUseV1 extends ThemeDesignReferenceUse {
80
+ token_path: string;
81
+ }
82
+
83
+ export interface MaterializedThemeWireV1 {
84
+ schema_version: 1;
85
+ authoring_schema_version: 1;
86
+ expansion_version: 1;
87
+ spec_schema_version: 1;
88
+ spec: ThemeJsonObject;
89
+ references?: ThemeDesignReferenceUse[];
90
+ }
91
+
92
+ export interface ThemeRecipeInspectionV1 {
93
+ schema_version: 1;
94
+ recipe_schema_version: 1;
95
+ supported_appearances: ThemeAppearance[];
96
+ default_appearance: ThemeAppearance | null;
97
+ appearances: {
98
+ appearance: ThemeAppearance | null;
99
+ references: ThemeRecipeReferenceUseV1[];
100
+ }[];
101
+ }
102
+
103
+ export interface MaterializedThemeRecipeV1 {
104
+ schema_version: 1;
105
+ recipe_schema_version: 1;
106
+ supported_appearances: ThemeAppearance[];
107
+ default_appearance: ThemeAppearance | null;
108
+ effective_appearance: ThemeAppearance | null;
109
+ spec: ThemeJsonObject;
110
+ references: ThemeRecipeReferenceUseV1[];
111
+ }
112
+
113
+ export type ThemeAuthoringResult =
114
+ | MaterializedThemeWireV1 | ThemeRecipeInspectionV1 | MaterializedThemeRecipeV1;
115
+ export type ThemeAuthoringResultFor<Input extends ThemeAuthoringInput> =
116
+ Input extends { action: "inspect" } ? ThemeRecipeInspectionV1
117
+ : Input extends { action: "materialize" } ? MaterializedThemeRecipeV1
118
+ : Input extends string ? ThemeAuthoringResult : MaterializedThemeWireV1;
119
+
120
+ export interface ThemeSupportQueryV1 {
121
+ schema_version: 1;
122
+ family: string;
123
+ output: string;
124
+ subject:
125
+ | { kind: "rule"; target: string; facet: string }
126
+ | { kind: "ordinal-palette"; target: string }
127
+ | { kind: "base-typography"; property: string };
128
+ }
129
+
130
+ export interface ThemeCapabilityDescriptorV1 {
131
+ schema_version: 1;
132
+ claim_revision: number;
133
+ query: ThemeSupportQueryV1;
134
+ state: "unconditional" | "conditional" | "not-applicable" | "unsupported" | "unverified" | (string & {});
135
+ reason_ids: string[];
136
+ }
137
+
22
138
  /** One host-loaded Iconify pack, admitted once into an immutable engine-local registry. */
23
139
  export interface MermanIconPack {
24
140
  json: string;
@@ -201,6 +317,17 @@ export declare class MermanEngine {
201
317
  source: string,
202
318
  options?: Omit<RenderSvgOptions, "signal">,
203
319
  ): string;
320
+ /** Raw strings preserve duplicate-field admission and source paths in Rust. */
321
+ materializeTheme<Input extends ThemeAuthoringInput>(
322
+ input: Input,
323
+ options?: RenderSvgOptions,
324
+ ): Promise<ThemeAuthoringResultFor<Input>>;
325
+ describeThemeSupport(
326
+ query: ThemeSupportQueryV1 | string,
327
+ options?: RenderSvgOptions,
328
+ ): Promise<ThemeCapabilityDescriptorV1>;
329
+ /** Exports the complete editable design, including every declared appearance. */
330
+ exportThemePreset(presetId: string, options?: RenderSvgOptions): Promise<ThemeRecipeV1>;
204
331
  metadataJson(id: string): string;
205
332
  executeOperation(
206
333
  request: MermanOperationRequest,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mermanjs/node-wasm",
3
- "version": "0.10.0-alpha.2",
3
+ "version": "0.10.0",
4
4
  "description": "Explicit Node-targeted WebAssembly rendering package for Merman.",
5
5
  "type": "module",
6
6
  "engines": {