@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.
- package/README.md +27 -4
- package/THIRD_PARTY_NOTICES.md +65 -4
- package/dist/core.js +2 -0
- package/dist/core.js.map +1 -1
- package/dist/errors.d.ts +2 -0
- package/dist/errors.js +4 -0
- package/dist/errors.js.map +1 -1
- package/dist/graph/backend-pdf.js +3 -2
- package/dist/graph/backend-pdf.js.map +1 -1
- package/dist/graph/backend-png.js +3 -2
- package/dist/graph/backend-png.js.map +1 -1
- package/dist/graph/backend-svg.js +3 -2
- package/dist/graph/backend-svg.js.map +1 -1
- package/dist/graph/dot.d.ts +0 -2
- package/dist/graph/dot.js +0 -4
- package/dist/graph/dot.js.map +1 -1
- package/dist/graph/text.d.ts +12 -0
- package/dist/graph/text.js +21 -0
- package/dist/graph/text.js.map +1 -0
- package/dist/mermaid/backend-pdf.js +2 -1
- package/dist/mermaid/backend-pdf.js.map +1 -1
- package/dist/mermaid/backend-png.js +2 -1
- package/dist/mermaid/backend-png.js.map +1 -1
- package/dist/mermaid/backend-svg.js +2 -1
- package/dist/mermaid/backend-svg.js.map +1 -1
- package/dist/mermaid/class.js +3 -7
- package/dist/mermaid/class.js.map +1 -1
- package/dist/mermaid/common.d.ts +0 -10
- package/dist/mermaid/common.js +2 -16
- package/dist/mermaid/common.js.map +1 -1
- package/dist/mermaid/sequence-layout.js +1 -1
- package/dist/mermaid/sequence-layout.js.map +1 -1
- package/dist/mermaid/sequence.js +2 -1
- package/dist/mermaid/sequence.js.map +1 -1
- package/dist/mermaid/state.js +3 -1
- package/dist/mermaid/state.js.map +1 -1
- package/dist/registry.js +6 -0
- package/dist/registry.js.map +1 -1
- package/dist/sysml/backend-pdf.d.ts +3 -0
- package/dist/sysml/backend-pdf.js +10 -0
- package/dist/sysml/backend-pdf.js.map +1 -0
- package/dist/sysml/backend-png.d.ts +6 -0
- package/dist/sysml/backend-png.js +19 -0
- package/dist/sysml/backend-png.js.map +1 -0
- package/dist/sysml/backend-svg.d.ts +3 -0
- package/dist/sysml/backend-svg.js +8 -0
- package/dist/sysml/backend-svg.js.map +1 -0
- package/dist/sysml/index.d.ts +8 -0
- package/dist/sysml/index.js +9 -0
- package/dist/sysml/index.js.map +1 -0
- package/dist/sysml/parse.d.ts +99 -0
- package/dist/sysml/parse.js +480 -0
- package/dist/sysml/parse.js.map +1 -0
- package/dist/sysml/render.d.ts +7 -0
- package/dist/sysml/render.js +11 -0
- package/dist/sysml/render.js.map +1 -0
- package/dist/sysml/tokens.d.ts +14 -0
- package/dist/sysml/tokens.js +93 -0
- package/dist/sysml/tokens.js.map +1 -0
- package/dist/sysml/views.d.ts +16 -0
- package/dist/sysml/views.js +156 -0
- package/dist/sysml/views.js.map +1 -0
- package/dist/tex/backend-pdf.d.ts +3 -0
- package/dist/tex/backend-pdf.js +10 -0
- package/dist/tex/backend-pdf.js.map +1 -0
- package/dist/tex/backend-png.d.ts +6 -0
- package/dist/tex/backend-png.js +19 -0
- package/dist/tex/backend-png.js.map +1 -0
- package/dist/tex/backend-svg.d.ts +3 -0
- package/dist/tex/backend-svg.js +8 -0
- package/dist/tex/backend-svg.js.map +1 -0
- package/dist/tex/bundles.d.ts +43 -0
- package/dist/tex/bundles.js +150 -0
- package/dist/tex/bundles.js.map +1 -0
- package/dist/tex/bundles.json +26 -0
- package/dist/tex/detect.d.ts +27 -0
- package/dist/tex/detect.js +212 -0
- package/dist/tex/detect.js.map +1 -0
- package/dist/tex/dvi.d.ts +44 -0
- package/dist/tex/dvi.js +280 -0
- package/dist/tex/dvi.js.map +1 -0
- package/dist/tex/host.d.ts +82 -0
- package/dist/tex/host.js +313 -0
- package/dist/tex/host.js.map +1 -0
- package/dist/tex/index.d.ts +16 -0
- package/dist/tex/index.js +17 -0
- package/dist/tex/index.js.map +1 -0
- package/dist/tex/render.d.ts +66 -0
- package/dist/tex/render.js +72 -0
- package/dist/tex/render.js.map +1 -0
- package/dist/tex/run.d.ts +51 -0
- package/dist/tex/run.js +54 -0
- package/dist/tex/run.js.map +1 -0
- package/dist/tex/specials.d.ts +32 -0
- package/dist/tex/specials.js +145 -0
- package/dist/tex/specials.js.map +1 -0
- package/dist/tex/stage.d.ts +15 -0
- package/dist/tex/stage.js +93 -0
- package/dist/tex/stage.js.map +1 -0
- package/dist/tex/tfm.d.ts +15 -0
- package/dist/tex/tfm.js +33 -0
- package/dist/tex/tfm.js.map +1 -0
- package/dist/tex/type1.d.ts +32 -0
- package/dist/tex/type1.js +402 -0
- package/dist/tex/type1.js.map +1 -0
- package/dist/tex/vfs.d.ts +37 -0
- package/dist/tex/vfs.js +80 -0
- package/dist/tex/vfs.js.map +1 -0
- package/dist/tex/wasm.d.ts +16 -0
- package/dist/tex/wasm.js +8 -0
- package/dist/tex/wasm.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/dist/worker/protocol.d.ts +4 -0
- package/package.json +10 -2
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type SysmlModel } from "./parse.ts";
|
|
2
|
+
/** The views of the design: block definition, internal block and requirements. */
|
|
3
|
+
export type SysmlView = "bdd" | "ibd" | "requirements";
|
|
4
|
+
/** The options of a SysML render after the check. */
|
|
5
|
+
export interface SysmlOptions {
|
|
6
|
+
view: SysmlView;
|
|
7
|
+
root: string | undefined;
|
|
8
|
+
lenient: boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Reads the options `view`, `root` and `lenient`. Another key, an unknown view, `ibd` without `root`, and `root` with
|
|
12
|
+
* another view reject with E_INPUT. An undefined value counts as an absent key.
|
|
13
|
+
*/
|
|
14
|
+
export declare function readSysmlOptions(options: Record<string, unknown>): SysmlOptions;
|
|
15
|
+
/** Builds the DOT source of one view of a parsed model. */
|
|
16
|
+
export declare function sysmlToDot(model: SysmlModel, options: SysmlOptions): string;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { RenderError } from "../errors.js";
|
|
2
|
+
import { escapeDot, escapeRecord } from "../graph/text.js";
|
|
3
|
+
import { baseChain } from "./parse.js";
|
|
4
|
+
const VIEWS = ["bdd", "ibd", "requirements"];
|
|
5
|
+
/**
|
|
6
|
+
* Reads the options `view`, `root` and `lenient`. Another key, an unknown view, `ibd` without `root`, and `root` with
|
|
7
|
+
* another view reject with E_INPUT. An undefined value counts as an absent key.
|
|
8
|
+
*/
|
|
9
|
+
export function readSysmlOptions(options) {
|
|
10
|
+
const out = { view: "bdd", root: undefined, lenient: false };
|
|
11
|
+
for (const [key, value] of Object.entries(options)) {
|
|
12
|
+
if (value === undefined)
|
|
13
|
+
continue;
|
|
14
|
+
if (key === "lenient") {
|
|
15
|
+
if (typeof value !== "boolean")
|
|
16
|
+
throw new RenderError("E_INPUT", "option lenient must be true or false");
|
|
17
|
+
out.lenient = value;
|
|
18
|
+
}
|
|
19
|
+
else if (key === "view") {
|
|
20
|
+
if (!VIEWS.includes(value))
|
|
21
|
+
throw new RenderError("E_INPUT", "option view must be bdd, ibd or requirements");
|
|
22
|
+
out.view = value;
|
|
23
|
+
}
|
|
24
|
+
else if (key === "root") {
|
|
25
|
+
if (typeof value !== "string")
|
|
26
|
+
throw new RenderError("E_INPUT", "option root must be the name of a part def");
|
|
27
|
+
out.root = value;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
throw new RenderError("E_INPUT", `sysml takes no option ${key}`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (out.view === "ibd" && out.root === undefined)
|
|
34
|
+
throw new RenderError("E_INPUT", "the ibd view needs the option root");
|
|
35
|
+
if (out.view !== "ibd" && out.root !== undefined)
|
|
36
|
+
throw new RenderError("E_INPUT", "the option root is only for the ibd view");
|
|
37
|
+
return out;
|
|
38
|
+
}
|
|
39
|
+
/** Builds the DOT source of one view of a parsed model. */
|
|
40
|
+
export function sysmlToDot(model, options) {
|
|
41
|
+
const out = ["digraph sysml {"];
|
|
42
|
+
if (options.view === "bdd")
|
|
43
|
+
bdd(model, out);
|
|
44
|
+
else if (options.view === "ibd")
|
|
45
|
+
ibd(model, options.root, out);
|
|
46
|
+
else
|
|
47
|
+
requirements(model, out);
|
|
48
|
+
out.push("}");
|
|
49
|
+
return out.join("\n") + "\n";
|
|
50
|
+
}
|
|
51
|
+
const q = (text) => `"${escapeDot(text)}"`;
|
|
52
|
+
function attributeText(a) {
|
|
53
|
+
return `${a.name}${a.type === undefined ? "" : ` : ${a.type}`}${a.value === undefined ? "" : ` = ${a.value}`}`;
|
|
54
|
+
}
|
|
55
|
+
/** A record label: the head, then one compartment for each non-empty list of lines. */
|
|
56
|
+
function record(head, ...compartments) {
|
|
57
|
+
const fields = [head, ...compartments.filter((c) => c.length > 0).map((c) => c.map((l) => `${escapeRecord(l)}\\l`).join(""))];
|
|
58
|
+
return `{${fields.join("|")}}`;
|
|
59
|
+
}
|
|
60
|
+
function defHead(kind, name) {
|
|
61
|
+
return `${kind}\\n${escapeRecord(name)}`;
|
|
62
|
+
}
|
|
63
|
+
function bdd(model, out) {
|
|
64
|
+
out.push(" rankdir=TB;", " node [shape=record];");
|
|
65
|
+
for (const def of model.partDefs) {
|
|
66
|
+
const label = record(defHead("part def", def.name), def.attributes.map(attributeText), def.ports.map((p) => `port ${p.name} : ${p.type}`));
|
|
67
|
+
out.push(` ${q(def.name)} [label="${label}"];`);
|
|
68
|
+
}
|
|
69
|
+
const plain = (kind, def) => {
|
|
70
|
+
out.push(` ${q(def.name)} [label="${record(defHead(kind, def.name), def.attributes.map(attributeText))}"];`);
|
|
71
|
+
};
|
|
72
|
+
for (const def of model.portDefs)
|
|
73
|
+
plain("port def", def);
|
|
74
|
+
for (const def of model.interfaceDefs)
|
|
75
|
+
plain("interface def", def);
|
|
76
|
+
for (const def of model.partDefs) {
|
|
77
|
+
for (const part of def.parts) {
|
|
78
|
+
const name = part.multiplicity === undefined ? part.name : `${part.name} [${part.multiplicity}]`;
|
|
79
|
+
out.push(` ${q(def.name)} -> ${q(part.type)} [dir=both, arrowtail=diamond, arrowhead=none, headlabel=${q(name)}];`);
|
|
80
|
+
}
|
|
81
|
+
if (def.base !== undefined)
|
|
82
|
+
out.push(` ${q(def.name)} -> ${q(def.base)} [arrowhead=empty];`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function chain(model, def) {
|
|
86
|
+
return baseChain(model.partDefs, def);
|
|
87
|
+
}
|
|
88
|
+
function ibd(model, rootName, out) {
|
|
89
|
+
const root = model.partDefs.find((d) => d.name === rootName);
|
|
90
|
+
if (root === undefined)
|
|
91
|
+
throw new RenderError("E_INPUT", `the option root: ${rootName} names no part def`);
|
|
92
|
+
const defs = chain(model, root);
|
|
93
|
+
out.push(" rankdir=LR;", " subgraph cluster_root {", ` label=${q(root.name)};`);
|
|
94
|
+
for (const part of defs.flatMap((d) => d.parts)) {
|
|
95
|
+
const type = model.partDefs.find((d) => d.name === part.type);
|
|
96
|
+
const ports = chain(model, type).flatMap((d) => d.ports).map((p) => `<${p.name}> ${escapeRecord(p.name)}`);
|
|
97
|
+
const head = escapeRecord(`${part.name} : ${part.type}${part.multiplicity === undefined ? "" : ` [${part.multiplicity}]`}`);
|
|
98
|
+
const label = ports.length === 0 ? `{${head}}` : `{${head}|{${ports.join("|")}}}`;
|
|
99
|
+
out.push(` ${q(`part:${part.name}`)} [shape=record, label="${label}"];`);
|
|
100
|
+
}
|
|
101
|
+
for (const port of defs.flatMap((d) => d.ports)) {
|
|
102
|
+
out.push(` ${q(`port:${port.name}`)} [shape=box, label=${q(`${port.name} : ${port.type}`)}];`);
|
|
103
|
+
}
|
|
104
|
+
out.push(" }");
|
|
105
|
+
const end = (e) => e.part === undefined ? q(`port:${e.port}`) : `${q(`part:${e.part}`)}:${q(e.port)}`;
|
|
106
|
+
for (const c of defs.flatMap((d) => d.connections)) {
|
|
107
|
+
const label = c.name === undefined ? "" : `, label=${q(`${c.name} : ${c.def}`)}`;
|
|
108
|
+
out.push(` ${end(c.from)} -> ${end(c.to)} [dir=none${label}];`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
function requirements(model, out) {
|
|
112
|
+
out.push(" rankdir=TB;");
|
|
113
|
+
const id = (address) => q(`req:${address}`);
|
|
114
|
+
const node = (address, label) => {
|
|
115
|
+
out.push(` ${id(address)} [shape=record, label="${label}"];`);
|
|
116
|
+
};
|
|
117
|
+
const edges = [];
|
|
118
|
+
const usage = (r, owner) => {
|
|
119
|
+
const head = defHead("requirement", r.def === undefined ? r.name : `${r.name} : ${r.def}`);
|
|
120
|
+
node(r.address, record(head, r.attributes.map(attributeText)));
|
|
121
|
+
if (owner !== undefined)
|
|
122
|
+
edges.push(` ${id(owner)} -> ${id(r.address)} [dir=both, arrowtail=odot, arrowhead=none];`);
|
|
123
|
+
if (r.def !== undefined)
|
|
124
|
+
edges.push(` ${id(r.address)} -> ${id(r.def)} [style=dashed, arrowhead=normal];`);
|
|
125
|
+
for (const child of r.children)
|
|
126
|
+
usage(child, r.address);
|
|
127
|
+
};
|
|
128
|
+
const def = (d) => {
|
|
129
|
+
node(d.name, record(defHead("requirement def", d.name), d.attributes.map(attributeText)));
|
|
130
|
+
if (d.base !== undefined)
|
|
131
|
+
edges.push(` ${id(d.name)} -> ${id(d.base)} [arrowhead=empty];`);
|
|
132
|
+
for (const child of d.children)
|
|
133
|
+
usage(child, d.name);
|
|
134
|
+
};
|
|
135
|
+
model.requirementDefs.forEach(def);
|
|
136
|
+
model.requirements.forEach((r) => usage(r, undefined));
|
|
137
|
+
const seen = new Set();
|
|
138
|
+
for (const s of model.satisfies) {
|
|
139
|
+
const element = q(`elem:${s.path}`);
|
|
140
|
+
if (!seen.has(s.path)) {
|
|
141
|
+
seen.add(s.path);
|
|
142
|
+
const [defName, partName] = s.path.split(".");
|
|
143
|
+
if (partName === undefined) {
|
|
144
|
+
out.push(` ${element} [shape=record, label="${record(defHead("part def", defName))}"];`);
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
const owner = model.partDefs.find((d) => d.name === defName);
|
|
148
|
+
const part = chain(model, owner).flatMap((d) => d.parts).find((p) => p.name === partName);
|
|
149
|
+
out.push(` ${element} [shape=box, label=${q(`${part.name} : ${part.type}`)}];`);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
edges.push(` ${element} -> ${id(s.requirement)} [style=dashed, arrowhead=open, label="<<satisfy>>"];`);
|
|
153
|
+
}
|
|
154
|
+
out.push(...edges);
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=views.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"views.js","sourceRoot":"","sources":["../../src/sysml/views.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAuG,MAAM,YAAY,CAAC;AAY5I,MAAM,KAAK,GAAyB,CAAC,KAAK,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC;AAEnE;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAgC;IAC/D,MAAM,GAAG,GAAiB,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC3E,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACnD,IAAI,KAAK,KAAK,SAAS;YAAE,SAAS;QAClC,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACtB,IAAI,OAAO,KAAK,KAAK,SAAS;gBAAE,MAAM,IAAI,WAAW,CAAC,SAAS,EAAE,sCAAsC,CAAC,CAAC;YACzG,GAAG,CAAC,OAAO,GAAG,KAAK,CAAC;QACtB,CAAC;aAAM,IAAI,GAAG,KAAK,MAAM,EAAE,CAAC;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,EAAE,CAAC,IAAI,CAAC,CAAC;YACnF,CAAC;QACH,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,KAAK,OAAO,OAAO,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,uDAAuD,CAAC,CAAC;IAC1G,CAAC;IACD,GAAG,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { sourceText } from "../graph/text.js";
|
|
2
|
+
import { drawSvgToPdf } from "../mermaid/browser.js";
|
|
3
|
+
import { renderTikzSvg } from "./stage.js";
|
|
4
|
+
/** Renders one tikz source to pdf: the SVG of the tex stage, then the pdf of that SVG in the browser stage. */
|
|
5
|
+
export async function render(request) {
|
|
6
|
+
const svg = await renderTikzSvg(sourceText(request.source), request.options, request.settings);
|
|
7
|
+
const draw = await drawSvgToPdf(svg.svg, request.settings);
|
|
8
|
+
return { bytes: draw.bytes, warnings: [...svg.warnings, ...draw.warnings] };
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=backend-pdf.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backend-pdf.js","sourceRoot":"","sources":["../../src/tex/backend-pdf.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,+GAA+G;AAC/G,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,OAA6B;IACxD,MAAM,GAAG,GAAG,MAAM,aAAa,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC/F,MAAM,IAAI,GAAG,MAAM,YAAY,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC3D,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,CAAC,GAAG,GAAG,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;AAC9E,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { BackendOutput, WorkerJob } from "../worker/protocol.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Renders one tikz source to PNG: the SVG of the tex stage, then the raster stage. The option scale multiplies the pixel
|
|
4
|
+
* size. The worker calls this function for the tikz:png pair.
|
|
5
|
+
*/
|
|
6
|
+
export declare function render(request: WorkerJob["request"]): Promise<BackendOutput>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { MAX_SCALE } from "../browser/input.js";
|
|
2
|
+
import { RenderError } from "../errors.js";
|
|
3
|
+
import { readScale, svgDocumentToPng } from "../graph/backend-png.js";
|
|
4
|
+
import { sourceText } from "../graph/text.js";
|
|
5
|
+
import { renderTikzSvg } from "./stage.js";
|
|
6
|
+
/**
|
|
7
|
+
* Renders one tikz source to PNG: the SVG of the tex stage, then the raster stage. The option scale multiplies the pixel
|
|
8
|
+
* size. The worker calls this function for the tikz:png pair.
|
|
9
|
+
*/
|
|
10
|
+
export async function render(request) {
|
|
11
|
+
const { scale: _scale, ...rest } = request.options;
|
|
12
|
+
const scale = readScale(request.options);
|
|
13
|
+
if (scale > MAX_SCALE)
|
|
14
|
+
throw new RenderError("E_INPUT", `option scale must not be more than ${MAX_SCALE}`);
|
|
15
|
+
const svg = await renderTikzSvg(sourceText(request.source), rest, request.settings);
|
|
16
|
+
const png = await svgDocumentToPng(svg.svg, request, scale);
|
|
17
|
+
return { bytes: png.bytes, warnings: [...svg.warnings, ...(png.warnings ?? [])] };
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=backend-png.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backend-png.js","sourceRoot":"","sources":["../../src/tex/backend-png.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,OAA6B;IACxD,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IACnD,MAAM,KAAK,GAAG,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACzC,IAAI,KAAK,GAAG,SAAS;QAAE,MAAM,IAAI,WAAW,CAAC,SAAS,EAAE,sCAAsC,SAAS,EAAE,CAAC,CAAC;IAC3G,MAAM,GAAG,GAAG,MAAM,aAAa,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IACpF,MAAM,GAAG,GAAG,MAAM,gBAAgB,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IAC5D,OAAO,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,CAAC,GAAG,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,GAAG,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;AACpF,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { BackendOutput, WorkerJob } from "../worker/protocol.ts";
|
|
2
|
+
/** Renders one tikz source to SVG through the tex stage. The worker calls this function for the tikz:svg pair. */
|
|
3
|
+
export declare function render(request: WorkerJob["request"]): Promise<BackendOutput>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { sourceText } from "../graph/text.js";
|
|
2
|
+
import { renderTikzSvg } from "./stage.js";
|
|
3
|
+
/** Renders one tikz source to SVG through the tex stage. The worker calls this function for the tikz:svg pair. */
|
|
4
|
+
export async function render(request) {
|
|
5
|
+
const result = await renderTikzSvg(sourceText(request.source), request.options, request.settings);
|
|
6
|
+
return { bytes: new TextEncoder().encode(result.svg), warnings: result.warnings };
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=backend-svg.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backend-svg.js","sourceRoot":"","sources":["../../src/tex/backend-svg.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,kHAAkH;AAClH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,OAA6B;IACxD,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IAClG,OAAO,EAAE,KAAK,EAAE,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC;AACpF,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { NetworkPolicy } from "../config.ts";
|
|
2
|
+
import type { BundleName } from "./detect.ts";
|
|
3
|
+
/** One bundle of the engine package: its name, the file name on the download server, the pinned sha256 and the size. */
|
|
4
|
+
export interface BundleEntry {
|
|
5
|
+
name: BundleName;
|
|
6
|
+
file: string;
|
|
7
|
+
sha256: string;
|
|
8
|
+
bytes: number;
|
|
9
|
+
}
|
|
10
|
+
/** The bundles of this build. `tools/tex/bundles.mjs` writes `bundles.json`, and CI fails when a built bundle differs from it. */
|
|
11
|
+
export declare const BUNDLES: readonly BundleEntry[];
|
|
12
|
+
/** The configuration values that the bundle manager reads. */
|
|
13
|
+
export interface BundleSettings {
|
|
14
|
+
/** The folder of the cache. The bundles go in its `tex-bundles` folder. */
|
|
15
|
+
cacheDir: string;
|
|
16
|
+
/** The base URL of the bundles. The download URL of a bundle is this value and the file name. */
|
|
17
|
+
texBundleUrl: string;
|
|
18
|
+
/** The network rule. A download needs `tex-bundles` in it. */
|
|
19
|
+
allowNetwork: NetworkPolicy;
|
|
20
|
+
/** The time limit of one download, in milliseconds. */
|
|
21
|
+
timeoutMs: number;
|
|
22
|
+
}
|
|
23
|
+
/** The sub-folder of the cache folder for the bundles. */
|
|
24
|
+
export declare const CACHE_SUBFOLDER = "tex-bundles";
|
|
25
|
+
/** The path of a bundle in the cache. */
|
|
26
|
+
export declare function cachePath(entry: BundleEntry, settings: Pick<BundleSettings, "cacheDir">): string;
|
|
27
|
+
/** The download URL of a bundle. A base URL with no end slash gets one. */
|
|
28
|
+
export declare function bundleUrl(entry: BundleEntry, settings: Pick<BundleSettings, "texBundleUrl">): string;
|
|
29
|
+
/** Looks up a bundle of the list by name. A name that is not in the list is an internal error. */
|
|
30
|
+
export declare function findBundle(name: BundleName, bundles?: readonly BundleEntry[]): BundleEntry;
|
|
31
|
+
/**
|
|
32
|
+
* Returns the verified bytes of a bundle. The order is the cache, then the download.
|
|
33
|
+
* A cached file is hashed on every load. A cached file with a wrong hash is deleted, and the load goes on to the download.
|
|
34
|
+
* A download is allowed only when `allowNetwork` has `tex-bundles`. It goes to a temporary file in the cache folder,
|
|
35
|
+
* its hash and size are checked, and only then does a rename put it in place. A wrong hash deletes the temporary file and
|
|
36
|
+
* rejects with `E_INTEGRITY`, so a wrong file never stays in the cache. A bundle that is not cached, with the download not allowed,
|
|
37
|
+
* rejects with `E_STAGE_MISSING`.
|
|
38
|
+
*/
|
|
39
|
+
export declare function loadBundleBytes(entry: BundleEntry, settings: BundleSettings): Promise<Uint8Array>;
|
|
40
|
+
/** Unpacks an SCTB1 container (see `tools/tex/bundles.mjs`) to a map from the tree name to the file bytes. */
|
|
41
|
+
export declare function unpackBundle(bytes: Uint8Array): Map<string, Uint8Array>;
|
|
42
|
+
/** Loads the named bundles and returns the files of each, in the order of the names. A name twice loads once. */
|
|
43
|
+
export declare function loadBundles(names: readonly BundleName[], settings: BundleSettings, bundles?: readonly BundleEntry[]): Promise<Map<BundleName, Map<string, Uint8Array>>>;
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { createHash, randomBytes } from "node:crypto";
|
|
2
|
+
import { mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { inflateRawSync } from "node:zlib";
|
|
6
|
+
import { RenderError } from "../errors.js";
|
|
7
|
+
import list from "./bundles.json" with { type: "json" };
|
|
8
|
+
/** The bundles of this build. `tools/tex/bundles.mjs` writes `bundles.json`, and CI fails when a built bundle differs from it. */
|
|
9
|
+
export const BUNDLES = list;
|
|
10
|
+
/** The sub-folder of the cache folder for the bundles. */
|
|
11
|
+
export const CACHE_SUBFOLDER = "tex-bundles";
|
|
12
|
+
const MAGIC = "SCTB1\0\0\0";
|
|
13
|
+
const sha256 = (b) => createHash("sha256").update(b).digest("hex");
|
|
14
|
+
/** The path of a bundle in the cache. */
|
|
15
|
+
export function cachePath(entry, settings) {
|
|
16
|
+
return path.join(settings.cacheDir, CACHE_SUBFOLDER, entry.file);
|
|
17
|
+
}
|
|
18
|
+
/** The download URL of a bundle. A base URL with no end slash gets one. */
|
|
19
|
+
export function bundleUrl(entry, settings) {
|
|
20
|
+
const base = settings.texBundleUrl;
|
|
21
|
+
return `${base.endsWith("/") ? base : `${base}/`}${entry.file}`;
|
|
22
|
+
}
|
|
23
|
+
/** Looks up a bundle of the list by name. A name that is not in the list is an internal error. */
|
|
24
|
+
export function findBundle(name, bundles = BUNDLES) {
|
|
25
|
+
const entry = bundles.find((b) => b.name === name);
|
|
26
|
+
if (entry === undefined)
|
|
27
|
+
throw new RenderError("E_INTERNAL", `the build has no TeX bundle named ${name}`);
|
|
28
|
+
return entry;
|
|
29
|
+
}
|
|
30
|
+
/** Reads a file or rejects with `undefined` when it is not there. */
|
|
31
|
+
async function readIfThere(file) {
|
|
32
|
+
try {
|
|
33
|
+
return new Uint8Array(await readFile(file));
|
|
34
|
+
}
|
|
35
|
+
catch (e) {
|
|
36
|
+
if (e.code === "ENOENT")
|
|
37
|
+
return undefined;
|
|
38
|
+
throw e;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/** Downloads the bytes of a bundle from an `http:`, `https:` or `file:` URL. */
|
|
42
|
+
async function download(url, settings, entry) {
|
|
43
|
+
const fail = (why) => new RenderError("E_STAGE_MISSING", `the TeX bundle ${entry.name} is not available at ${url}: ${why}`);
|
|
44
|
+
let parsed;
|
|
45
|
+
try {
|
|
46
|
+
parsed = new URL(url);
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
throw new RenderError("E_CONFIG", `texBundleUrl gives the URL ${url} for the TeX bundle ${entry.name}, and it is not a URL`);
|
|
50
|
+
}
|
|
51
|
+
if (parsed.protocol === "file:") {
|
|
52
|
+
try {
|
|
53
|
+
return new Uint8Array(await readFile(fileURLToPath(parsed)));
|
|
54
|
+
}
|
|
55
|
+
catch (e) {
|
|
56
|
+
throw fail(e instanceof Error ? e.message : String(e));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (parsed.protocol !== "https:" && parsed.protocol !== "http:")
|
|
60
|
+
throw fail(`the protocol ${parsed.protocol} is not supported`);
|
|
61
|
+
try {
|
|
62
|
+
const res = await fetch(parsed, { redirect: "follow", signal: AbortSignal.timeout(settings.timeoutMs) });
|
|
63
|
+
if (!res.ok)
|
|
64
|
+
throw fail(`the server answered ${res.status}`);
|
|
65
|
+
const length = Number(res.headers.get("content-length") ?? 0);
|
|
66
|
+
if (length > entry.bytes)
|
|
67
|
+
throw new RenderError("E_INTEGRITY", `the TeX bundle ${entry.name} from ${url} is ${length} bytes, and the pin says ${entry.bytes}`);
|
|
68
|
+
return new Uint8Array(await res.arrayBuffer());
|
|
69
|
+
}
|
|
70
|
+
catch (e) {
|
|
71
|
+
if (e instanceof RenderError)
|
|
72
|
+
throw e;
|
|
73
|
+
throw fail(e instanceof Error ? e.message : String(e));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Returns the verified bytes of a bundle. The order is the cache, then the download.
|
|
78
|
+
* A cached file is hashed on every load. A cached file with a wrong hash is deleted, and the load goes on to the download.
|
|
79
|
+
* A download is allowed only when `allowNetwork` has `tex-bundles`. It goes to a temporary file in the cache folder,
|
|
80
|
+
* its hash and size are checked, and only then does a rename put it in place. A wrong hash deletes the temporary file and
|
|
81
|
+
* rejects with `E_INTEGRITY`, so a wrong file never stays in the cache. A bundle that is not cached, with the download not allowed,
|
|
82
|
+
* rejects with `E_STAGE_MISSING`.
|
|
83
|
+
*/
|
|
84
|
+
export async function loadBundleBytes(entry, settings) {
|
|
85
|
+
const target = cachePath(entry, settings);
|
|
86
|
+
const cached = await readIfThere(target);
|
|
87
|
+
if (cached !== undefined) {
|
|
88
|
+
if (sha256(cached) === entry.sha256)
|
|
89
|
+
return cached;
|
|
90
|
+
await rm(target, { force: true });
|
|
91
|
+
}
|
|
92
|
+
const url = bundleUrl(entry, settings);
|
|
93
|
+
if (settings.allowNetwork === "none") {
|
|
94
|
+
throw new RenderError("E_STAGE_MISSING", `the TeX bundle ${entry.name} is not in the cache (${target}), and the configuration does not allow the download of ${url}. Set allowNetwork to tex-bundles, or put the file ${entry.file} in the cache folder.`);
|
|
95
|
+
}
|
|
96
|
+
const bytes = await download(url, settings, entry);
|
|
97
|
+
await mkdir(path.dirname(target), { recursive: true });
|
|
98
|
+
const temp = `${target}.${process.pid}.${randomBytes(6).toString("hex")}.tmp`;
|
|
99
|
+
await writeFile(temp, bytes);
|
|
100
|
+
try {
|
|
101
|
+
if (bytes.length !== entry.bytes || sha256(bytes) !== entry.sha256) {
|
|
102
|
+
await rm(temp, { force: true });
|
|
103
|
+
throw new RenderError("E_INTEGRITY", `the TeX bundle ${entry.name} from ${url} does not match its pin (sha256 ${entry.sha256}, ${entry.bytes} bytes). The download is deleted.`);
|
|
104
|
+
}
|
|
105
|
+
await rename(temp, target);
|
|
106
|
+
}
|
|
107
|
+
catch (e) {
|
|
108
|
+
await rm(temp, { force: true });
|
|
109
|
+
throw e;
|
|
110
|
+
}
|
|
111
|
+
return bytes;
|
|
112
|
+
}
|
|
113
|
+
/** Unpacks an SCTB1 container (see `tools/tex/bundles.mjs`) to a map from the tree name to the file bytes. */
|
|
114
|
+
export function unpackBundle(bytes) {
|
|
115
|
+
const buf = Buffer.from(bytes.buffer, bytes.byteOffset, bytes.length);
|
|
116
|
+
if (buf.length < 8 || buf.toString("latin1", 0, 8) !== MAGIC)
|
|
117
|
+
throw new RenderError("E_INTEGRITY", "a TeX bundle is not an SCTB1 container");
|
|
118
|
+
let body;
|
|
119
|
+
try {
|
|
120
|
+
body = inflateRawSync(buf.subarray(8));
|
|
121
|
+
}
|
|
122
|
+
catch (e) {
|
|
123
|
+
throw new RenderError("E_INTEGRITY", `a TeX bundle does not inflate: ${e instanceof Error ? e.message : String(e)}`);
|
|
124
|
+
}
|
|
125
|
+
const out = new Map();
|
|
126
|
+
let at = 4;
|
|
127
|
+
const count = body.readUInt32LE(0);
|
|
128
|
+
for (let i = 0; i < count; i++) {
|
|
129
|
+
const nameLength = body.readUInt16LE(at);
|
|
130
|
+
at += 2;
|
|
131
|
+
const name = body.toString("utf8", at, at + nameLength);
|
|
132
|
+
at += nameLength;
|
|
133
|
+
const size = body.readUInt32LE(at);
|
|
134
|
+
at += 4;
|
|
135
|
+
out.set(name, new Uint8Array(body.buffer, body.byteOffset + at, size));
|
|
136
|
+
at += size;
|
|
137
|
+
}
|
|
138
|
+
return out;
|
|
139
|
+
}
|
|
140
|
+
/** Loads the named bundles and returns the files of each, in the order of the names. A name twice loads once. */
|
|
141
|
+
export async function loadBundles(names, settings, bundles = BUNDLES) {
|
|
142
|
+
const out = new Map();
|
|
143
|
+
for (const name of names) {
|
|
144
|
+
if (out.has(name))
|
|
145
|
+
continue;
|
|
146
|
+
out.set(name, unpackBundle(await loadBundleBytes(findBundle(name, bundles), settings)));
|
|
147
|
+
}
|
|
148
|
+
return out;
|
|
149
|
+
}
|
|
150
|
+
//# sourceMappingURL=bundles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundles.js","sourceRoot":"","sources":["../../src/tex/bundles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,IAAI,MAAM,gBAAgB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAWxD,kIAAkI;AAClI,MAAM,CAAC,MAAM,OAAO,GAA2B,IAAqB,CAAC;AAcrE,0DAA0D;AAC1D,MAAM,CAAC,MAAM,eAAe,GAAG,aAAa,CAAC;AAE7C,MAAM,KAAK,GAAG,aAAa,CAAC;AAE5B,MAAM,MAAM,GAAG,CAAC,CAAa,EAAU,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAEvF,yCAAyC;AACzC,MAAM,UAAU,SAAS,CAAC,KAAkB,EAAE,QAA0C;IAC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WAAW,CAC/B,KAA4B,EAC5B,QAAwB,EACxB,OAAO,GAA2B,OAAO;IAEzC,MAAM,GAAG,GAAG,IAAI,GAAG,EAAuC,CAAC;IAC3D,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,SAAS;QAC5B,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,YAAY,CAAC,MAAM,eAAe,CAAC,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC1F,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"name": "core",
|
|
4
|
+
"file": "scieng-tex-core.sctb",
|
|
5
|
+
"sha256": "20b7654bbf6da695eed7eef7895f3a59533f99e675cdb10e48f73d22ac47f43c",
|
|
6
|
+
"bytes": 9383293
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"name": "diagrams",
|
|
10
|
+
"file": "scieng-tex-diagrams.sctb",
|
|
11
|
+
"sha256": "d11be2a1c7931c0d37496852adebe9b3de3deda4bcad98e5396e7eab9c56f2f7",
|
|
12
|
+
"bytes": 71534
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"name": "science",
|
|
16
|
+
"file": "scieng-tex-science.sctb",
|
|
17
|
+
"sha256": "38990ecd718cf5c670c7661418b2a0e427100a8f6b1bb0fc95f21faed0bb45df",
|
|
18
|
+
"bytes": 90196
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"name": "math",
|
|
22
|
+
"file": "scieng-tex-math.sctb",
|
|
23
|
+
"sha256": "ffb760bdb04aa35d4ee56e8bf9ae6a628dd7d204c6aac55d147e651f1854343e",
|
|
24
|
+
"bytes": 721870
|
|
25
|
+
}
|
|
26
|
+
]
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Package detection of the TeX stage.
|
|
3
|
+
*
|
|
4
|
+
* The method follows the templater of the Upmath renderer (parpalak/i.upmath.me, MIT licence,
|
|
5
|
+
* copyright Roman Parpalak): the scan looks for known environments and commands in the source
|
|
6
|
+
* and names the package that each one needs. This module adds package lines, TikZ libraries,
|
|
7
|
+
* the comment and verbatim blanking, the bundle tables and the rejection of packages that no
|
|
8
|
+
* bundle holds. It copies no code of the templater.
|
|
9
|
+
*
|
|
10
|
+
* The scan is not a security boundary. TeX runs on a virtual file tree that holds only the
|
|
11
|
+
* bundles, so a package that the scan misses fails inside TeX.
|
|
12
|
+
*/
|
|
13
|
+
/** The name of a TeX bundle. */
|
|
14
|
+
export type BundleName = "core" | "diagrams" | "science" | "math";
|
|
15
|
+
/** The result of a scan. */
|
|
16
|
+
export interface Detection {
|
|
17
|
+
/** The bundles that the source needs, sorted, with `core` first. */
|
|
18
|
+
bundles: BundleName[];
|
|
19
|
+
/** The packages that the source names or implies, sorted, each one once. */
|
|
20
|
+
packages: string[];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Scans a TeX source and names the bundles that it needs.
|
|
24
|
+
* Throws E_UNSUPPORTED for a package with the GPL as its only licence, for a package that no bundle holds
|
|
25
|
+
* and for a `fontenc` option other than OT1.
|
|
26
|
+
*/
|
|
27
|
+
export declare function detectBundles(source: string): Detection;
|