@danielsimonjr/sciengjs 0.1.1 → 0.3.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.
Files changed (94) hide show
  1. package/README.md +24 -4
  2. package/THIRD_PARTY_NOTICES.md +17 -1
  3. package/assets/licenses/MIT-mermaid.txt +21 -0
  4. package/assets/licenses/MIT-viz-js.txt +21 -0
  5. package/assets/licenses/mermaid-bundle.txt +2128 -0
  6. package/assets/mermaid.min.js +3636 -0
  7. package/dist/browser/backend-pdf.d.ts +3 -0
  8. package/dist/browser/backend-pdf.js +15 -0
  9. package/dist/browser/backend-pdf.js.map +1 -0
  10. package/dist/browser/backend-png.d.ts +3 -0
  11. package/dist/browser/backend-png.js +18 -0
  12. package/dist/browser/backend-png.js.map +1 -0
  13. package/dist/browser/cdp.d.ts +37 -0
  14. package/dist/browser/cdp.js +161 -0
  15. package/dist/browser/cdp.js.map +1 -0
  16. package/dist/browser/flags.d.ts +10 -0
  17. package/dist/browser/flags.js +33 -0
  18. package/dist/browser/flags.js.map +1 -0
  19. package/dist/browser/index.d.ts +5 -0
  20. package/dist/browser/index.js +6 -0
  21. package/dist/browser/index.js.map +1 -0
  22. package/dist/browser/input.d.ts +38 -0
  23. package/dist/browser/input.js +97 -0
  24. package/dist/browser/input.js.map +1 -0
  25. package/dist/browser/page.d.ts +10 -0
  26. package/dist/browser/page.js +33 -0
  27. package/dist/browser/page.js.map +1 -0
  28. package/dist/browser/pinned.d.ts +16 -0
  29. package/dist/browser/pinned.js +13 -0
  30. package/dist/browser/pinned.js.map +1 -0
  31. package/dist/browser/profile.d.ts +9 -0
  32. package/dist/browser/profile.js +33 -0
  33. package/dist/browser/profile.js.map +1 -0
  34. package/dist/browser/proxy.d.ts +14 -0
  35. package/dist/browser/proxy.js +64 -0
  36. package/dist/browser/proxy.js.map +1 -0
  37. package/dist/browser/render.d.ts +58 -0
  38. package/dist/browser/render.js +421 -0
  39. package/dist/browser/render.js.map +1 -0
  40. package/dist/core.js +10 -2
  41. package/dist/core.js.map +1 -1
  42. package/dist/graph/backend-pdf.d.ts +3 -0
  43. package/dist/graph/backend-pdf.js +14 -0
  44. package/dist/graph/backend-pdf.js.map +1 -0
  45. package/dist/graph/backend-png.d.ts +7 -0
  46. package/dist/graph/backend-png.js +30 -12
  47. package/dist/graph/backend-png.js.map +1 -1
  48. package/dist/mermaid/backend-pdf.d.ts +6 -0
  49. package/dist/mermaid/backend-pdf.js +19 -0
  50. package/dist/mermaid/backend-pdf.js.map +1 -0
  51. package/dist/mermaid/backend-png.d.ts +7 -0
  52. package/dist/mermaid/backend-png.js +27 -0
  53. package/dist/mermaid/backend-png.js.map +1 -0
  54. package/dist/mermaid/backend-svg.d.ts +6 -0
  55. package/dist/mermaid/backend-svg.js +18 -0
  56. package/dist/mermaid/backend-svg.js.map +1 -0
  57. package/dist/mermaid/browser.d.ts +30 -0
  58. package/dist/mermaid/browser.js +52 -0
  59. package/dist/mermaid/browser.js.map +1 -0
  60. package/dist/mermaid/class.d.ts +37 -0
  61. package/dist/mermaid/class.js +190 -0
  62. package/dist/mermaid/class.js.map +1 -0
  63. package/dist/mermaid/common.d.ts +50 -0
  64. package/dist/mermaid/common.js +144 -0
  65. package/dist/mermaid/common.js.map +1 -0
  66. package/dist/mermaid/index.d.ts +10 -0
  67. package/dist/mermaid/index.js +11 -0
  68. package/dist/mermaid/index.js.map +1 -0
  69. package/dist/mermaid/render.d.ts +10 -0
  70. package/dist/mermaid/render.js +24 -0
  71. package/dist/mermaid/render.js.map +1 -0
  72. package/dist/mermaid/sequence-layout.d.ts +6 -0
  73. package/dist/mermaid/sequence-layout.js +268 -0
  74. package/dist/mermaid/sequence-layout.js.map +1 -0
  75. package/dist/mermaid/sequence.d.ts +62 -0
  76. package/dist/mermaid/sequence.js +199 -0
  77. package/dist/mermaid/sequence.js.map +1 -0
  78. package/dist/mermaid/state.d.ts +24 -0
  79. package/dist/mermaid/state.js +132 -0
  80. package/dist/mermaid/state.js.map +1 -0
  81. package/dist/pairs.d.ts +2 -1
  82. package/dist/pairs.js +8 -6
  83. package/dist/pairs.js.map +1 -1
  84. package/dist/registry.js +6 -0
  85. package/dist/registry.js.map +1 -1
  86. package/dist/types.d.ts +2 -0
  87. package/dist/version.d.ts +1 -1
  88. package/dist/version.js +1 -1
  89. package/dist/worker/entry.js +1 -1
  90. package/dist/worker/entry.js.map +1 -1
  91. package/dist/worker/protocol.d.ts +7 -0
  92. package/dist/worker/run.js +1 -1
  93. package/dist/worker/run.js.map +1 -1
  94. package/package.json +10 -1
