@mermanjs/node-wasm 0.10.0-alpha.2 → 0.11.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 +50 -0
- package/README.md +28 -13
- package/THIRD_PARTY_LICENSES/grok-build/LICENSE +204 -0
- package/THIRD_PARTY_LICENSES/rust-cargo-dependencies.json +5 -13
- package/THIRD_PARTY_LICENSES/usvg/LICENSE-APACHE +176 -0
- package/THIRD_PARTY_LICENSES/usvg/LICENSE-MIT +25 -0
- package/THIRD_PARTY_NOTICES.md +46 -12
- package/artifact/merman_node_bg.wasm +0 -0
- package/dist/bounded-executor.mjs +3 -4
- package/dist/candidates/wrap-engine.mjs +14 -2
- package/dist/engine.mjs +138 -48
- package/dist/errors.mjs +62 -27
- package/dist/generated/binding-contract.mjs +81 -1
- package/dist/generated/node-wire-contract.json +2 -1
- package/dist/index.d.ts +162 -2
- package/dist/native-loader.mjs +75 -0
- package/dist/transport-contract.mjs +1 -1
- package/package.json +1 -1
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -15,19 +15,19 @@ license or notice files. This inventory is engineering evidence, not legal advic
|
|
|
15
15
|
|
|
16
16
|
ASCII rendering source, copied fixtures, and behavior references.
|
|
17
17
|
|
|
18
|
-
Components: `beautiful-mermaid`, `mermaid`, `mermaid-ascii`, `mermaid-rs-renderer`.
|
|
18
|
+
Components: `beautiful-mermaid`, `grok-build`, `mermaid`, `mermaid-ascii`, `mermaid-rs-renderer`.
|
|
19
19
|
|
|
20
20
|
### `cli-default`
|
|
21
21
|
|
|
22
22
|
The source-default CLI feature closure including ELK without RaTeX math/font support.
|
|
23
23
|
|
|
24
|
-
Components: `cose-base-v1`, `cose-base-v2`, `cytoscape`, `cytoscape-cose-bilkent`, `cytoscape-fcose`, `d3-path`, `d3-shape`, `dagre`, `dompurify`, `eclipse-elk`, `elkjs`, `fmin`, `graphlib`, `layout-base-v1`, `layout-base-v2`, `mermaid`, `non-layered-tidy-tree-layout`, `rough-rs`, `roughjs`, `roxmltree-dom`, `sanitize-url`, `unicode-linebreak`, `venn-js`, `zenuml-core`.
|
|
24
|
+
Components: `cose-base-v1`, `cose-base-v2`, `cytoscape`, `cytoscape-cose-bilkent`, `cytoscape-fcose`, `d3-path`, `d3-shape`, `dagre`, `dompurify`, `eclipse-elk`, `elkjs`, `fmin`, `graphlib`, `layout-base-v1`, `layout-base-v2`, `mermaid`, `non-layered-tidy-tree-layout`, `rough-rs`, `roughjs`, `roxmltree-dom`, `sanitize-url`, `unicode-linebreak`, `usvg`, `venn-js`, `zenuml-core`.
|
|
25
25
|
|
|
26
26
|
### `cli-release`
|
|
27
27
|
|
|
28
28
|
The published complete CLI release closure, including explicit ELK and RaTeX math/font support.
|
|
29
29
|
|
|
30
|
-
Components: `cose-base-v1`, `cose-base-v2`, `cytoscape`, `cytoscape-cose-bilkent`, `cytoscape-fcose`, `d3-path`, `d3-shape`, `dagre`, `dompurify`, `eclipse-elk`, `elkjs`, `fmin`, `graphlib`, `katex-fonts`, `layout-base-v1`, `layout-base-v2`, `mermaid`, `non-layered-tidy-tree-layout`, `ratex`, `rough-rs`, `roughjs`, `roxmltree-dom`, `sanitize-url`, `unicode-linebreak`, `venn-js`, `zenuml-core`.
|
|
30
|
+
Components: `cose-base-v1`, `cose-base-v2`, `cytoscape`, `cytoscape-cose-bilkent`, `cytoscape-fcose`, `d3-path`, `d3-shape`, `dagre`, `dompurify`, `eclipse-elk`, `elkjs`, `fmin`, `graphlib`, `katex-fonts`, `layout-base-v1`, `layout-base-v2`, `mermaid`, `non-layered-tidy-tree-layout`, `ratex`, `rough-rs`, `roughjs`, `roxmltree-dom`, `sanitize-url`, `unicode-linebreak`, `usvg`, `venn-js`, `zenuml-core`.
|
|
31
31
|
|
|
32
32
|
### `elk-render`
|
|
33
33
|
|
|
@@ -57,43 +57,43 @@ Components: `cose-base-v1`, `cose-base-v2`, `cytoscape`, `cytoscape-cose-bilkent
|
|
|
57
57
|
|
|
58
58
|
Embedding SDK full legal closure.
|
|
59
59
|
|
|
60
|
-
Components: `cose-base-v1`, `cose-base-v2`, `cytoscape`, `cytoscape-cose-bilkent`, `cytoscape-fcose`, `d3-path`, `d3-shape`, `dagre`, `dompurify`, `eclipse-elk`, `elkjs`, `fmin`, `graphlib`, `katex-fonts`, `layout-base-v1`, `layout-base-v2`, `mermaid`, `non-layered-tidy-tree-layout`, `ratex`, `rough-rs`, `roughjs`, `roxmltree-dom`, `sanitize-url`, `sdk-cousine`, `unicode-linebreak`, `venn-js`, `zenuml-core`.
|
|
60
|
+
Components: `cose-base-v1`, `cose-base-v2`, `cytoscape`, `cytoscape-cose-bilkent`, `cytoscape-fcose`, `d3-path`, `d3-shape`, `dagre`, `dompurify`, `eclipse-elk`, `elkjs`, `fmin`, `graphlib`, `katex-fonts`, `layout-base-v1`, `layout-base-v2`, `mermaid`, `non-layered-tidy-tree-layout`, `ratex`, `rough-rs`, `roughjs`, `roxmltree-dom`, `sanitize-url`, `sdk-cousine`, `unicode-linebreak`, `usvg`, `venn-js`, `zenuml-core`.
|
|
61
61
|
|
|
62
62
|
### `sdk-math`
|
|
63
63
|
|
|
64
64
|
Embedding SDK math legal closure.
|
|
65
65
|
|
|
66
|
-
Components: `cose-base-v1`, `cose-base-v2`, `cytoscape`, `cytoscape-cose-bilkent`, `cytoscape-fcose`, `d3-path`, `d3-shape`, `dagre`, `dompurify`, `fmin`, `graphlib`, `katex-fonts`, `layout-base-v1`, `layout-base-v2`, `mermaid`, `non-layered-tidy-tree-layout`, `ratex`, `rough-rs`, `roughjs`, `roxmltree-dom`, `sanitize-url`, `sdk-cousine`, `unicode-linebreak`, `venn-js`, `zenuml-core`.
|
|
66
|
+
Components: `cose-base-v1`, `cose-base-v2`, `cytoscape`, `cytoscape-cose-bilkent`, `cytoscape-fcose`, `d3-path`, `d3-shape`, `dagre`, `dompurify`, `fmin`, `graphlib`, `katex-fonts`, `layout-base-v1`, `layout-base-v2`, `mermaid`, `non-layered-tidy-tree-layout`, `ratex`, `rough-rs`, `roughjs`, `roxmltree-dom`, `sanitize-url`, `sdk-cousine`, `unicode-linebreak`, `usvg`, `venn-js`, `zenuml-core`.
|
|
67
67
|
|
|
68
68
|
### `sdk-native-full`
|
|
69
69
|
|
|
70
70
|
Native C full SDK, including its ASCII source notices.
|
|
71
71
|
|
|
72
|
-
Components: `beautiful-mermaid`, `cose-base-v1`, `cose-base-v2`, `cytoscape`, `cytoscape-cose-bilkent`, `cytoscape-fcose`, `d3-path`, `d3-shape`, `dagre`, `dompurify`, `eclipse-elk`, `elkjs`, `fmin`, `graphlib`, `katex-fonts`, `layout-base-v1`, `layout-base-v2`, `mermaid`, `mermaid-ascii`, `mermaid-rs-renderer`, `non-layered-tidy-tree-layout`, `ratex`, `rough-rs`, `roughjs`, `roxmltree-dom`, `sanitize-url`, `sdk-cousine`, `unicode-linebreak`, `venn-js`, `zenuml-core`.
|
|
72
|
+
Components: `beautiful-mermaid`, `cose-base-v1`, `cose-base-v2`, `cytoscape`, `cytoscape-cose-bilkent`, `cytoscape-fcose`, `d3-path`, `d3-shape`, `dagre`, `dompurify`, `eclipse-elk`, `elkjs`, `fmin`, `graphlib`, `grok-build`, `katex-fonts`, `layout-base-v1`, `layout-base-v2`, `mermaid`, `mermaid-ascii`, `mermaid-rs-renderer`, `non-layered-tidy-tree-layout`, `ratex`, `rough-rs`, `roughjs`, `roxmltree-dom`, `sanitize-url`, `sdk-cousine`, `unicode-linebreak`, `usvg`, `venn-js`, `zenuml-core`.
|
|
73
73
|
|
|
74
74
|
### `sdk-native-math`
|
|
75
75
|
|
|
76
76
|
Native C math SDK, including its ASCII source notices.
|
|
77
77
|
|
|
78
|
-
Components: `beautiful-mermaid`, `cose-base-v1`, `cose-base-v2`, `cytoscape`, `cytoscape-cose-bilkent`, `cytoscape-fcose`, `d3-path`, `d3-shape`, `dagre`, `dompurify`, `fmin`, `graphlib`, `katex-fonts`, `layout-base-v1`, `layout-base-v2`, `mermaid`, `mermaid-ascii`, `mermaid-rs-renderer`, `non-layered-tidy-tree-layout`, `ratex`, `rough-rs`, `roughjs`, `roxmltree-dom`, `sanitize-url`, `sdk-cousine`, `unicode-linebreak`, `venn-js`, `zenuml-core`.
|
|
78
|
+
Components: `beautiful-mermaid`, `cose-base-v1`, `cose-base-v2`, `cytoscape`, `cytoscape-cose-bilkent`, `cytoscape-fcose`, `d3-path`, `d3-shape`, `dagre`, `dompurify`, `fmin`, `graphlib`, `grok-build`, `katex-fonts`, `layout-base-v1`, `layout-base-v2`, `mermaid`, `mermaid-ascii`, `mermaid-rs-renderer`, `non-layered-tidy-tree-layout`, `ratex`, `rough-rs`, `roughjs`, `roxmltree-dom`, `sanitize-url`, `sdk-cousine`, `unicode-linebreak`, `usvg`, `venn-js`, `zenuml-core`.
|
|
79
79
|
|
|
80
80
|
### `sdk-native-standard`
|
|
81
81
|
|
|
82
82
|
Native C standard SDK, including its ASCII source notices.
|
|
83
83
|
|
|
84
|
-
Components: `beautiful-mermaid`, `cose-base-v1`, `cose-base-v2`, `cytoscape`, `cytoscape-cose-bilkent`, `cytoscape-fcose`, `d3-path`, `d3-shape`, `dagre`, `dompurify`, `fmin`, `graphlib`, `layout-base-v1`, `layout-base-v2`, `mermaid`, `mermaid-ascii`, `mermaid-rs-renderer`, `non-layered-tidy-tree-layout`, `rough-rs`, `roughjs`, `roxmltree-dom`, `sanitize-url`, `sdk-cousine`, `unicode-linebreak`, `venn-js`, `zenuml-core`.
|
|
84
|
+
Components: `beautiful-mermaid`, `cose-base-v1`, `cose-base-v2`, `cytoscape`, `cytoscape-cose-bilkent`, `cytoscape-fcose`, `d3-path`, `d3-shape`, `dagre`, `dompurify`, `fmin`, `graphlib`, `grok-build`, `layout-base-v1`, `layout-base-v2`, `mermaid`, `mermaid-ascii`, `mermaid-rs-renderer`, `non-layered-tidy-tree-layout`, `rough-rs`, `roughjs`, `roxmltree-dom`, `sanitize-url`, `sdk-cousine`, `unicode-linebreak`, `usvg`, `venn-js`, `zenuml-core`.
|
|
85
85
|
|
|
86
86
|
### `sdk-standard`
|
|
87
87
|
|
|
88
88
|
Embedding SDK standard legal closure.
|
|
89
89
|
|
|
90
|
-
Components: `cose-base-v1`, `cose-base-v2`, `cytoscape`, `cytoscape-cose-bilkent`, `cytoscape-fcose`, `d3-path`, `d3-shape`, `dagre`, `dompurify`, `fmin`, `graphlib`, `layout-base-v1`, `layout-base-v2`, `mermaid`, `non-layered-tidy-tree-layout`, `rough-rs`, `roughjs`, `roxmltree-dom`, `sanitize-url`, `sdk-cousine`, `unicode-linebreak`, `venn-js`, `zenuml-core`.
|
|
90
|
+
Components: `cose-base-v1`, `cose-base-v2`, `cytoscape`, `cytoscape-cose-bilkent`, `cytoscape-fcose`, `d3-path`, `d3-shape`, `dagre`, `dompurify`, `fmin`, `graphlib`, `layout-base-v1`, `layout-base-v2`, `mermaid`, `non-layered-tidy-tree-layout`, `rough-rs`, `roughjs`, `roxmltree-dom`, `sanitize-url`, `sdk-cousine`, `unicode-linebreak`, `usvg`, `venn-js`, `zenuml-core`.
|
|
91
91
|
|
|
92
92
|
### `source-archive`
|
|
93
93
|
|
|
94
94
|
Conservative repository source archive inventory covering every translated, copied, linked, embedded, fixture, and behavior-reference component recorded here.
|
|
95
95
|
|
|
96
|
-
Components: `beautiful-mermaid`, `cose-base-v1`, `cose-base-v2`, `cytoscape`, `cytoscape-cose-bilkent`, `cytoscape-fcose`, `d3-path`, `d3-shape`, `dagre`, `dompurify`, `eclipse-elk`, `elkjs`, `fmin`, `graphlib`, `layout-base-v1`, `layout-base-v2`, `mermaid`, `mermaid-ascii`, `mermaid-rs-renderer`, `monaqa-tree-sitter-mermaid`, `non-layered-tidy-tree-layout`, `pappasam-tree-sitter-mermaid`, `rough-rs`, `roughjs`, `roxmltree-dom`, `sanitize-url`, `singularity-tree-sitter-mermaid`, `tree-sitter-generator`, `tree-sitter-mermaid-mermaid-12-new-families`, `tree-sitter-mermaid-mermaid-baseline`, `tree-sitter-mermaid-zenuml-baseline`, `tree-sitter-templates`, `unicode-linebreak`, `venn-js`, `wasm-minimal-protocol`, `zenuml-core`.
|
|
96
|
+
Components: `beautiful-mermaid`, `cose-base-v1`, `cose-base-v2`, `cytoscape`, `cytoscape-cose-bilkent`, `cytoscape-fcose`, `d3-path`, `d3-shape`, `dagre`, `dompurify`, `eclipse-elk`, `elkjs`, `fmin`, `graphlib`, `grok-build`, `layout-base-v1`, `layout-base-v2`, `mermaid`, `mermaid-ascii`, `mermaid-rs-renderer`, `monaqa-tree-sitter-mermaid`, `non-layered-tidy-tree-layout`, `pappasam-tree-sitter-mermaid`, `rough-rs`, `roughjs`, `roxmltree-dom`, `sanitize-url`, `singularity-tree-sitter-mermaid`, `tree-sitter-generator`, `tree-sitter-mermaid-mermaid-12-new-families`, `tree-sitter-mermaid-mermaid-baseline`, `tree-sitter-mermaid-zenuml-baseline`, `tree-sitter-templates`, `unicode-linebreak`, `usvg`, `venn-js`, `wasm-minimal-protocol`, `zenuml-core`.
|
|
97
97
|
|
|
98
98
|
### `tree-sitter-mermaid-source`
|
|
99
99
|
|
|
@@ -117,7 +117,7 @@ Components: `dompurify`, `mermaid`, `sanitize-url`, `zenuml-core`.
|
|
|
117
117
|
|
|
118
118
|
Browser ASCII artifacts combining the core parser legal closure with the ASCII renderer's copied fixtures and behavior references.
|
|
119
119
|
|
|
120
|
-
Components: `beautiful-mermaid`, `dompurify`, `mermaid`, `mermaid-ascii`, `mermaid-rs-renderer`, `sanitize-url`, `zenuml-core`.
|
|
120
|
+
Components: `beautiful-mermaid`, `dompurify`, `grok-build`, `mermaid`, `mermaid-ascii`, `mermaid-rs-renderer`, `sanitize-url`, `zenuml-core`.
|
|
121
121
|
|
|
122
122
|
### `web-editor`
|
|
123
123
|
|
|
@@ -129,7 +129,7 @@ Components: `dompurify`, `mermaid`, `sanitize-url`, `zenuml-core`.
|
|
|
129
129
|
|
|
130
130
|
Browser SDK including ASCII, Cytoscape, ELK and RaTeX math/font support.
|
|
131
131
|
|
|
132
|
-
Components: `beautiful-mermaid`, `cose-base-v1`, `cose-base-v2`, `cytoscape`, `cytoscape-cose-bilkent`, `cytoscape-fcose`, `d3-path`, `d3-shape`, `dagre`, `dompurify`, `eclipse-elk`, `elkjs`, `fmin`, `graphlib`, `katex-fonts`, `layout-base-v1`, `layout-base-v2`, `mermaid`, `mermaid-ascii`, `mermaid-rs-renderer`, `non-layered-tidy-tree-layout`, `ratex`, `rough-rs`, `roughjs`, `roxmltree-dom`, `sanitize-url`, `unicode-linebreak`, `venn-js`, `zenuml-core`.
|
|
132
|
+
Components: `beautiful-mermaid`, `cose-base-v1`, `cose-base-v2`, `cytoscape`, `cytoscape-cose-bilkent`, `cytoscape-fcose`, `d3-path`, `d3-shape`, `dagre`, `dompurify`, `eclipse-elk`, `elkjs`, `fmin`, `graphlib`, `grok-build`, `katex-fonts`, `layout-base-v1`, `layout-base-v2`, `mermaid`, `mermaid-ascii`, `mermaid-rs-renderer`, `non-layered-tidy-tree-layout`, `ratex`, `rough-rs`, `roughjs`, `roxmltree-dom`, `sanitize-url`, `unicode-linebreak`, `venn-js`, `zenuml-core`.
|
|
133
133
|
|
|
134
134
|
### `web-render`
|
|
135
135
|
|
|
@@ -366,6 +366,22 @@ dugong-graphlib is a modified Rust translation of the graph model used by Dagre.
|
|
|
366
366
|
- Legal files:
|
|
367
367
|
- [`THIRD_PARTY_LICENSES/graphlib/LICENSE`](THIRD_PARTY_LICENSES/graphlib/LICENSE) (license, SHA-256 `6a349742a6cb219d5a2fc8d0844f6d89a6efc62e20c664450d884fc7ff2d6015`)
|
|
368
368
|
|
|
369
|
+
### Grok terminal Mermaid (xai-grok-markdown) (`grok-build`)
|
|
370
|
+
|
|
371
|
+
Grok's Apache-2.0 terminal Mermaid module is a behavior and presentation reference for terminal graph rendering. No Grok renderer, parser, test, or fixture implementation is included in distributed Merman artifacts. The separate MIT-licensed third_party/mermaid-to-svg component does not license this terminal module.
|
|
372
|
+
|
|
373
|
+
- Version: `0.1.0`
|
|
374
|
+
- Source: <https://github.com/xai-org/grok-build>
|
|
375
|
+
- Source ref: `2bdd1d6a6369de0e8c68132ea4539e9abd9e14a8`
|
|
376
|
+
- Source commit: `2bdd1d6a6369de0e8c68132ea4539e9abd9e14a8`
|
|
377
|
+
- Source path: `crates/codegen/xai-grok-markdown/src/mermaid.rs`
|
|
378
|
+
- Relationship: `behavior-reference`
|
|
379
|
+
- License expression: `Apache-2.0`
|
|
380
|
+
- Artifact scopes: `ascii-render`, `sdk-native-full`, `sdk-native-math`, `sdk-native-standard`, `source-archive`, `web-ascii`, `web-full`
|
|
381
|
+
- Local evidence: `crates/merman-ascii`
|
|
382
|
+
- Legal files:
|
|
383
|
+
- [`THIRD_PARTY_LICENSES/grok-build/LICENSE`](THIRD_PARTY_LICENSES/grok-build/LICENSE) (license, SHA-256 `116f7778b9802e569b7fa3a532b17bd80eb13c67837def01eed093d4ea472f28`)
|
|
384
|
+
|
|
369
385
|
### KaTeX fonts bundled by ratex-katex-fonts (`katex-fonts`)
|
|
370
386
|
|
|
371
387
|
The RaTeX SVG backend embeds twenty KaTeX TrueType fonts; those font bytes are licensed under OFL-1.1 rather than RaTeX's MIT code license.
|
|
@@ -722,6 +738,24 @@ merman-unicode-linebreak is an Apache-2.0 fork of unicode-linebreak 0.1.5, prese
|
|
|
722
738
|
- Legal files:
|
|
723
739
|
- [`THIRD_PARTY_LICENSES/unicode-linebreak/LICENSE`](THIRD_PARTY_LICENSES/unicode-linebreak/LICENSE) (license, SHA-256 `c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4`)
|
|
724
740
|
|
|
741
|
+
### usvg (`usvg`)
|
|
742
|
+
|
|
743
|
+
Source-tree builds of the native font and image export pipeline link usvg 0.47.0 with a local font fallback backport. This source component carries the two upstream license texts.
|
|
744
|
+
|
|
745
|
+
- Version: `0.47.0 with font fallback backport`
|
|
746
|
+
- Source: <https://github.com/linebender/resvg>
|
|
747
|
+
- Source ref: `v0.47.0`
|
|
748
|
+
- Source commit: `3a0fdba53ccf2d346b54cc53ba7adf0ee60d0707`
|
|
749
|
+
- Source path: `crates/usvg`
|
|
750
|
+
- Relationship: `copied`, `linked`, `modified`
|
|
751
|
+
- License expression: `Apache-2.0 OR MIT`
|
|
752
|
+
- Selected license path: `MIT`
|
|
753
|
+
- Artifact scopes: `cli-default`, `cli-release`, `sdk-full`, `sdk-math`, `sdk-native-full`, `sdk-native-math`, `sdk-native-standard`, `sdk-standard`, `source-archive`
|
|
754
|
+
- Local evidence: `vendor/usvg`
|
|
755
|
+
- Legal files:
|
|
756
|
+
- [`THIRD_PARTY_LICENSES/usvg/LICENSE-APACHE`](THIRD_PARTY_LICENSES/usvg/LICENSE-APACHE) (license, SHA-256 `a6cba85bc92e0cff7a450b1d873c0eaa2e9fc96bf472df0247a26bec77bf3ff9`)
|
|
757
|
+
- [`THIRD_PARTY_LICENSES/usvg/LICENSE-MIT`](THIRD_PARTY_LICENSES/usvg/LICENSE-MIT) (license, SHA-256 `f5d934dc281b44e0003ee461ac740b18b6629a454decd872c774d34e4ee0b21d`)
|
|
758
|
+
|
|
725
759
|
### @upsetjs/venn.js (`venn-js`)
|
|
726
760
|
|
|
727
761
|
The Venn family uses a modified Rust translation of the venn.js geometry and layout kernel.
|
|
Binary file
|
|
@@ -98,14 +98,13 @@ export class BoundedExecutor {
|
|
|
98
98
|
this.#removeAbortListener(job);
|
|
99
99
|
this.#active += 1;
|
|
100
100
|
const operation = Promise.resolve().then(job.run);
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
: operation;
|
|
104
|
-
return observed.finally(() => {
|
|
101
|
+
// Release capacity and admit FIFO successors before callers observe either outcome.
|
|
102
|
+
const finished = operation.finally(() => {
|
|
105
103
|
this.#active -= 1;
|
|
106
104
|
this.#pump();
|
|
107
105
|
this.#completeDisposeIfIdle();
|
|
108
106
|
});
|
|
107
|
+
return job.resolve || job.reject ? finished.then(job.resolve, job.reject) : finished;
|
|
109
108
|
}
|
|
110
109
|
|
|
111
110
|
#pump() {
|
|
@@ -3,7 +3,7 @@ import { MermanDisposedError, MermanInvalidTransportError } from "../errors.mjs"
|
|
|
3
3
|
export function wrapCandidateEngine(
|
|
4
4
|
engine,
|
|
5
5
|
label,
|
|
6
|
-
{ forwardsAbortSignal = false } = {},
|
|
6
|
+
{ forwardsAbortSignal = false, directSvgAddon = false } = {},
|
|
7
7
|
) {
|
|
8
8
|
if (
|
|
9
9
|
typeof engine?.execute !== "function" ||
|
|
@@ -18,7 +18,12 @@ export function wrapCandidateEngine(
|
|
|
18
18
|
if (!ownedEngine) throw new MermanDisposedError();
|
|
19
19
|
return ownedEngine;
|
|
20
20
|
};
|
|
21
|
-
|
|
21
|
+
const executeSvg = directSvgAddon ? engine.executeSvg : undefined;
|
|
22
|
+
const executeSvgSync = directSvgAddon ? engine.executeSvgSync : undefined;
|
|
23
|
+
if (directSvgAddon && (typeof executeSvg !== "function" || typeof executeSvgSync !== "function")) {
|
|
24
|
+
throw new MermanInvalidTransportError(`${label} does not implement the direct SVG contract.`);
|
|
25
|
+
}
|
|
26
|
+
const transport = {
|
|
22
27
|
execute: (requestJson, signal, timeoutMs) =>
|
|
23
28
|
forwardsAbortSignal
|
|
24
29
|
? currentEngine().execute(requestJson, signal, timeoutMs)
|
|
@@ -33,4 +38,11 @@ export function wrapCandidateEngine(
|
|
|
33
38
|
return disposing?.dispose?.();
|
|
34
39
|
},
|
|
35
40
|
};
|
|
41
|
+
if (directSvgAddon) {
|
|
42
|
+
transport.executeSvg = (source, optionsJson, signal, timeoutMs) =>
|
|
43
|
+
executeSvg.call(currentEngine(), source, optionsJson, signal, timeoutMs);
|
|
44
|
+
transport.executeSvgSync = (source, optionsJson, timeoutMs) =>
|
|
45
|
+
executeSvgSync.call(currentEngine(), source, optionsJson, timeoutMs);
|
|
46
|
+
}
|
|
47
|
+
return transport;
|
|
36
48
|
}
|
package/dist/engine.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BoundedExecutor } from "./bounded-executor.mjs";
|
|
2
|
+
import { supportsDirectNativeSvg } from "./native-loader.mjs";
|
|
2
3
|
import {
|
|
3
4
|
MermanInvalidTransportError,
|
|
4
5
|
NODE_TRANSPORT_FIELD_LIMITS,
|
|
@@ -9,6 +10,7 @@ import {
|
|
|
9
10
|
decodeWireInvocationError,
|
|
10
11
|
decodeWireResponse,
|
|
11
12
|
encodeTransportJson,
|
|
13
|
+
jsonStringFieldBytes,
|
|
12
14
|
parseRuntimeCatalogJsonText,
|
|
13
15
|
parseTransportJsonText,
|
|
14
16
|
sameJsonValue,
|
|
@@ -88,7 +90,20 @@ const COMPILED_PREREQUISITES_BY_OPERATION_ID = new Map(
|
|
|
88
90
|
const KNOWN_OUTPUT_CONTRACT_BY_ID = new Map(
|
|
89
91
|
NODE_WIRE_CONTRACT.artifact.output_contracts.map((contract) => [contract.id, contract]),
|
|
90
92
|
);
|
|
93
|
+
const THEME_AUTHORING_INPUT_LIMITS = Object.freeze({
|
|
94
|
+
...NODE_TRANSPORT_LIMITS.metadata,
|
|
95
|
+
max_utf8_bytes: NODE_TRANSPORT_FIELD_LIMITS.source_utf8_bytes,
|
|
96
|
+
max_string_utf8_bytes: NODE_TRANSPORT_FIELD_LIMITS.source_utf8_bytes,
|
|
97
|
+
});
|
|
98
|
+
const THEME_AUTHORING_RESULT_LIMITS = Object.freeze({
|
|
99
|
+
...NODE_TRANSPORT_LIMITS.metadata,
|
|
100
|
+
max_utf8_bytes: NODE_TRANSPORT_FIELD_LIMITS.data_utf8_bytes,
|
|
101
|
+
max_string_utf8_bytes: NODE_TRANSPORT_FIELD_LIMITS.data_utf8_bytes,
|
|
102
|
+
});
|
|
91
103
|
const MAX_OPERATION_TIMEOUT_MS = 0xffff_ffff;
|
|
104
|
+
const SVG_REQUEST_FRAME_BYTES = '{"operation_id":"svg","source":"","uri":null,"include_metadata":false}'.length;
|
|
105
|
+
const SVG_OPTIONS_FRAME_BYTES = ',"options_json":""'.length;
|
|
106
|
+
const SVG_TIMEOUT_FRAME_BYTES = ',"operation_control":{"timeout_ms":}'.length;
|
|
92
107
|
const MERMAN_ENGINE_CONSTRUCTION_TOKEN = Symbol("MermanEngine construction");
|
|
93
108
|
|
|
94
109
|
export async function createNodeEngine(
|
|
@@ -114,11 +129,14 @@ export async function createNodeEngine(
|
|
|
114
129
|
try {
|
|
115
130
|
assertTransport(transport);
|
|
116
131
|
const runtimeCatalog = validateRuntimeCatalog(await transport.runtimeCatalogJson());
|
|
132
|
+
const directSvg = supportsDirectNativeSvg(transport) &&
|
|
133
|
+
runtimeCatalog.capabilities.operation_ids.includes("svg");
|
|
117
134
|
return new MermanEngine(
|
|
118
135
|
MERMAN_ENGINE_CONSTRUCTION_TOKEN,
|
|
119
136
|
transport,
|
|
120
137
|
runtimeCatalog,
|
|
121
138
|
{ concurrency, maxQueue },
|
|
139
|
+
directSvg,
|
|
122
140
|
);
|
|
123
141
|
} catch (error) {
|
|
124
142
|
await disposeUnusableTransport(transport);
|
|
@@ -197,6 +215,7 @@ export function normalizeBindingOptions(value = {}) {
|
|
|
197
215
|
}
|
|
198
216
|
|
|
199
217
|
export class MermanEngine {
|
|
218
|
+
#directSvg;
|
|
200
219
|
#disposePromise = null;
|
|
201
220
|
#executor;
|
|
202
221
|
#metadataIds;
|
|
@@ -204,13 +223,14 @@ export class MermanEngine {
|
|
|
204
223
|
#runtimeCatalog;
|
|
205
224
|
#transport;
|
|
206
225
|
|
|
207
|
-
constructor(constructionToken, transport, runtimeCatalog, queueOptions) {
|
|
226
|
+
constructor(constructionToken, transport, runtimeCatalog, queueOptions, directSvg) {
|
|
208
227
|
if (constructionToken !== MERMAN_ENGINE_CONSTRUCTION_TOKEN) {
|
|
209
228
|
throw new MermanInvalidTransportError(
|
|
210
229
|
"MermanEngine instances must be created with createNodeEngine().",
|
|
211
230
|
);
|
|
212
231
|
}
|
|
213
232
|
this.#transport = transport;
|
|
233
|
+
this.#directSvg = directSvg;
|
|
214
234
|
this.#runtimeCatalog = runtimeCatalog;
|
|
215
235
|
this.#metadataIds = new Set(
|
|
216
236
|
runtimeCatalog.metadata_ids.filter((id) => METADATA_SPEC_BY_ID.has(id)),
|
|
@@ -259,6 +279,33 @@ export class MermanEngine {
|
|
|
259
279
|
);
|
|
260
280
|
}
|
|
261
281
|
|
|
282
|
+
materializeTheme(input, options = {}) {
|
|
283
|
+
return this.#themeAuthoring("materialize-theme-json", input, options);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
describeThemeSupport(query, options = {}) {
|
|
287
|
+
return this.#themeAuthoring("describe-theme-support-json", query, options);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
exportThemePreset(presetId, options = {}) {
|
|
291
|
+
if (typeof presetId !== "string") {
|
|
292
|
+
return Promise.reject(new TypeError("theme preset ID must be a string."));
|
|
293
|
+
}
|
|
294
|
+
return this.#themeAuthoring("export-theme-preset-json", presetId, options);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
async #themeAuthoring(operationId, input, options) {
|
|
298
|
+
const source = typeof input === "string"
|
|
299
|
+
? input
|
|
300
|
+
: encodeTransportJson(input, "theme authoring input", THEME_AUTHORING_INPUT_LIMITS);
|
|
301
|
+
const json = await this.#execute(
|
|
302
|
+
{ operationId, source, optionsJson: options.optionsJson },
|
|
303
|
+
{ signal: options.signal, timeoutMs: options.timeoutMs },
|
|
304
|
+
false,
|
|
305
|
+
);
|
|
306
|
+
return parseTransportJsonText(json, "theme authoring result", THEME_AUTHORING_RESULT_LIMITS);
|
|
307
|
+
}
|
|
308
|
+
|
|
262
309
|
metadataJson(id) {
|
|
263
310
|
this.#executor.assertOpen();
|
|
264
311
|
if (typeof id !== "string" || id.length === 0) {
|
|
@@ -293,30 +340,35 @@ export class MermanEngine {
|
|
|
293
340
|
} catch (error) {
|
|
294
341
|
return Promise.reject(error);
|
|
295
342
|
}
|
|
296
|
-
const
|
|
343
|
+
const directSvg = this.#usesDirectSvg(request, includeMetadata);
|
|
344
|
+
const prepared = prepareOperationRequest(request, { timeoutMs, directSvg });
|
|
345
|
+
const { expectation } = prepared;
|
|
297
346
|
if (signal?.aborted) return Promise.reject(abortError());
|
|
298
|
-
|
|
347
|
+
let execute;
|
|
348
|
+
if (directSvg) {
|
|
349
|
+
const optionsJson = prepareDirectSvgOptions(prepared, timeoutMs);
|
|
350
|
+
const { source } = prepared.request;
|
|
351
|
+
execute = (forwarded) => this.#transport.executeSvg(source, optionsJson, forwarded, timeoutMs);
|
|
352
|
+
} else {
|
|
353
|
+
const requestJson = operationRequestJson(prepared, includeMetadata);
|
|
354
|
+
execute = (forwarded) => this.#transport.execute(requestJson, forwarded, timeoutMs);
|
|
355
|
+
}
|
|
299
356
|
return this.#executor.submit(
|
|
300
357
|
async () => {
|
|
301
358
|
// A signal can flip after queue admission but before this start microtask runs. That work
|
|
302
359
|
// has not crossed the transport boundary, so preserve the established AbortError result.
|
|
303
360
|
if (signal?.aborted) throw abortError();
|
|
304
|
-
let
|
|
361
|
+
let response;
|
|
305
362
|
try {
|
|
306
|
-
|
|
307
|
-
this.#transport,
|
|
308
|
-
encoded.json,
|
|
309
|
-
signal,
|
|
310
|
-
timeoutMs,
|
|
311
|
-
);
|
|
363
|
+
response = await executeTransportOperation(execute, signal);
|
|
312
364
|
} catch (cause) {
|
|
313
365
|
throw decodeWireInvocationError(cause, "Merman operation");
|
|
314
366
|
}
|
|
315
|
-
return
|
|
367
|
+
return this.#decodeOperationResponse(response, expectation, {
|
|
316
368
|
includeMetadata,
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
369
|
+
directSvg,
|
|
370
|
+
signal,
|
|
371
|
+
timeoutMs,
|
|
320
372
|
});
|
|
321
373
|
},
|
|
322
374
|
{ signal },
|
|
@@ -329,20 +381,43 @@ export class MermanEngine {
|
|
|
329
381
|
|
|
330
382
|
#executeSync(request, { timeoutMs } = {}, includeMetadata) {
|
|
331
383
|
this.#executor.assertSyncAvailable();
|
|
332
|
-
const
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
384
|
+
const directSvg = this.#usesDirectSvg(request, includeMetadata);
|
|
385
|
+
const prepared = prepareOperationRequest(request, { timeoutMs, directSvg });
|
|
386
|
+
const payload = directSvg
|
|
387
|
+
? prepareDirectSvgOptions(prepared, timeoutMs)
|
|
388
|
+
: operationRequestJson(prepared, includeMetadata);
|
|
389
|
+
let response;
|
|
337
390
|
try {
|
|
338
|
-
|
|
391
|
+
response = directSvg
|
|
392
|
+
? this.#transport.executeSvgSync(prepared.request.source, payload, timeoutMs)
|
|
393
|
+
: this.#transport.executeSync(payload, timeoutMs);
|
|
339
394
|
} catch (cause) {
|
|
340
395
|
throw decodeWireInvocationError(cause, "Merman operation");
|
|
341
396
|
}
|
|
342
|
-
return
|
|
397
|
+
return this.#decodeOperationResponse(response, prepared.expectation, {
|
|
398
|
+
includeMetadata,
|
|
399
|
+
directSvg,
|
|
400
|
+
timeoutMs,
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
#usesDirectSvg(request, includeMetadata) {
|
|
405
|
+
return this.#directSvg && !includeMetadata && request.operationId === "svg";
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
#decodeOperationResponse(response, expectation, { includeMetadata, directSvg, signal, timeoutMs }) {
|
|
409
|
+
if (directSvg) {
|
|
410
|
+
if (typeof response === "string") return response;
|
|
411
|
+
if (response === null || typeof response !== "object" || !Object.hasOwn(response, "errorJson")) {
|
|
412
|
+
throw new MermanInvalidTransportError("The native SVG operation returned an invalid result.");
|
|
413
|
+
}
|
|
414
|
+
response = response.errorJson;
|
|
415
|
+
}
|
|
416
|
+
return decodeWireResponse(response, expectation, {
|
|
343
417
|
includeMetadata,
|
|
344
|
-
|
|
345
|
-
|
|
418
|
+
requireError: directSvg,
|
|
419
|
+
allowedCancellationReasons: invocationCancellationReasons(signal, timeoutMs),
|
|
420
|
+
requireUnavailable: !this.#operationIds.has(expectation.operation_id),
|
|
346
421
|
availableCapabilityIds: this.#runtimeCatalog.capabilities.capability_ids,
|
|
347
422
|
});
|
|
348
423
|
}
|
|
@@ -363,7 +438,7 @@ function invocationCancellationReasons(signal, timeoutMs) {
|
|
|
363
438
|
return reasons;
|
|
364
439
|
}
|
|
365
440
|
|
|
366
|
-
function prepareOperationRequest(value, { timeoutMs
|
|
441
|
+
function prepareOperationRequest(value, { timeoutMs, directSvg }) {
|
|
367
442
|
if (!isPlainObject(value)) throw new TypeError("operation request must be a plain object.");
|
|
368
443
|
const knownFields = new Set(["operationId", "source", "uri", "optionsJson"]);
|
|
369
444
|
for (const field of Object.keys(value)) {
|
|
@@ -397,7 +472,7 @@ function prepareOperationRequest(value, { timeoutMs } = {}) {
|
|
|
397
472
|
"operation request operationId",
|
|
398
473
|
NODE_TRANSPORT_FIELD_LIMITS.operation_id_utf8_bytes,
|
|
399
474
|
);
|
|
400
|
-
assertUtf8Field(
|
|
475
|
+
const sourceBytes = (directSvg ? jsonStringFieldBytes : assertUtf8Field)(
|
|
401
476
|
source,
|
|
402
477
|
"operation request source",
|
|
403
478
|
NODE_TRANSPORT_FIELD_LIMITS.source_utf8_bytes,
|
|
@@ -426,36 +501,51 @@ function prepareOperationRequest(value, { timeoutMs } = {}) {
|
|
|
426
501
|
}
|
|
427
502
|
request.operation_control = { timeout_ms: timeoutMs };
|
|
428
503
|
}
|
|
429
|
-
return { expectation, request, value };
|
|
504
|
+
return { expectation, request, value, sourceBytes };
|
|
430
505
|
}
|
|
431
506
|
|
|
432
|
-
function operationRequestJson({
|
|
507
|
+
function operationRequestJson({ request, value }, includeMetadata) {
|
|
433
508
|
if (!includeMetadata) request.include_metadata = false;
|
|
434
509
|
const optionsJson = value.optionsJson;
|
|
435
510
|
if (optionsJson !== undefined) {
|
|
436
|
-
|
|
437
|
-
throw new TypeError("optionsJson must be a JSON string when provided.");
|
|
438
|
-
}
|
|
439
|
-
assertUtf8Field(
|
|
440
|
-
optionsJson,
|
|
441
|
-
"operation request optionsJson",
|
|
442
|
-
NODE_TRANSPORT_FIELD_LIMITS.options_json_utf8_bytes,
|
|
443
|
-
);
|
|
444
|
-
parseTransportJsonText(
|
|
445
|
-
optionsJson,
|
|
446
|
-
"operation request optionsJson",
|
|
447
|
-
NODE_TRANSPORT_LIMITS.binding_options,
|
|
448
|
-
);
|
|
511
|
+
validateOperationOptionsJson(optionsJson, assertUtf8Field);
|
|
449
512
|
request.options_json = optionsJson;
|
|
450
513
|
}
|
|
451
|
-
return
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
514
|
+
return encodeTransportJson(request, "operation request", NODE_TRANSPORT_LIMITS.request);
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
function prepareDirectSvgOptions({ value, sourceBytes }, timeoutMs) {
|
|
518
|
+
// Match the former fixed request's byte budget without building or scanning the document.
|
|
519
|
+
let requestBytes = SVG_REQUEST_FRAME_BYTES + sourceBytes;
|
|
520
|
+
if (timeoutMs !== undefined) {
|
|
521
|
+
requestBytes += SVG_TIMEOUT_FRAME_BYTES + String(timeoutMs).length;
|
|
522
|
+
}
|
|
523
|
+
const optionsJson = value.optionsJson;
|
|
524
|
+
if (optionsJson !== undefined) {
|
|
525
|
+
requestBytes +=
|
|
526
|
+
SVG_OPTIONS_FRAME_BYTES + validateOperationOptionsJson(optionsJson, jsonStringFieldBytes);
|
|
527
|
+
}
|
|
528
|
+
const max = NODE_TRANSPORT_LIMITS.request.max_utf8_bytes;
|
|
529
|
+
if (requestBytes > max) {
|
|
530
|
+
throw new MermanInvalidTransportError(
|
|
531
|
+
`Merman transport operation request exceeds the ${max}-byte wire limit.`,
|
|
532
|
+
);
|
|
533
|
+
}
|
|
534
|
+
return optionsJson;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
function validateOperationOptionsJson(optionsJson, measureField) {
|
|
538
|
+
if (typeof optionsJson !== "string") {
|
|
539
|
+
throw new TypeError("optionsJson must be a JSON string when provided.");
|
|
540
|
+
}
|
|
541
|
+
const label = "operation request optionsJson";
|
|
542
|
+
const bytes = measureField(optionsJson, label, NODE_TRANSPORT_FIELD_LIMITS.options_json_utf8_bytes);
|
|
543
|
+
parseTransportJsonText(optionsJson, label, NODE_TRANSPORT_LIMITS.binding_options);
|
|
544
|
+
return bytes;
|
|
455
545
|
}
|
|
456
546
|
|
|
457
|
-
async function executeTransportOperation(
|
|
458
|
-
if (!signal) return
|
|
547
|
+
async function executeTransportOperation(execute, signal) {
|
|
548
|
+
if (!signal) return execute(undefined);
|
|
459
549
|
|
|
460
550
|
// Forward into a private signal so the N-API bridge cannot replace a caller-owned `onabort`
|
|
461
551
|
// handler while it installs its cooperative cancellation callback.
|
|
@@ -471,7 +561,7 @@ async function executeTransportOperation(transport, requestJson, signal, timeout
|
|
|
471
561
|
};
|
|
472
562
|
signal.addEventListener("abort", forwardAbort, { once: true });
|
|
473
563
|
try {
|
|
474
|
-
const operation =
|
|
564
|
+
const operation = execute(transportAbort.signal);
|
|
475
565
|
transportReady = true;
|
|
476
566
|
if (pendingAbort || signal.aborted) transportAbort.abort(signal.reason);
|
|
477
567
|
return await operation;
|
|
@@ -514,7 +604,7 @@ export function validateRuntimeCatalog(value) {
|
|
|
514
604
|
}
|
|
515
605
|
if (
|
|
516
606
|
catalog.schema_version !== RUNTIME_CATALOG_SCHEMA_VERSION ||
|
|
517
|
-
catalog.transport_api_version !==
|
|
607
|
+
catalog.transport_api_version !== NODE_WIRE_CONTRACT.transport_api_version
|
|
518
608
|
) {
|
|
519
609
|
throw new MermanInvalidTransportError("Merman transport returned an unsupported runtime catalog version.");
|
|
520
610
|
}
|