@lofcz/tikz 0.0.0-stage → 0.2.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 (118) hide show
  1. package/LICENSE +674 -0
  2. package/NOTICE.md +30 -0
  3. package/README.md +127 -2
  4. package/package.json +56 -4
  5. package/runtime/LICENSE +165 -0
  6. package/runtime/NOTICE.md +32 -0
  7. package/runtime/dist/auto.d.ts +68 -0
  8. package/runtime/dist/auto.js +564 -0
  9. package/runtime/dist/bibtex.mjs +2 -0
  10. package/runtime/dist/bibtex.wasm +0 -0
  11. package/runtime/dist/bundles/cm-tfm/files.br +0 -0
  12. package/runtime/dist/bundles/cm-tfm/files.index.json +1 -0
  13. package/runtime/dist/bundles/cm-tfm/manifest.json +1 -0
  14. package/runtime/dist/bundles/cm-type1/files.br +0 -0
  15. package/runtime/dist/bundles/cm-type1/files.index.json +1 -0
  16. package/runtime/dist/bundles/cm-type1/manifest.json +1 -0
  17. package/runtime/dist/bundles/core/files.br +0 -0
  18. package/runtime/dist/bundles/core/files.index.json +1 -0
  19. package/runtime/dist/bundles/core/manifest.json +1 -0
  20. package/runtime/dist/bundles/hot.json +1 -0
  21. package/runtime/dist/bundles/index.json +80 -0
  22. package/runtime/dist/bundles/latex-core/files.br +0 -0
  23. package/runtime/dist/bundles/latex-core/files.index.json +1 -0
  24. package/runtime/dist/bundles/latex-core/manifest.json +1 -0
  25. package/runtime/dist/bundles/latex-extra/files.br +0 -0
  26. package/runtime/dist/bundles/latex-extra/files.index.json +1 -0
  27. package/runtime/dist/bundles/latex-extra/manifest.json +1 -0
  28. package/runtime/dist/bundles/lm-fonts/files.br +0 -0
  29. package/runtime/dist/bundles/lm-fonts/files.index.json +1 -0
  30. package/runtime/dist/bundles/lm-fonts/manifest.json +1 -0
  31. package/runtime/dist/bundles/luatex/files.br +0 -0
  32. package/runtime/dist/bundles/luatex/files.index.json +1 -0
  33. package/runtime/dist/bundles/luatex/manifest.json +1 -0
  34. package/runtime/dist/bundles/ps-fonts/files.br +0 -0
  35. package/runtime/dist/bundles/ps-fonts/files.index.json +1 -0
  36. package/runtime/dist/bundles/ps-fonts/manifest.json +1 -0
  37. package/runtime/dist/bundles/tex-plain/files.br +0 -0
  38. package/runtime/dist/bundles/tex-plain/files.index.json +1 -0
  39. package/runtime/dist/bundles/tex-plain/manifest.json +1 -0
  40. package/runtime/dist/bundles/tikz-snapshot/files.br +0 -0
  41. package/runtime/dist/bundles/tikz-snapshot/files.index.json +1 -0
  42. package/runtime/dist/bundles/tikz-snapshot/manifest.json +1 -0
  43. package/runtime/dist/bundles-config.d.ts +3 -0
  44. package/runtime/dist/bundles-config.js +16 -0
  45. package/runtime/dist/cli.d.ts +2 -0
  46. package/runtime/dist/cli.js +372 -0
  47. package/runtime/dist/core.d.ts +124 -0
  48. package/runtime/dist/core.js +927 -0
  49. package/runtime/dist/diagnostics.d.ts +53 -0
  50. package/runtime/dist/diagnostics.js +184 -0
  51. package/runtime/dist/dvisvgm.d.ts +20 -0
  52. package/runtime/dist/dvisvgm.js +46 -0
  53. package/runtime/dist/dvisvgm.mjs +2 -0
  54. package/runtime/dist/dvisvgm.wasm +0 -0
  55. package/runtime/dist/figures.d.ts +92 -0
  56. package/runtime/dist/figures.js +250 -0
  57. package/runtime/dist/ghostscript.d.ts +92 -0
  58. package/runtime/dist/ghostscript.js +218 -0
  59. package/runtime/dist/index.d.ts +87 -0
  60. package/runtime/dist/index.js +364 -0
  61. package/runtime/dist/logger.d.ts +48 -0
  62. package/runtime/dist/logger.js +55 -0
  63. package/runtime/dist/luatex.mjs +2 -0
  64. package/runtime/dist/luatex.wasm +0 -0
  65. package/runtime/dist/makeindex.mjs +2 -0
  66. package/runtime/dist/makeindex.wasm +0 -0
  67. package/runtime/dist/mplib.d.ts +106 -0
  68. package/runtime/dist/mplib.js +85 -0
  69. package/runtime/dist/mplib.mjs +2 -0
  70. package/runtime/dist/mplib.wasm +0 -0
  71. package/runtime/dist/node.d.ts +4 -0
  72. package/runtime/dist/node.js +49 -0
  73. package/runtime/dist/postscript.d.ts +21 -0
  74. package/runtime/dist/postscript.js +130 -0
  75. package/runtime/dist/prerender.d.ts +55 -0
  76. package/runtime/dist/prerender.js +106 -0
  77. package/runtime/dist/render/svg.d.ts +20 -0
  78. package/runtime/dist/render/svg.js +96 -0
  79. package/runtime/dist/tex/bridge.d.ts +93 -0
  80. package/runtime/dist/tex/bridge.js +223 -0
  81. package/runtime/dist/tex/cache-key.d.ts +33 -0
  82. package/runtime/dist/tex/cache-key.js +150 -0
  83. package/runtime/dist/tex/mpto.d.ts +60 -0
  84. package/runtime/dist/tex/mpto.js +112 -0
  85. package/runtime/dist/tex/mpx.d.ts +25 -0
  86. package/runtime/dist/tex/mpx.js +54 -0
  87. package/runtime/dist/tex/scanner.d.ts +78 -0
  88. package/runtime/dist/tex/scanner.js +326 -0
  89. package/runtime/dist/tex.mjs +2 -0
  90. package/runtime/dist/tex.wasm +0 -0
  91. package/runtime/dist/texengine.d.ts +35 -0
  92. package/runtime/dist/texengine.js +57 -0
  93. package/runtime/dist/texutils.d.ts +19 -0
  94. package/runtime/dist/texutils.js +60 -0
  95. package/runtime/dist/types.d.ts +376 -0
  96. package/runtime/dist/types.js +6 -0
  97. package/runtime/dist/vfs/bundle.d.ts +88 -0
  98. package/runtime/dist/vfs/bundle.js +315 -0
  99. package/runtime/dist/vfs/lazyfs.d.ts +62 -0
  100. package/runtime/dist/vfs/lazyfs.js +133 -0
  101. package/runtime/dist/worker.d.ts +15 -0
  102. package/runtime/dist/worker.js +143 -0
  103. package/runtime/licenses/COPYING.AFPL +230 -0
  104. package/runtime/licenses/COPYING.makeindex +42 -0
  105. package/runtime/licenses/GPL-3.0.txt +674 -0
  106. package/runtime/licenses/LGPL-3.0.txt +165 -0
  107. package/runtime/licenses/OFL-1.1.txt +93 -0
  108. package/runtime/package.json +1 -0
  109. package/runtime/upstream.json +27 -0
  110. package/src/browser-worker.js +26 -0
  111. package/src/browser.d.ts +18 -0
  112. package/src/browser.js +68 -0
  113. package/src/deploy.d.ts +5 -0
  114. package/src/deploy.js +48 -0
  115. package/src/index.d.ts +28 -0
  116. package/src/index.js +103 -0
  117. package/src/worker.js +15 -0
  118. package/upstream.json +27 -0