package/README.md CHANGED
@@ -10,14 +10,19 @@ sciengjs turns diagram source into images on your own machine. It sends no sourc
10
10
 
11
11
  ## What this release does
12
12
 
13
- Release 0.1.0 holds the first input type: **Graphviz DOT**.
13
+ Release 0.3.0 holds three input types: **Graphviz DOT**, **Mermaid** (every diagram type) and **HTML** (to PNG and PDF). The browser stage draws the Mermaid types other than class, state and sequence, and every PDF.
14
14
 
15
15
  | Input | Output | Engine |
16
16
  |---|---|---|
17
17
  | DOT | SVG | Graphviz 16.1.0, compiled to WASM (`@viz-js/viz`) |
18
18
  | DOT | PNG | Graphviz, then resvg compiled to WASM (`@resvg/resvg-wasm`), with a bundled font |
19
+ | Mermaid (class, state, sequence) | SVG | The engine's own parsers and layouts. Class and state diagrams go through Graphviz. |
20
+ | Mermaid (class, state, sequence) | PNG | The same SVG, then resvg compiled to WASM (`@resvg/resvg-wasm`), with a bundled font |
21
+ | Mermaid (all other types) | SVG, PNG, PDF | The pinned Mermaid 11.17.2 build in the browser stage. The engine serves the build from the package. |
22
+ | DOT, Mermaid | PDF | The SVG, printed by the browser stage |
23
+ | HTML | PNG, PDF | The browser stage |
19
24
 
20
- - **No network.** The DOT path makes no network request.
25
+ - **No network.** The DOT and Mermaid paths make no network request. The browser stage starts Chrome or Chromium from `SCIENG_BROWSER` with a new profile. Its flags stop every connection out of the host. The client refuses every request except the page and the pinned Mermaid build. CI checks the browser process tree on Linux, macOS and Windows.
21
26
  - **Unsafe attributes are removed.** The engine removes each `image` and `stylesheet` attribute before the layout and gives a warning for each one. A DOT file cannot make the engine or a browser fetch a file or a URL. A `URL` attribute stays as a link in the SVG.
22
27
  - **The same text on every machine.** PNG text uses the bundled Liberation Serif font, not the fonts of the host. The engine gives a warning when the drawing asks for bold, italic or a character that the font does not have.
23
28
  - **Limits.** Each render has a time limit, a source size limit and a heap limit. A PNG has a pixel limit of 1024 MB.
@@ -137,6 +142,21 @@ const png = await svgToPng(svg, { scale: 1, maxMemoryMb: 512 });
137
142
 
138
143
  A subpath call runs in the calling thread, without the worker and its limits. Use `render` for input that you do not trust.
139
144
 
145
+ ## Mermaid
146
+
147
+ The `mermaid` input draws class, state and sequence diagrams without a browser. A line outside the grammar rejects the render with `E_INPUT`, and the message names the line. Set `lenient` to `true` to skip such a line and get a warning instead.
148
+
149
+ Other Mermaid types, for example `flowchart` and `gantt`, need the browser stage. A `png` takes the option `scale` (above 0, not more than 8, default 1) on both paths. The browser path sizes the page from the `viewBox` of the diagram. The `svg` of the browser path has an explicit `width` and `height`. Any other `png` option rejects with `E_INPUT`.
150
+
151
+ ```js
152
+ import { render } from "@danielsimonjr/sciengjs";
153
+
154
+ const source = "sequenceDiagram\nAlice->>Bob: Hello Bob\nBob-->>Alice: Hi Alice";
155
+ const { bytes, warnings } = await render({ type: "mermaid", source, format: "svg" }, {});
156
+ ```
157
+
158
+ Other Mermaid diagram types (for example flowchart and gantt) go through the browser stage. They need `SCIENG_BROWSER`. Without it they reject with `E_STAGE_MISSING`. The pinned Mermaid build ships in the package, and the browser stage serves it to the page, so no request leaves the process.
159
+
140
160
  ## Roadmap
141
161
 
142
162
  The [build plan](docs/superpowers/plans/2026-11-01-scieng-engine-build.md) gives the order of the increments. Each increment adds one input type, its tests and one release. The [design](docs/superpowers/specs/2026-11-01-scieng-engine-design.md) gives the API, the stages, the security controls and the licence of each engine.
