@danielsimonjr/mathts-workbook 0.4.9 → 0.4.11
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/cli.js +1608 -1587
- package/dist/formatter-8ja3r-YP.js +609 -0
- package/dist/fs-atomic.d.ts +10 -2
- package/dist/fs-atomic.d.ts.map +1 -1
- package/dist/index.js +18 -72
- package/dist/run-worker.js +40 -37
- package/dist/timeout-runner-BNZheTmR.js +567 -0
- package/package.json +9 -9
- package/dist/chunk-KP3ZC37Y.js +0 -587
- package/dist/chunk-M2K7SQG2.js +0 -740
package/dist/index.js
CHANGED
|
@@ -1,74 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
VERSION,
|
|
5
|
-
WorkbookTimeoutError,
|
|
6
|
-
addCell,
|
|
7
|
-
editCell,
|
|
8
|
-
handleRequest,
|
|
9
|
-
moveCell,
|
|
10
|
-
removeCell,
|
|
11
|
-
renameCell,
|
|
12
|
-
runWorkbookWithTimeout,
|
|
13
|
-
setMetadata
|
|
14
|
-
} from "./chunk-KP3ZC37Y.js";
|
|
15
|
-
import {
|
|
16
|
-
WorkbookExecutor,
|
|
17
|
-
buildDependencyGraph,
|
|
18
|
-
createExecutor,
|
|
19
|
-
detectCellType,
|
|
20
|
-
detectCycles,
|
|
21
|
-
formatResult,
|
|
22
|
-
getAncestors,
|
|
23
|
-
getDependents,
|
|
24
|
-
parseWorkbook,
|
|
25
|
-
serializeWorkbook,
|
|
26
|
-
stripOutputs,
|
|
27
|
-
toMermaid,
|
|
28
|
-
topologicalSort
|
|
29
|
-
} from "./chunk-M2K7SQG2.js";
|
|
30
|
-
|
|
31
|
-
// src/svg-math.ts
|
|
1
|
+
import { _ as topologicalSort, a as detectCellType, c as parseWorkbook, d as buildDependencyGraph, f as detectCycles, g as toMermaid, l as serializeWorkbook, m as getDependents, n as WorkbookExecutor, p as getAncestors, r as createExecutor, t as formatResult, u as stripOutputs } from "./formatter-8ja3r-YP.js";
|
|
2
|
+
import { d as addCell, f as editCell, g as setMetadata, h as renameCell, l as SCHEMA_VERSION, m as removeCell, n as runWorkbookWithTimeout, p as moveCell, r as handleRequest, s as Session, t as WorkbookTimeoutError, u as VERSION } from "./timeout-runner-BNZheTmR.js";
|
|
3
|
+
//#region src/svg-math.ts
|
|
32
4
|
function mathMLToSVG(mathml, options = {}) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
5
|
+
const display = options.display ?? "block";
|
|
6
|
+
const pad = options.padding ?? 4;
|
|
7
|
+
const inner = mathml.includes("<math") ? mathml : `<math xmlns="http://www.w3.org/1998/Math/MathML" display="${display}">${mathml}</math>`;
|
|
8
|
+
const text = inner.replace(/<[^>]+>/g, "");
|
|
9
|
+
const width = Math.max(24, text.length * 10 + pad * 2);
|
|
10
|
+
const height = display === "block" ? 36 + pad * 2 : 20 + pad * 2;
|
|
11
|
+
return [
|
|
12
|
+
`<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}" viewBox="0 0 ${width} ${height}">`,
|
|
13
|
+
`<foreignObject x="${pad}" y="${pad}" width="${width - pad * 2}" height="${height - pad * 2}">`,
|
|
14
|
+
inner,
|
|
15
|
+
`</foreignObject>`,
|
|
16
|
+
`</svg>`
|
|
17
|
+
].join("");
|
|
46
18
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
Session,
|
|
50
|
-
VERSION,
|
|
51
|
-
WorkbookExecutor,
|
|
52
|
-
WorkbookTimeoutError,
|
|
53
|
-
addCell,
|
|
54
|
-
buildDependencyGraph,
|
|
55
|
-
createExecutor,
|
|
56
|
-
detectCellType,
|
|
57
|
-
detectCycles,
|
|
58
|
-
editCell,
|
|
59
|
-
formatResult,
|
|
60
|
-
getAncestors,
|
|
61
|
-
getDependents,
|
|
62
|
-
handleRequest,
|
|
63
|
-
mathMLToSVG,
|
|
64
|
-
moveCell,
|
|
65
|
-
parseWorkbook,
|
|
66
|
-
removeCell,
|
|
67
|
-
renameCell,
|
|
68
|
-
runWorkbookWithTimeout,
|
|
69
|
-
serializeWorkbook,
|
|
70
|
-
setMetadata,
|
|
71
|
-
stripOutputs,
|
|
72
|
-
toMermaid,
|
|
73
|
-
topologicalSort
|
|
74
|
-
};
|
|
19
|
+
//#endregion
|
|
20
|
+
export { SCHEMA_VERSION, Session, VERSION, WorkbookExecutor, WorkbookTimeoutError, addCell, buildDependencyGraph, createExecutor, detectCellType, detectCycles, editCell, formatResult, getAncestors, getDependents, handleRequest, mathMLToSVG, moveCell, parseWorkbook, removeCell, renameCell, runWorkbookWithTimeout, serializeWorkbook, setMetadata, stripOutputs, toMermaid, topologicalSort };
|
package/dist/run-worker.js
CHANGED
|
@@ -1,39 +1,42 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
parseWorkbook
|
|
5
|
-
} from "./chunk-M2K7SQG2.js";
|
|
6
|
-
|
|
7
|
-
// src/run-worker.ts
|
|
8
|
-
import { parentPort, workerData } from "worker_threads";
|
|
1
|
+
import { c as parseWorkbook, r as createExecutor, t as formatResult } from "./formatter-8ja3r-YP.js";
|
|
2
|
+
import { parentPort, workerData } from "node:worker_threads";
|
|
3
|
+
//#region src/run-worker.ts
|
|
9
4
|
async function main() {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
5
|
+
const port = parentPort;
|
|
6
|
+
if (!port) throw new Error("run-worker.js must be run as a worker_threads Worker");
|
|
7
|
+
let message;
|
|
8
|
+
try {
|
|
9
|
+
const { source } = workerData;
|
|
10
|
+
const parsed = parseWorkbook(source);
|
|
11
|
+
if (!parsed.success || !parsed.workbook) message = {
|
|
12
|
+
ok: false,
|
|
13
|
+
error: `Parse error: ${(parsed.errors ?? []).join("; ") || "invalid workbook"}`
|
|
14
|
+
};
|
|
15
|
+
else {
|
|
16
|
+
const report = await createExecutor(parsed.workbook).runReport();
|
|
17
|
+
const cells = report.cells.map((c) => ({
|
|
18
|
+
id: c.id,
|
|
19
|
+
type: c.type,
|
|
20
|
+
status: c.status,
|
|
21
|
+
output: c.output === void 0 ? void 0 : formatResult(c.output),
|
|
22
|
+
error: c.error
|
|
23
|
+
}));
|
|
24
|
+
message = {
|
|
25
|
+
ok: true,
|
|
26
|
+
report: {
|
|
27
|
+
ok: report.ok,
|
|
28
|
+
cells
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
} catch (error) {
|
|
33
|
+
message = {
|
|
34
|
+
ok: false,
|
|
35
|
+
error: error instanceof Error ? error.message : String(error)
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
port.postMessage(message);
|
|
38
39
|
}
|
|
39
|
-
|
|
40
|
+
main();
|
|
41
|
+
//#endregion
|
|
42
|
+
export {};
|