@danielsimonjr/sciengjs 0.8.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/README.md +27 -4
  2. package/THIRD_PARTY_NOTICES.md +65 -4
  3. package/dist/core.js +2 -0
  4. package/dist/core.js.map +1 -1
  5. package/dist/errors.d.ts +2 -0
  6. package/dist/errors.js +4 -0
  7. package/dist/errors.js.map +1 -1
  8. package/dist/graph/backend-pdf.js +3 -2
  9. package/dist/graph/backend-pdf.js.map +1 -1
  10. package/dist/graph/backend-png.js +3 -2
  11. package/dist/graph/backend-png.js.map +1 -1
  12. package/dist/graph/backend-svg.js +3 -2
  13. package/dist/graph/backend-svg.js.map +1 -1
  14. package/dist/graph/dot.d.ts +0 -2
  15. package/dist/graph/dot.js +0 -4
  16. package/dist/graph/dot.js.map +1 -1
  17. package/dist/graph/text.d.ts +12 -0
  18. package/dist/graph/text.js +21 -0
  19. package/dist/graph/text.js.map +1 -0
  20. package/dist/mermaid/backend-pdf.js +2 -1
  21. package/dist/mermaid/backend-pdf.js.map +1 -1
  22. package/dist/mermaid/backend-png.js +2 -1
  23. package/dist/mermaid/backend-png.js.map +1 -1
  24. package/dist/mermaid/backend-svg.js +2 -1
  25. package/dist/mermaid/backend-svg.js.map +1 -1
  26. package/dist/mermaid/class.js +3 -7
  27. package/dist/mermaid/class.js.map +1 -1
  28. package/dist/mermaid/common.d.ts +0 -10
  29. package/dist/mermaid/common.js +2 -16
  30. package/dist/mermaid/common.js.map +1 -1
  31. package/dist/mermaid/sequence-layout.js +1 -1
  32. package/dist/mermaid/sequence-layout.js.map +1 -1
  33. package/dist/mermaid/sequence.js +2 -1
  34. package/dist/mermaid/sequence.js.map +1 -1
  35. package/dist/mermaid/state.js +3 -1
  36. package/dist/mermaid/state.js.map +1 -1
  37. package/dist/registry.js +6 -0
  38. package/dist/registry.js.map +1 -1
  39. package/dist/sysml/backend-pdf.d.ts +3 -0
  40. package/dist/sysml/backend-pdf.js +10 -0
  41. package/dist/sysml/backend-pdf.js.map +1 -0
  42. package/dist/sysml/backend-png.d.ts +6 -0
  43. package/dist/sysml/backend-png.js +19 -0
  44. package/dist/sysml/backend-png.js.map +1 -0
  45. package/dist/sysml/backend-svg.d.ts +3 -0
  46. package/dist/sysml/backend-svg.js +8 -0
  47. package/dist/sysml/backend-svg.js.map +1 -0
  48. package/dist/sysml/index.d.ts +8 -0
  49. package/dist/sysml/index.js +9 -0
  50. package/dist/sysml/index.js.map +1 -0
  51. package/dist/sysml/parse.d.ts +99 -0
  52. package/dist/sysml/parse.js +480 -0
  53. package/dist/sysml/parse.js.map +1 -0
  54. package/dist/sysml/render.d.ts +7 -0
  55. package/dist/sysml/render.js +11 -0
  56. package/dist/sysml/render.js.map +1 -0
  57. package/dist/sysml/tokens.d.ts +14 -0
  58. package/dist/sysml/tokens.js +93 -0
  59. package/dist/sysml/tokens.js.map +1 -0
  60. package/dist/sysml/views.d.ts +16 -0
  61. package/dist/sysml/views.js +156 -0
  62. package/dist/sysml/views.js.map +1 -0
  63. package/dist/tex/backend-pdf.d.ts +3 -0
  64. package/dist/tex/backend-pdf.js +10 -0
  65. package/dist/tex/backend-pdf.js.map +1 -0
  66. package/dist/tex/backend-png.d.ts +6 -0
  67. package/dist/tex/backend-png.js +19 -0
  68. package/dist/tex/backend-png.js.map +1 -0
  69. package/dist/tex/backend-svg.d.ts +3 -0
  70. package/dist/tex/backend-svg.js +8 -0
  71. package/dist/tex/backend-svg.js.map +1 -0
  72. package/dist/tex/bundles.d.ts +43 -0
  73. package/dist/tex/bundles.js +150 -0
  74. package/dist/tex/bundles.js.map +1 -0
  75. package/dist/tex/bundles.json +26 -0
  76. package/dist/tex/detect.d.ts +27 -0
  77. package/dist/tex/detect.js +212 -0
  78. package/dist/tex/detect.js.map +1 -0
  79. package/dist/tex/dvi.d.ts +44 -0
  80. package/dist/tex/dvi.js +280 -0
  81. package/dist/tex/dvi.js.map +1 -0
  82. package/dist/tex/host.d.ts +82 -0
  83. package/dist/tex/host.js +313 -0
  84. package/dist/tex/host.js.map +1 -0
  85. package/dist/tex/index.d.ts +16 -0
  86. package/dist/tex/index.js +17 -0
  87. package/dist/tex/index.js.map +1 -0
  88. package/dist/tex/render.d.ts +66 -0
  89. package/dist/tex/render.js +72 -0
  90. package/dist/tex/render.js.map +1 -0
  91. package/dist/tex/run.d.ts +51 -0
  92. package/dist/tex/run.js +54 -0
  93. package/dist/tex/run.js.map +1 -0
  94. package/dist/tex/specials.d.ts +32 -0
  95. package/dist/tex/specials.js +145 -0
  96. package/dist/tex/specials.js.map +1 -0
  97. package/dist/tex/stage.d.ts +15 -0
  98. package/dist/tex/stage.js +93 -0
  99. package/dist/tex/stage.js.map +1 -0
  100. package/dist/tex/tfm.d.ts +15 -0
  101. package/dist/tex/tfm.js +33 -0
  102. package/dist/tex/tfm.js.map +1 -0
  103. package/dist/tex/type1.d.ts +32 -0
  104. package/dist/tex/type1.js +402 -0
  105. package/dist/tex/type1.js.map +1 -0
  106. package/dist/tex/vfs.d.ts +37 -0
  107. package/dist/tex/vfs.js +80 -0
  108. package/dist/tex/vfs.js.map +1 -0
  109. package/dist/tex/wasm.d.ts +16 -0
  110. package/dist/tex/wasm.js +8 -0
  111. package/dist/tex/wasm.js.map +1 -0
  112. package/dist/version.d.ts +1 -1
  113. package/dist/version.js +1 -1
  114. package/dist/version.js.map +1 -1
  115. package/dist/worker/protocol.d.ts +4 -0
  116. package/package.json +10 -2