@@ -144,13 +164,13 @@ The [build plan](docs/superpowers/plans/2026-11-01-scieng-engine-build.md) gives
144
164
  | Input type | Stage | Status |
145
165
  |---|---|---|
146
166
  | DOT | graph, raster | released in 0.1.0 |
147
- | Mermaid | mermaid, browser | planned |
167
+ | Mermaid | graph, mermaid, browser | class, state and sequence: released in 0.2.0; other types: released in 0.3.0 |
148
168
  | LaTeX math | math (MathJax) | planned |
149
169
  | TikZ, circuitikz, LaTeX | tex (an own WASM build of `tex.web`) | trial builds pass |
150
170
  | Plots | plot | planned |
151
171
  | SysML v2 | sysml | planned |
152
172
  | STEP, IGES, BREP | mesh (OpenCascade WASM) | trial build passes |
153
- | HTML to PNG, PDF and Markdown | html, browser | planned |
173
+ | HTML to PNG, PDF and Markdown | html, browser | PNG and PDF: released in 0.3.0; Markdown: planned |
154
174
 
155
175
  ## Use from an agent
156
176
 
@@ -17,6 +17,7 @@ Version: each row gives the version that the engine pins.
17
17
  | mesh | `occt-import-js` (OpenCascade compiled to WASM) | LGPL-2.1 | not yet a dependency |
18
18
  | mesh | `manifold-3d` | Apache-2.0 | not yet a dependency |
19
19
  | mesh (viewer page) | `three` | MIT | not yet a dependency |
20
+ | browser | `mermaid` 11.17.2 (the pinned build `dist/mermaid.min.js`, copied into the assets folder at build) | MIT | a devDependency. The browser stage serves the copy to pages |
20
21
  | raster | `@resvg/resvg-wasm` 2.6.2 | MPL-2.0 | a dependency |
21
22
  | raster | Liberation Serif Regular 2.1.5 (font, in `assets/fonts/`) | SIL Open Font License 1.1 | bundled |
22
23
  | html | `parse5` | MIT | not yet a dependency |
@@ -26,7 +27,22 @@ Version: each row gives the version that the engine pins.
26
27
 
27
28
  ### Graphviz (EPL-2.0)
28
29
 
29
- The Eclipse Public License 2.0 applies to Graphviz. The wrapper `@viz-js/viz` is licensed under MIT. The package does not ship a Graphviz licence file. The licence text of Graphviz is in `assets/licenses/EPL-2.0.txt`. The source repository of the wrapper is https://github.com/mdaines/viz-js.
30
+ The Eclipse Public License 2.0 applies to Graphviz. The MIT licence applies to the wrapper `@viz-js/viz`. The package does not ship a Graphviz licence file. The licence text of Graphviz is in `assets/licenses/EPL-2.0.txt`. The MIT licence text of the wrapper is in `assets/licenses/MIT-viz-js.txt`, copied from the tag `release-viz-3.31.0` of the source repository https://github.com/mdaines/viz-js. The npm package does not ship this file.
31
+
32
+ ### Mermaid (MIT)
33
+
34
+ The MIT licence applies to `mermaid` 11.17.2. The build writes the file mermaid.min.js into the assets folder. That file is generated at build time and is not committed. The licence text is in `assets/licenses/MIT-mermaid.txt`.
35
+
36
+ The file mermaid.min.js also holds the code of the runtime dependencies of `mermaid`. Each of these packages keeps its own licence:
37
+
38
+ - MIT: `cytoscape`, `cytoscape-cose-bilkent`, `cytoscape-fcose`, `dagre-d3-es`, `dayjs`, `katex`, `khroma`, `marked`, `roughjs`, `stylis`, `ts-dedent`, `uuid`, `es-toolkit`, `fastdom`, `@braintree/sanitize-url`, `@iconify/utils`, `@upsetjs/venn.js`, `@mermaid-js/parser` and `lodash-es`.
39
+ - ISC: `d3` and most of the `d3-*` modules.
40
+ - BSD-3-Clause: `d3-sankey`, `d3-ease`, `rw` and the older copies of `d3-array`, `d3-shape` and `d3-path` that `d3-sankey` uses.
41
+ - MPL-2.0 OR Apache-2.0: `dompurify`. The engine uses it under the Apache-2.0 licence.
42
+ - Apache-2.0: `@chevrotain/types`.
43
+ - Unlicense: `robust-predicates`.
44
+
45
+ The file `assets/licenses/mermaid-bundle.txt` holds the licence text of each of the 79 packages, with its name and version. The script `scripts/mermaid-licenses.mjs` writes that file from the installed `mermaid` package. Run the script again after a change of the pinned Mermaid version.
30
46
 
31
47
  ### OpenCascade (LGPL-2.1)
32
48
 
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 - 2022 Knut Sveidqvist
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Michael Daines
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.