@zonks/wasm 0.0.0-stage → 0.1.1
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/LICENSE +21 -0
- package/README.md +205 -2
- package/THIRD_PARTY_NOTICES.md +156 -0
- package/fonts/GPL-2 +339 -0
- package/fonts/LICENSE +102 -0
- package/fonts/LiberationMono-Bold.ttf +0 -0
- package/fonts/LiberationMono-BoldItalic.ttf +0 -0
- package/fonts/LiberationMono-Italic.ttf +0 -0
- package/fonts/LiberationMono.ttf +0 -0
- package/fonts/LiberationSans-Bold.ttf +0 -0
- package/fonts/LiberationSans-BoldItalic.ttf +0 -0
- package/fonts/LiberationSans-Italic.ttf +0 -0
- package/fonts/LiberationSans.ttf +0 -0
- package/fonts/LiberationSerif-Bold.ttf +0 -0
- package/fonts/LiberationSerif-BoldItalic.ttf +0 -0
- package/fonts/LiberationSerif-Italic.ttf +0 -0
- package/fonts/LiberationSerif-Regular.COPYRIGHT +73 -0
- package/fonts/LiberationSerif.ttf +0 -0
- package/fonts/NotoEmoji-Regular.ttf +0 -0
- package/fonts/NotoSans-Regular.ttf +0 -0
- package/fonts/NotoSansCJKsc-Regular.otf +0 -0
- package/fonts/NotoSansMath-Regular.ttf +0 -0
- package/fonts/NotoSansSymbols-Regular.ttf +0 -0
- package/fonts/NotoSansSymbols2-Regular.ttf +0 -0
- package/fonts/OFL-NotoEmoji.txt +93 -0
- package/fonts/OFL-NotoSans.txt +93 -0
- package/fonts/OFL-NotoSansCJK.txt +94 -0
- package/fonts/OFL-NotoSansMath.txt +93 -0
- package/fonts/OFL-NotoSansSymbols.txt +93 -0
- package/fonts/OFL-NotoSansSymbols2.txt +93 -0
- package/fonts/fonts.json +128 -0
- package/node.d.ts +24 -0
- package/node.js +38 -0
- package/package.json +19 -4
- package/zonks_wasm.d.ts +163 -0
- package/zonks_wasm.js +660 -0
- package/zonks_wasm_bg.wasm +0 -0
- package/zonks_wasm_bg.wasm.d.ts +29 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Thomas Linke
|
|
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.
|
package/README.md
CHANGED
|
@@ -1,3 +1,206 @@
|
|
|
1
|
-
#
|
|
1
|
+
# zonks-wasm
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
zonks as WebAssembly for JavaScript hosts (browsers, Workers, Node). The
|
|
4
|
+
module is the library itself: no browser measurement, no fallback renderer;
|
|
5
|
+
inputs it does not support fail with the library's explicit errors.
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
cargo xtask wasm build [--no-opt] [--bundled-fonts|--noto] # -> target/wasm-pkg (wasm-bindgen --target web, wasm-opt -Os)
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
`build` needs the `wasm32-unknown-unknown` target, the `wasm-bindgen` command
|
|
12
|
+
at the version `Cargo.lock` pins (`cargo install wasm-bindgen-cli --locked
|
|
13
|
+
--version =0.2.130`) and binaryen's `wasm-opt` (or `--no-opt`). The `wasm` profile builds at `opt-level = "s"`: `"z"` is about 14 %
|
|
14
|
+
smaller but about 43 % slower, and an editor renders on every pause in
|
|
15
|
+
typing.
|
|
16
|
+
|
|
17
|
+
## npm package
|
|
18
|
+
|
|
19
|
+
`target/wasm-pkg` is the npm package `@zonks/wasm` (version, license,
|
|
20
|
+
repository and homepage from the workspace's `Cargo.toml`): ESM only, one
|
|
21
|
+
`wasm-bindgen --target web` build, no fonts bundled; `fonts/` (see Fonts)
|
|
22
|
+
ships with it. `package.json` `exports` give Node the Node entry
|
|
23
|
+
(`node.js`, kept in `crates/zonks-wasm/npm/`) and everything else the web
|
|
24
|
+
glue (`zonks_wasm.js`); `@zonks/wasm/zonks_wasm_bg.wasm` and
|
|
25
|
+
`@zonks/wasm/fonts/*` are exported for hosts that load them themselves.
|
|
26
|
+
|
|
27
|
+
In Node, the glue's own `init()` fetches the module by a `file:` URL, which
|
|
28
|
+
Node's `fetch` refuses; the Node entry's default export reads the module and
|
|
29
|
+
the fonts from the package instead:
|
|
30
|
+
|
|
31
|
+
```js
|
|
32
|
+
import init, { createInstance, render, Renderer } from '@zonks/wasm';
|
|
33
|
+
|
|
34
|
+
const { fonts } = await init(); // the Liberation set; init({ fallbackFonts: true }) adds the Noto fallbacks
|
|
35
|
+
render('flowchart LR\n A --> B'); // the free render, with those fonts
|
|
36
|
+
const renderer = new Renderer();
|
|
37
|
+
renderer.setFonts(fonts);
|
|
38
|
+
|
|
39
|
+
// A panic traps the instance for good (the glue initialises once per module):
|
|
40
|
+
const { api } = await createInstance(); // a new instance, its own memory and fonts
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
`init` is an explicit call rather than a top-level await on import, so an
|
|
44
|
+
import costs nothing, the host chooses the fonts, and recovery has the same
|
|
45
|
+
shape: `createInstance` loads a fresh copy of the glue (a distinct module
|
|
46
|
+
URL) and returns its API (`api`) with the fonts it set (`fonts`). The
|
|
47
|
+
module is compiled once and shared by every instance. Node's module cache
|
|
48
|
+
keeps every instance, its memory and its fonts until the process exits
|
|
49
|
+
(about 11 MiB each, 16 MiB with `fallbackFonts`), so recover sparingly and restart the process after
|
|
50
|
+
repeated panics.
|
|
51
|
+
|
|
52
|
+
TypeScript picks the types by the same conditions: `moduleResolution`
|
|
53
|
+
`node16`/`nodenext` types the Node entry; under `bundler` (Bun, Vite SSR,
|
|
54
|
+
tsx) add `"customConditions": ["node"]` to `compilerOptions` for server
|
|
55
|
+
code, or the import is typed as the web glue.
|
|
56
|
+
|
|
57
|
+
In a browser or a bundler, use the web glue as in API below: its default
|
|
58
|
+
`init()` fetches `zonks_wasm_bg.wasm` beside itself; a bundler that does not
|
|
59
|
+
copy it takes `@zonks/wasm/zonks_wasm_bg.wasm` through its URL import (Vite's
|
|
60
|
+
`?url`, as `tools/playground` does) for `init({ module_or_path })`, and the
|
|
61
|
+
fonts the same way from `@zonks/wasm/fonts/`.
|
|
62
|
+
|
|
63
|
+
The installed-tarball smoke test packs the package, installs it into a new
|
|
64
|
+
directory and renders in Node (`import '@zonks/wasm'`) and in headless
|
|
65
|
+
Chromium (the web entry, served over local HTTP); it uses the playground's
|
|
66
|
+
Playwright and TypeScript and installs nothing else:
|
|
67
|
+
|
|
68
|
+
```sh
|
|
69
|
+
cargo xtask wasm build
|
|
70
|
+
(cd tools/playground && bun install --frozen-lockfile)
|
|
71
|
+
node crates/zonks-wasm/npm/smoke.mjs [<new directory>]
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
The default build fails when the optimised module exceeds 9 MiB
|
|
75
|
+
(`MAX_MODULE` in `xtask/src/wasm.rs`; 8.45 MiB at 0.1.0).
|
|
76
|
+
|
|
77
|
+
## Fonts
|
|
78
|
+
|
|
79
|
+
By default the module bundles no fonts (8.45 MiB; 3.4 MB gzipped, 2.4 MB
|
|
80
|
+
with brotli, the cheapest transfer saving to serve). The build
|
|
81
|
+
writes the fonts beside it, `target/wasm-pkg/fonts/`, to ship with the module:
|
|
82
|
+
the Liberation set (12 files, 3.9 MiB), then the Noto fallbacks (math,
|
|
83
|
+
symbols, emoji, a CJK subset: 6 files, 5.2 MiB) in the order the library's
|
|
84
|
+
`noto` feature uses (`zonks::fonts::NOTO_FILES`); `fonts.json` lists
|
|
85
|
+
them in that order, each `{file, family, weight, style, fallback}`
|
|
86
|
+
(`fallback` marks the Noto files); the
|
|
87
|
+
licenses (`LICENSE`: SIL OFL 1.1; Liberation Serif Regular's `COPYRIGHT` and
|
|
88
|
+
`GPL-2`; `OFL-*.txt` for Noto). The host fetches the files it wants (the
|
|
89
|
+
Liberation set, optionally the fallbacks after it) and passes them in once,
|
|
90
|
+
in that order:
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
const files: { file: string; fallback: boolean }[] = await (await fetch(`${base}/fonts/fonts.json`)).json();
|
|
94
|
+
const get = async (n: string) => {
|
|
95
|
+
const response = await fetch(`${base}/fonts/${n}`);
|
|
96
|
+
if (!response.ok) throw new Error(`font ${n}: HTTP ${response.status}`);
|
|
97
|
+
return new Uint8Array(await response.arrayBuffer());
|
|
98
|
+
};
|
|
99
|
+
setFonts(await Promise.all(files.filter((f) => withNoto || !f.fallback).map(({ file }) => get(file))));
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
`renderer.setFonts(files)` (or the free `setFonts` for the free `render`)
|
|
103
|
+
replaces the fonts for every later render (returns the number of faces;
|
|
104
|
+
invalid data throws a `ConfigurationError` and keeps the previous set). The
|
|
105
|
+
number of files, each element's type (`Uint8Array`) and their total size
|
|
106
|
+
are checked on the JavaScript side before any byte is copied into the module (at most 128 files of 256 MiB together, `zonks::fonts::MAX_FONT_FILES`
|
|
107
|
+
and `MAX_FONT_BYTES`), so oversized or mistyped input throws the same
|
|
108
|
+
`ConfigurationError` instead of exhausting the module's memory. Lengths are
|
|
109
|
+
read once, as JavaScript numbers, and the bytes are copied from snapshots (`new Uint8Array(file)`), so a buffer detached or resized meanwhile, or a
|
|
110
|
+
throwing getter or a revoked proxy, is a `ConfigurationError` too and the
|
|
111
|
+
renderer stays usable (a host that patches the `Uint8Array` or `Array`
|
|
112
|
+
globals is out of reach). Any fonts work, e.g. the web font a page also
|
|
113
|
+
displays with (set `fontFamily` to it); the Liberation set gives the
|
|
114
|
+
library's own measurements. Until fonts are set, text fails explicitly ("no
|
|
115
|
+
supplied font matches font-family …"); diagrams without text render. The
|
|
116
|
+
page draws SVG text with its own fonts: `tools/playground` registers the
|
|
117
|
+
Liberation files through `FontFace` under the CSS names the engine resolves
|
|
118
|
+
to them (Arial, Helvetica, Times, Courier and the theme fonts that fall
|
|
119
|
+
through to Arial), so text displays as measured without `embedFonts`; other
|
|
120
|
+
hosts need the same step. Characters only a Noto fallback covers draw with
|
|
121
|
+
the browser's own fallback unless the fonts are embedded.
|
|
122
|
+
`--bundled-fonts` compiles the Liberation set in instead (11.8 MiB, 5.4 MB
|
|
123
|
+
gzipped; `version().bundledFonts`), `--noto` the Noto fallbacks too.
|
|
124
|
+
|
|
125
|
+
## API
|
|
126
|
+
|
|
127
|
+
```ts
|
|
128
|
+
import init, { Renderer, detect, version } from './zonks_wasm.js';
|
|
129
|
+
await init(); // or init({ module_or_path }) / initSync({ module })
|
|
130
|
+
const renderer = new Renderer();
|
|
131
|
+
renderer.setFonts(fontFiles); // Uint8Array[], see Fonts
|
|
132
|
+
renderer.registerIconifyPack('fa7-solid', iconifyJsonText); // once, not per render
|
|
133
|
+
|
|
134
|
+
const svg = renderer.render(source, JSON.stringify({ id: 'd1', config: { theme: 'dark' } }));
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
- `new Renderer()`: one long-lived engine session, for an editor or any
|
|
138
|
+
host that renders more than once. It keeps its fonts, icon packs and
|
|
139
|
+
caches (shaped text, stylesheets, theme variables) between renders, so
|
|
140
|
+
its warm renders are faster than fresh ones (which also take any icon
|
|
141
|
+
packs in their options each time); every render equals a fresh
|
|
142
|
+
session's with the same fonts, packs and options, whatever was rendered
|
|
143
|
+
before. Methods:
|
|
144
|
+
- `render(source, options)`: as the free `render` below, except that
|
|
145
|
+
`iconPacks` throws (register packs once instead).
|
|
146
|
+
- `setFonts(files)`: see Fonts; empties the caches, keeps the packs.
|
|
147
|
+
- `registerIconifyPack(name, iconifyJsonText)`: registers an Iconify set
|
|
148
|
+
without the resolved pack crossing to JavaScript;
|
|
149
|
+
`registerIconPack(JSON.stringify(pack))` registers a resolved pack (`iconPackFromIconify`'s). Both replace a pack of that name and return
|
|
150
|
+
its number of icons; an invalid pack throws and changes nothing (the
|
|
151
|
+
library's limits: 64 packs, 4,096 icons and 4 MiB per pack, 16 MiB in
|
|
152
|
+
all, 256 KiB per icon body). `removeIconPack(name)` (whether there was one), `clearIconPacks()`.
|
|
153
|
+
- `setCacheBudget(bytes)` (a whole number, 0 keeps nothing, 16 MiB by
|
|
154
|
+
default; empties the caches; anything else throws), `clearCaches()`,
|
|
155
|
+
`cacheBytes()` (the estimate the budget counts).
|
|
156
|
+
- `lastRenderWork()`: the work units the last render spent (see
|
|
157
|
+
`workBudget`).
|
|
158
|
+
- `free()` releases it. One renderer belongs to one thread (a Worker).
|
|
159
|
+
- `render(source, options)`: SVG from a fresh session with the instance's
|
|
160
|
+
fonts (the free `setFonts`). `options` is a JSON string (or empty) with
|
|
161
|
+
`id` (default `mermaid`), `config` (Mermaid site configuration, an object),
|
|
162
|
+
`background` (CSS colour), `width` (layout width for gantt and C4),
|
|
163
|
+
`nowUnixMs` (integer; `Date.now()` when absent), `embedFonts`,
|
|
164
|
+
`iconPacks` (resolved packs) and `workBudget` (the render's work units, a
|
|
165
|
+
whole number up to 2^53, `null` for unlimited; when absent the library's
|
|
166
|
+
default, 2^25 units per 50,000 characters of `maxTextSize`: a render beyond
|
|
167
|
+
it throws a `LimitError` instead of running on). Unknown keys fail.
|
|
168
|
+
- Failures throw an `Error` named `zonksError`; its `detail` carries the
|
|
169
|
+
library's `RenderError` fields: `category` (`Error`, `UnknownDiagramError`,
|
|
170
|
+
`PreprocessError`, `ConfigurationError`, `UnsupportedFeature`,
|
|
171
|
+
`NativeRenderError`, `LimitError`), `message`, `display`, `location` (`{line, column}`,
|
|
172
|
+
1-based, columns in characters), `node`, `edge`, `subgraph`, `config`,
|
|
173
|
+
`stage`, `diagram`, `configured`. The instance and its renderers stay
|
|
174
|
+
usable.
|
|
175
|
+
- `detect(source)`: `{keyword, family}` or `null`.
|
|
176
|
+
- `setFonts(files)`: the free `render`'s fonts, see Fonts.
|
|
177
|
+
- `version()`: `{zonks, mermaidSyntax, bundledFonts, noto}`.
|
|
178
|
+
- `iconPackFromIconify(name, iconifyJsonText)`: a resolved pack for
|
|
179
|
+
`iconPacks` (or `Renderer.registerIconPack`, stringified).
|
|
180
|
+
|
|
181
|
+
Arguments are checked before anything is copied into the module, and a bad
|
|
182
|
+
one throws a `ConfigurationError` with the instance usable: text (sources,
|
|
183
|
+
options, packs, Iconify sets, names) must be a primitive string; other than a
|
|
184
|
+
source to render (below), at most 64 MiB of UTF-8 (`zonks_wasm::api::MAX_TEXT_BYTES`). Lengths are checked
|
|
185
|
+
in UTF-16 units first: text of more units than its limit is never copied in;
|
|
186
|
+
text within it is copied (at most three bytes per unit) and its UTF-8 length
|
|
187
|
+
checked then. A source to render over the library's 1 MiB limit (`zonks::engine::MAX_SOURCE_BYTES`) fails as the library fails it (a
|
|
188
|
+
`PreprocessError`, after the options and the render id): one of more than
|
|
189
|
+
1 Mi units is not copied (a stand-in fails in its place), a shorter one is
|
|
190
|
+
copied and refused by the library; `detect` takes sources up to the 64 MiB
|
|
191
|
+
text limit; `setCacheBudget` takes a number; font files must be genuine
|
|
192
|
+
`Uint8Array`s (a proxy or a forged prototype is refused). Options may be
|
|
193
|
+
omitted. No host object is converted; the only host code that can run is
|
|
194
|
+
what the module reads with caught reads: a font array's length and elements (proxy traps, getters) and a caught exception's `message`. `free()` called
|
|
195
|
+
from inside one of a `Renderer`'s own calls (a host getter) throws
|
|
196
|
+
wasm-bindgen's "attempted to take ownership of Rust value while it was
|
|
197
|
+
borrowed" yet releases the renderer when that call returns; later calls
|
|
198
|
+
throw "null pointer passed to rust", as for any freed object.
|
|
199
|
+
|
|
200
|
+
A panic (a bug) traps the instance: its message goes to `console.error`,
|
|
201
|
+
every `Renderer` of the instance is lost with it, and the host creates a new
|
|
202
|
+
instance and renderer and passes its fonts and packs in again (`tools/playground` replaces its Worker). Runaway input is not a panic: the
|
|
203
|
+
work budget (`workBudget`) stops it with a `LimitError` and the instance
|
|
204
|
+
stays usable. Nesting is walked without recursion, or bounded where a
|
|
205
|
+
parser recurses (math labels, railroad groups: a `LimitError` too), so deep
|
|
206
|
+
input fits within the module's 1 MiB stack.
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# Third-party notices
|
|
2
|
+
|
|
3
|
+
## Bundled fonts
|
|
4
|
+
|
|
5
|
+
The playground and desktop UI use DM Sans and Spectral italic from the Fontsource 5.3.0 Latin distributions under the SIL Open Font License 1.1. Their notices ship in `fonts/DM-Sans-OFL.txt` and `fonts/Spectral-OFL.txt` in each frontend build.
|
|
6
|
+
|
|
7
|
+
The Liberation fonts in `crates/zonks/assets/fonts` (the default set) are covered by `crates/zonks/assets/fonts/LICENSE` (SIL Open Font License 1.1); the Liberation Serif build in `fonts/sequence` keeps its package `COPYRIGHT` and `GPL-2` notices (with the font exception).
|
|
8
|
+
|
|
9
|
+
With the cargo feature `noto`, the binary also contains the Noto faces in `crates/zonks/assets/fonts/noto` (Noto Sans, Noto Sans Math, Noto Emoji, Noto Sans Symbols and Symbols 2: Copyright 2013 Google LLC / 2022 The Noto Project Authors; Noto Sans CJK SC: © 2014-2021 Adobe, with Reserved Font Name 'Source'), modified (static instances, hinting and control characters removed, the CJK face subset) under the SIL Open Font License 1.1; each family's license is the `OFL-*.txt` file next to the faces. They are built by the development-only `tools/noto-fonts/build.py` with fontTools (MIT, not distributed).
|
|
10
|
+
|
|
11
|
+
With `embed_fonts` (`--embed-fonts`), the SVG carries the used font files whole as `data:` URLs: an SVG embedding the bundled fonts redistributes them under these licenses, which allow it (the OFL; the GPL font exception for documents embedding the font). For fonts an application supplies, zonks refuses faces whose OS/2 `fsType` forbids embedding ("restricted license embedding"); the licenses themselves are the caller's responsibility.
|
|
12
|
+
|
|
13
|
+
The WebAssembly module `crates/zonks-wasm` builds (`target/wasm-pkg`) contains the same assets (and, with `--bundled-fonts`, the fonts), so the notices of this file apply to it as well; the font files written beside it (`fonts/`) carry their licenses (Liberation: `LICENSE`, `LiberationSerif-Regular.COPYRIGHT`, `GPL-2`; the Noto fallbacks: `OFL-*.txt`); its binding crates (`wasm-bindgen`, `js-sys`, MIT/Apache-2.0) are recorded in Cargo.lock. The browser playground and Zonks Desktop share a React frontend with CodeMirror, Web Awesome and lucide. Its build contains Font Awesome Free's icons (Fonticons, Inc., by Dave Gandy; CC BY 4.0, https://creativecommons.org/licenses/by/4.0/) as the `@iconify-json/fa7-*` packs publish them (converted to Iconify JSON by the Iconify project), not modified further; the library ships none. The build credits them in the page's footer and ships the license (`tools/playground/licenses/Font-Awesome-Free-LICENSE`, with the CC BY 4.0 text) in `dist/licenses/`, beside the Web Awesome and lucide licenses; every font it emits travels with its license files in `dist/fonts/` (the build fails for a font without one).
|
|
14
|
+
|
|
15
|
+
## PNG output of the command line
|
|
16
|
+
|
|
17
|
+
The `zonks` command line (crate `zonks-cli`, cargo feature `png`, on by default) rasterizes the rendered SVG with resvg 0.50.0 and usvg 0.50.0 (Apache-2.0 OR MIT, used under MIT), tiny-skia 0.12.0 and tiny-skia-path 0.12.0 (BSD-3-Clause), harfrust 0.15.0 (MIT), skrifa 0.49.0, read-fonts 0.46.0 and font-types 0.12.7 (MIT OR Apache-2.0), simplecss 0.2.2 and svgtypes 0.16.2 (Apache-2.0 OR MIT) and the PNG encoder png 0.18.1 (MIT OR Apache-2.0) with its compression crates; their remaining dependencies are MIT, Apache-2.0, BSD-2-Clause or Unicode-3.0 licensed. Beyond those, it contains Zlib `foldhash` 0.2.0 (through `read-fonts`). The library and the WebAssembly build contain none of them. Versions and checksums are recorded in Cargo.lock.
|
|
18
|
+
|
|
19
|
+
## Zonks Desktop
|
|
20
|
+
|
|
21
|
+
`tools/desktop` builds Zonks Desktop: the engine (with the Noto fallbacks, so the font notices above apply), the shared frontend and the Tauri 2 stack. The frontend build (`tools/playground/dist-desktop`, embedded in the executable) ships `licenses/React-LICENSE` (React and React DOM, MIT), `licenses/Web-Awesome-LICENSE`, `licenses/Lucide-LICENSE` and `licenses/Font-Awesome-Free-LICENSE` (as above), and `licenses/Frontend.md`, the notices of every JavaScript package the bundle contains. Bundles also install this file and the asset licenses (`licenses/` in the app's resources; `tauri.conf.json`).
|
|
22
|
+
|
|
23
|
+
Its Rust dependencies and their checksums are recorded in `tools/desktop/Cargo.lock`; Tauri, wry, tao and the platform bindings are MIT/Apache-2.0. Beyond the MIT, Apache-2.0, BSD and Unicode-3.0 licenses, the executable contains code under:
|
|
24
|
+
|
|
25
|
+
- MPL-2.0: `cssparser` 0.37.0 and 0.38.0, `dtoa-short` 0.3.5, `option-ext` 0.2.0, `selectors` 0.38.0 and 0.41.0 (unmodified; their source is published on crates.io, https://www.mozilla.org/MPL/2.0/; the build also runs the MPL-2.0 procedural macro `cssparser-macros` 0.7.1, which the executable does not contain);
|
|
26
|
+
- Zlib: `foldhash` 0.2.0, `slotmap` 1.1.1, `zlib-rs` 0.6.8;
|
|
27
|
+
- ISC: `libloading` 0.7.4 (Linux, through `libappindicator-sys`).
|
|
28
|
+
|
|
29
|
+
The executable uses the system webview (WebKitGTK and GTK on Linux, WebView2 on Windows, WKWebView on macOS), which it links against but does not ship.
|
|
30
|
+
|
|
31
|
+
## Assets derived from Mermaid 12.2.0 and its libraries
|
|
32
|
+
|
|
33
|
+
`crates/zonks/assets` holds data derived from the pinned Mermaid 12.2.0 sources (MIT) and the libraries it bundles: static CSS, markers, icons and palettes; each directory keeps the licenses it derives from: `MERMAID-LICENSE`, D3 (`mermaid-xychart/D3-*-LICENSE`, `mermaid-pie/D3-SHAPE-LICENSE` and `D3-PATH-LICENSE`, `mermaid-sankey/D3-SANKEY-LICENSE` (BSD), `mermaid-treemap/D3-HIERARCHY-LICENSE` (ISC)), Rough.js (`mermaid-flow-shapes/ROUGHJS-LICENSE`), venn.js (`mermaid-venn/VENN-JS-LICENSE`), Iconify utils (`mermaid-architecture/ICONIFY-UTILS-LICENSE`) and the formel MathML operator dictionary (`mathml-core/LICENSE`).
|
|
34
|
+
|
|
35
|
+
The diagram renderers port parsing, layout and SVG construction from the corresponding Mermaid renderers; production code reads no reference output. `crates/zonks-svg/src/rough_rs` is rough-rs 0.1.0 (MIT, Copyright (c) 2026 Trần Quang Đãng; `rough_rs/LICENSE`), vendored and reduced to the generator surface `sketch` uses. `crates/zonks-svg/src/bezier.rs` ports the Bézier extrema, SVG arc conversion and arc lengths of kurbo 0.13.1 (MIT OR Apache-2.0, used under MIT, Copyright (c) 2018 Raph Levien; `bezier/KURBO-LICENSE`). `crates/zonks-katex` (the published fork `zonks-katex`) is katex-rs 0.3.0 (MIT, Copyright (c) 2025 katex-rs; `crates/zonks-katex/LICENSE`, from the upstream repository's `katex-rs-v0.3.0` tag, since the crates.io package omits it), the math labels' TeX parser and MathML builder, vendored with a nesting bound (`crates/zonks-katex/README-VENDORED.md`); it ports KaTeX (MIT, Copyright (c) 2013-2020 Khan Academy and other contributors; `crates/zonks-katex/KATEX-LICENSE`) and its data. Native dependencies (among them `libm` 0.2.16, MIT; `self_cell` 1.3.0, used under Apache-2.0 of its Apache-2.0 OR GPL-2.0-only; `zmij` 1.0.23, MIT; `serde_yaml_ng`) and their checksums are recorded in Cargo.lock. Beyond MIT, Apache-2.0, BSD and Unicode-3.0, the engine contains MPL-2.0 `cssparser` 0.38.0 and `dtoa-short` 0.3.5 (through `zonks-html`; unmodified, source on crates.io, https://www.mozilla.org/MPL/2.0/; the build also runs the MPL-2.0 procedural macro `cssparser-macros` 0.7.1) and Zlib `slotmap` 1.1.1 (through `fontdb`).
|
|
36
|
+
|
|
37
|
+
## Test data
|
|
38
|
+
|
|
39
|
+
The unit-test fixtures in `crates/*/fixtures` were recorded from the pinned Mermaid and its libraries (Langium, stylis, DOMPurify, KaTeX, Rough.js). `crates/zonks/fixtures/fonts` holds unchanged Debian bookworm builds of DejaVu Sans and Serif and Noto Sans Math with their package copyright files. None of this is compiled into a product crate. The fixtures are not in the published crates.io packages.
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
## jison-lex 0.3.4
|
|
43
|
+
|
|
44
|
+
`crate::parse::jison_lex` and the hand-written parsers on it (such as `diagrams/flowchart/parser`) reproduce jison-lex's scanning rules. jison is distributed under the MIT License:
|
|
45
|
+
|
|
46
|
+
```text
|
|
47
|
+
Copyright (c) 2009-2014 Zachary Carter
|
|
48
|
+
|
|
49
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
50
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
51
|
+
in the Software without restriction, including without limitation the rights
|
|
52
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
53
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
54
|
+
furnished to do so, subject to the following conditions:
|
|
55
|
+
|
|
56
|
+
The above copyright notice and this permission notice shall be included in all
|
|
57
|
+
copies or substantial portions of the Software.
|
|
58
|
+
|
|
59
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
60
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
61
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
62
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
63
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
64
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
65
|
+
SOFTWARE.
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## @braintree/sanitize-url 7.1.2
|
|
69
|
+
|
|
70
|
+
`crates/zonks-html/src/sanitize.rs` ports `sanitizeUrl`, which Mermaid applies to flowchart links. It is distributed under the MIT License:
|
|
71
|
+
|
|
72
|
+
```text
|
|
73
|
+
MIT License
|
|
74
|
+
|
|
75
|
+
Copyright (c) 2017 Braintree
|
|
76
|
+
|
|
77
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
78
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
79
|
+
in the Software without restriction, including without limitation the rights
|
|
80
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
81
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
82
|
+
furnished to do so, subject to the following conditions:
|
|
83
|
+
|
|
84
|
+
The above copyright notice and this permission notice shall be included in all
|
|
85
|
+
copies or substantial portions of the Software.
|
|
86
|
+
|
|
87
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
88
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
89
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
90
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
91
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
92
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
93
|
+
SOFTWARE.
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
The same file reproduces DOMPurify 3.4.12's (Apache-2.0 or MPL-2.0) attribute value checks without copying its code.
|
|
97
|
+
|
|
98
|
+
## stylis 4.3.6
|
|
99
|
+
|
|
100
|
+
`crates/zonks/src/theme/stylesheet/sheet.rs` writes rules in the minified form of stylis 4.3.6 (its token classes, `src/Tokenizer.js`), the CSS compiler Mermaid namespaces its stylesheets with. stylis is distributed under the MIT License:
|
|
101
|
+
|
|
102
|
+
```text
|
|
103
|
+
MIT License
|
|
104
|
+
|
|
105
|
+
Copyright (c) 2016-present Sultan Tarimo
|
|
106
|
+
|
|
107
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
108
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
109
|
+
in the Software without restriction, including without limitation the rights
|
|
110
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
111
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
112
|
+
furnished to do so, subject to the following conditions:
|
|
113
|
+
|
|
114
|
+
The above copyright notice and this permission notice shall be included in all
|
|
115
|
+
copies or substantial portions of the Software.
|
|
116
|
+
|
|
117
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
118
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
119
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
120
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
121
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
122
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
123
|
+
SOFTWARE.
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Mermaid themes and stylesheet functions
|
|
127
|
+
|
|
128
|
+
`crates/zonks/src/theme/themes` ports Mermaid's theme classes (`themes/theme-*.js`) and `crates/zonks/src/theme/stylesheet` its stylesheet (`styles.ts`, every diagram's styles provider and the helpers they use) to Rust; `crates/zonks/src/theme` keeps Mermaid's MIT license (`MERMAID-LICENSE`). `crates/zonks/src/config/keys.rs` holds Mermaid 12.2.0's `configKeys` and `getDiagramConfigKey`'s aliases; `crates/zonks/src/config` keeps the same license (`MERMAID-LICENSE`).
|
|
129
|
+
|
|
130
|
+
## khroma 2.1.0
|
|
131
|
+
|
|
132
|
+
`crates/zonks-css/src/khroma.rs` ports the khroma 2.1.0 color functions Mermaid's themes and stylesheets use. khroma is distributed under the MIT License:
|
|
133
|
+
|
|
134
|
+
```text
|
|
135
|
+
The MIT License (MIT)
|
|
136
|
+
|
|
137
|
+
Copyright (c) 2019-present Fabio Spampinato, Andrew Maney
|
|
138
|
+
|
|
139
|
+
Permission is hereby granted, free of charge, to any person obtaining a
|
|
140
|
+
copy of this software and associated documentation files (the "Software"),
|
|
141
|
+
to deal in the Software without restriction, including without limitation
|
|
142
|
+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
143
|
+
and/or sell copies of the Software, and to permit persons to whom the
|
|
144
|
+
Software is furnished to do so, subject to the following conditions:
|
|
145
|
+
|
|
146
|
+
The above copyright notice and this permission notice shall be included in
|
|
147
|
+
all copies or substantial portions of the Software.
|
|
148
|
+
|
|
149
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
150
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
151
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
152
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
153
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
154
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
155
|
+
DEALINGS IN THE SOFTWARE.
|
|
156
|
+
```
|