@danielsimonjr/mathts-plot 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/dist/render-file.js +4 -4
- package/package.json +70 -70
package/dist/index.js
CHANGED
package/dist/render-file.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/render-file.ts
|
|
2
2
|
import { spawn } from "child_process";
|
|
3
3
|
import { writeFile, rm, rename, mkdtemp, readFile } from "fs/promises";
|
|
4
|
-
import { extname, join as joinPath
|
|
4
|
+
import { extname, join as joinPath } from "path";
|
|
5
5
|
import { tmpdir } from "os";
|
|
6
6
|
var PlotRenderError = class extends Error {
|
|
7
7
|
constructor(message, missingTool) {
|
|
@@ -14,7 +14,7 @@ var PlotRenderError = class extends Error {
|
|
|
14
14
|
var ALLOWED_TOOLS = ["rsvg-convert", "resvg", "pdflatex", "xelatex", "lualatex", "tectonic"];
|
|
15
15
|
function runTool(cmd, args, opts = {}) {
|
|
16
16
|
return new Promise((resolve, reject) => {
|
|
17
|
-
if (!ALLOWED_TOOLS.includes(
|
|
17
|
+
if (!ALLOWED_TOOLS.includes(cmd)) {
|
|
18
18
|
reject(new PlotRenderError(`Security Error: Execution of tool '${cmd}' is not allowed.`));
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
@@ -44,7 +44,7 @@ async function hasTool(name) {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
async function renderToFile(svg, outPath, opts = {}) {
|
|
47
|
-
if (opts.tool && !ALLOWED_TOOLS.includes(
|
|
47
|
+
if (opts.tool && !ALLOWED_TOOLS.includes(opts.tool)) {
|
|
48
48
|
throw new PlotRenderError(`Security Error: Execution of tool '${opts.tool}' is not allowed.`);
|
|
49
49
|
}
|
|
50
50
|
const ext = extname(outPath).toLowerCase();
|
|
@@ -116,7 +116,7 @@ function latexArgs(engine, workDir, texPath) {
|
|
|
116
116
|
];
|
|
117
117
|
}
|
|
118
118
|
async function latexToPdf(texSource, outPath, opts = {}) {
|
|
119
|
-
if (opts.tool && !ALLOWED_TOOLS.includes(
|
|
119
|
+
if (opts.tool && !ALLOWED_TOOLS.includes(opts.tool)) {
|
|
120
120
|
throw new PlotRenderError(`Security Error: Execution of tool '${opts.tool}' is not allowed.`);
|
|
121
121
|
}
|
|
122
122
|
if (extname(outPath).toLowerCase() !== ".pdf") {
|
package/package.json
CHANGED
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@danielsimonjr/mathts-plot",
|
|
3
|
-
"version": "0.4.
|
|
4
|
-
"description": "Headless SVG 2D/3D plotting for MathTS — dependency-light, expression-aware, built on core/functions/expression",
|
|
5
|
-
"author": "Daniel Simon Jr.",
|
|
6
|
-
"license": "MIT",
|
|
7
|
-
"type": "module",
|
|
8
|
-
"main": "./dist/index.js",
|
|
9
|
-
"module": "./dist/index.js",
|
|
10
|
-
"types": "./dist/index.d.ts",
|
|
11
|
-
"exports": {
|
|
12
|
-
".": {
|
|
13
|
-
"import": "./dist/index.js",
|
|
14
|
-
"types": "./dist/index.d.ts"
|
|
15
|
-
},
|
|
16
|
-
"./render": {
|
|
17
|
-
"import": "./dist/render-file.js",
|
|
18
|
-
"types": "./dist/render-file.d.ts"
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
"files": [
|
|
22
|
-
"dist",
|
|
23
|
-
"README.md"
|
|
24
|
-
],
|
|
25
|
-
"scripts": {
|
|
26
|
-
"build": "tsup",
|
|
27
|
-
"dev": "tsup --watch",
|
|
28
|
-
"test": "vitest run",
|
|
29
|
-
"test:watch": "vitest",
|
|
30
|
-
"test:coverage": "vitest run --coverage",
|
|
31
|
-
"typecheck": "tsc --noEmit",
|
|
32
|
-
"lint": "eslint src --ext .ts",
|
|
33
|
-
"lint:fix": "eslint src --ext .ts --fix",
|
|
34
|
-
"clean": "rm -rf dist"
|
|
35
|
-
},
|
|
36
|
-
"dependencies": {
|
|
37
|
-
"@danielsimonjr/mathts-core": "^0.14.
|
|
38
|
-
"@danielsimonjr/mathts-functions": "^0.
|
|
39
|
-
"@danielsimonjr/mathts-expression": "^0.7.
|
|
40
|
-
},
|
|
41
|
-
"devDependencies": {
|
|
42
|
-
"@types/node": "^25.5.2",
|
|
43
|
-
"tsup": "^8.0.0",
|
|
44
|
-
"typescript": "^5.3.0",
|
|
45
|
-
"vitest": "^4.1.
|
|
46
|
-
},
|
|
47
|
-
"publishConfig": {
|
|
48
|
-
"access": "public"
|
|
49
|
-
},
|
|
50
|
-
"repository": {
|
|
51
|
-
"type": "git",
|
|
52
|
-
"url": "git+https://github.com/danielsimonjr/MathTS.git",
|
|
53
|
-
"directory": "plot"
|
|
54
|
-
},
|
|
55
|
-
"keywords": [
|
|
56
|
-
"math",
|
|
57
|
-
"typescript",
|
|
58
|
-
"plot",
|
|
59
|
-
"plotting",
|
|
60
|
-
"chart",
|
|
61
|
-
"svg",
|
|
62
|
-
"2d",
|
|
63
|
-
"3d",
|
|
64
|
-
"surface",
|
|
65
|
-
"contour",
|
|
66
|
-
"heatmap",
|
|
67
|
-
"visualization",
|
|
68
|
-
"headless"
|
|
69
|
-
]
|
|
70
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@danielsimonjr/mathts-plot",
|
|
3
|
+
"version": "0.4.1",
|
|
4
|
+
"description": "Headless SVG 2D/3D plotting for MathTS — dependency-light, expression-aware, built on core/functions/expression",
|
|
5
|
+
"author": "Daniel Simon Jr.",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"module": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"types": "./dist/index.d.ts"
|
|
15
|
+
},
|
|
16
|
+
"./render": {
|
|
17
|
+
"import": "./dist/render-file.js",
|
|
18
|
+
"types": "./dist/render-file.d.ts"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"README.md"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "tsup",
|
|
27
|
+
"dev": "tsup --watch",
|
|
28
|
+
"test": "vitest run",
|
|
29
|
+
"test:watch": "vitest",
|
|
30
|
+
"test:coverage": "vitest run --coverage",
|
|
31
|
+
"typecheck": "tsc --noEmit",
|
|
32
|
+
"lint": "eslint src --ext .ts",
|
|
33
|
+
"lint:fix": "eslint src --ext .ts --fix",
|
|
34
|
+
"clean": "rm -rf dist"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@danielsimonjr/mathts-core": "^0.14.1",
|
|
38
|
+
"@danielsimonjr/mathts-functions": "^0.63.0",
|
|
39
|
+
"@danielsimonjr/mathts-expression": "^0.7.1"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@types/node": "^25.5.2",
|
|
43
|
+
"tsup": "^8.0.0",
|
|
44
|
+
"typescript": "^5.3.0",
|
|
45
|
+
"vitest": "^4.1.10"
|
|
46
|
+
},
|
|
47
|
+
"publishConfig": {
|
|
48
|
+
"access": "public"
|
|
49
|
+
},
|
|
50
|
+
"repository": {
|
|
51
|
+
"type": "git",
|
|
52
|
+
"url": "git+https://github.com/danielsimonjr/MathTS.git",
|
|
53
|
+
"directory": "plot"
|
|
54
|
+
},
|
|
55
|
+
"keywords": [
|
|
56
|
+
"math",
|
|
57
|
+
"typescript",
|
|
58
|
+
"plot",
|
|
59
|
+
"plotting",
|
|
60
|
+
"chart",
|
|
61
|
+
"svg",
|
|
62
|
+
"2d",
|
|
63
|
+
"3d",
|
|
64
|
+
"surface",
|
|
65
|
+
"contour",
|
|
66
|
+
"heatmap",
|
|
67
|
+
"visualization",
|
|
68
|
+
"headless"
|
|
69
|
+
]
|
|
70
|
+
}
|