@danielsimonjr/mathts-workbook 0.4.10 → 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/index.js CHANGED
@@ -1,74 +1,20 @@
1
- import {
2
- SCHEMA_VERSION,
3
- Session,
4
- VERSION,
5
- WorkbookTimeoutError,
6
- addCell,
7
- editCell,
8
- handleRequest,
9
- moveCell,
10
- removeCell,
11
- renameCell,
12
- runWorkbookWithTimeout,
13
- setMetadata
14
- } from "./chunk-EBDCDNR3.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
- const display = options.display ?? "block";
34
- const pad = options.padding ?? 4;
35
- const inner = mathml.includes("<math") ? mathml : `<math xmlns="http://www.w3.org/1998/Math/MathML" display="${display}">${mathml}</math>`;
36
- const text = inner.replace(/<[^>]+>/g, "");
37
- const width = Math.max(24, text.length * 10 + pad * 2);
38
- const height = display === "block" ? 36 + pad * 2 : 20 + pad * 2;
39
- return [
40
- `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}" viewBox="0 0 ${width} ${height}">`,
41
- `<foreignObject x="${pad}" y="${pad}" width="${width - pad * 2}" height="${height - pad * 2}">`,
42
- inner,
43
- `</foreignObject>`,
44
- `</svg>`
45
- ].join("");
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
- export {
48
- SCHEMA_VERSION,
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 };
@@ -1,39 +1,42 @@
1
- import {
2
- createExecutor,
3
- formatResult,
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
- const port = parentPort;
11
- if (!port) {
12
- throw new Error("run-worker.js must be run as a worker_threads Worker");
13
- }
14
- let message;
15
- try {
16
- const { source } = workerData;
17
- const parsed = parseWorkbook(source);
18
- if (!parsed.success || !parsed.workbook) {
19
- message = {
20
- ok: false,
21
- error: `Parse error: ${(parsed.errors ?? []).join("; ") || "invalid workbook"}`
22
- };
23
- } else {
24
- const report = await createExecutor(parsed.workbook).runReport();
25
- const cells = report.cells.map((c) => ({
26
- id: c.id,
27
- type: c.type,
28
- status: c.status,
29
- output: c.output === void 0 ? void 0 : formatResult(c.output),
30
- error: c.error
31
- }));
32
- message = { ok: true, report: { ok: report.ok, cells } };
33
- }
34
- } catch (error) {
35
- message = { ok: false, error: error instanceof Error ? error.message : String(error) };
36
- }
37
- port.postMessage(message);
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
- void main();
40
+ main();
41
+ //#endregion
42
+ export {};