package/NOTICE.md ADDED
@@ -0,0 +1,30 @@
1
+ # Third-party runtime
2
+
3
+ This wrapper maintains a fork of mp-tikz-wasm 0.5.0 by jmckalex, based on commit
4
+ d44aeeba98b0e60d13c35dfd080076e6b05c68b5. `upstream.json` records the archive and
5
+ SHA-256. Only package maintainers download the native baseline from our fork during `npm run build`.
6
+ Engine TypeScript is compiled from `packages/engine` in https://github.com/lofcz/tikz;
7
+ the fork is mirrored at https://github.com/lofcz/mp-tikz-wasm/tree/tikz-monorepo.
8
+
9
+ The wrapper is GPL-3.0-or-later. Runtime components and fonts retain their
10
+ respective licenses; see the complete upstream `runtime/NOTICE.md`,
11
+ `runtime/LICENSE` and `runtime/licenses/`, included in every npm package.
12
+ The runtime includes GPL pdfTeX/LuaTeX/dvisvgm, LGPL glue, and separately licensed
13
+ TeX macros and fonts. This is not an MIT-only distribution.
14
+
15
+ Only the ten upstream default bundles are shipped. Optional Classico (AFPL),
16
+ Ghostscript, latex-doc, OpenType and otf-fonts bundles are excluded. No Ghostscript
17
+ engine is included. Native binaries and macro contents are unchanged. Bundle payloads are Brotli-compressed
18
+ without changing their contents. Our Node I/O decompresses them on demand and
19
+ uses portable file URL handling. Browser I/O still uses uncompressed assets.
20
+
21
+ Corresponding upstream source, patches and reproducible build instructions:
22
+ https://github.com/jmckalex/mp-tikz-wasm/tree/d44aeeba98b0e60d13c35dfd080076e6b05c68b5
23
+ Source archive:
24
+ https://github.com/jmckalex/mp-tikz-wasm/archive/d44aeeba98b0e60d13c35dfd080076e6b05c68b5.tar.gz
25
+ Pinned engine sources:
26
+ https://github.com/jmckalex/mp-tikz-wasm/blob/d44aeeba98b0e60d13c35dfd080076e6b05c68b5/vendor/SOURCES.lock
27
+
28
+ See the upstream Makefile, vendor/ and patches/ for rebuilding/replacing the
29
+ runtime. The package resolves its runtime from its own install directory;
30
+ consumers can replace those files with compatible rebuilt versions.
package/README.md CHANGED
@@ -1,3 +1,128 @@
1
- # Temporary Holding Version
1
+ # @lofcz/tikz
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Render standard TikZ and standalone LaTeX to SVG using
4
+ our maintained [mp-tikz-wasm fork](https://github.com/lofcz/mp-tikz-wasm). Node 22.19+ and
5
+ Bun with Node on PATH. No system TeX installation, network access, runtime
6
+ download, install script, framework, or API key is needed by consumers.
7
+
8
+ ```sh
9
+ npm install @lofcz/tikz
10
+ ```
11
+
12
+ ```js
13
+ import { renderTikz } from '@lofcz/tikz';
14
+
15
+ const image = await renderTikz(String.raw`
16
+ \begin{tikzpicture}
17
+ \draw[->] (-2,0) -- (2,0);
18
+ \draw[blue,thick] (0,0) circle (1);
19
+ \node at (1,1) {$\frac{1}{2}$};
20
+ \end{tikzpicture}
21
+ `);
22
+ // image.svg, image.width, image.height, image.dataUrl
23
+ ```
24
+
25
+ Use `dataUrl` as an image source. Do not insert untrusted SVG as HTML. Text is
26
+ outlined, so the image does not need web fonts. Full `\documentclass` documents
27
+ are accepted unchanged. Snippets receive a standalone wrapper and the standard
28
+ calc, intersections, angles, quotes, arrows.meta and positioning libraries.
29
+ pgfplots is available through `\usepackage{pgfplots}` in a complete document.
30
+
31
+ ## Limits and cancellation
32
+
33
+ One page; 12,000 source characters; 30 seconds per execution and queue wait;
34
+ 4 MB output; two running processes and eight queued jobs per renderer instance.
35
+ Only bundled TeX packages, no external files. Rendering does not verify the
36
+ mathematics. The default `renderTikz` shares one renderer within a process.
37
+
38
+ ```js
39
+ import { createTikzRenderer } from '@lofcz/tikz';
40
+ const renderer = createTikzRenderer({ concurrency: 1, maxQueue: 4, timeoutMs: 15_000 });
41
+ const image = await renderer.render(source, { signal: AbortSignal.timeout(10_000) });
42
+ ```
43
+
44
+ Each request runs in a fresh child process with an empty environment and WASM
45
+ virtual filesystem. Timeouts/aborts kill that process, including synchronous TeX
46
+ loops; queue capacity is not released until the process closes. The Node heap
47
+ limit is 512 MB, not a total RSS/WASM memory limit. Apply container/OS resource
48
+ limits when serving untrusted workloads. Browser apps use the worker entry below; backend generation uses the Node entry.
49
+
50
+ ## Browser rendering
51
+
52
+ Compile locally in a dedicated Web Worker:
53
+
54
+ ```js
55
+ import { createTikzRenderer } from '@lofcz/tikz/browser';
56
+ const renderer = createTikzRenderer({ assetBaseUrl: '/tikz/' });
57
+ const image = await renderer.render(source, { signal });
58
+ // On teardown: renderer.dispose();
59
+ ```
60
+
61
+ Copy static assets during your app build and serve them from that same-origin URL:
62
+
63
+ ```js
64
+ import { copyTikzBrowserAssets } from '@lofcz/tikz/deploy';
65
+ await copyTikzBrowserAssets('public/tikz');
66
+ ```
67
+
68
+ The helper expands compressed TeX bundles for ordinary static hosting. WASM and
69
+ TeX files load lazily on the first figure, with normal HTTP caching; there is no
70
+ rendering endpoint or CDN dependency. The worker is reused for successive figures
71
+ and terminated on cancellation, failure, or the 30-second compilation deadline.
72
+ Initial runtime loading has a separate 60-second deadline. Eight jobs may queue.
73
+ Call `dispose()` when the host is destroyed. Use versioned asset URLs on deployment.
74
+
75
+ With Streamdown, pass `render: source => renderer.render(source)` to
76
+ `createTikzPlugin`. The plugin displays the returned `dataUrl` as an isolated image.
77
+
78
+ ## Bundlers and deployment
79
+
80
+ Ordinary Node/Bun installs work directly. Keep `@lofcz/tikz` external when
81
+ possible. For a standalone serverless artifact that omits node_modules:
82
+
83
+ ```js
84
+ import { copyTikzAssets } from '@lofcz/tikz/deploy';
85
+ await copyTikzAssets('.vercel/output/functions/render.func');
86
+ ```
87
+
88
+ This copies the complete package into that function's node_modules. The small
89
+ entry module can also be bundled: it resolves `@lofcz/tikz/package.json` from the
90
+ output location, rather than resolving WASM relative to a relocated chunk. Call
91
+ the helper for each function that includes the renderer. File tracers must retain
92
+ the full package including `runtime/`; copying only JavaScript is insufficient.
93
+
94
+ ## Development
95
+
96
+ ```sh
97
+ npm ci
98
+ npm run check
99
+ ```
100
+
101
+ The engine source lives in `packages/engine`, imported from upstream v0.5.0 as a
102
+ Git subtree. Every build compiles this source. Native WASM and TeX data come from
103
+ a checksum-pinned release in our fork; their original build provenance is recorded
104
+ in `upstream.json`. Set `TIKZ_ARCHIVE=/path/to/archive.tar.gz` for offline builds.
105
+ The native binaries are the upstream baseline, not a new native compilation.
106
+
107
+ The server distribution Brotli-compresses complete bundles and lazily decompresses each bundle
108
+ on its first file request. It retains all ten default bundles, including pgfplots and LuaTeX.
109
+ The engine source still supports ordinary uncompressed assets and browser I/O.
110
+
111
+
112
+ Tests render real TikZ/pgfplots, exercise cancellation and limits, and install the
113
+ packed tarball offline before rendering from a relocated function directory.
114
+
115
+ For engine development and native rebuilds, see [packages/engine](packages/engine).
116
+ Mirror engine changes to the fork with:
117
+
118
+ ```sh
119
+ git subtree push --prefix=packages/engine https://github.com/lofcz/mp-tikz-wasm.git tikz-monorepo
120
+ ```
121
+
122
+ Release through GitHub Actions with npm trusted publishing:
123
+
124
+ ```sh
125
+ gh workflow run release.yml -R lofcz/tikz -f release_type=patch
126
+ ```
127
+
128
+ Licensing and native source links are in [NOTICE.md](NOTICE.md).
package/package.json CHANGED
@@ -1,6 +1,58 @@
1
1
  {
2
2
  "name": "@lofcz/tikz",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "description": "Self-contained, process-isolated TikZ to SVG rendering powered by mp-tikz-wasm.",
5
+ "type": "module",
6
+ "license": "GPL-3.0-or-later",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./src/index.d.ts",
10
+ "default": "./src/index.js"
11
+ },
12
+ "./deploy": {
13
+ "types": "./src/deploy.d.ts",
14
+ "default": "./src/deploy.js"
15
+ },
16
+ "./package.json": "./package.json",
17
+ "./browser": {
18
+ "types": "./src/browser.d.ts",
19
+ "default": "./src/browser.js"
20
+ }
21
+ },
22
+ "files": [
23
+ "src",
24
+ "runtime",
25
+ "LICENSE",
26
+ "NOTICE.md",
27
+ "upstream.json"
28
+ ],
29
+ "engines": {
30
+ "node": ">=22.19.0"
31
+ },
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "git+https://github.com/lofcz/tikz.git"
35
+ },
36
+ "homepage": "https://github.com/lofcz/tikz#readme",
37
+ "bugs": {
38
+ "url": "https://github.com/lofcz/tikz/issues"
39
+ },
40
+ "publishConfig": {
41
+ "access": "public"
42
+ },
43
+ "scripts": {
44
+ "build": "node scripts/prepare-runtime.mjs",
45
+ "test": "node --test test/*.test.mjs",
46
+ "test:package": "node scripts/test-package.mjs",
47
+ "check": "npm run build && npm test && npm run test:package",
48
+ "prepack": "npm run build",
49
+ "build:engine": "tsc -p packages/engine/tsconfig.build.json",
50
+ "test:browser": "node test/browser.mjs"
51
+ },
52
+ "devDependencies": {
53
+ "@types/node": "^22.20.5",
54
+ "playwright": "^1.64.1",
55
+ "tar": "^7.5.22",
56
+ "typescript": "^5.9.3"
57
+ }
58
+ }
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
@@ -0,0 +1,32 @@
1
+ # Licences (NOTICE)
2
+
3
+ mp-tikz-wasm is a build of several upstream programs plus its own glue.
4
+ Each part keeps its licence; the table says what applies to what.
5
+
6
+ | Part | Licence | Notes |
7
+ | --- | --- | --- |
8
+ | `src/`, `scripts/`, `site/`, `test/`, `docs/` (this project's own code and documents) | LGPL-3.0-or-later | so that the whole `mplib.wasm` can be distributed under one licence |
9
+ | MetaPost (`mplib`: `mp.w`, `psout.w`, `svgout.w`, …) | public domain | Taco Hoekwater, Luigi Scarso, John Hobby; TeX Live 2025 |
10
+ | `avl.c` (in `mplib.wasm`) | LGPL-3.0-or-later | hence `mplib.wasm` is LGPL-3.0-or-later; the sources, the patches in `patches/` and a reproducible build (`make wasm`) are in this repository |
11
+ | decNumber (in `mplib.wasm`) | ICU licence | |
12
+ | pdfTeX, kpathsea (`tex.wasm`) | GPL-2.0-or-later / LGPL-2.1-or-later | `tex.wasm` is distributed under the GPL |
13
+ | LuaTeX (`luatex.wasm`) | GPL-2.0-or-later | includes Lua 5.3 (MIT), pplib (Paweł Jackowski, permissive; see `libs/pplib` in the TeX Live source), zziplib (LGPL-2.1-or-later or MPL-1.1), the fontforge-derived font loader (BSD-3-Clause), kpathsea, and our patched mplib; `luatex.wasm` is distributed under the GPL |
14
+ | dvisvgm (`dvisvgm.wasm`) | GPL-3.0-or-later | includes FreeType (FTL), potrace (GPL-2.0-or-later), clipper (Boost), woff2 and brotli (MIT), xxHash (BSD), the URW base-14 CFF fonts as distributed by dvisvgm |
15
+ | BibTeX (`bibtex.wasm`) | BibTeX's own terms (as Knuth's TeX) / LGPL-2.1-or-later (kpathsea) | Oren Patashnik's BibTeX 0.99d with web2c's change file and `lib/` (public domain), from the pinned TeX Live 2025 source, unmodified: `bibtex.web` is "available under the same terms as Donald Knuth's TeX program". Built by `scripts/build-texutils-wasm.sh` |
16
+ | makeindex (`makeindex.wasm`) | **MakeIndex Distribution Notice** (`licenses/COPYING.makeindex`) / LGPL-2.1-or-later (kpathsea) | Pehong Chen, Nelson Beebe and the TeX Live project; makeindex 2.17 from the pinned TeX Live 2025 source (`texk/makeindexk`, see `vendor/SOURCES.lock`), unmodified. The notice allows copying and distribution; whoever ships the binary without its source must include the notice conspicuously and say where the source is: here, `vendor/texlive-source/texk/makeindexk` after `scripts/extract-vendor.sh`, or TeX Live's own source |
17
+ | Computer Modern, AMS and Latin Modern fonts (`bundles/`) | Knuth's licence / AMS / GUST Font License | |
18
+ | EB Garamond and Garamond-Math (`bundles/latex-doc`, opt-in) | **SIL Open Font License 1.1** (`licenses/OFL-1.1.txt`) | EB Garamond: The EB Garamond Project Authors (Georg Duffner, Octavio Pardo), four of its faces; Garamond-Math: Yuansheng Zhao. From TeX Live's `ebgaramond` and `garamond-math`, unmodified |
19
+ | The `latex-doc` bundle's macro packages, BibTeX and makeindex styles (`bundles/latex-doc`, opt-in) | LPPL 1.3c, 1.3 or 1.2, and package-specific free licences | tcolorbox, cleveref, thmtools, natbib, caption, adjustbox, soul, setspace, multirow, fancyhdr, csquotes, float, fvextra, fancyvrb, microtype, titling, babel and its languages, and the rest: LPPL; enumitem and titlesec: MIT; greek-fontenc: LPPL or BSD-2-Clause; babel-hungarian: LPPL or GPL; BibTeX's standard styles: Patashnik's terms in `btxbst.doc` (changed copies must be renamed). From TeX Live 2025, unmodified |
20
+ | Hyphenation patterns (`bundles/latex-doc`, opt-in: `tex/generic/hyph-utf8`) | each file's own free licence, stated in its header | hyph-utf8 (MIT); the patterns: MIT, LPPL, BSD-3-Clause (Portuguese), the Unlicense (Galician), public domain (Finnish), GPL (Czech, Slovak), and several with a choice of MIT, LPPL, LGPL, MPL or GPL. The Romanian patterns (Adrian Rezus, 1995–96) state a copyright but no licence; TeX Live distributes them, and so do we |
21
+ | URW Classico fonts (`bundles/classico`, opt-in) | **Aladdin Free Public License** (`licenses/COPYING.AFPL`) | (URW)++ Design & Development, 2000 and 2013; the LaTeX support (`classico.sty`, `.fd`, metrics) by Michael Sharpe, from CTAN's `classico`. The AFPL allows modification and **non-commercial** distribution only, which is why TeX Live does not include it: anyone redistributing this project's bundles in a commercial product must leave the `classico` bundle out. Not part of TeX Live; built from a local install. |
22
+ | LaTeX, PGF/TikZ, pgfplots and the other macro packages (`bundles/`) | LPPL 1.3c and package-specific free licences | see each package's header in TeX Live |
23
+ | Ghostscript (`dist/ghostscript/`: `gs.mjs`, `gs.wasm`; opt-in, released as an archive of its own) | **GNU AGPL v3** (`dist/ghostscript/COPYING`; `LICENSE` says which parts it covers) | Artifex Software. Ghostscript 10.08.0 built to WebAssembly by the Ghostscript port (pinned in `vendor/GHOSTSCRIPT.lock`): the upstream source unmodified apart from a new `svg` device and a dependency fix in `pdf/pdf.mak`, in its lean variant. It is a separate module, never linked into the engines here: dvisvgm reaches it through `src/c/gs-bridge.c` and `src/ts/ghostscript.ts` when a document carries PostScript. Anyone serving or shipping it must offer its corresponding source: each release carries it as `mp-tikz-wasm-ghostscript-<version>-source.tar.gz` (the port's tree at the commit pinned in `vendor/GHOSTSCRIPT.lock`), and `dist/ghostscript/SOURCE.md` says so. Its fonts carry the AGPL with Artifex's font exception. |
24
+ | dvips's PostScript headers and the PSTricks family (`bundles/ghostscript`, opt-in) | GPL (dvips's `.pro` headers) / LPPL 1.3c (PSTricks, `pst-*`, `multido`) | from TeX Live; the `.pro` files are what dvips itself prepends to PostScript |
25
+
26
+ The full texts are in the repository: `LICENSE` (LGPL-3.0, this project's own
27
+ licence) and `licenses/GPL-3.0.txt` / `licenses/LGPL-3.0.txt`, copied from
28
+ <https://www.gnu.org/licenses/>; `licenses/COPYING.AFPL` is the Aladdin Free Public
29
+ License of the URW Classico fonts, as distributed with CTAN's `classico`;
30
+ `licenses/COPYING.makeindex` is makeindex's distribution notice, as in TeX Live's
31
+ source; `licenses/OFL-1.1.txt` is the SIL Open Font License of EB Garamond and
32
+ Garamond-Math, as distributed with TeX Live's `ebgaramond`.
@@ -0,0 +1,68 @@
1
+ import type { MetaPostOptions, LogLevel } from './types.js';
2
+ import { figureHash, figureName, wrapTikz, wrapMetaPost } from './figures.js';
3
+ import type { FigureRequest, FigureResult, SavedFigure } from './figures.js';
4
+ export { wrapTikz, wrapMetaPost, figureHash, figureName };
5
+ export type { FigureRequest as RenderRequest, SavedFigure };
6
+ /** Where the SVG came from: the IndexedDB result cache, a saved figure file, or the engines. */
7
+ export type RenderSource = 'cache' | 'file' | 'engine';
8
+ /** ms is the engine's own time for this diagram (queueing and engine start-up excluded). */
9
+ export interface RenderOutput extends FigureResult {
10
+ cached: boolean;
11
+ from: RenderSource;
12
+ hash: string;
13
+ name: string;
14
+ }
15
+ export interface AutoOptions extends MetaPostOptions {
16
+ /** false: neither read nor write the IndexedDB result cache (data-cache="off" on the loader). */
17
+ cacheResults?: boolean;
18
+ /** Base URL of the saved figures (`figure-HASH.svg`), looked up before the engines start (data-figures on the loader). */
19
+ figuresBaseUrl?: string;
20
+ }
21
+ export declare class AutoRenderer {
22
+ private options;
23
+ private engine;
24
+ private readonly log;
25
+ private readonly rendered;
26
+ private readonly inFlight;
27
+ /** Files handed over before the engine existed; applied when it starts (see addFiles). */
28
+ private readonly pendingFiles;
29
+ constructor(options?: AutoOptions);
30
+ /** Has an engine been started? A page whose figures all came from the cache or the saved files never starts one. */
31
+ get started(): boolean;
32
+ /**
33
+ * Put files where this page's TeX runs will find them: a font the host wants to
34
+ * typeset in (`\setmainfont{X.ttf}[Path=./]` — the run's working directory leads
35
+ * OPENTYPEFONTS and TTFONTS), an image, a .sty. They stay for the life of the page.
36
+ *
37
+ * Deliberately does NOT start the engine: files handed over before the first
38
+ * render are held and applied when one is created, so a page whose figures all
39
+ * come from the cache or from saved files still starts nothing. Call it before
40
+ * the figures that need the font, and with the `opentype` bundle loaded
41
+ * (`data-bundles="+opentype"`) if the font is for fontspec.
42
+ */
43
+ addFiles(files: Record<string, string | Uint8Array>): Promise<void>;
44
+ private get mp();
45
+ /** How much reaches the console (see `MetaPostOptions.logLevel`), for the engine now and later. */
46
+ setLogLevel(level: LogLevel): void;
47
+ render(req: FigureRequest): Promise<RenderOutput>;
48
+ private renderFrom;
49
+ private done;
50
+ /** Drop a figure from figures() (and so from saveFigures()): a live element has replaced it. */
51
+ forget(nameOrHash: string): void;
52
+ /** Resolves when no render is in flight. */
53
+ idle(): Promise<void>;
54
+ /** Every figure that has rendered successfully so far (from any source), in the order it finished. */
55
+ figures(): SavedFigure[];
56
+ /**
57
+ * Write every figure on the page as figure-HASH.svg: into a folder chosen with the
58
+ * directory picker where the browser has one (Chrome, Edge), otherwise as a zip
59
+ * download. Waits for figures still rendering. Returns the file names written.
60
+ */
61
+ saveFigures(opts?: {
62
+ zip?: boolean;
63
+ name?: string;
64
+ }): Promise<string[]>;
65
+ }
66
+ export declare function renderElement(el: Element): Promise<void>;
67
+ /** Render every diagram element currently in the document (and later ones, unless observe is off). */
68
+ export declare function autoRender(root?: ParentNode): void;