@@ -0,0 +1,212 @@
1
+ import { RenderError } from "../errors.js";
2
+ /** The allowed package names of each bundle. */
3
+ const BUNDLE_PACKAGES = {
4
+ core: [
5
+ "tikz", "pgf", "xcolor", "color", "circuitikz", "standalone", "graphicx", "xkeyval",
6
+ "etoolbox", "ifthen", "array", "calc", "fontenc", "inputenc", "textcomp", "xspace",
7
+ ],
8
+ diagrams: ["tikz-cd", "tikz-3dplot", "smartdiagram"],
9
+ science: ["chemfig", "simplekv", "mhchem", "chemgreek", "l3packages", "bussproofs"],
10
+ math: ["amsmath", "amssymb", "amsfonts", "amsthm", "amscd", "amsbsy", "amsopn", "amstext", "amsgen", "eucal"],
11
+ };
12
+ /** The TikZ libraries that a bundle other than core holds. */
13
+ const DIAGRAM_LIBRARIES = ["hobby", "cd"];
14
+ /** The packages with the GPL as their only licence, each with its replacement. */
15
+ const GPL_REPLACEMENTS = {
16
+ pgfplots: "the plotly input type and the plot stage",
17
+ "pgf-umlsd": "a Mermaid sequence diagram",
18
+ xy: "tikz-cd",
19
+ esvect: "\\vec or \\overrightarrow",
20
+ mathrsfs: "\\mathscr from the AMS eucal package",
21
+ };
22
+ /** Environments that need a package. A starred form matches too. */
23
+ const ENVIRONMENT_RULES = [
24
+ ["tikzpicture", "tikz"],
25
+ ["circuitikz", "circuitikz"],
26
+ ["tikzcd", "tikz-cd"],
27
+ ["prooftree", "bussproofs"],
28
+ ["sequencediagram", "pgf-umlsd"],
29
+ ["axis", "pgfplots"],
30
+ ["xy", "xy"],
31
+ ...[
32
+ "align", "alignat", "flalign", "gather", "multline", "split", "aligned", "gathered", "subequations",
33
+ "cases", "matrix", "pmatrix", "bmatrix", "Bmatrix", "vmatrix", "Vmatrix", "smallmatrix",
34
+ ].map((name) => [name, "amsmath"]),
35
+ ];
36
+ /** Commands that need a package. A longer command name never matches. */
37
+ const COMMAND_RULES = [
38
+ ["tikz", "tikz"],
39
+ ["smartdiagram", "smartdiagram"],
40
+ ["tdplotsetmaincoords", "tikz-3dplot"],
41
+ ["tdplotsetrotatedcoords", "tikz-3dplot"],
42
+ ["ce", "mhchem"],
43
+ ["chemfig", "chemfig"],
44
+ ["addplot", "pgfplots"],
45
+ ["xymatrix", "xy"],
46
+ ["vv", "esvect"],
47
+ ["mathscr", "mathrsfs"],
48
+ ...["DisplayProof", "AxiomC", "UnaryInfC", "BinaryInfC", "TrinaryInfC", "QuaternaryInfC", "QuinaryInfC"].map((name) => [name, "bussproofs"]),
49
+ ...["color", "textcolor", "colorbox", "pagecolor", "definecolor"].map((name) => [name, "xcolor"]),
50
+ ...["mathbb", "mathfrak"].map((name) => [name, "amssymb"]),
51
+ ...["text", "dfrac", "tfrac", "binom", "operatorname", "intertext", "substack"].map((name) => [name, "amsmath"]),
52
+ ];
53
+ /** Environments whose body the scan blanks. */
54
+ const VERBATIM_BEGIN = /^\\begin\s*\{(verbatim\*?|lstlisting|minted)\}/;
55
+ const VERB = /^\\verb\*?([^A-Za-z\s*])/;
56
+ const PACKAGE_LINE = /\\(?:usepackage|RequirePackage(?:WithOptions)?)\s*(?:\[([^\]]*)\])?\s*\{([^}]*)\}/g;
57
+ const LIBRARY_LINE = /\\usetikzlibrary\s*\{([^}]*)\}/g;
58
+ const BUNDLE_OF = new Map();
59
+ for (const [bundle, names] of Object.entries(BUNDLE_PACKAGES)) {
60
+ for (const name of names) {
61
+ BUNDLE_OF.set(name, bundle);
62
+ }
63
+ }
64
+ /** The only font encoding that the bundles hold. Latin Modern, which T1 and the other encodings need, is in no bundle. */
65
+ const BUNDLED_ENCODING = "OT1";
66
+ /** The first option of a `fontenc` line that names an encoding other than OT1, or `undefined`. */
67
+ function foreignEncoding(options) {
68
+ return (options ?? "")
69
+ .split(",")
70
+ .map((option) => option.trim())
71
+ .find((option) => option !== "" && option !== BUNDLED_ENCODING);
72
+ }
73
+ /** Replaces the characters of a range with spaces and keeps the line breaks. */
74
+ function blank(chars, from, to) {
75
+ for (let k = from; k < to; k += 1) {
76
+ if (chars[k] !== "\n") {
77
+ chars[k] = " ";
78
+ }
79
+ }
80
+ }
81
+ /**
82
+ * Blanks the comments, the verbatim bodies, the `\verb` text and each double backslash.
83
+ * The result has the length of the source and the same line breaks.
84
+ */
85
+ function sanitize(source) {
86
+ const chars = source.split("");
87
+ let i = 0;
88
+ while (i < source.length) {
89
+ const c = source[i];
90
+ if (c === "%") {
91
+ const end = source.indexOf("\n", i);
92
+ const stop = end < 0 ? source.length : end;
93
+ blank(chars, i, stop);
94
+ i = stop;
95
+ }
96
+ else if (c === "\\") {
97
+ const rest = source.slice(i, i + 40);
98
+ const begin = VERBATIM_BEGIN.exec(rest);
99
+ const verb = VERB.exec(rest);
100
+ const next = source[i + 1];
101
+ if (begin !== null) {
102
+ const bodyStart = i + begin[0].length;
103
+ const end = source.indexOf(`\\end{${begin[1]}}`, bodyStart);
104
+ if (end >= 0) {
105
+ blank(chars, bodyStart, end);
106
+ i = end;
107
+ }
108
+ else {
109
+ i = bodyStart;
110
+ }
111
+ }
112
+ else if (verb !== null) {
113
+ const textStart = i + verb[0].length;
114
+ const close = source.indexOf(verb[1], textStart);
115
+ const lineEnd = source.indexOf("\n", textStart);
116
+ if (close >= 0 && (lineEnd < 0 || close < lineEnd)) {
117
+ blank(chars, i, close + 1);
118
+ i = close + 1;
119
+ }
120
+ else {
121
+ i += verb[0].length;
122
+ }
123
+ }
124
+ else if (next === "\\") {
125
+ blank(chars, i, i + 2);
126
+ i += 2;
127
+ }
128
+ else {
129
+ i += 2;
130
+ }
131
+ }
132
+ else {
133
+ i += 1;
134
+ }
135
+ }
136
+ return chars.join("");
137
+ }
138
+ /** Collects the first position of each package that the clean text names or implies. */
139
+ function findPackages(text) {
140
+ const findings = [];
141
+ const extra = new Set();
142
+ for (const m of text.matchAll(PACKAGE_LINE)) {
143
+ for (const part of m[2].split(",")) {
144
+ const name = part.trim();
145
+ if (name !== "") {
146
+ const encoding = name === "fontenc" ? foreignEncoding(m[1]) : undefined;
147
+ findings.push(encoding === undefined ? { name, index: m.index } : { name, index: m.index, encoding });
148
+ }
149
+ }
150
+ }
151
+ for (const m of text.matchAll(LIBRARY_LINE)) {
152
+ for (const part of m[1].split(",")) {
153
+ if (DIAGRAM_LIBRARIES.includes(part.trim())) {
154
+ extra.add("diagrams");
155
+ }
156
+ }
157
+ }
158
+ for (const [env, name] of ENVIRONMENT_RULES) {
159
+ const hit = new RegExp(`\\\\begin\\s*\\{${env}\\*?\\}`).exec(text);
160
+ if (hit !== null) {
161
+ findings.push({ name, index: hit.index });
162
+ }
163
+ }
164
+ for (const [command, name] of COMMAND_RULES) {
165
+ const hit = new RegExp(`\\\\${command}(?![A-Za-z])`).exec(text);
166
+ if (hit !== null) {
167
+ findings.push({ name, index: hit.index });
168
+ }
169
+ }
170
+ return { findings, extra };
171
+ }
172
+ function lineOf(text, index) {
173
+ let line = 1;
174
+ for (let k = 0; k < index; k += 1) {
175
+ if (text[k] === "\n") {
176
+ line += 1;
177
+ }
178
+ }
179
+ return line;
180
+ }
181
+ /**
182
+ * Scans a TeX source and names the bundles that it needs.
183
+ * Throws E_UNSUPPORTED for a package with the GPL as its only licence, for a package that no bundle holds
184
+ * and for a `fontenc` option other than OT1.
185
+ */
186
+ export function detectBundles(source) {
187
+ const text = sanitize(source);
188
+ const { findings, extra } = findPackages(text);
189
+ findings.sort((a, b) => a.index - b.index);
190
+ const bundles = new Set(["core", ...extra]);
191
+ const packages = new Set();
192
+ for (const { name, index, encoding } of findings) {
193
+ if (encoding !== undefined) {
194
+ throw new RenderError("E_UNSUPPORTED", `Font encoding "${encoding}" is not available: only the OT1 encoding is bundled, and the Latin Modern fonts that T1 needs are in no bundle. Use the OT1 encoding or remove the fontenc option.`, { line: lineOf(text, index) });
195
+ }
196
+ const replacement = Object.hasOwn(GPL_REPLACEMENTS, name) ? GPL_REPLACEMENTS[name] : undefined;
197
+ const bundle = BUNDLE_OF.get(name);
198
+ if (replacement !== undefined) {
199
+ throw new RenderError("E_UNSUPPORTED", `TeX package "${name}" has the GPL as its only licence, so no bundle holds it. Replacement: ${replacement}.`, { line: lineOf(text, index) });
200
+ }
201
+ if (bundle === undefined) {
202
+ throw new RenderError("E_UNSUPPORTED", `TeX package "${name}" is not in any bundle.`, {
203
+ line: lineOf(text, index),
204
+ });
205
+ }
206
+ bundles.add(bundle);
207
+ packages.add(name);
208
+ }
209
+ const rest = [...bundles].filter((b) => b !== "core").sort();
210
+ return { bundles: ["core", ...rest], packages: [...packages].sort() };
211
+ }
212
+ //# sourceMappingURL=detect.js.map
@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,MAAM,IAAI,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;IAC7D,OAAO,EAAE,OAAO,EAAE,CAAC,MAAM,EAAE,GAAG,IAAI,CAAiB,EAAE,QAAQ,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;AACxF,CAAC"}
@@ -0,0 +1,44 @@
1
+ import type { SpecialPosition, SpecialResult } from "./specials.ts";
2
+ /** The files of one font: the TFM, and the PFB when the font has outlines. */
3
+ export interface FontFiles {
4
+ tfm: Uint8Array;
5
+ pfb: Uint8Array | null;
6
+ }
7
+ /** The options of the DVI converter. */
8
+ export interface DviOptions {
9
+ /** The page to draw, counted from 1. The default is 1. */
10
+ page?: number;
11
+ /** The border around the marks, in SVG units. The default is 1. */
12
+ margin?: number;
13
+ /** The size of one TeX point in SVG units. The default is 1. */
14
+ unitPerPt?: number;
15
+ /** Reads one `\special` at the current position. It can give SVG text for the page and a box for the bounds. */
16
+ special?: (text: string, at: SpecialPosition) => SpecialResult | null;
17
+ /**
18
+ * Tells whether the page is inside a transformed group. While it gives true, the boxes of glyphs and rules do not
19
+ * join the bounds, because their DVI positions are not their places on the page. The boxes of specials still do.
20
+ */
21
+ transformed?: () => boolean;
22
+ }
23
+ /** The result of the DVI converter. */
24
+ export interface DviSvg {
25
+ svg: string;
26
+ /** The number of glyph paths on the drawn page. */
27
+ glyphs: number;
28
+ /** The number of rules on the drawn page. */
29
+ rules: number;
30
+ /** The number of `\special` commands in the file. */
31
+ specials: number;
32
+ /** The number of pages in the file. */
33
+ pages: number;
34
+ /** The fonts and glyphs (`font:code`) that have no file or no outline. */
35
+ missing: string[];
36
+ /** The fonts that the file names, by font name. */
37
+ fonts: string[];
38
+ }
39
+ /**
40
+ * Converts a DVI file to SVG.
41
+ * `fontFiles` gives the files of a font by name. It returns `null` for an unknown font.
42
+ * A font with no PFB keeps its TFM advances, and each of its glyphs goes in the missing list.
43
+ */
44
+ export declare function dviToSvg(dvi: Uint8Array, fontFiles: (name: string) => FontFiles | null, opt?: DviOptions): DviSvg;
@@ -0,0 +1,280 @@
1
+ // DVI to SVG. Each glyph becomes one <path> with the outline of its Type 1 font; each rule becomes a <rect>.
2
+ // The format of the DVI file: dvitype.web, part 3. Units: the SVG unit is the TeX point, unless the option
3
+ // unitPerPt gives another unit.
4
+ import { readTfm } from "./tfm.js";
5
+ import { readType1 } from "./type1.js";
6
+ const r = (v) => String(Math.round(v * 1000) / 1000);
7
+ /**
8
+ * Converts a DVI file to SVG.
9
+ * `fontFiles` gives the files of a font by name. It returns `null` for an unknown font.
10
+ * A font with no PFB keeps its TFM advances, and each of its glyphs goes in the missing list.
11
+ */
12
+ export function dviToSvg(dvi, fontFiles, opt = {}) {
13
+ let p = 0;
14
+ const u = (n) => {
15
+ let v = 0;
16
+ for (let i = 0; i < n; i++)
17
+ v = v * 256 + dvi[p++];
18
+ return v;
19
+ };
20
+ const s = (n) => {
21
+ const v = u(n);
22
+ const lim = 2 ** (8 * n - 1);
23
+ return v >= lim ? v - 2 * lim : v;
24
+ };
25
+ if (dvi[0] !== 247 || dvi[1] !== 2)
26
+ throw new Error("not a DVI file");
27
+ p = 2;
28
+ const num = u(4);
29
+ const den = u(4);
30
+ const mag = u(4);
31
+ p += 1 + dvi[14];
32
+ // the SVG unit: the TeX point, or another unit with opt.unitPerPt (72/72.27 gives the big point)
33
+ const toPt = (num / den) * (mag / 1000) * (72.27 / 254000) * (opt.unitPerPt ?? 1);
34
+ const fonts = new Map();
35
+ const loaded = new Map();
36
+ const missing = new Set();
37
+ const out = [];
38
+ let glyphs = 0;
39
+ let rules = 0;
40
+ let specials = 0;
41
+ let page = 0;
42
+ let minX = Infinity;
43
+ let minY = Infinity;
44
+ let maxX = -Infinity;
45
+ let maxY = -Infinity;
46
+ const box = (x0, y0, x1, y1) => {
47
+ minX = Math.min(minX, x0);
48
+ minY = Math.min(minY, y0);
49
+ maxX = Math.max(maxX, x1);
50
+ maxY = Math.max(maxY, y1);
51
+ };
52
+ const want = opt.page ?? 1;
53
+ let h = 0;
54
+ let v = 0;
55
+ let w = 0;
56
+ let x = 0;
57
+ let y = 0;
58
+ let z = 0;
59
+ let f;
60
+ const stack = [];
61
+ const fontDef = (k) => {
62
+ u(4); // checksum
63
+ const sz = u(4);
64
+ u(4); // design size
65
+ const a = u(1);
66
+ const l = u(1);
67
+ let name = "";
68
+ for (let i = 0; i < a + l; i++)
69
+ name += String.fromCharCode(dvi[p++]);
70
+ if (fonts.has(k))
71
+ return;
72
+ let ld = loaded.get(name);
73
+ if (ld === undefined) {
74
+ const files = fontFiles(name);
75
+ if (!files) {
76
+ missing.add(name);
77
+ ld = null;
78
+ }
79
+ else
80
+ ld = { tfm: readTfm(files.tfm), t1: files.pfb ? readType1(files.pfb) : null };
81
+ loaded.set(name, ld);
82
+ }
83
+ fonts.set(k, { name, size: sz, ld });
84
+ };
85
+ const drawChar = (c) => {
86
+ const fnt = f;
87
+ if (!fnt)
88
+ throw new Error("char before a font");
89
+ let adv = 0;
90
+ if (fnt.ld) {
91
+ const wd = fnt.ld.tfm.widths.get(c);
92
+ if (wd === undefined)
93
+ throw new Error(`no width for char ${c} in ${fnt.name}`);
94
+ adv = wd * fnt.size; // TFM width times the font size, in DVI units
95
+ }
96
+ if (page === want && fnt.ld) {
97
+ const g = fnt.ld.t1?.glyph(c);
98
+ if (!g)
99
+ missing.add(`${fnt.name}:${c}`);
100
+ else if (g.d) {
101
+ const k = (fnt.size * toPt) / 1000;
102
+ const X = h * toPt;
103
+ const Y = v * toPt;
104
+ const ks = Number(k.toFixed(6));
105
+ out.push(`<path transform="translate(${r(X)} ${r(Y)}) scale(${ks} ${-ks})" d="${g.d}"/>`);
106
+ if (!opt.transformed?.())
107
+ box(X + g.bbox[0] * k, Y - g.bbox[3] * k, X + g.bbox[2] * k, Y - g.bbox[1] * k);
108
+ glyphs++;
109
+ }
110
+ }
111
+ return adv;
112
+ };
113
+ const drawRule = (a, b) => {
114
+ if (page === want && a > 0 && b > 0) {
115
+ const X = h * toPt;
116
+ const Y = (v - a) * toPt;
117
+ out.push(`<rect x="${r(X)}" y="${r(Y)}" width="${r(b * toPt)}" height="${r(a * toPt)}"/>`);
118
+ if (!opt.transformed?.())
119
+ box(X, Y, X + b * toPt, Y + a * toPt);
120
+ rules++;
121
+ }
122
+ };
123
+ for (;;) {
124
+ if (p >= dvi.length)
125
+ throw new Error("DVI ended without post");
126
+ const o = dvi[p++];
127
+ if (o < 128) {
128
+ h += drawChar(o);
129
+ continue;
130
+ }
131
+ if (o >= 171 && o <= 234) {
132
+ f = fonts.get(o - 171);
133
+ continue;
134
+ }
135
+ switch (o) {
136
+ case 128:
137
+ case 129:
138
+ case 130:
139
+ case 131:
140
+ h += drawChar(u(o - 127));
141
+ break;
142
+ case 133:
143
+ case 134:
144
+ case 135:
145
+ case 136:
146
+ drawChar(u(o - 132));
147
+ break;
148
+ case 132: {
149
+ const a = s(4);
150
+ const b = s(4);
151
+ drawRule(a, b);
152
+ h += b;
153
+ break;
154
+ }
155
+ case 137: {
156
+ const a = s(4);
157
+ const b = s(4);
158
+ drawRule(a, b);
159
+ break;
160
+ }
161
+ case 138:
162
+ break;
163
+ case 139:
164
+ p += 44;
165
+ page++;
166
+ h = v = w = x = y = z = 0;
167
+ stack.length = 0;
168
+ f = undefined;
169
+ break;
170
+ case 140:
171
+ break;
172
+ case 141:
173
+ stack.push([h, v, w, x, y, z]);
174
+ break;
175
+ case 142: {
176
+ const top = stack.pop();
177
+ if (!top)
178
+ throw new Error("DVI pop with an empty stack");
179
+ [h, v, w, x, y, z] = top;
180
+ break;
181
+ }
182
+ case 143:
183
+ case 144:
184
+ case 145:
185
+ case 146:
186
+ h += s(o - 142);
187
+ break;
188
+ case 147:
189
+ h += w;
190
+ break;
191
+ case 148:
192
+ case 149:
193
+ case 150:
194
+ case 151:
195
+ w = s(o - 147);
196
+ h += w;
197
+ break;
198
+ case 152:
199
+ h += x;
200
+ break;
201
+ case 153:
202
+ case 154:
203
+ case 155:
204
+ case 156:
205
+ x = s(o - 152);
206
+ h += x;
207
+ break;
208
+ case 157:
209
+ case 158:
210
+ case 159:
211
+ case 160:
212
+ v += s(o - 156);
213
+ break;
214
+ case 161:
215
+ v += y;
216
+ break;
217
+ case 162:
218
+ case 163:
219
+ case 164:
220
+ case 165:
221
+ y = s(o - 161);
222
+ v += y;
223
+ break;
224
+ case 166:
225
+ v += z;
226
+ break;
227
+ case 167:
228
+ case 168:
229
+ case 169:
230
+ case 170:
231
+ z = s(o - 166);
232
+ v += z;
233
+ break;
234
+ case 235:
235
+ case 236:
236
+ case 237:
237
+ case 238:
238
+ f = fonts.get(u(o - 234));
239
+ break;
240
+ case 239:
241
+ case 240:
242
+ case 241:
243
+ case 242: {
244
+ const k = u(o - 238);
245
+ let text = "";
246
+ for (let i = 0; i < k; i++)
247
+ text += String.fromCharCode(dvi[p + i]);
248
+ p += k;
249
+ specials++;
250
+ // opt.special reads one \special at the current position (in SVG units) and can
251
+ // give SVG text for the page and a box [x0, y0, x1, y1] for the bounds
252
+ const res = page === want && opt.special ? opt.special(text, { x: h * toPt, y: v * toPt, unit: opt.unitPerPt ?? 1 }) : null;
253
+ if (res?.svg)
254
+ out.push(res.svg);
255
+ if (res?.box)
256
+ box(res.box[0], res.box[1], res.box[2], res.box[3]);
257
+ break;
258
+ }
259
+ case 243:
260
+ case 244:
261
+ case 245:
262
+ case 246:
263
+ fontDef(u(o - 242));
264
+ break;
265
+ case 248: {
266
+ const m = opt.margin ?? 1;
267
+ if (!Number.isFinite(minX)) {
268
+ minX = minY = 0;
269
+ maxX = maxY = 1;
270
+ }
271
+ const vb = [minX - m, minY - m, maxX - minX + 2 * m, maxY - minY + 2 * m].map(r).join(" ");
272
+ const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="${vb}" width="${r(maxX - minX + 2 * m)}pt" height="${r(maxY - minY + 2 * m)}pt">\n${out.join("\n")}\n</svg>\n`;
273
+ return { svg, glyphs, rules, specials, pages: page, missing: [...missing], fonts: [...loaded.keys()] };
274
+ }
275
+ default:
276
+ throw new Error(`DVI opcode ${o} at byte ${p - 1}`);
277
+ }
278
+ }
279
+ }
280
+ //# sourceMappingURL=dvi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dvi.js","sourceRoot":"","sources":["../../src/tex/dvi.ts"],"names":[],"mappings":"AAAA,6GAA6G;AAC7G,2GAA2G;AAC3G,gCAAgC;AAChC,OAAO,EAAE,OAAO,EAAY,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAkB,MAAM,YAAY,CAAC;AA2CvD,MAAM,CAAC,GAAG,CAAC,CAAS,EAAU,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;AAarE;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAe,EAAE,SAA6C,EAAE,GAAG,GAAe,EAAE;IAC3G,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,MAAM,CAAC,GAAG,CAAC,CAAS,EAAU,EAAE;QAC9B,IAAI,CAAC,GAAG,CAAC,CAAC;QACV,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;YAAE,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC,EAAE,CAAE,CAAC;QACpD,OAAO,CAAC,CAAC;IACX,CAAC,CAAC;IACF,MAAM,CAAC,GAAG,CAAC,CAAS,EAAU,EAAE;QAC9B,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACf,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QAC7B,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,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AE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;YACzG,CAAC;YACD;gBACE,MAAM,IAAI,KAAK,CAAC,cAAc,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,82 @@
1
+ import type { EngineImports, WasmInstance } from "./wasm.ts";
2
+ import { type TexTree } from "./vfs.ts";
3
+ /**
4
+ * The default bound on the bytes that one run writes, in the terminal output and in the output files together.
5
+ * It is 64 MiB: the log, the DVI and the terminal of a render hold well under 1 MiB, and the format build writes about 24 MB.
6
+ * A caller sets another bound with `maxOutputBytes`, for example from the `maxMemoryMb` key of the configuration.
7
+ */
8
+ export declare const DEFAULT_MAX_OUTPUT_BYTES: number;
9
+ /** Thrown by the `hostexit` import to leave the program with an exit code. */
10
+ export declare class ExitSignal extends Error {
11
+ readonly code: number;
12
+ constructor(code: number);
13
+ }
14
+ /** The options of the host. */
15
+ export interface HostOptions {
16
+ /** The virtual file tree. Output files go to the tree when the program closes them. */
17
+ files: TexTree;
18
+ /** The lines of terminal input. */
19
+ terminal?: string[];
20
+ /** The slot addresses of the standard files `input` and `output`. */
21
+ std: {
22
+ input: number;
23
+ output: number;
24
+ };
25
+ /** More imports (external procedures). */
26
+ extra?: Record<string, (...args: number[]) => unknown>;
27
+ /** The names that mean the terminal. The default is `TTY:`. */
28
+ ttyNames?: string[];
29
+ /**
30
+ * Turns a file name of the program into the key of the tree. The default is `treeName`.
31
+ * A caller key must return a name that `treeName` accepts, because the tree reduces the key again.
32
+ */
33
+ nameKey?: (raw: string) => string;
34
+ /** Echo the terminal input lines to the terminal output, as a terminal does. The default is true. */
35
+ echo?: boolean;
36
+ /** The time in milliseconds on the `performance.now()` clock after which a host call throws `E_TIMEOUT`. */
37
+ deadline?: number;
38
+ /** The time limit in milliseconds, for the message of the timeout. */
39
+ timeoutMs?: number;
40
+ /** The bound on the bytes that the run writes to the terminal and to files. The default is `DEFAULT_MAX_OUTPUT_BYTES`. */
41
+ maxOutputBytes?: number;
42
+ }
43
+ /** The host of one run. */
44
+ export declare class TexHost {
45
+ private readonly files;
46
+ private readonly std;
47
+ private readonly extra;
48
+ private readonly ttyNames;
49
+ private readonly echoInput;
50
+ private readonly nameKey;
51
+ private readonly termIn;
52
+ private readonly termOut;
53
+ private readonly handles;
54
+ private mem;
55
+ private dv;
56
+ private ticks;
57
+ private outputBytes;
58
+ private readonly maxOutputBytes;
59
+ private readonly refusedNames;
60
+ private readonly deadline;
61
+ private readonly timeoutMs;
62
+ constructor(o: HostOptions);
63
+ /** Connects the host to the instance, whose memory the host functions read and write. */
64
+ attach(instance: WasmInstance): void;
65
+ /** The text that the program wrote to the terminal. */
66
+ terminalText(): string;
67
+ /** The file names that the program tried to open and that escape the tree. Each open failed. */
68
+ get refused(): string[];
69
+ /** Stores every file that is still open for writing. */
70
+ finish(): void;
71
+ private flush;
72
+ private charge;
73
+ private tick;
74
+ private handleOf;
75
+ private newHandle;
76
+ private name;
77
+ private fill;
78
+ private echo;
79
+ private eofOf;
80
+ /** The import object for `WebAssembly.instantiate`. */
81
+ imports(): EngineImports;
82
+ }